diff --git a/lib/coder.js b/lib/coder.js index 9387e98..22dc755 100644 --- a/lib/coder.js +++ b/lib/coder.js @@ -25,13 +25,16 @@ var ICEcoder = { mouseDown: false, // If the mouse is down or not draggingFilesW: false, // If we're dragging the file manager width or not serverQueueItems: [], // Array of URLs to call in order + stickyTab: false, // If we have a sticky tab open or not + stickyTabWindow: false, // Target variable for the sticky tab window + pluginIntervalRefs: [], // Array of plugin interval refs // Don't consider these tags as part of nesting as they're singles, JS, PHP or Ruby code blocks tagNestExceptions: ["!DOCTYPE","meta","link","img","br","hr","input","script","?php","?","%"], // On load, set aliases, set the layout and get the nest location - init: function() { - var aliasArray = ["header","files","account","fmLock","filesFrame","editor","tabsBar","findBar","content","footer","nestValid","nestDisplay","charDisplay"]; + init: function(login) { + var aliasArray = ["header","files","account","accountLogin","fmLock","filesFrame","editor","tabsBar","findBar","content","footer","nestValid","nestDisplay","charDisplay"]; // Create our ID aliases for (var i=0;i0) { - cM.setOption("mode","javascript"); - } else if (fileName.indexOf('.rb')>0) { - cM.setOption("mode","ruby"); - } else if (fileName.indexOf('.css')>0) { - cM.setOption("mode","css"); - } else { - cM.setOption("mode","application/x-httpd-php"); + if (fileName) { + if (fileName.indexOf('.js')>0) { + cM.setOption("mode","javascript"); + } else if (fileName.indexOf('.rb')>0) { + cM.setOption("mode","ruby"); + } else if (fileName.indexOf('.css')>0) { + cM.setOption("mode","css"); + } else { + cM.setOption("mode","application/x-httpd-php"); + } } }, @@ -960,19 +981,22 @@ var ICEcoder = { }, // Start running plugin intervals according to given specifics - startPluginIntervals: function(plugURL,plugTarget,plugTimer) { + startPluginIntervals: function(plugRef,plugURL,plugTarget,plugTimer) { // For this window instances if (plugTarget=="_parent"||plugTarget=="_top"||plugTarget=="_self"||plugTarget=="") { - setInterval('window.location=\''+plugURL+'\'',plugTimer*1000*60); + top.ICEcoder['plugTimer'+plugRef] = setInterval('window.location=\''+plugURL+'\'',plugTimer*1000*60); // for fileControl iframe instances } else if (plugTarget.indexOf("fileControl")==0) { - setInterval(function() {top.ICEcoder.serverQueue("add",plugURL);top.ICEcoder.serverMessage(plugTarget.split(":")[1]);},plugTimer*1000*60); + top.ICEcoder['plugTimer'+plugRef] = setInterval(function() {top.ICEcoder.serverQueue("add",plugURL);top.ICEcoder.serverMessage(plugTarget.split(":")[1]);},plugTimer*1000*60); // for _blank or named target window instances } else { - setInterval('window.open(\''+plugURL+'\',\''+plugTarget+'\')',plugTimer*1000*60); + top.ICEcoder['plugTimer'+plugRef] = setInterval('window.open(\''+plugURL+'\',\''+plugTarget+'\')',plugTimer*1000*60); } + + // push the plugin ref into our array + top.ICEcoder.pluginIntervalRefs.push(plugRef); }, // Comment or uncomment line on keypress @@ -1363,13 +1387,65 @@ var ICEcoder = { }, // Refresh file manager on demand - refreshFileManager: function() { + refreshFileManager: function(loginAttempt) { top.document.getElementById('loadingMask').style.visibility = "visible"; top.ICEcoder.filesFrame.src="files.php"; top.ICEcoder.filesFrame.style.opacity="0"; top.ICEcoder.filesFrame.onload = function() { top.ICEcoder.filesFrame.style.opacity="1"; top.document.getElementById('loadingMask').style.visibility = "hidden"; + if (loginAttempt) { + if (loginAttempt == "loginOK") { + top.document.getElementById('accountLogin').style.top = "-50px"; + setTimeout(function() {top.document.getElementById('accountLoginContainer').style.display = "none";},300); + } else { + alert('Sorry, that\'s not correct.'); + } + } } + }, + + // Show the settings screen + settingsScreen: function(vis) { + if (vis=="show") { + top.document.getElementById('mediaContainer').innerHTML = ''; + } + top.ICEcoder.showHide(vis,top.document.getElementById('blackMask')); + }, + + // Update the settings used when we make a change to them + useNewSettings: function(themeURL,tabsIndent,codeAssist,lockedNav,visibleTabs,refreshFM) { + var styleNode, strCSS, cMCSS; + + // Add new stylesheet for selected theme + top.theme = themeURL.slice(themeURL.lastIndexOf("/")+1,themeURL.lastIndexOf(".")); + if (top.theme=="editor") {top.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); + top.ICEcoder.switchTab(top.ICEcoder.selectedTab); + + // Tabs indent setting + top.tabsIndent = tabsIndent; + + // Check/uncheck Code Assist setting + top.document.getElementById('codeAssist').checked = codeAssist; + + // Unlock/lock the file manager + if (lockedNav != top.ICEcoder.lockedNav) {top.ICEcoder.lockUnlockNav()}; + if (!lockedNav) { + ICEcoder.changeFilesW('contract'); + top.document.getElementById('fileMenu').style.display='none'; + } + + // Show visible tabs or not + document.all ? strCSS = 'rules' : strCSS = 'cssRules'; + cMCSS = ICEcoder.content.contentWindow.document; + visibleTabs ? cMCSS.styleSheets[2][strCSS][5].style['content'] = '"\\21e5"' : cMCSS.styleSheets[2][strCSS][5].style['content'] = '" "'; + + // Finally, refresh the file manager if we need to + if (refreshFM) {top.ICEcoder.refreshFileManager()}; } }; \ No newline at end of file