mirror of
https://github.com/icecoder/ICEcoder.git
synced 2026-03-07 00:56:48 +01:00
Condensing & removing code & tweaks
Tweaking comments to be more accurate Removed snippetLine, no longer used Handling openClose dir in a more simplistic way, only need to define iframe.src once Replaced text is no longer lowercase Setting the cursor by setting zone as a variable and then using that Removed 2 x calls to removeSnippet, no longer a function Correcting unnecessary .parent
This commit is contained in:
@@ -5,7 +5,7 @@ var ICEcoder = {
|
||||
// ==============
|
||||
|
||||
// Define settings
|
||||
filesW: 250, // Initial width of the files pane
|
||||
filesW: 250, // Width of the files pane
|
||||
minFilesW: 14, // Min width of the files pane
|
||||
maxFilesW: 250, // Max width of the files pane
|
||||
selectedTab: 0, // The tab that's currently selected
|
||||
@@ -13,7 +13,7 @@ var ICEcoder = {
|
||||
ctrlKeyDown: false, // Indicates if CTRL keydown
|
||||
altKeyDown: false, // Indicates if Alt keydown
|
||||
shiftKeyDown: false, // Indicates if Shift keydown
|
||||
delKeyDown: false, // Indicates if DEL keydown
|
||||
delKeyDown: false, // Indicates if Del keydown
|
||||
canSwitchTabs: true, // Stops switching of tabs when trying to close
|
||||
openFiles: [], // Array of open file URLs
|
||||
openFileMDTs: [], // Array of open file modification datetimes
|
||||
@@ -24,7 +24,6 @@ var ICEcoder = {
|
||||
lockedNav: true, // Nav is locked or not
|
||||
htmlTagArray: [], // Array storing the nest of tags
|
||||
codeAssist: true, // Assist user with their coding
|
||||
snippetLine: false, // Line no of snippet, if shown
|
||||
mouseDown: false, // If the mouse is down or not
|
||||
draggingFilesW: false, // If we're dragging the file manager width or not
|
||||
draggingTab: false, // If we're dragging a tab
|
||||
@@ -224,7 +223,7 @@ var ICEcoder = {
|
||||
}
|
||||
},
|
||||
|
||||
// Comment or uncomment line on keypress
|
||||
// Comment/uncomment line or selected range on keypress
|
||||
lineCommentToggle: function() {
|
||||
var cM, cursorPos, linePos, lineContent, lCLen, adjustCursor, startLine, endLine;
|
||||
|
||||
@@ -379,22 +378,23 @@ var ICEcoder = {
|
||||
|
||||
// Open/close dirs on demand
|
||||
openCloseDir: function(dir,load) {
|
||||
var node, d;
|
||||
|
||||
dir.onclick = function() {top.ICEcoder.openCloseDir(this,false)};
|
||||
var node = dir.parentNode;
|
||||
node = dir.parentNode;
|
||||
if (node.nextSibling) {node = node.nextSibling};
|
||||
if (node && node.tagName=="UL") {
|
||||
d = node.style.display=="none";
|
||||
d ? load = true : node.style.display = "none";
|
||||
dir.parentNode.className = dir.className = d ? "pft-directory dirOpen" : "pft-directory";
|
||||
}
|
||||
if (load) {
|
||||
top.ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href = "lib/get-branch.php?location="+dir.childNodes[1].id;
|
||||
} else if (node && node.tagName=="UL") {
|
||||
var d = node.style.display=="none";
|
||||
if (d) {
|
||||
top.ICEcoder.filesFrame.contentWindow.frames['fileControl'].location.href = "lib/get-branch.php?location="+dir.childNodes[1].id;
|
||||
} else {node.style.display = "none"}
|
||||
dir.parentNode.className=dir.className = d ? "pft-directory dirOpen" : "pft-directory";
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
// Note which files or foldets we are over on mouseover/mouseout
|
||||
// Note which files or folders we are over on mouseover/mouseout
|
||||
overFileFolder: function(type, link) {
|
||||
ICEcoder.thisFileFolderType=type;
|
||||
ICEcoder.thisFileFolderLink=link;
|
||||
@@ -495,7 +495,7 @@ var ICEcoder = {
|
||||
}
|
||||
},
|
||||
|
||||
// Open a file on demand
|
||||
// Open a file
|
||||
openFile: function(fileLink) {
|
||||
var shortURL, canOpenFile;
|
||||
|
||||
@@ -541,7 +541,7 @@ var ICEcoder = {
|
||||
}
|
||||
},
|
||||
|
||||
// Save a file on demand
|
||||
// Save a file
|
||||
saveFile: function(saveAs) {
|
||||
var saveType;
|
||||
|
||||
@@ -550,7 +550,7 @@ var ICEcoder = {
|
||||
top.ICEcoder.serverMessage('<b>Saving</b><br>'+ICEcoder.openFiles[ICEcoder.selectedTab-1].replace(top.iceRoot,""));
|
||||
},
|
||||
|
||||
// Prompt a rename dialog on demand
|
||||
// Prompt a rename dialog
|
||||
renameFile: function(oldName,newName) {
|
||||
var shortURL, fileName, i;
|
||||
|
||||
@@ -580,12 +580,11 @@ var ICEcoder = {
|
||||
}
|
||||
},
|
||||
|
||||
// Delete a file on demand
|
||||
// Delete a file
|
||||
deleteFile: function() {
|
||||
var delFiles, selectedFilesList;
|
||||
|
||||
delFiles = top.ICEcoder.ask('Delete:\n\n'+top.ICEcoder.selectedFiles.toString().replace(/\|/g,"/").replace(/,/g,"\n")+'?');
|
||||
// Upon supply a new name, rename tabs and update filename on server
|
||||
if (delFiles) {
|
||||
selectedFilesList = "";
|
||||
for (var i=0;i<top.ICEcoder.selectedFiles.length;i++) {
|
||||
@@ -597,14 +596,14 @@ var ICEcoder = {
|
||||
};
|
||||
},
|
||||
|
||||
// Copy a file on demand
|
||||
// Copy a file
|
||||
copyFile: function(selFile) {
|
||||
top.ICEcoder.copiedFile = selFile;
|
||||
top.document.getElementById('fmMenuPasteOption').style.display = "block";
|
||||
top.ICEcoder.hideFileMenu();
|
||||
},
|
||||
|
||||
// Paste a file on demand
|
||||
// Paste a file
|
||||
pasteFile: function(location) {
|
||||
if (top.ICEcoder.copiedFile) {
|
||||
top.ICEcoder.serverQueue("add","lib/file-control.php?action=paste&file="+top.ICEcoder.copiedFile+"&location="+location);
|
||||
@@ -786,7 +785,7 @@ var ICEcoder = {
|
||||
}
|
||||
},
|
||||
|
||||
// Refresh file manager on demand
|
||||
// Refresh file manager
|
||||
refreshFileManager: function() {
|
||||
var pB;
|
||||
|
||||
@@ -824,7 +823,7 @@ var ICEcoder = {
|
||||
|
||||
// Determine our find & replace strings and the length of them
|
||||
find = top.document.getElementById('find').value.toLowerCase();
|
||||
replace = top.document.getElementById('replace').value.toLowerCase();
|
||||
replace = top.document.getElementById('replace').value;
|
||||
results = top.document.getElementById('results');
|
||||
|
||||
// If we have something to find in currrent document
|
||||
@@ -1005,11 +1004,11 @@ var ICEcoder = {
|
||||
if (cM && fileName && ["js","coffee","rb","css","less"].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.backgroundColor = nestOK ? "#0b0" : "#f00";
|
||||
ICEcoder.nestValid.style.background = nestOK ? "#0b0" : "#f00";
|
||||
ICEcoder.nestValid.innerHTML = nestOK ? "Nesting OK" : "Nesting Broken";
|
||||
},
|
||||
|
||||
// Get the caret position on demand
|
||||
// Get the caret position
|
||||
getCaretPosition: function() {
|
||||
var cM, content, line, char, charPos, charCount;
|
||||
|
||||
@@ -1079,7 +1078,7 @@ var ICEcoder = {
|
||||
},
|
||||
|
||||
|
||||
// Determine the CodeMirror instance we're using on demand
|
||||
// Determine the CodeMirror instance we're using
|
||||
getcMInstance: function(newTab) {
|
||||
return top.ICEcoder.content.contentWindow[
|
||||
newTab=="new"||(newTab!="new" && ICEcoder.openFiles.length>0)
|
||||
@@ -1088,7 +1087,7 @@ var ICEcoder = {
|
||||
];
|
||||
},
|
||||
|
||||
// Get the mouse position on demand
|
||||
// Get the mouse position
|
||||
getMouseXY: function(e,area) {
|
||||
var tempX, tempY, scrollTop;
|
||||
|
||||
@@ -1106,7 +1105,7 @@ var ICEcoder = {
|
||||
|
||||
// Test if we need to show a drag cursor or not
|
||||
dragCursorTest: function() {
|
||||
var winH, cursorName, diffX;
|
||||
var winH, cursorName, diffX, zone;
|
||||
|
||||
diffX = top.ICEcoder.mouseX - top.ICEcoder.diffStartX;
|
||||
if (top.ICEcoder.draggingTab!==false && top.ICEcoder.diffStartX && (diffX <= -10 || diffX >= 10)) {
|
||||
@@ -1125,8 +1124,8 @@ var ICEcoder = {
|
||||
: "auto";
|
||||
if (top.ICEcoder.content.contentWindow.document && top.ICEcoder.filesFrame.contentWindow) {
|
||||
top.document.body.style.cursor = cursorName;
|
||||
if (top.ICEcoder.content.contentWindow.document.body) {top.ICEcoder.content.contentWindow.document.body.style.cursor = cursorName};
|
||||
if (top.ICEcoder.filesFrame.contentWindow.document.body) {top.ICEcoder.filesFrame.contentWindow.document.body.style.cursor = cursorName};
|
||||
if (zone = top.ICEcoder.content.contentWindow.document.body) {zone.style.cursor = cursorName};
|
||||
if (zone = top.ICEcoder.filesFrame.contentWindow.document.body) {zone.style.cursor = cursorName};
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -1171,7 +1170,7 @@ var ICEcoder = {
|
||||
}
|
||||
},
|
||||
|
||||
// Change opacity of the file manager icons on demand
|
||||
// Change opacity of the file manager icons
|
||||
fMIconVis: function(icon, vis) {
|
||||
var i;
|
||||
|
||||
@@ -1663,7 +1662,7 @@ var ICEcoder = {
|
||||
}
|
||||
// Highlight the selected tab after splicing the change state out of the array
|
||||
top.ICEcoder.changedContent.splice(closeTabNum-1,1);
|
||||
top.parent.ICEcoder.redoTabHighlight(ICEcoder.selectedTab);
|
||||
top.ICEcoder.redoTabHighlight(ICEcoder.selectedTab);
|
||||
|
||||
// Update the nesting indicator
|
||||
top.ICEcoder.getNestLocation('update');
|
||||
@@ -2011,10 +2010,6 @@ var ICEcoder = {
|
||||
addSnippet: function() {
|
||||
var cM, lineNo, whiteSpace, content;
|
||||
|
||||
if (top.ICEcoder.snippetLine!==false) {
|
||||
top.ICEcoder.removeSnippet();
|
||||
}
|
||||
|
||||
cM = ICEcoder.getcMInstance();
|
||||
lineNo = cM.getCursor().line;
|
||||
whiteSpace = cM.getLine(lineNo).length - cM.getLine(lineNo).replace(/^\s\s*/, '').length;
|
||||
@@ -2057,7 +2052,6 @@ var ICEcoder = {
|
||||
cM.setLine(lineNo, replacedLine.replace("CURSOR",""));
|
||||
cM.setCursor(lineNoCount,curPos);
|
||||
cM.focus();
|
||||
top.ICEcoder.removeSnippet();
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user