diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 6209b6d..74229a1 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -1005,46 +1005,48 @@ var ICEcoder = { var cM, nestCheck, state, cx, startPos, fileName, events; cM = ICEcoder.getcMInstance(); - nestCheck = cM.getValue(); + if (cM) { + nestCheck = cM.getValue(); - // Set up array to store nest data - state = cM.getTokenAt(cM.getCursor()).state; - if ("undefined" != typeof state.curState) { - ICEcoder.htmlTagArray = []; - for (cx = state.curState.context; cx; cx = cx.prev) { - if ("undefined" != typeof cx.tagName) { - ICEcoder.htmlTagArray.unshift(cx.tagName); + // Set up array to store nest data + state = cM.getTokenAt(cM.getCursor()).state; + if ("undefined" != typeof state.curState) { + ICEcoder.htmlTagArray = []; + for (cx = state.curState.context; cx; cx = cx.prev) { + if ("undefined" != typeof cx.tagName) { + ICEcoder.htmlTagArray.unshift(cx.tagName); + } } } - } - ICEcoder.tagString = ICEcoder.htmlTagArray[ICEcoder.htmlTagArray.length-1]; - if (ICEcoder.caretLocType=="JavaScript") { - ICEcoder.tagString = "script"; - } + ICEcoder.tagString = ICEcoder.htmlTagArray[ICEcoder.htmlTagArray.length-1]; + if (ICEcoder.caretLocType=="JavaScript") { + ICEcoder.tagString = "script"; + } - // Now we've built up our nest depth array, if we're due to show it in the display - if (updateNestDisplay && !top.ICEcoder.dontUpdateNest) { - // Clear the display - ICEcoder.nestDisplayText.innerHTML = ""; - ICEcoder.nestDisplay.innerHTML = ""; - if ("undefined" != typeof ICEcoder.openFiles[ICEcoder.selectedTab-1]) { - fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1]; - if (["js","coffee","rb","css","less"].indexOf(fileName.split(".")[1])<0 && - (nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)&& - (nestCheck.indexOf("-1||nestCheck.indexOf("
-1)) { + // Now we've built up our nest depth array, if we're due to show it in the display + if (updateNestDisplay && !top.ICEcoder.dontUpdateNest) { + // Clear the display + ICEcoder.nestDisplayText.innerHTML = ""; + ICEcoder.nestDisplay.innerHTML = ""; + if ("undefined" != typeof ICEcoder.openFiles[ICEcoder.selectedTab-1]) { + fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1]; + if (["js","coffee","rb","css","less"].indexOf(fileName.split(".")[1])<0 && + (nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)&& + (nestCheck.indexOf("-1||nestCheck.indexOf("-1)) { - ICEcoder.nestDisplayText.innerHTML = ICEcoder.htmlTagArray.length > 0 ? "Cursor Position" : ""; - // Then for all the array items, output as the nest display - for (var i=0;i