mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-07 00:56:48 +01:00
Condensing code in a few areas
Reworked detecting if it's a JS, CoffeeScript, Ruby, CSS or LESS file by switching the indexOf around Also performed indexOf on an array rather than looking at each array item in a for loop Ternary shortening of code in a few areas
This commit is contained in:
21
lib/coder.js
21
lib/coder.js
@@ -95,7 +95,7 @@ var ICEcoder = {
|
||||
|
||||
// If it's not a JS, CoffeeScript Ruby, CSS or LESS file, replace & and our temp </textarea> value
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (fileName.indexOf(".js")<0 && fileName.indexOf(".coffee")<0 && fileName.indexOf(".rb")<0 && fileName.indexOf(".css")<0 && fileName.indexOf(".less")<0) {
|
||||
if (["js","coffee","rb","css","less"].indexOf(fileName.split(".")[1])<0) {
|
||||
cM = ICEcoder.getcMInstance();
|
||||
content = cM.getValue();
|
||||
content = content.replace(/<ICEcoder:\/:textarea>/g,'</textarea>');
|
||||
@@ -141,10 +141,8 @@ var ICEcoder = {
|
||||
canDoTheEndTag=true;
|
||||
|
||||
// Check it's not on our list of exceptions
|
||||
for (var j=0;j<ICEcoder.tagNestExceptions.length;j++) {
|
||||
if (tagString==ICEcoder.tagNestExceptions[j]) {
|
||||
if (ICEcoder.tagNestExceptions.indexOf(tagString)>-1) {
|
||||
canDoTheEndTag=false;
|
||||
}
|
||||
}
|
||||
|
||||
if (canDoTheEndTag) {
|
||||
@@ -181,7 +179,7 @@ var ICEcoder = {
|
||||
ICEcoder.nestDisplay.innerHTML = "";
|
||||
if ("undefined" != typeof ICEcoder.openFiles[ICEcoder.selectedTab-1]) {
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (fileName.indexOf(".js")<0 && fileName.indexOf(".coffee")<0 && fileName.indexOf(".rb")<0 && fileName.indexOf(".css")<0 && fileName.indexOf(".less")<0 &&
|
||||
if (["js","coffee","rb","css","less"].indexOf(fileName.split(".")[1])<0 &&
|
||||
(nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)&&
|
||||
(nestCheck.indexOf("<html")>-1||nestCheck.indexOf("<body")>-1)) {
|
||||
|
||||
@@ -371,7 +369,7 @@ var ICEcoder = {
|
||||
// Switch mode to HTML, PHP, CSS etc
|
||||
ICEcoder.switchMode();
|
||||
|
||||
// Set all cM instances to be hidden, then make our selected instance visable
|
||||
// Set all cM instances to be hidden, then make our selected instance visible
|
||||
for (var i=0;i<ICEcoder.cMInstances.length;i++) {
|
||||
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].getWrapperElement().style.display = "none";
|
||||
}
|
||||
@@ -402,15 +400,16 @@ var ICEcoder = {
|
||||
cM = ICEcoder.getcMInstance();
|
||||
for(var i=1;i<=ICEcoder.changedContent.length;i++) {
|
||||
if (document.getElementById('closeTabButton'+i)) {
|
||||
ICEcoder.changedContent[i-1]==1 && cM.historySize().undo>0 ? document.getElementById('closeTabButton'+i).style.backgroundColor = "#b00" : document.getElementById('closeTabButton'+i).style.backgroundColor = "rgba(255,255,255,0.3)";
|
||||
document.getElementById('closeTabButton'+i).style.backgroundColor = ICEcoder.changedContent[i-1]==1 && cM.historySize().undo>0
|
||||
? "#b00" : "rgba(255,255,255,0.3)";
|
||||
}
|
||||
i==selectedTab ? tColor = "#000" : tColor = "#fff";
|
||||
tColor = i==selectedTab ? "#000" : "#fff";
|
||||
if ("undefined" != typeof top.ICEcoder.openFiles[i-1] && top.ICEcoder.openFiles[i-1] != "/[NEW]") {
|
||||
fileLink = top.ICEcoder.filesFrame.contentWindow.document.getElementById(top.ICEcoder.openFiles[i-1].replace(/\//g,"|"));
|
||||
if (fileLink) {i==selectedTab ? fileLink.style.backgroundColor = "#49d" : fileLink.style.backgroundColor = "rgba(255,255,255,0.15)";};
|
||||
if (fileLink) {fileLink.style.backgroundColor = i==selectedTab ? "#49d" : "rgba(255,255,255,0.15)";};
|
||||
}
|
||||
document.getElementById('tab'+i).style.color = tColor;
|
||||
i==selectedTab ? bgVPos = -22 : bgVPos = 0;
|
||||
bgVPos = i==selectedTab ? -22 : 0;
|
||||
document.getElementById('tab'+i).style.backgroundPosition = "0 "+bgVPos+"px";
|
||||
}
|
||||
top.ICEcoder.fMIconVis('fMSave',ICEcoder.changedContent[selectedTab-1]==1 ? 1 : 0.3);
|
||||
@@ -498,7 +497,7 @@ var ICEcoder = {
|
||||
ICEcoder.getNestLocation();
|
||||
nestOK = false;
|
||||
// Nesting is OK if at the end of the file we have no nests left, or it's a JS, Ruby or CSS file
|
||||
if (ICEcoder.htmlTagArray.length==0||fileName.indexOf(".js")>0||fileName.indexOf(".coffee")>0||fileName.indexOf(".rb")>0||fileName.indexOf(".css")>0||fileName.indexOf(".less")>0) {
|
||||
if (ICEcoder.htmlTagArray.length==0||["js","coffee","rb","css","less"].indexOf(fileName.split(".")[1])>0) {
|
||||
nestOK = true;
|
||||
}
|
||||
ICEcoder.nestValid.style.backgroundColor = nestOK ? "#0b0" : "#f00";
|
||||
|
||||
Reference in New Issue
Block a user