From caca29656274698eb19620d0b0882a258e829e16 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Fri, 20 Jul 2012 17:30:27 +0100 Subject: [PATCH] Ternary shortening htmlTagArray & getcMInstance Reduced & simplified code to get the same result --- lib/coder.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/lib/coder.js b/lib/coder.js index b5940ba..2553179 100644 --- a/lib/coder.js +++ b/lib/coder.js @@ -173,13 +173,8 @@ var ICEcoder = { if (!ICEcoder.codeBlock) { // OK, we can do something further as we're not in a code block // If it's the same as the previously logged tag preceeded by /, it's the equivalent end tag - if (tagEnd=="/"+ICEcoder.htmlTagArray[ICEcoder.htmlTagArray.length-1]) { - // So remove the last logged tag, thereby going up one in the nest - ICEcoder.htmlTagArray.pop(); - } else { - // Otherwise it's a different tag, add it to the end - ICEcoder.htmlTagArray.push(tagString); - } + // so remove the last logged tag, thereby going up one in the nest, otherwise it's a different tag, add it to the end + tagEnd=="/"+ICEcoder.htmlTagArray[ICEcoder.htmlTagArray.length-1] ? ICEcoder.htmlTagArray.pop() : ICEcoder.htmlTagArray.push(tagString); } else if ( ((ICEcoder.tagStart=="script"||ICEcoder.tagStart=="/script")&&tagEndJS=="0)) { - cM = top.ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[ICEcoder.selectedTab-1]]; - } else { - cM = top.ICEcoder.content.contentWindow['cM1']; - } + cM = top.ICEcoder.content.contentWindow[ + newTab=="new"||(newTab!="new" && ICEcoder.openFiles.length>0) + ? 'cM'+ICEcoder.cMInstances[ICEcoder.selectedTab-1] + : 'cM1' + ]; return cM; },