Live editing of CSS files

Tries to find CSS files in the stickyTab shown window. If it does it
appends a new stylesheet to it as you type.
This commit is contained in:
Matt Pass
2013-04-30 08:07:03 +01:00
parent 44cac8a7e1
commit d87e932030

View File

@@ -181,10 +181,23 @@ function createNewCMInstance(num) {
}
// Update HTML edited files live
if (top.ICEcoder.stickyTab.location) {
var filename = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
var filepath = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
var filename = filepath.substr(filepath.lastIndexOf("/")+1);
var fileExt = filename.substr(filename.lastIndexOf(".")+1);
if (["htm","html"].indexOf(fileExt) > -1) {
if (["htm","html","txt"].indexOf(fileExt) > -1) {
top.ICEcoder.stickyTab.document.documentElement.innerHTML = window['cM'+num].getValue();
} else if (["css"].indexOf(fileExt) > -1) {
if (top.ICEcoder.stickyTab.document.documentElement.innerHTML.indexOf(filename) > -1) {
var css = window['cM'+num].getValue();
var style = document.createElement('style');
style.type = 'text/css';
if (style.styleSheet){
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
top.ICEcoder.stickyTab.document.documentElement.appendChild(style);
}
}
};
}