From 89777eebcf0120b376b55f46f930683fad851457 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 27 Jun 2012 21:23:54 +0100 Subject: [PATCH] message, ask & getInput functions alert calls now routed to message function confirm calls now routed to ask function prompt calls now routed to getInput function This is so you can replace how these are handled if you wish (Useful if you want to get away from browser chrome & UA dialogs) --- files.php | 2 +- index.php | 4 ++-- lib/coder.js | 27 +++++++++++++++++++++------ lib/file-control.php | 34 +++++++++++++++++----------------- lib/multiple-results.php | 2 +- lib/settings-screen.php | 6 +++--- plugins/zip-it/index.php | 2 +- 7 files changed, 46 insertions(+), 31 deletions(-) diff --git a/files.php b/files.php index da619d1..f935f26 100644 --- a/files.php +++ b/files.php @@ -122,7 +122,7 @@ function fileManager_dir($directory, $return_link, $first_call=true) { } $fileManager .= "
  •         " . htmlspecialchars($this_file) . " ".$fileAtts."
  • "; } else { - $fileAtts = ""; + $fileAtts = ""; $fileManager .= "
  •         [HIDDEN] ".$fileAtts."
  • "; } } diff --git a/index.php b/index.php index 13faab4..9ca8048 100644 --- a/index.php +++ b/index.php @@ -15,12 +15,12 @@ if ($checkUpdates) { $ICEcoderLatestVer = json_encode(file_get_contents("http://icecoder.net/latest-version.txt")); $ICEcoderLatestVer = rtrim(ltrim($ICEcoderLatestVer,"\""),"\"\\n"); if (ltrim($versionNo,"v ")alert(\'ICEcoder '.$ICEcoderLatestVer.' now released\n\nPlease upgrade\');'; + echo ''; } else { $cMLatestVer = json_encode(file_get_contents("http://codemirror.net/latest-version.txt")); $cMLatestVer = rtrim(ltrim($cMLatestVer,"\""),"\"\\n"); if ($cMThisVer<$cMLatestVer) { - echo ''; + echo ''; } } } diff --git a/lib/coder.js b/lib/coder.js index b272bac..3183250 100644 --- a/lib/coder.js +++ b/lib/coder.js @@ -550,7 +550,7 @@ var ICEcoder = { cM = ICEcoder.getcMInstance(); okToRemove = true; if (ICEcoder.changedContent[closeTabNum-1]==1) { - okToRemove = confirm('You have made changes.\n\nAre you sure you want to close without saving?'); + okToRemove = top.ICEcoder.ask('You have made changes.\n\nAre you sure you want to close without saving?'); } if (okToRemove) { @@ -743,7 +743,7 @@ var ICEcoder = { var newFolder, shortURL; shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/"); - newFolder = prompt('Enter New Folder Name at '+shortURL+'/',''); + newFolder = top.ICEcoder.getInput('Enter New Folder Name at '+shortURL+'/',''); if (newFolder) { newFolder = shortURL + "/" + newFolder; top.ICEcoder.serverQueue("add","lib/file-control.php?action=newFolder&file="+newFolder.replace(/\//g,"|")); @@ -780,7 +780,7 @@ var ICEcoder = { } } else { // show a message because we have 10 files open - alert('Sorry, you can only have 10 files open at a time!'); + top.ICEcoder.message('Sorry, you can only have 10 files open at a time!'); canOpenFile = false; } @@ -815,7 +815,7 @@ var ICEcoder = { var renamedFile, shortURL; shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/"); - renamedFile = prompt('Please enter the new name for',shortURL); + renamedFile = top.ICEcoder.getInput('Please enter the new name for',shortURL); if (renamedFile) { for (var i=0;ichMod '+perms+' on
    '+file); }, + + // Show a message + message: function(msg) { + alert(msg); + }, + + // Ask for confirmation + ask: function(question) { + return confirm(question); + }, + + // Get the users input + getInput: function(question,defaultValue) { + return prompt(question,defaultValue); + } }; \ No newline at end of file diff --git a/lib/file-control.php b/lib/file-control.php index 0372d0c..6805907 100644 --- a/lib/file-control.php +++ b/lib/file-control.php @@ -35,7 +35,7 @@ if ($_GET['action']=="load") { echo '","",$loadedFile).''; } else { echo ''; - echo ''; + echo ''; } }; @@ -55,9 +55,9 @@ if ($_GET['action']=="newFolder") { echo ''; } else { if (!is_writable($docRoot.$file)) { - echo ""; + echo ""; } else { - echo ''; + echo ''; } echo ''; } @@ -74,9 +74,9 @@ if ($_GET['action']=="rename") { echo ''; } else { if (!is_writable($_GET['oldFileName'])) { - echo ""; + echo ""; } else { - echo ''; + echo ''; } echo ''; } @@ -93,9 +93,9 @@ if ($_GET['action']=="perms") { echo ''; } else { if (!is_writable($docRoot.$file)) { - echo ""; + echo ""; } else { - echo ''; + echo ''; } echo ''; } @@ -118,15 +118,15 @@ if ($_GET['action']=="delete") { if ($fileLoc=="") {$fileLoc = "/";}; echo ''; } else { - echo ""; + echo ""; } echo ''; } } else { if (!is_writable($docRoot.$filesArray[$i])) { - echo ""; + echo ""; } else { - echo ''; + echo ''; } echo ''; } @@ -181,7 +181,7 @@ if ($_GET['action']=="save") { echo ''; ?> '; } } else { - echo ""; + echo ""; echo ''; } } else { if (!is_writable($saveFile)) { - echo ""; + echo ""; } else { - echo ''; + echo ''; } echo ''; } @@ -269,12 +269,12 @@ if (action=="save") { ?> if (top.ICEcoder.rightClickedFile) { shortURL = top.ICEcoder.rightClickedFile.substr((top.ICEcoder.rightClickedFile.indexOf(top.shortURLStarts)+top.shortURLStarts.length),top.ICEcoder.rightClickedFile.length).replace(/\|/g,"/")+"/"; - newFileName = prompt('Enter Filename',shortURL); + newFileName = top.ICEcoder.getInput('Enter Filename',shortURL); } else { - newFileName = prompt('Enter Filename','/'); + newFileName = top.ICEcoder.getInput('Enter Filename','/'); } if (newFileName && top.document.getElementById('filesFrame').contentWindow.document.getElementById(newFileName.replace(/\//g,"|"))) { - overwriteOK = confirm('That file exists already, overwrite?'); + overwriteOK = top.ICEcoder.ask('That file exists already, overwrite?'); } document.saveFile.newFileName.value = newFileName; diff --git a/lib/multiple-results.php b/lib/multiple-results.php index ac7642d..2b2505b 100644 --- a/lib/multiple-results.php +++ b/lib/multiple-results.php @@ -41,7 +41,7 @@ if (startTab!=top.ICEcoder.selectedTab) { } foundTabArray.length==0 ? showHide = "hide" : showHide = "show"; top.ICEcoder.showHide(showHide,top.document.getElementById('blackMask')); -if (foundTabArray.length==0) {alert('No matches found')}; +if (foundTabArray.length==0) {top.ICEcoder.message('No matches found')}; if (foundTabArray.length!=0) {document.getElementById('replaceAll').style.opacity = 1}; diff --git a/lib/settings-screen.php b/lib/settings-screen.php index ec58bbc..cb1ef18 100644 --- a/lib/settings-screen.php +++ b/lib/settings-screen.php @@ -192,16 +192,16 @@ var showHideTabs = function() { var validatePasswords = function() { if (document.settings.accountPassword.value != 0 && document.settings.accountPassword.value.length<8) { - alert('Please use at least 8 chars in the password'); + top.ICEcoder.message('Please use at least 8 chars in the password'); } else { if (document.settings.accountPassword.value != document.settings.confirmPassword.value) { - alert('Sorry, your passwords don\'t match') + top.ICEcoder.message('Sorry, your passwords don\'t match') } else { document.settings.submit(); } } - alert('Sorry, you need to be logged in to change settings'); + top.ICEcoder.message('Sorry, you need to be logged in to change settings'); } diff --git a/plugins/zip-it/index.php b/plugins/zip-it/index.php index a3fd8bd..c4eecba 100644 --- a/plugins/zip-it/index.php +++ b/plugins/zip-it/index.php @@ -64,7 +64,7 @@ if($_SESSION['userLevel']==10) { echo ''; $zipItAddToZip = $zipItDoZip->zipFilesUp($zipItSaveLocation.$zipItFileName); if (!$zipItAddToZip) { - echo ''; + echo ''; } else { echo ''; }