comparison mquery.js @ 110:d715fb3c39ab

Implemented clicking on symbols inside inscope box to replace function name in funcall.
author Mike Pavone <pavone@retrodev.com>
date Sat, 13 Apr 2013 23:37:54 -0700
parents 76a21129e8f5
children c0bfff39abe3
comparison
equal deleted inserted replaced
109:a647cdad620b 110:d715fb3c39ab
1 function each(container, fun) 1 function each(container, fun)
2 { 2 {
3 if (container instanceof Array) { 3 if (container instanceof Array || container instanceof HTMLCollection || container instanceof NodeList) {
4 for (var i = 0; i < container.length; i++) { 4 for (var i = 0; i < container.length; i++) {
5 fun(i, container[i]); 5 fun(i, container[i]);
6 } 6 }
7 } else { 7 } else {
8 for (var i in container) { 8 for (var i in container) {
66 classes.splice(idx, 1); 66 classes.splice(idx, 1);
67 el.className = classes.join(' '); 67 el.className = classes.join(' ');
68 } 68 }
69 } 69 }
70 70
71 function hasClass(el, classname)
72 {
73 return el.className == classname || el.className.split(' ').indexOf(classname) > -1
74 }
75
71 function ajax(method, url, data, onSuccess, onFail, onOthers) 76 function ajax(method, url, data, onSuccess, onFail, onOthers)
72 { 77 {
73 var req; 78 var req;
74 try { 79 try {
75 req = new XMLHttpRequest(); 80 req = new XMLHttpRequest();
108 ajax('POST', url, data, onSuccess, onFail, onOthers); 113 ajax('POST', url, data, onSuccess, onFail, onOthers);
109 } 114 }
110 115
111 function newEl(tagname, props) 116 function newEl(tagname, props)
112 { 117 {
118 console.log('tagname:', tagname, 'props:', props);
113 var el = document.createElement(tagname); 119 var el = document.createElement(tagname);
114 if (typeof props == 'object') { 120 if (typeof props == 'object') {
115 each(props, function (key, val) { 121 each(props, function (key, val) {
116 el[key] = val; 122 el[key] = val;
117 }); 123 });