Permalink
Browse files

improving

  • Loading branch information...
Jorge Falcão Jorge Falcão
Jorge Falcão authored and Jorge Falcão committed Nov 16, 2010
1 parent 0f21bdc commit e97e6c90c746d051a12b1c7125bf1720a6a8e160
Showing with 17 additions and 40 deletions.
  1. +5 −3 ext-reload.js
  2. +12 −37 lib/textmate/Support/lib/mozrepl_tools.rb
View
@@ -19,13 +19,15 @@ Ext.reg = Ext.reg.createSequence(function(xtype) {
o.remove(item);
//add it again
var it = o.add(Ext.apply({xtype: xtype}, ic));
var it = o.add(Ext.apply({xtype: xtype}, ic));
//TODO: test if it was indeed active
//TODO: handle border layout
TODO: test if it was indeed active
if ( it && o.getLayout().setActiveItem ) {
o.getLayout().setActiveItem(it);
};
o.doLayout();
//it.doLayout();
o.doLayout();
}
});
});
@@ -39,25 +39,6 @@
}
})();
// TODO: refactory
function found_script(a,s) {
var t = s.split("?");
var pu = t[0].split("/").reverse();
var pc = a.split("/").reverse();
var c = 0;
for ( var i = 0; i < pu.length; i++ ) {
if ( pu[i] == pc [i] ) {
c++;
} else {
break;
}
}
repl.print(c)
if ( c > 0 ) {
return s + ((t[1])?"&":"?") + Math.random();
}
}
var document = doc = window.document;
var Ext = window.Ext;
@@ -91,25 +72,19 @@
head.appendChild(script);
},
js:function(filename) {
var scripts = document.getElementsByTagName("script");
for (var i = 0; i < scripts.length; i++ ) {
repl.print(scripts[i].src);
if ( scripts[i].src ) {
var s = found_script(filename, scripts[i].src)
repl.print(filename);
repl.print("s:", s);
if ( s ) {
var script = document.createElement('script');
script.type = "text/javascript";
script.src = s;
repl.print(filename);
head.appendChild(script);
return;
}
}
var filename = filename.split("/").pop();
// console.debug("filename:", filename);
// TODO: sometimes cant't work.'
var xpath = '//script[contains(@src, "'+ filename +'")]';
var node = document.evaluate(xpath, document, null, XPathResult.ANY_TYPE, null).iterateNext()
if ( node ) {
var newScript = document.createElement('script');
newScript.src = node.src.split("?")[0] + "?" + Math.random();
document.getElementsByTagName('head')[0].appendChild(newScript);
console.debug("reloaded")
} else {
console.debug("this file isn't included.'")
}
}
};
})(content, window);

0 comments on commit e97e6c9

Please sign in to comment.