mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-03 07:13:59 +01:00
Language related items moved to seperate files
Makes it easier for users to customise languages supported
This commit is contained in:
10
editor.php
10
editor.php
@@ -54,6 +54,7 @@ h2 {color: rgba(0,198,255,0.7)}
|
||||
.heading {color:#888}
|
||||
</style>
|
||||
<link rel="stylesheet" href="lib/file-types.css">
|
||||
<link rel="stylesheet" href="lib/file-type-icons.css">
|
||||
</head>
|
||||
|
||||
<body style="color: #fff; margin: 0" onKeyDown="return top.ICEcoder.interceptKeys('content', event);" onKeyUp="top.ICEcoder.resetKeys(event);" onBlur="parent.ICEcoder.resetKeys(event);">
|
||||
@@ -150,13 +151,6 @@ CodeMirror.keyMap.ICEcoder = {
|
||||
"Ctrl-Down" : false,
|
||||
fallthrough: ["default"]
|
||||
};
|
||||
CodeMirror.commands.autocomplete = function(cm) {
|
||||
var langType = top.ICEcoder.caretLocType;
|
||||
if (["JavaScript","CoffeeScript","SQL","CSS","HTML","XML","Content"].indexOf(langType)>-1) {
|
||||
if (langType=="XML"||langType=="Content") {langType="HTML"};
|
||||
CodeMirror.showHint(cm,CodeMirror.hint[langType.toLowerCase()]);
|
||||
}
|
||||
}
|
||||
|
||||
function createNewCMInstance(num) {
|
||||
var fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
|
||||
@@ -317,6 +311,8 @@ var debounce;
|
||||
|
||||
<div style="position: absolute; display: none; width: 5px; height: 100%; top: 0; right: 0; background: rgba(255,255,255,0.1); overflow: hidden; z-index: 2" id="resultsBar"></div>
|
||||
|
||||
<?php include_once("processes/on-editor-load.php"); ?>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -7,6 +7,7 @@
|
||||
<meta name="robots" content="noindex, nofollow">
|
||||
<link rel="stylesheet" type="text/css" href="lib/files.css">
|
||||
<link rel="stylesheet" type="text/css" href="lib/file-types.css">
|
||||
<link rel="stylesheet" type="text/css" href="lib/file-type-icons.css">
|
||||
<script src="lib/ice-coder<?php if (!$ICEcoder['devMode']) {echo '.min';};?>.js" type="text/javascript"></script>
|
||||
</head>
|
||||
|
||||
|
||||
17
lib/file-type-icons.css
Normal file
17
lib/file-type-icons.css
Normal file
@@ -0,0 +1,17 @@
|
||||
/* Additional file types */
|
||||
.fileManager LI.ext-coffee:before {background-position: -48px 0}
|
||||
.fileManager LI.ext-css:before {background-position: -64px 0}
|
||||
.fileManager LI.ext-gif:before {background-position: -80px 0}
|
||||
.fileManager LI.ext-htm:before, .fileManager LI.ext-html:before {background-position: -96px 0}
|
||||
.fileManager LI.ext-jpg:before, .fileManager LI.ext-jpeg:before {background-position: -112px 0}
|
||||
.fileManager LI.ext-js:before, .fileManager LI.ext-json:before {background-position: -128px 0}
|
||||
.fileManager LI.ext-less:before {background-position: -144px 0}
|
||||
.fileManager LI.ext-md:before {background-position: -160px 0}
|
||||
.fileManager LI.ext-php:before {background-position: -176px 0}
|
||||
.fileManager LI.ext-png:before {background-position: -192px 0}
|
||||
.fileManager LI.ext-py:before {background-position: -208px 0}
|
||||
.fileManager LI.ext-rb:before, .fileManager LI.ext-ruby:before {background-position: -224px 0}
|
||||
.fileManager LI.ext-sql:before {background-position: -240px 0}
|
||||
.fileManager LI.ext-txt:before {background-position: -256px 0}
|
||||
.fileManager LI.ext-xml:before {background-position: -272px 0}
|
||||
.fileManager LI.ext-zip:before {background-position: -288px 0}
|
||||
@@ -22,22 +22,4 @@
|
||||
margin-top: -19px;
|
||||
}
|
||||
}
|
||||
.fileManager LI.pft-file:before {background-position: -32px 0}
|
||||
|
||||
/* Additional file types */
|
||||
.fileManager LI.ext-coffee:before {background-position: -48px 0}
|
||||
.fileManager LI.ext-css:before {background-position: -64px 0}
|
||||
.fileManager LI.ext-gif:before {background-position: -80px 0}
|
||||
.fileManager LI.ext-htm:before, .fileManager LI.ext-html:before {background-position: -96px 0}
|
||||
.fileManager LI.ext-jpg:before, .fileManager LI.ext-jpeg:before {background-position: -112px 0}
|
||||
.fileManager LI.ext-js:before, .fileManager LI.ext-json:before {background-position: -128px 0}
|
||||
.fileManager LI.ext-less:before {background-position: -144px 0}
|
||||
.fileManager LI.ext-md:before {background-position: -160px 0}
|
||||
.fileManager LI.ext-php:before {background-position: -176px 0}
|
||||
.fileManager LI.ext-png:before {background-position: -192px 0}
|
||||
.fileManager LI.ext-py:before {background-position: -208px 0}
|
||||
.fileManager LI.ext-rb:before, .fileManager LI.ext-ruby:before {background-position: -224px 0}
|
||||
.fileManager LI.ext-sql:before {background-position: -240px 0}
|
||||
.fileManager LI.ext-txt:before {background-position: -256px 0}
|
||||
.fileManager LI.ext-xml:before {background-position: -272px 0}
|
||||
.fileManager LI.ext-zip:before {background-position: -288px 0}
|
||||
.fileManager LI.pft-file:before {background-position: -32px 0}
|
||||
132
lib/ice-coder.js
132
lib/ice-coder.js
@@ -297,31 +297,9 @@ var ICEcoder = {
|
||||
return false;
|
||||
},
|
||||
|
||||
// Switch the CodeMirror mode on demand
|
||||
switchMode: function(mode) {
|
||||
var cM, fileName;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (cM && mode) {
|
||||
cM.setOption("mode",mode);
|
||||
} else if (cM && fileName) {
|
||||
fileName.indexOf('.js')>0 ? cM.setOption("mode","javascript")
|
||||
: fileName.indexOf('.coffee')>0 ? cM.setOption("mode","coffeescript")
|
||||
: fileName.indexOf('.rb')>0 ? cM.setOption("mode","ruby")
|
||||
: fileName.indexOf('.py')>0 ? cM.setOption("mode","python")
|
||||
: fileName.indexOf('.css')>0 ? cM.setOption("mode","css")
|
||||
: fileName.indexOf('.less')>0 ? cM.setOption("mode","less")
|
||||
: fileName.indexOf('.md')>0 ? cM.setOption("mode","markdown")
|
||||
: fileName.indexOf('.xml')>0 ? cM.setOption("mode","xml")
|
||||
: fileName.indexOf('.sql')>0 ? cM.setOption("mode","text/x-mysql") // also text/x-sql, text/x-mariadb, text/x-cassandra or text/x-plsql
|
||||
: cM.setOption("mode","application/x-httpd-php");
|
||||
}
|
||||
},
|
||||
|
||||
// Comment/uncomment line or selected range on keypress
|
||||
lineCommentToggle: function() {
|
||||
var cM, cursorPos, linePos, lineContent, lCLen, adjustCursor, startLine, endLine;
|
||||
var cM, cursorPos, linePos, lineContent, lCLen, adjustCursor;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
cursorPos = cM.getCursor().ch;
|
||||
@@ -330,51 +308,8 @@ var ICEcoder = {
|
||||
lCLen = lineContent.length;
|
||||
adjustCursor = 2;
|
||||
|
||||
if (["JavaScript","CoffeeScript","PHP","Python","Ruby","CSS","SQL"].indexOf(ICEcoder.caretLocType)>-1) {
|
||||
if (cM.somethingSelected()) {
|
||||
if (ICEcoder.caretLocType=="Ruby"||ICEcoder.caretLocType=="Python") {
|
||||
startLine = cM.getCursor(true).line;
|
||||
endLine = cM.getCursor().line;
|
||||
for (var i=startLine; i<=endLine; i++) {
|
||||
cM.setLine(i, cM.getLine(i).slice(0,1)!="#"
|
||||
? "#" + cM.getLine(i)
|
||||
: cM.getLine(i).slice(1,cM.getLine(i).length));
|
||||
}
|
||||
} else {
|
||||
cM.replaceSelection(cM.getSelection().slice(0,2)!="/*"
|
||||
? "/*" + cM.getSelection() + "*/"
|
||||
: cM.getSelection().slice(2,cM.getSelection().length-2));
|
||||
}
|
||||
} else {
|
||||
if (["CoffeeScript","CSS","SQL"].indexOf(ICEcoder.caretLocType)>-1) {
|
||||
cM.setLine(linePos, lineContent.slice(0,2)!="/*"
|
||||
? "/*" + lineContent + "*/"
|
||||
: lineContent.slice(2,lCLen).slice(0,lCLen-4));
|
||||
if (lineContent.slice(0,2)=="/*") {adjustCursor = -adjustCursor};
|
||||
} else if (ICEcoder.caretLocType=="Ruby") {
|
||||
cM.setLine(linePos, lineContent.slice(0,1)!="#"
|
||||
? "#" + lineContent
|
||||
: lineContent.slice(1,lCLen));
|
||||
if (lineContent.slice(0,1)=="#") {adjustCursor = -adjustCursor};
|
||||
} else {
|
||||
cM.setLine(linePos, lineContent.slice(0,2)!="//"
|
||||
? "//" + lineContent
|
||||
: lineContent.slice(2,lCLen));
|
||||
if (lineContent.slice(0,2)=="//") {adjustCursor = -adjustCursor};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (cM.somethingSelected()) {
|
||||
cM.replaceSelection(cM.getSelection().slice(0,4)!="<\!--"
|
||||
? "<\!--" + cM.getSelection() + "//-->"
|
||||
: cM.getSelection().slice(4,cM.getSelection().length-5));
|
||||
} else {
|
||||
cM.setLine(linePos, lineContent.slice(0,4)!="<\!--"
|
||||
? "<\!--" + lineContent + "//-->"
|
||||
: lineContent.slice(4,lCLen).slice(0,lCLen-9));
|
||||
adjustCursor = lineContent.slice(0,4)=="<\!--" ? -4 : 4;
|
||||
}
|
||||
}
|
||||
ICEcoder.lineCommentToggleSub(cM, cursorPos, linePos, lineContent, lCLen, adjustCursor);
|
||||
|
||||
if (!cM.somethingSelected()) {cM.setCursor(linePos, cursorPos+adjustCursor)};
|
||||
},
|
||||
|
||||
@@ -1337,7 +1272,7 @@ var ICEcoder = {
|
||||
|
||||
// Work out the nesting depth location on demand and update our display if required
|
||||
getNestLocation: function(updateNestDisplay) {
|
||||
var cM, nestCheck, state, cx, startPos, fileName, events;
|
||||
var cM, nestCheck, state, cx, startPos, fileName;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
if (cM) {
|
||||
@@ -1376,41 +1311,13 @@ var ICEcoder = {
|
||||
ICEcoder.nestDisplay.innerHTML = "";
|
||||
if ("undefined" != typeof ICEcoder.openFiles[ICEcoder.selectedTab-1]) {
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (["js","coffee","css","less","sql"].indexOf(fileName.split(".")[1])<0 &&
|
||||
(nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)) {
|
||||
|
||||
// Then for all the array items, output as the nest display
|
||||
for (var i=0;i<ICEcoder.htmlTagArray.length;i++) {
|
||||
events = 'onMouseover="top.ICEcoder.highlightBlock('+i+')" onMouseout="top.ICEcoder.highlightBlock('+i+',\'hide\')" onClick="top.ICEcoder.setPosition('+i+',top.ICEcoder.startPosLine,\''+ICEcoder.htmlTagArray[i]+'\')"';
|
||||
if (i==0) {ICEcoder.nestDisplay.innerHTML += '<div '+events+' style="display: inline-block; width: 7px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif)"></div>'};
|
||||
ICEcoder.nestDisplay.innerHTML += '<a '+events+' style="display: inline-block; cursor: pointer; background: #333; padding: 7px 2px 7px 7px; margin-top: -5px; height: 30px">'+ICEcoder.htmlTagArray[i]+'</a>';
|
||||
ICEcoder.nestDisplay.innerHTML += i<ICEcoder.htmlTagArray.length-1
|
||||
? '<div '+events+' style="display: inline-block; width: 8px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif); background-position: -7px 0; cursor: pointer"></div>'
|
||||
: '<div '+events+' style="display: inline-block; width: 7px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif); background-position: -15px 0; cursor: pointer"></div>';
|
||||
}
|
||||
if (ICEcoder.tagString != "script") {
|
||||
ICEcoder.nestDisplay.innerHTML += '<a style="display: inline-block; cursor: default; padding: 7px 2px 7px 7px; margin-top: -5px; height: 30px; color: #666">content</a>';
|
||||
}
|
||||
}
|
||||
ICEcoder.getNestLocationSub(nestCheck, fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Indicate if the nesting structure of the code is OK
|
||||
updateNestingIndicator: function() {
|
||||
var cM, nestOK, fileName;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
nestOK = true;
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (cM && fileName && ["js","coffee","css","less","sql"].indexOf(fileName.split(".")[1])==-1) {
|
||||
nestOK = cM.getTokenAt({line:cM.lineCount(),ch:cM.lineInfo(cM.lineCount()-1).text.length}).className != "error" ? true : false;
|
||||
}
|
||||
ICEcoder.nestValid.style.background = nestOK ? "#0b0" : "#f00";
|
||||
ICEcoder.nestValid.title = nestOK ? "Nesting OK" : "Nesting Broken";
|
||||
},
|
||||
|
||||
// Get the caret position
|
||||
getCaretPosition: function() {
|
||||
var cM, line, ch, chPos;
|
||||
@@ -1446,35 +1353,6 @@ var ICEcoder = {
|
||||
top.ICEcoder.charDisplay.style.display = show == "char" ? "inline-block" : "none";
|
||||
},
|
||||
|
||||
// Determine which area of the document we're in
|
||||
caretLocationType: function() {
|
||||
var cM, caretLocType, caretChunk, fileName;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
caretLocType = "Unknown";
|
||||
caretChunk = cM.getValue().substr(0,ICEcoder.caretPos+1);
|
||||
if (caretChunk.lastIndexOf("<script")>caretChunk.lastIndexOf("</script>")&&caretLocType=="Unknown") {caretLocType = "JavaScript"}
|
||||
else if (caretChunk.lastIndexOf("<?")>caretChunk.lastIndexOf("?>")&&caretLocType=="Unknown") {caretLocType = "PHP"}
|
||||
else if (caretChunk.lastIndexOf("<%")>caretChunk.lastIndexOf("%>")&&caretLocType=="Unknown") {caretLocType = "Ruby"}
|
||||
else if (caretChunk.lastIndexOf("<")>caretChunk.lastIndexOf(">")&&caretLocType=="Unknown") {caretLocType = "HTML"}
|
||||
else if (caretLocType=="Unknown") {caretLocType = "Content"};
|
||||
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
if (fileName) {
|
||||
if (fileName.indexOf(".js")>0) {caretLocType="JavaScript"}
|
||||
else if (fileName.indexOf(".coffee")>0) {caretLocType="CoffeeScript"}
|
||||
else if (fileName.indexOf(".py")>0) {caretLocType="Python"}
|
||||
else if (fileName.indexOf(".rb")>0) {caretLocType="Ruby"}
|
||||
else if (fileName.indexOf(".css")>0) {caretLocType="CSS"}
|
||||
else if (fileName.indexOf(".less")>0) {caretLocType="LESS"}
|
||||
else if (fileName.indexOf(".md")>0) {caretLocType="Markdown"}
|
||||
else if (fileName.indexOf(".xml")>0) {caretLocType="XML"}
|
||||
else if (fileName.indexOf(".sql")>0) {caretLocType="SQL"};
|
||||
}
|
||||
|
||||
ICEcoder.caretLocType = caretLocType;
|
||||
},
|
||||
|
||||
// Show & hide target element
|
||||
showHide: function(doVis,elem) {
|
||||
elem.style.visibility = doVis=="show" ? 'visible' : 'hidden';
|
||||
|
||||
152
processes/on-editor-load.php
Normal file
152
processes/on-editor-load.php
Normal file
@@ -0,0 +1,152 @@
|
||||
<!--
|
||||
Purpose: This file is run when ICEcoder editor has loaded
|
||||
Langs: Anything - PHP, JS etc
|
||||
//-->
|
||||
<script>
|
||||
CodeMirror.commands.autocomplete = function(cm) {
|
||||
var langType = top.ICEcoder.caretLocType;
|
||||
if (["JavaScript","CoffeeScript","SQL","CSS","HTML","XML","Content"].indexOf(langType)>-1) {
|
||||
if (langType=="XML"||langType=="Content") {langType="HTML"};
|
||||
CodeMirror.showHint(cm,CodeMirror.hint[langType.toLowerCase()]);
|
||||
}
|
||||
}
|
||||
|
||||
// Switch the CodeMirror mode on demand
|
||||
top.ICEcoder.switchMode = function(mode) {
|
||||
var cM, fileName;
|
||||
|
||||
cM = top.ICEcoder.getcMInstance();
|
||||
fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
|
||||
if (cM && mode) {
|
||||
cM.setOption("mode",mode);
|
||||
} else if (cM && fileName) {
|
||||
fileName.indexOf('.js')>0 ? cM.setOption("mode","javascript")
|
||||
: fileName.indexOf('.coffee')>0 ? cM.setOption("mode","coffeescript")
|
||||
: fileName.indexOf('.rb')>0 ? cM.setOption("mode","ruby")
|
||||
: fileName.indexOf('.py')>0 ? cM.setOption("mode","python")
|
||||
: fileName.indexOf('.css')>0 ? cM.setOption("mode","css")
|
||||
: fileName.indexOf('.less')>0 ? cM.setOption("mode","less")
|
||||
: fileName.indexOf('.md')>0 ? cM.setOption("mode","markdown")
|
||||
: fileName.indexOf('.xml')>0 ? cM.setOption("mode","xml")
|
||||
: fileName.indexOf('.sql')>0 ? cM.setOption("mode","text/x-mysql") // also text/x-sql, text/x-mariadb, text/x-cassandra or text/x-plsql
|
||||
: cM.setOption("mode","application/x-httpd-php");
|
||||
}
|
||||
}
|
||||
|
||||
// Comment/uncomment line or selected range on keypress
|
||||
top.ICEcoder.lineCommentToggleSub = function(cM, cursorPos, linePos, lineContent, lCLen, adjustCursor) {
|
||||
var startLine, endLine;
|
||||
|
||||
if (["JavaScript","CoffeeScript","PHP","Python","Ruby","CSS","SQL"].indexOf(top.ICEcoder.caretLocType)>-1) {
|
||||
if (cM.somethingSelected()) {
|
||||
if (top.ICEcoder.caretLocType=="Ruby"||top.ICEcoder.caretLocType=="Python") {
|
||||
startLine = cM.getCursor(true).line;
|
||||
endLine = cM.getCursor().line;
|
||||
for (var i=startLine; i<=endLine; i++) {
|
||||
cM.setLine(i, cM.getLine(i).slice(0,1)!="#"
|
||||
? "#" + cM.getLine(i)
|
||||
: cM.getLine(i).slice(1,cM.getLine(i).length));
|
||||
}
|
||||
} else {
|
||||
cM.replaceSelection(cM.getSelection().slice(0,2)!="/*"
|
||||
? "/*" + cM.getSelection() + "*/"
|
||||
: cM.getSelection().slice(2,cM.getSelection().length-2));
|
||||
}
|
||||
} else {
|
||||
if (["CoffeeScript","CSS","SQL"].indexOf(top.ICEcoder.caretLocType)>-1) {
|
||||
cM.setLine(linePos, lineContent.slice(0,2)!="/*"
|
||||
? "/*" + lineContent + "*/"
|
||||
: lineContent.slice(2,lCLen).slice(0,lCLen-4));
|
||||
if (lineContent.slice(0,2)=="/*") {adjustCursor = -adjustCursor};
|
||||
} else if (top.ICEcoder.caretLocType=="Ruby") {
|
||||
cM.setLine(linePos, lineContent.slice(0,1)!="#"
|
||||
? "#" + lineContent
|
||||
: lineContent.slice(1,lCLen));
|
||||
if (lineContent.slice(0,1)=="#") {adjustCursor = -adjustCursor};
|
||||
} else {
|
||||
cM.setLine(linePos, lineContent.slice(0,2)!="//"
|
||||
? "//" + lineContent
|
||||
: lineContent.slice(2,lCLen));
|
||||
if (lineContent.slice(0,2)=="//") {adjustCursor = -adjustCursor};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (cM.somethingSelected()) {
|
||||
cM.replaceSelection(cM.getSelection().slice(0,4)!="<\!--"
|
||||
? "<\!--" + cM.getSelection() + "//-->"
|
||||
: cM.getSelection().slice(4,cM.getSelection().length-5));
|
||||
} else {
|
||||
cM.setLine(linePos, lineContent.slice(0,4)!="<\!--"
|
||||
? "<\!--" + lineContent + "//-->"
|
||||
: lineContent.slice(4,lCLen).slice(0,lCLen-9));
|
||||
adjustCursor = lineContent.slice(0,4)=="<\!--" ? -4 : 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Work out the nesting depth location on demand and update our display if required
|
||||
top.ICEcoder.getNestLocationSub = function(nestCheck, fileName) {
|
||||
var events;
|
||||
|
||||
if (["js","coffee","css","less","sql"].indexOf(fileName.split(".")[1])<0 &&
|
||||
(nestCheck.indexOf("include(")==-1)&&(nestCheck.indexOf("include_once(")==-1)) {
|
||||
|
||||
// Then for all the array items, output as the nest display
|
||||
for (var i=0;i<top.ICEcoder.htmlTagArray.length;i++) {
|
||||
events = 'onMouseover="top.ICEcoder.highlightBlock('+i+')" onMouseout="top.ICEcoder.highlightBlock('+i+',\'hide\')" onClick="top.ICEcoder.setPosition('+i+',top.ICEcoder.startPosLine,\''+top.ICEcoder.htmlTagArray[i]+'\')"';
|
||||
if (i==0) {top.ICEcoder.nestDisplay.innerHTML += '<div '+events+' style="display: inline-block; width: 7px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif)"></div>'};
|
||||
top.ICEcoder.nestDisplay.innerHTML += '<a '+events+' style="display: inline-block; cursor: pointer; background: #333; padding: 7px 2px 7px 7px; margin-top: -5px; height: 30px">'+top.ICEcoder.htmlTagArray[i]+'</a>';
|
||||
top.ICEcoder.nestDisplay.innerHTML += i<top.ICEcoder.htmlTagArray.length-1
|
||||
? '<div '+events+' style="display: inline-block; width: 8px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif); background-position: -7px 0; cursor: pointer"></div>'
|
||||
: '<div '+events+' style="display: inline-block; width: 7px; margin-top: -5px; height: 30px; background-image: url(images/nest-tag-bg.gif); background-position: -15px 0; cursor: pointer"></div>';
|
||||
}
|
||||
if (top.ICEcoder.tagString != "script") {
|
||||
top.ICEcoder.nestDisplay.innerHTML += '<a style="display: inline-block; cursor: default; padding: 7px 2px 7px 7px; margin-top: -5px; height: 30px; color: #666">content</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Indicate if the nesting structure of the code is OK
|
||||
top.ICEcoder.updateNestingIndicator = function() {
|
||||
var cM, nestOK, fileName;
|
||||
|
||||
cM = top.ICEcoder.getcMInstance();
|
||||
nestOK = true;
|
||||
fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
|
||||
if (cM && fileName && ["js","coffee","css","less","sql"].indexOf(fileName.split(".")[1])==-1) {
|
||||
nestOK = cM.getTokenAt({line:cM.lineCount(),ch:cM.lineInfo(cM.lineCount()-1).text.length}).className != "error" ? true : false;
|
||||
}
|
||||
top.ICEcoder.nestValid.style.background = nestOK ? "#0b0" : "#f00";
|
||||
top.ICEcoder.nestValid.title = nestOK ? "Nesting OK" : "Nesting Broken";
|
||||
}
|
||||
|
||||
// Determine which area of the document we're in
|
||||
top.ICEcoder.caretLocationType = function() {
|
||||
var cM, caretLocType, caretChunk, fileName;
|
||||
|
||||
cM = top.ICEcoder.getcMInstance();
|
||||
caretLocType = "Unknown";
|
||||
caretChunk = cM.getValue().substr(0,top.ICEcoder.caretPos+1);
|
||||
|
||||
if(caretChunk.lastIndexOf("<script")>caretChunk.lastIndexOf("/script>")&&caretLocType=="Unknown") {caretLocType = "JavaScript";}
|
||||
else if (caretChunk.lastIndexOf("<?")>caretChunk.lastIndexOf("?>")&&caretLocType=="Unknown") {caretLocType = "PHP";}
|
||||
else if (caretChunk.lastIndexOf("<%")>caretChunk.lastIndexOf("%>")&&caretLocType=="Unknown") {caretLocType = "Ruby";}
|
||||
else if (caretChunk.lastIndexOf("<")>caretChunk.lastIndexOf(">")&&caretLocType=="Unknown") {caretLocType = "HTML";}
|
||||
else if (caretLocType=="Unknown") {caretLocType = "Content";};
|
||||
|
||||
fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
|
||||
if (fileName) {
|
||||
if (fileName.indexOf(".js")>0) {caretLocType="JavaScript"}
|
||||
else if (fileName.indexOf(".coffee")>0) {caretLocType="CoffeeScript"}
|
||||
else if (fileName.indexOf(".py")>0) {caretLocType="Python"}
|
||||
else if (fileName.indexOf(".rb")>0) {caretLocType="Ruby"}
|
||||
else if (fileName.indexOf(".css")>0) {caretLocType="CSS"}
|
||||
else if (fileName.indexOf(".less")>0) {caretLocType="LESS"}
|
||||
else if (fileName.indexOf(".md")>0) {caretLocType="Markdown"}
|
||||
else if (fileName.indexOf(".xml")>0) {caretLocType="XML"}
|
||||
else if (fileName.indexOf(".sql")>0) {caretLocType="SQL"};
|
||||
}
|
||||
|
||||
top.ICEcoder.caretLocType = caretLocType;
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user