|
@@ -17,7 +17,7 @@
|
|
|
|
|
|
The Initial Developer of the Original Code is
|
|
|
Mark J Crane <[email protected]>
|
|
|
- Portions created by the Initial Developer are Copyright (C) 2008-2012
|
|
|
+ Portions created by the Initial Developer are Copyright (C) 2008-2016
|
|
|
the Initial Developer. All Rights Reserved.
|
|
|
|
|
|
Contributor(s):
|
|
@@ -41,169 +41,230 @@ else {
|
|
|
|
|
|
//set the directory
|
|
|
$_SESSION["app"]["edit"]["dir"] = $_GET["dir"];
|
|
|
+ $title = strtoupper($_GET["dir"]);
|
|
|
+ unset($mode);
|
|
|
+ switch ($_GET["dir"]) {
|
|
|
+ case 'xml': $mode['xml'] = 'selected'; break;
|
|
|
+ case 'provision': $mode['xml'] = 'selected'; break;
|
|
|
+ case 'php': $mode['php'] = 'selected'; break;
|
|
|
+ case 'scripts': $mode['lua'] = 'selected'; break;
|
|
|
+ case 'grammar': //use default
|
|
|
+ default: $mode['text'] = 'selected';
|
|
|
+ }
|
|
|
+?>
|
|
|
|
|
|
-echo "<html>\n";
|
|
|
-echo "<head>\n";
|
|
|
-echo " <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" />\n";
|
|
|
-echo " <title></title>";
|
|
|
-
|
|
|
- echo "<script type=\"text/javascript\" language=\"javascript\">\n";
|
|
|
- echo "// Replaces all instances of the given substring.\n";
|
|
|
- echo "String.prototype.replaceall = function(\n";
|
|
|
- echo "strTarget, \n"; // The substring you want to replace
|
|
|
- echo "strSubString \n"; // The string you want to replace in
|
|
|
- echo ")\n";
|
|
|
- echo "{\n";
|
|
|
- echo " var strText = this;\n";
|
|
|
- echo " var intIndexOfMatch = strText.indexOf( strTarget );\n";
|
|
|
- echo " \n";
|
|
|
- echo " // Keep looping while an instance of the target string\n";
|
|
|
- echo " // still exists in the string.\n";
|
|
|
- echo " while (intIndexOfMatch != -1){\n";
|
|
|
- echo " // Relace out the current instance.\n";
|
|
|
- echo " strText = strText.replace( strTarget, strSubString )\n";
|
|
|
- echo " \n";
|
|
|
- echo " // Get the index of any next matching substring.\n";
|
|
|
- echo " intIndexOfMatch = strText.indexOf( strTarget );\n";
|
|
|
- echo "}\n";
|
|
|
- echo "return( strText );\n";
|
|
|
- echo "}\n";
|
|
|
-
|
|
|
- echo "function urlencode(str) {\n";
|
|
|
- echo " str=escape(str); \n"; //Escape does not encode '/' and '+' character
|
|
|
- echo " str=str.replaceall(\"+\", \"%2B\");\n";
|
|
|
- echo " str=str.replaceall(\"/\", \"%2F\");\n";
|
|
|
- echo " return str;\n";
|
|
|
- echo "}";
|
|
|
- echo "</script>\n";
|
|
|
-
|
|
|
- echo "<script type=\"text/javascript\" language=\"javascript\">\n";
|
|
|
- echo " function makeRequest(url, strpost) {\n";
|
|
|
- echo " var http_request = false;\n";
|
|
|
- echo "\n";
|
|
|
- echo " if (window.XMLHttpRequest) { // Mozilla, Safari, ...\n";
|
|
|
- echo " http_request = new XMLHttpRequest();\n";
|
|
|
- echo " if (http_request.overrideMimeType) {\n";
|
|
|
- echo " http_request.overrideMimeType('text/xml');\n";
|
|
|
- echo " // See note below about this line\n";
|
|
|
- echo " }\n";
|
|
|
- echo " } else if (window.ActiveXObject) { // IE\n";
|
|
|
- echo " try {\n";
|
|
|
- echo " http_request = new ActiveXObject(\"Msxml2.XMLHTTP\");\n";
|
|
|
- echo " } catch (e) {\n";
|
|
|
- echo " try {\n";
|
|
|
- echo " http_request = new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
|
|
|
- echo " } catch (e) {}\n";
|
|
|
- echo " }\n";
|
|
|
- echo " }\n";
|
|
|
- echo "\n";
|
|
|
- echo " if (!http_request) {\n";
|
|
|
- echo " alert('".$text['message-give-up']."');\n";
|
|
|
- echo " return false;\n";
|
|
|
- echo " }\n";
|
|
|
- echo " http_request.onreadystatechange = function() { returnContent(http_request); };\n";
|
|
|
- echo " if (http_request.overrideMimeType) {\n";
|
|
|
- echo " http_request.overrideMimeType('text/html');\n";
|
|
|
- echo " }\n";
|
|
|
- echo " http_request.open('POST', url, true);\n";
|
|
|
- echo "\n";
|
|
|
- echo " if (strpost.length == 0) {\n";
|
|
|
- echo " //http_request.send(null);\n";
|
|
|
- echo " http_request.send('name=value&foo=bar');\n";
|
|
|
- echo " }\n";
|
|
|
- echo " else {\n";
|
|
|
- echo " http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');\n";
|
|
|
- echo " http_request.send(strpost);\n";
|
|
|
- echo " }\n";
|
|
|
- echo " }\n";
|
|
|
- echo "\n";
|
|
|
- echo " function returnContent(http_request) {\n";
|
|
|
- echo " if (http_request.readyState == 4) {\n";
|
|
|
- echo " if (http_request.status == 200) {\n";
|
|
|
- echo " parent.editAreaLoader.setValue('edit1', http_request.responseText); \n";
|
|
|
- echo " }\n";
|
|
|
- echo " else {\n";
|
|
|
- echo " alert('".$text['message-problem']."');\n";
|
|
|
- echo " }\n";
|
|
|
- echo " }\n";
|
|
|
- echo " }\n";
|
|
|
- echo "</script>";
|
|
|
- ?>
|
|
|
- <script language="Javascript" type="text/javascript" src="<?php echo PROJECT_PATH; ?>/resources/edit_area/edit_area_full.js"></script>
|
|
|
- <script language="Javascript" type="text/javascript">
|
|
|
- // initialisation
|
|
|
- editAreaLoader.init({
|
|
|
- id: "edit1" // id of the textarea to transform
|
|
|
- ,start_highlight: false
|
|
|
- ,allow_toggle: false
|
|
|
- ,word_wrap: false
|
|
|
- ,language: "en"
|
|
|
- ,syntax: "xml"
|
|
|
- ,toolbar: "save, |, search, go_to_line,|, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, word_wrap, |, help"
|
|
|
- ,syntax_selection_allow: "css,html,js,php,xml,c,cpp,sql"
|
|
|
- ,show_line_colors: true
|
|
|
- ,load_callback: "my_load"
|
|
|
- ,save_callback: "my_save"
|
|
|
- });
|
|
|
-
|
|
|
- // callback functions
|
|
|
- function my_save(id, content){
|
|
|
- makeRequest('filesave.php','file='+document.getElementById('file').value+'&content='+urlencode(content));
|
|
|
- parent.document.title=''+unescape(document.getElementById('file').value)+' :: Saved';
|
|
|
+<html>
|
|
|
+<head>
|
|
|
+ <meta http-equiv='Content-Type' content='text/html; charset=UTF-8' />
|
|
|
+ <title><?=$title?></title>
|
|
|
+ <script language="JavaScript" type="text/javascript" src="<?php echo PROJECT_PATH; ?>/resources/jquery/jquery-1.11.1.js"></script>
|
|
|
+ <script language="JavaScript" type="text/javascript">
|
|
|
+ function submit_check() {
|
|
|
+ if (document.getElementById('filepath').value != '') {
|
|
|
+ document.getElementById('editor_source').value = editor.getSession().getValue();
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ focus_editor();
|
|
|
+ return false;
|
|
|
}
|
|
|
|
|
|
- function my_load(elem){
|
|
|
- elem.value="The content is loaded from the load_callback function into EditArea";
|
|
|
+ function preview_theme(opt) {
|
|
|
+ editor.setTheme('ace/theme/' + opt.value);
|
|
|
}
|
|
|
|
|
|
- function my_setSelectionRange(id){
|
|
|
- editAreaLoader.setSelectionRange(id, 0, 0);
|
|
|
+ function toggle_option(opt) {
|
|
|
+ switch (opt) {
|
|
|
+ case 'numbering': toggle_option_do('showGutter'); break;
|
|
|
+ case 'invisibles': toggle_option_do('showInvisibles'); break;
|
|
|
+ case 'indenting': toggle_option_do('displayIndentGuides'); break;
|
|
|
+ }
|
|
|
+ focus_editor();
|
|
|
}
|
|
|
|
|
|
- function test_setSelectionRange(id){
|
|
|
- editAreaLoader.setSelectionRange(id, 0, 0);
|
|
|
+ function toggle_option_do(opt_name) {
|
|
|
+ var opt_val = editor.getOption(opt_name);
|
|
|
+ editor.setOption(opt_name, ((opt_val) ? false : true));
|
|
|
}
|
|
|
|
|
|
- function test_getSelectionRange(id){
|
|
|
- var sel =editAreaLoader.getSelectionRange(id);
|
|
|
- alert("start: "+sel["start"]+"\nend: "+sel["end"]);
|
|
|
+ function toggle_sidebar() {
|
|
|
+ var td_sidebar = document.getElementById('sidebar');
|
|
|
+ td_sidebar.style.display = (td_sidebar.style.display == '') ? 'none' : '';
|
|
|
+ focus_editor();
|
|
|
}
|
|
|
|
|
|
- function test_setSelectedText(id){
|
|
|
- text= "[REPLACED SELECTION]";
|
|
|
- editAreaLoader.setSelectedText(id, text);
|
|
|
+ function insert_clip(before, after) {
|
|
|
+ var selected_text = editor.session.getTextRange(editor.getSelectionRange());
|
|
|
+ editor.insert(before + selected_text + after);
|
|
|
+ focus_editor();
|
|
|
}
|
|
|
|
|
|
- function test_getSelectedText(id){
|
|
|
- alert(editAreaLoader.getSelectedText(id));
|
|
|
+ function focus_editor() {
|
|
|
+ editor.focus();
|
|
|
}
|
|
|
- </script>
|
|
|
+ </script>
|
|
|
+ <style>
|
|
|
+ img.control {
|
|
|
+ cursor: pointer;
|
|
|
+ width: auto;
|
|
|
+ height: 23px;
|
|
|
+ border: none;
|
|
|
+ opacity: 0.5;
|
|
|
+ }
|
|
|
+
|
|
|
+ img.control:hover {
|
|
|
+ opacity: 1.0;
|
|
|
+ }
|
|
|
+
|
|
|
+ div#editor {
|
|
|
+ box-shadow: 0 5px 15px #333;
|
|
|
+ }
|
|
|
+
|
|
|
+ </style>
|
|
|
</head>
|
|
|
-<table border='0' style="height: 100%; width: 100%;">
|
|
|
+<body style='padding: 0; margin: 0; overflow: hidden;'>
|
|
|
+<table id='frame' cellpadding='0' cellspacing='0' border='0' style="height: 100%; width: 100%;">
|
|
|
<tr>
|
|
|
- <td id='toolbar' valign='top' width='200' style="width: 200;" height='100%' nowrap>
|
|
|
- <IFRAME SRC='filelist.php' style='border: solid 1px #CCCCCC; height: 50%; width: 100%;' TITLE=''>
|
|
|
- <!-- File List: Requires IFRAME support -->
|
|
|
- </IFRAME>
|
|
|
- <IFRAME SRC='cliplist.php' style='border: solid 1px #CCCCCC; height: 50%; width: 100%;' TITLE=''>
|
|
|
- <!-- Clip List: Requires IFRAME support -->
|
|
|
- </IFRAME>
|
|
|
+ <td id='sidebar' valign='top' style="width: 300px; height: 100%;">
|
|
|
+ <iframe id='file_list' src='filelist.php' style='border: none; height: 65%; width: 100%;'></iframe><br>
|
|
|
+ <iframe id='clip_list' src='cliplist.php' style='border: none; border-top: 1px solid #ccc; height: calc(35% - 1px); width: 100%;'></iframe>
|
|
|
</td>
|
|
|
- <td valign='top' width="100%" height='100%' style="height: 100%;">
|
|
|
- <?php
|
|
|
- if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) {
|
|
|
- //IE doesn't work with the 100% width with the IFRAME
|
|
|
- echo "<textarea id='edit1' style='height: 100%; width: 800px;' name=''>\n";
|
|
|
- echo "</textarea>\n";
|
|
|
- }
|
|
|
- else {
|
|
|
- echo "<textarea id='edit1' style='height: 100%; width: 100%;' name=''>\n";
|
|
|
- echo "</textarea>\n";
|
|
|
- }
|
|
|
- ?>
|
|
|
- <input type='hidden' id='file' name='file' value='' />
|
|
|
+ <td align='right' valign='top' style='height: 100%;'>
|
|
|
+ <form style='margin: 0;' name='frm_edit' id='frm_edit' method='post' target='proc' action='filesave.php' onsubmit="return submit_check();">
|
|
|
+ <textarea name='content' id='editor_source' style='display: none;'></textarea>
|
|
|
+ <input type='hidden' name='filepath' id='filepath' value=''>
|
|
|
+ <table cellpadding='0' cellspacing='0' border='0' style='width: 100%;'>
|
|
|
+ <tr>
|
|
|
+ <td valign='middle'><img src='resources/images/icon_save.png' title='Save Changes [Ctrl+S]' class='control' onclick="$('form#frm_edit').submit();";></td>
|
|
|
+ <td align='left' valign='middle' width='100%' style='padding: 0 4px 0 6px;'><input id='current_file' type='text' disabled='disabled' style='height: 23px; width: 100%; color: #000;'></td>
|
|
|
+ <td style='padding: 0;'><img src='resources/images/blank.gif' style='width: 1px; height: 30px; border: none;'></td>
|
|
|
+ <td valign='middle' style='padding-left: 6px;'><img src='resources/images/icon_sidebar.png' title='Toggle Side Bar [Ctrl+Q]' class='control' onclick="toggle_sidebar();"></td>
|
|
|
+ <td valign='middle' style='padding-left: 6px;'><img src='resources/images/icon_numbering.png' title='Toggle Line Numbers' class='control' onclick="toggle_option('numbering');"></td>
|
|
|
+ <td valign='middle' style='padding-left: 6px;'><img src='resources/images/icon_invisibles.png' title='Toggle Invisibles' class='control' onclick="toggle_option('invisibles');"></td>
|
|
|
+ <td valign='middle' style='padding-left: 6px;'><img src='resources/images/icon_indenting.png' title='Toggle Indent Guides' class='control' onclick="toggle_option('indenting');"></td>
|
|
|
+ <td valign='middle' style='padding-left: 10px;'>
|
|
|
+ <select id='mode' style='height: 23px;' onchange="editor.getSession().setMode('ace/mode/' + this.options[this.selectedIndex].value); focus_editor();">
|
|
|
+ <option value='php' <?=$mode['php']?>>PHP</option>
|
|
|
+ <option value='css'>CSS</option>
|
|
|
+ <option value='html'>HTML</option>
|
|
|
+ <option value='javascript'>JS</option>
|
|
|
+ <option value='json'>JSON</option>
|
|
|
+ <option value='ini'>Conf</option>
|
|
|
+ <option value='lua' <?=$mode['lua']?>>Lua</option>
|
|
|
+ <option value='text' <?=$mode['text']?>>Text</option>
|
|
|
+ <option value='xml' <?=$mode['xml']?>>XML</option>
|
|
|
+ <option value='sql'>SQL</option>
|
|
|
+ </select>
|
|
|
+ </td>
|
|
|
+ <td valign='middle' style='padding-left: 4px;'>
|
|
|
+ <select id='size' style='height: 23px;' onchange="document.getElementById('editor').style.fontSize = this.options[this.selectedIndex].value; focus_editor();">
|
|
|
+ <option value='9px'>9px</option>
|
|
|
+ <option value='10px'>10px</option>
|
|
|
+ <option value='11px'>11px</option>
|
|
|
+ <option value='12px' selected>12px</option>
|
|
|
+ <option value='14px'>14px</option>
|
|
|
+ <option value='16px'>16px</option>
|
|
|
+ <option value='18px'>18px</option>
|
|
|
+ <option value='20px'>20px</option>
|
|
|
+ </select>
|
|
|
+ </td>
|
|
|
+ <td valign='middle' style='padding-left: 4px; padding-right: 4px;'>
|
|
|
+ <select id='theme' style='height: 23px;' onchange="editor.setTheme('ace/theme/' + this.options[this.selectedIndex].value); focus_editor();">
|
|
|
+ <optgroup label="Bright">
|
|
|
+ <option value="chrome" onmouseover="preview_theme(this);">Chrome</option>
|
|
|
+ <option value="clouds" onmouseover="preview_theme(this);">Clouds</option>
|
|
|
+ <option value="crimson_editor" onmouseover="preview_theme(this);">Crimson Editor</option>
|
|
|
+ <option value="dawn" onmouseover="preview_theme(this);">Dawn</option>
|
|
|
+ <option value="dreamweaver" onmouseover="preview_theme(this);">Dreamweaver</option>
|
|
|
+ <option value="eclipse" onmouseover="preview_theme(this);">Eclipse</option>
|
|
|
+ <option value="github" onmouseover="preview_theme(this);">GitHub</option>
|
|
|
+ <option value="iplastic" onmouseover="preview_theme(this);">IPlastic</option>
|
|
|
+ <option value="solarized_light" onmouseover="preview_theme(this);">Solarized Light</option>
|
|
|
+ <option value="textmate" onmouseover="preview_theme(this);">TextMate</option>
|
|
|
+ <option value="tomorrow" onmouseover="preview_theme(this);">Tomorrow</option>
|
|
|
+ <option value="xcode" onmouseover="preview_theme(this);">XCode</option>
|
|
|
+ <option value="kuroir" onmouseover="preview_theme(this);">Kuroir</option>
|
|
|
+ <option value="katzenmilch" onmouseover="preview_theme(this);">KatzenMilch</option>
|
|
|
+ <option value="sqlserver" onmouseover="preview_theme(this);">SQL Server</option>
|
|
|
+ </optgroup>
|
|
|
+ <optgroup label="Dark">
|
|
|
+ <option value="ambiance" onmouseover="preview_theme(this);">Ambiance</option>
|
|
|
+ <option value="chaos" onmouseover="preview_theme(this);">Chaos</option>
|
|
|
+ <option value="clouds_midnight" onmouseover="preview_theme(this);">Clouds Midnight</option>
|
|
|
+ <option value="cobalt" onmouseover="preview_theme(this);" selected>Cobalt</option>
|
|
|
+ <option value="idle_fingers" onmouseover="preview_theme(this);">idle Fingers</option>
|
|
|
+ <option value="kr_theme" onmouseover="preview_theme(this);">krTheme</option>
|
|
|
+ <option value="merbivore" onmouseover="preview_theme(this);">Merbivore</option>
|
|
|
+ <option value="merbivore_soft" onmouseover="preview_theme(this);">Merbivore Soft</option>
|
|
|
+ <option value="mono_industrial" onmouseover="preview_theme(this);">Mono Industrial</option>
|
|
|
+ <option value="monokai" onmouseover="preview_theme(this);">Monokai</option>
|
|
|
+ <option value="pastel_on_dark" onmouseover="preview_theme(this);">Pastel on dark</option>
|
|
|
+ <option value="solarized_dark" onmouseover="preview_theme(this);">Solarized Dark</option>
|
|
|
+ <option value="terminal" onmouseover="preview_theme(this);">Terminal</option>
|
|
|
+ <option value="tomorrow_night" onmouseover="preview_theme(this);">Tomorrow Night</option>
|
|
|
+ <option value="tomorrow_night_blue" onmouseover="preview_theme(this);">Tomorrow Night Blue</option>
|
|
|
+ <option value="tomorrow_night_bright" onmouseover="preview_theme(this);">Tomorrow Night Bright</option>
|
|
|
+ <option value="tomorrow_night_eighties" onmouseover="preview_theme(this);">Tomorrow Night 80s</option>
|
|
|
+ <option value="twilight" onmouseover="preview_theme(this);">Twilight</option>
|
|
|
+ <option value="vibrant_ink" onmouseover="preview_theme(this);">Vibrant Ink</option>
|
|
|
+ </optgroup>
|
|
|
+ </select>
|
|
|
+ </td>
|
|
|
+ </tr>
|
|
|
+ </table>
|
|
|
+ </form>
|
|
|
+ <div id='editor' style="text-align: left; width: 100%; height: calc(100% - 30px); font-size: 12px;"></div>
|
|
|
+ <iframe id='proc' name='proc' src='#' style='display: none;'></iframe>
|
|
|
</td>
|
|
|
</tr>
|
|
|
</table>
|
|
|
+
|
|
|
+<script type="text/javascript" src="/resources/ace_mnc/ace.js" charset="utf-8"></script>
|
|
|
+<script type="text/javascript">
|
|
|
+ //load ace editor
|
|
|
+ var editor = ace.edit("editor");
|
|
|
+ editor.setOptions({
|
|
|
+ <?php
|
|
|
+ foreach ($mode as $lang => $meh) {
|
|
|
+ if ($meh == 'selected') { echo "mode: 'ace/mode/".$lang."',\n"; break; }
|
|
|
+ }
|
|
|
+ ?>
|
|
|
+ theme: 'ace/theme/cobalt',
|
|
|
+ selectionStyle: 'text',
|
|
|
+ cursorStyle: 'smooth',
|
|
|
+ showInvisibles: false,
|
|
|
+ displayIndentGuides: true,
|
|
|
+ showLineNumbers: true,
|
|
|
+ showGutter: true,
|
|
|
+ scrollPastEnd: true,
|
|
|
+ fadeFoldWidgets: true,
|
|
|
+ showPrintMargin: false,
|
|
|
+ highlightGutterLine: false,
|
|
|
+ useSoftTabs: false
|
|
|
+ });
|
|
|
+ focus_editor();
|
|
|
+
|
|
|
+ //keyboard shortcut to save file
|
|
|
+ $(window).keypress(function(event) {
|
|
|
+ //save file [Ctrl+S]
|
|
|
+ if ((event.which == 115 && event.ctrlKey) || (event.which == 19)) {
|
|
|
+ $('form#frm_edit').submit();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //open file manager/clip library pane [Ctrl+Q]
|
|
|
+ else if ((event.which == 113 && event.ctrlKey) || (event.which == 19)) {
|
|
|
+ toggle_sidebar();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ //otherwise, default action
|
|
|
+ else {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ //remove certain keyboard shortcuts
|
|
|
+ editor.commands.bindKey("Ctrl-T", null);
|
|
|
+</script>
|
|
|
+
|
|
|
+
|
|
|
</body>
|
|
|
</html>
|