lib/chook/server/public/js/chook.js in chook-1.1.2 vs lib/chook/server/public/js/chook.js in chook-1.1.5b1

- old
+ new

@@ -86,47 +86,26 @@ function hide_handler_viewer() { document.getElementById("handler_viewer_div").style.display = 'none'; } // show the handler editor with the selected handler code -// handler = the path to the hander fle. -function edit_handler(handler, type) { - var code = ''; - var editing_filename = handler; - - // new handler - if (handler == 'new_handler') { - editing_filename = new_handler_filename(); - if (editing_filename == 'Name Already Taken') { - code = editing_filename; - } - document.getElementById("handler_viewer").value = code; - - if (document.getElementById("add_handler_external_radio").checked) { - type = 'external'; - } else { - type = 'internal'; - } - - // existing handler - } else { - fetch_handler_code(handler) ; - } - var now_editing = editing_filename + ' (' + type + ')' - document.getElementById("currently_viewing_filename").innerHTML = now_editing; +// handler = the basename of the hander fle. +function view_handler_code(handler_path, type) { + fetch_handler_code(handler_path) ; + document.getElementById("currently_viewing_filename").innerHTML = 'Viewing handler file: ' + handler_path + ' (' + type + ')'; document.getElementById("handler_viewer_div").style.display = 'block'; } // get the code for an existing handler into the editor function fetch_handler_code(handler) { - var editor = document.getElementById("handler_viewer"); - var url = '/handler_code/' + handler + var viewer = document.getElementById("handler_viewer"); + var url = '/handler_code?filepath=' + encodeURIComponent(handler) var xhttp = new XMLHttpRequest(); xhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { - editor.value = xhttp.responseText; + viewer.value = xhttp.responseText; } else { - editor.value = 'ERROR: File Not Found'; + viewer.value = 'ERROR: File Not Found'; } }; xhttp.open("GET", url, true); xhttp.send(); }