mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-09 01:56:46 +01:00
Clearing global vars
theme, tabsIndent, openLastFiles, tabWidth, previousFiles, showFileMenu & foldStyle all now contained within ICEcoder object showFileMenu is a function to ensure file manager menu continues to show The few instances of i now have scope Initing the var fileName This is to reduce the number of global vars The only global vars should now be ICEcoder, docRoot & iceRoot
This commit is contained in:
12
editor.php
12
editor.php
@@ -92,16 +92,16 @@ span.CodeMirror-matchhighlight {background: #555}
|
||||
<script>
|
||||
function createNewCMInstance(num) {
|
||||
var fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
|
||||
top.foldStyle = '<span style="position: absolute; display: inline-block; width: 13px; height: 13px; left: 0; background-color: #b00; color: #fff; text-align: center; cursor: pointer"><span style="position: relative; left: -1px">+</span></span> %N%';
|
||||
var codeFoldTag = CodeMirror.newFoldFunction(CodeMirror.tagRangeFinder,top.foldStyle);
|
||||
var codeFoldBrace = CodeMirror.newFoldFunction(CodeMirror.braceRangeFinder,top.foldStyle);
|
||||
top.ICEcoder.foldStyle = '<span style="position: absolute; display: inline-block; width: 13px; height: 13px; left: 0; background-color: #b00; color: #fff; text-align: center; cursor: pointer"><span style="position: relative; left: -1px">+</span></span> %N%';
|
||||
var codeFoldTag = CodeMirror.newFoldFunction(CodeMirror.tagRangeFinder,top.ICEcoder.foldStyle);
|
||||
var codeFoldBrace = CodeMirror.newFoldFunction(CodeMirror.braceRangeFinder,top.ICEcoder.foldStyle);
|
||||
|
||||
window['cM'+num] = CodeMirror(document.body, {
|
||||
mode: "application/x-httpd-php",
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
indentUnit: top.tabWidth,
|
||||
tabSize: top.tabWidth,
|
||||
indentUnit: top.ICEcoder.tabWidth,
|
||||
tabSize: top.ICEcoder.tabWidth,
|
||||
indentWithTabs: true,
|
||||
electricChars: false,
|
||||
onCursorActivity: function(thisCM) {
|
||||
@@ -175,7 +175,7 @@ function createNewCMInstance(num) {
|
||||
},
|
||||
onGutterClick: !fileName || (fileName && fileName.indexOf(".js") == -1 && fileName.indexOf(".coffee") == -1 && fileName.indexOf(".php") && fileName.indexOf(".rb") == -1) ? codeFoldTag : codeFoldBrace,
|
||||
extraKeys: {
|
||||
"Tab": function(cm) {CodeMirror.commands[top.tabsIndent ? "defaultTab" : "insertTab"](cm);},
|
||||
"Tab": function(cm) {CodeMirror.commands[top.ICEcoder.tabsIndent ? "defaultTab" : "insertTab"](cm);},
|
||||
"Shift-Tab": "indentLess",
|
||||
"Ctrl-Up": function() {},
|
||||
"Ctrl-Down": function() {}
|
||||
|
||||
44
index.php
44
index.php
@@ -31,10 +31,6 @@ if ($ICEcoder["checkUpdates"]) {
|
||||
<link rel="stylesheet" type="text/css" href="lib/ice-coder.css">
|
||||
<link rel="icon" type="image/png" href="favicon.png">
|
||||
<script>
|
||||
theme = "<?php echo $ICEcoder["theme"]=="default" ? 'icecoder' : $ICEcoder["theme"];?>";
|
||||
tabsIndent = <?php echo $ICEcoder["tabsIndent"] ? 'true' : 'false';?>;
|
||||
openLastFiles = <?php echo $ICEcoder["openLastFiles"] ? 'true' : 'false';?>;
|
||||
tabWidth = <?php echo $ICEcoder["tabWidth"]; ?>;
|
||||
iceRoot = "<?php echo $ICEcoder["root"]; ?>";
|
||||
|
||||
window.onbeforeunload = function() {
|
||||
@@ -43,20 +39,26 @@ window.onbeforeunload = function() {
|
||||
}
|
||||
}
|
||||
|
||||
previousFiles = [<?php
|
||||
if ($ICEcoder["previousFiles"]!="") {
|
||||
$openFilesArray = explode(",",$ICEcoder["previousFiles"]);
|
||||
echo "'".implode("','",$openFilesArray)."'";
|
||||
}
|
||||
?>];
|
||||
showFileMenu = function() {
|
||||
document.getElementById('fileMenu').style.display='inline-block';
|
||||
}
|
||||
</script>
|
||||
<script language="JavaScript" src="lib/ice-coder.js"></script>
|
||||
</head>
|
||||
|
||||
<body onLoad="ICEcoder.init()<?php echo $updateMsg.$onLoadExtras;?>" onResize="ICEcoder.setLayout()" onKeyDown="return ICEcoder.interceptKeys('coder',event);" onKeyUp="parent.ICEcoder.resetKeys(event);">
|
||||
<body onLoad="<?php
|
||||
echo 'top.ICEcoder.previousFiles = [';
|
||||
if ($ICEcoder["previousFiles"]!="") {
|
||||
$openFilesArray = explode(",",$ICEcoder["previousFiles"]);
|
||||
echo "'".implode("','",$openFilesArray)."'";
|
||||
}
|
||||
echo "];top.ICEcoder.theme = '";
|
||||
echo $ICEcoder["theme"]=="default" ? 'icecoder' : $ICEcoder["theme"];
|
||||
echo "'";
|
||||
echo ';top.ICEcoder.tabsIndent = ';
|
||||
echo $ICEcoder["tabsIndent"] ? 'true' : 'false';
|
||||
echo ';top.ICEcoder.openLastFiles = ';
|
||||
echo $ICEcoder["openLastFiles"] ? 'true' : 'false';
|
||||
echo ';top.ICEcoder.tabWidth = ';
|
||||
echo $ICEcoder["tabWidth"];
|
||||
?>;ICEcoder.init()<?php echo $updateMsg.$onLoadExtras;?>" onResize="ICEcoder.setLayout()" onKeyDown="return ICEcoder.interceptKeys('coder',event);" onKeyUp="parent.ICEcoder.resetKeys(event);">
|
||||
|
||||
<div id="blackMask" class="blackMask" onClick="ICEcoder.showHide('hide',this)" onContextMenu="return false">
|
||||
<div class="popupVCenter">
|
||||
@@ -77,16 +79,16 @@ showFileMenu = function() {
|
||||
|
||||
<div id="fileMenu" class="fileMenu" onMouseOver="ICEcoder.changeFilesW('expand')" onMouseOut="ICEcoder.changeFilesW('contract');this.style.display='none'" onContextMenu="return false">
|
||||
<span id="folderMenuItems">
|
||||
<a href="javascript:top.ICEcoder.newFile()" onMouseOver="showFileMenu()">New File</a>
|
||||
<a href="javascript:top.ICEcoder.newFolder()" onMouseOver="showFileMenu()">New Folder</a>
|
||||
<a href="javascript:top.ICEcoder.newFile()" onMouseOver="ICEcoder.showFileMenu()">New File</a>
|
||||
<a href="javascript:top.ICEcoder.newFolder()" onMouseOver="ICEcoder.showFileMenu()">New Folder</a>
|
||||
</span>
|
||||
<a href="javascript:top.ICEcoder.deleteFile(top.ICEcoder.rightClickedFile)" onMouseOver="showFileMenu()">Delete</a>
|
||||
<a href="javascript:top.ICEcoder.deleteFile(top.ICEcoder.rightClickedFile)" onMouseOver="ICEcoder.showFileMenu()">Delete</a>
|
||||
<span id="singleFileMenuItems">
|
||||
<a href="javascript:top.ICEcoder.renameFile(top.ICEcoder.rightClickedFile)" onMouseOver="showFileMenu()">Rename</a>
|
||||
<a href="javascript:window.open(top.ICEcoder.rightClickedFile)" onMouseOver="showFileMenu()">View Webpage</a>
|
||||
<a href="javascript:top.ICEcoder.renameFile(top.ICEcoder.rightClickedFile)" onMouseOver="ICEcoder.showFileMenu()">Rename</a>
|
||||
<a href="javascript:window.open(top.ICEcoder.rightClickedFile)" onMouseOver="ICEcoder.showFileMenu()">View Webpage</a>
|
||||
</span>
|
||||
<a href="javascript:top.ICEcoder.zipIt(top.ICEcoder.rightClickedFile)" onMouseOver="showFileMenu()">Zip It!</a>
|
||||
<a href="javascript:top.ICEcoder.propertiesScreen(top.ICEcoder.rightClickedFile)" onMouseOver="showFileMenu()">Properties</a>
|
||||
<a href="javascript:top.ICEcoder.zipIt(top.ICEcoder.rightClickedFile)" onMouseOver="ICEcoder.showFileMenu()">Zip It!</a>
|
||||
<a href="javascript:top.ICEcoder.propertiesScreen(top.ICEcoder.rightClickedFile)" onMouseOver="ICEcoder.showFileMenu()">Properties</a>
|
||||
</div>
|
||||
|
||||
<div id="header" class="header" onContextMenu="return false">
|
||||
|
||||
@@ -53,7 +53,7 @@ var ICEcoder = {
|
||||
|
||||
// Hide the loading screen & auto open last files?
|
||||
top.ICEcoder.showHide('hide',top.document.getElementById('loadingMask'));
|
||||
if (top.openLastFiles) {top.ICEcoder.autoOpenFiles()};
|
||||
if (top.ICEcoder.openLastFiles) {top.ICEcoder.autoOpenFiles()};
|
||||
|
||||
// Add drag based events to our tabs
|
||||
var tabs = document.querySelectorAll('.tab');
|
||||
@@ -103,7 +103,7 @@ var ICEcoder = {
|
||||
|
||||
// Resize the CodeMirror instances to match the window size
|
||||
setTimeout(function(){
|
||||
for (i=0;i<top.ICEcoder.openFiles.length;i++) {
|
||||
for (var i=0;i<top.ICEcoder.openFiles.length;i++) {
|
||||
top.ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setSize("100%",top.ICEcoder.content.style.height);
|
||||
}},4);
|
||||
}
|
||||
@@ -216,7 +216,7 @@ var ICEcoder = {
|
||||
|
||||
// Switch the CodeMirror mode on demand
|
||||
switchMode: function() {
|
||||
var cM;
|
||||
var cM, fileName;
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
fileName = ICEcoder.openFiles[ICEcoder.selectedTab-1];
|
||||
@@ -612,6 +612,11 @@ var ICEcoder = {
|
||||
return false;
|
||||
},
|
||||
|
||||
// Continue to show the file manager
|
||||
showFileMenu: function() {
|
||||
document.getElementById('fileMenu').style.display='inline-block';
|
||||
},
|
||||
|
||||
// Update the file manager tree list on demand
|
||||
updateFileManagerList: function(action,location,file,perms,oldName) {
|
||||
var actionElemType, cssStyle, perms, targetElem, locNest, newText, innerLI, newUL, newLI, elemType, nameLI, shortURL, newMouseOver;
|
||||
@@ -1157,7 +1162,7 @@ var ICEcoder = {
|
||||
cM = ICEcoder.getcMInstance();
|
||||
// Firstly, work out how many saves we have to carry out
|
||||
nextSaveID=0;
|
||||
for (i=0;i<ICEcoder.serverQueueItems.length;i++) {
|
||||
for (var i=0;i<ICEcoder.serverQueueItems.length;i++) {
|
||||
if (ICEcoder.serverQueueItems[i].indexOf('action=save')>0) {
|
||||
nextSaveID++;
|
||||
}
|
||||
@@ -1177,7 +1182,7 @@ var ICEcoder = {
|
||||
if (action=="del") {
|
||||
if (ICEcoder.serverQueueItems[0] && ICEcoder.serverQueueItems[0].indexOf('action=save')>0) {
|
||||
topSaveID = nextSaveID-1;
|
||||
for (i=1;i<topSaveID;i++) {
|
||||
for (var i=1;i<topSaveID;i++) {
|
||||
document.getElementById('saveTemp'+i).value = document.getElementById('saveTemp'+(i+1)).value;
|
||||
}
|
||||
element = document.getElementById('saveTemp'+topSaveID);
|
||||
@@ -1217,8 +1222,8 @@ var ICEcoder = {
|
||||
|
||||
// Opens the last files we had open
|
||||
autoOpenFiles: function() {
|
||||
for (var i=0;i<top.previousFiles.length;i++) {
|
||||
top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=top.previousFiles[i].replace('|','/');
|
||||
for (var i=0;i<top.ICEcoder.previousFiles.length;i++) {
|
||||
top.ICEcoder.rightClickedFile=top.ICEcoder.thisFileFolderLink=top.ICEcoder.previousFiles[i].replace('|','/');
|
||||
top.ICEcoder.thisFileFolderType='file';
|
||||
top.ICEcoder.openFile();
|
||||
}
|
||||
@@ -1249,18 +1254,18 @@ var ICEcoder = {
|
||||
var styleNode, strCSS, cMCSS, activeLineBG;
|
||||
|
||||
// Add new stylesheet for selected theme
|
||||
top.theme = themeURL.slice(themeURL.lastIndexOf("/")+1,themeURL.lastIndexOf("."));
|
||||
if (top.theme=="editor") {top.theme="icecoder"};
|
||||
top.ICEcoder.theme = themeURL.slice(themeURL.lastIndexOf("/")+1,themeURL.lastIndexOf("."));
|
||||
if (top.ICEcoder.theme=="editor") {top.ICEcoder.theme="icecoder"};
|
||||
styleNode = document.createElement('link');
|
||||
styleNode.setAttribute('rel', 'stylesheet');
|
||||
styleNode.setAttribute('type', 'text/css');
|
||||
styleNode.setAttribute('href', themeURL);
|
||||
top.ICEcoder.content.contentWindow.document.getElementsByTagName('head')[0].appendChild(styleNode);
|
||||
activeLineBG = ["eclipse","elegant","neat"].indexOf(top.theme)>-1 ? "#ccc": "#000";
|
||||
activeLineBG = ["eclipse","elegant","neat"].indexOf(top.ICEcoder.theme)>-1 ? "#ccc": "#000";
|
||||
top.ICEcoder.switchTab(top.ICEcoder.selectedTab);
|
||||
|
||||
// Tabs indent setting
|
||||
top.tabsIndent = tabsIndent;
|
||||
top.ICEcoder.tabsIndent = tabsIndent;
|
||||
|
||||
// Check/uncheck Code Assist setting
|
||||
top.document.getElementById('codeAssist').checked = codeAssist;
|
||||
@@ -1277,10 +1282,10 @@ var ICEcoder = {
|
||||
cMCSS[strCSS][5].style['content'] = visibleTabs ? '"\\21e5"' : '" "';
|
||||
cMCSS[strCSS][2].style.cssText = "background: " + activeLineBG + " !important";
|
||||
|
||||
top.tabWidth = tabWidth;
|
||||
top.ICEcoder.tabWidth = tabWidth;
|
||||
for (var i=0;i<ICEcoder.cMInstances.length;i++) {
|
||||
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("indentUnit", top.tabWidth);
|
||||
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("tabSize", top.tabWidth);
|
||||
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("indentUnit", top.ICEcoder.tabWidth);
|
||||
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setOption("tabSize", top.ICEcoder.tabWidth);
|
||||
}
|
||||
|
||||
// Finally, refresh the file manager if we need to
|
||||
@@ -1421,7 +1426,7 @@ var ICEcoder = {
|
||||
for (var i=0;i<ICEcoder.cMInstances.length;i++) {
|
||||
ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].getWrapperElement().style.display = "none";
|
||||
}
|
||||
cM.setOption('theme',top.theme);
|
||||
cM.setOption('theme',top.ICEcoder.theme);
|
||||
cM.getWrapperElement().style.display = "block";
|
||||
|
||||
// Focus on & refresh our selected instance
|
||||
|
||||
@@ -162,8 +162,8 @@ function findSequence(goal) {
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
readOnly: "nocursor",
|
||||
indentUnit: top.tabWidth,
|
||||
tabSize: top.tabWidth,
|
||||
indentUnit: top.ICEcoder.tabWidth,
|
||||
tabSize: top.ICEcoder.tabWidth,
|
||||
mode: "javascript",
|
||||
theme: "<?php echo $ICEcoder["theme"]=="default" ? 'icecoder' : $ICEcoder["theme"];?>"
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user