code cleanup (to remove the code of former editors)
fix breakpoints integration
This commit is contained in:
@@ -11,12 +11,12 @@ function prepareMultiPartPOST(data) {
|
|||||||
var reqdata = '--' + boundary + '\r\n';
|
var reqdata = '--' + boundary + '\r\n';
|
||||||
//console.log(data.length);
|
//console.log(data.length);
|
||||||
for (var i=0;i < data.length;i++) {
|
for (var i=0;i < data.length;i++) {
|
||||||
reqdata += 'content-disposition: form-data; name="';
|
reqdata += 'content-disposition: form-data; name="';
|
||||||
reqdata += data[i].Name + '"';
|
reqdata += data[i].Name + '"';
|
||||||
reqdata += "\r\n\r\n" ;
|
reqdata += "\r\n\r\n" ;
|
||||||
reqdata += data[i].Data;
|
reqdata += data[i].Data;
|
||||||
reqdata += "\r\n" ;
|
reqdata += "\r\n" ;
|
||||||
reqdata += '--' + boundary + '\r\n';
|
reqdata += '--' + boundary + '\r\n';
|
||||||
}
|
}
|
||||||
return new Array(reqdata,boundary);
|
return new Array(reqdata,boundary);
|
||||||
}
|
}
|
||||||
@@ -26,37 +26,10 @@ function on_error() {
|
|||||||
jQuery("input[name='saved_on']").val('communication error');
|
jQuery("input[name='saved_on']").val('communication error');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getData() {
|
|
||||||
if (window.ace_editor) {
|
|
||||||
var data = window.ace_editor.getSession().getValue();
|
|
||||||
} else if (window.mirror) {
|
|
||||||
var data = window.mirror.getValue();
|
|
||||||
} else if (window.eamy) {
|
|
||||||
var data = window.eamy.instances[0].getText();
|
|
||||||
} else if (window.textarea) {
|
|
||||||
var data = textarea.value;
|
|
||||||
}
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
function doHighlight(highlight) {
|
|
||||||
if (window.ace_editor) {
|
|
||||||
window.ace_editor.gotoLine(highlight.lineno);
|
|
||||||
} else if (window.mirror) {
|
|
||||||
// Put the cursor at the offending line:
|
|
||||||
window.mirror.setCursor({line:highlight.lineno-1,
|
|
||||||
ch:highlight.offset+1});
|
|
||||||
} else if (window.eamy) {
|
|
||||||
// not implemented
|
|
||||||
} else if (window.textarea) {
|
|
||||||
editAreaLoader.setSelectionRange('body', highlight.start, highlight.end);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function doClickSave() {
|
function doClickSave() {
|
||||||
var currentTabID = '#' + jQuery('#edit_placeholder div.tab-pane.active').attr('id');
|
var currentTabID = '#' + jQuery('#edit_placeholder div.tab-pane.active').attr('id');
|
||||||
var editor = jQuery (currentTabID + ' textarea').data('editor');
|
var editor = jQuery (currentTabID + ' textarea').data('editor');
|
||||||
var data = editor.getValue();
|
var data = editor.getValue();
|
||||||
var dataForPost = prepareMultiPartPOST(new Array(
|
var dataForPost = prepareMultiPartPOST(new Array(
|
||||||
prepareDataForSave('data', data),
|
prepareDataForSave('data', data),
|
||||||
prepareDataForSave('file_hash',
|
prepareDataForSave('file_hash',
|
||||||
@@ -87,12 +60,7 @@ function doClickSave() {
|
|||||||
},
|
},
|
||||||
success: function(json,text,xhr){
|
success: function(json,text,xhr){
|
||||||
|
|
||||||
// show flash message (if any)
|
|
||||||
var flash=xhr.getResponseHeader('web2py-component-flash');
|
|
||||||
if (flash) {
|
|
||||||
var flashhtml = decodeURIComponent(flash);
|
|
||||||
jQuery('.flash').html(flashhtml).slideDown();
|
|
||||||
} else jQuery('.flash').hide();
|
|
||||||
|
|
||||||
// reenable disabled submit button
|
// reenable disabled submit button
|
||||||
var t=jQuery("input[name='save']");
|
var t=jQuery("input[name='save']");
|
||||||
@@ -100,24 +68,25 @@ function doClickSave() {
|
|||||||
t.attr('disabled','');
|
t.attr('disabled','');
|
||||||
try {
|
try {
|
||||||
if (json.error) {
|
if (json.error) {
|
||||||
window.location.href=json.redirect;
|
window.location.href=json.redirect;
|
||||||
} else {
|
} else {
|
||||||
// console.info( json.file_hash );
|
// console.info( json.file_hash );
|
||||||
jQuery(currentTabID + " input[name='file_hash']").val(json.file_hash);
|
jQuery(currentTabID + " input[name='file_hash']").val(json.file_hash);
|
||||||
jQuery(currentTabID + " input[name='saved_on']").val(json.saved_on);
|
jQuery(currentTabID + " input[name='saved_on']").val(json.saved_on);
|
||||||
if (json.highlight) {
|
if (json.highlight) {
|
||||||
doHighlight(json.highlight);
|
// Put the cursor at the offending line:
|
||||||
|
editor.setCursor({line:highlight.lineno-1, ch:highlight.offset+1});
|
||||||
} else {
|
} else {
|
||||||
jQuery(currentTabID + " input[name='saved_on']").attr('style','background-color:#99FF99');
|
jQuery(currentTabID + " input[name='saved_on']").attr('style','background-color:#99FF99');
|
||||||
//jQuery(".flash").delay(1000).fadeOut('slow');
|
//jQuery(".flash").delay(1000).fadeOut('slow');
|
||||||
}
|
}
|
||||||
// console.info(jQuery("input[name='file_hash']").val());
|
// console.info(jQuery("input[name='file_hash']").val());
|
||||||
var output = '<b>exposes:</b> ';
|
var output = '<b>exposes:</b> ';
|
||||||
for ( var i in json.functions) {
|
for ( var i in json.functions) {
|
||||||
output += ' <a href="/' + json.application + '/' + json.controller + '/' + json.functions[i] + '">' + json.functions[i] + '</a>,';
|
output += ' <a target="_blank" href="/' + json.application + '/' + json.controller + '/' + json.functions[i] + '">' + json.functions[i] + '</a>,';
|
||||||
}
|
}
|
||||||
if(output!='<b>exposes:</b> ') {
|
if(output!='<b>exposes:</b> ') {
|
||||||
jQuery("#exposed").html( output.substring(0, output.length-1));
|
jQuery(currentTabID + " .exposed").html( output.substring(0, output.length-1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch(e) { on_error();}
|
} catch(e) { on_error();}
|
||||||
@@ -127,37 +96,22 @@ function doClickSave() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectionRange() {
|
function getActiveEditor() {
|
||||||
var sel;
|
|
||||||
if (window.ace_editor) {
|
|
||||||
sel = {};
|
|
||||||
range = window.ace_editor.getSelectionRange();
|
|
||||||
// passing the line number directly, no need to read the text
|
|
||||||
sel['start'] = range.start.row;
|
|
||||||
sel['end'] = range.end.row;
|
|
||||||
sel['data'] = '';
|
|
||||||
} else if (window.mirror) {
|
|
||||||
var currentTabID = '#' + jQuery('#edit_placeholder div.tab-pane.active').attr('id');
|
|
||||||
var editor = jQuery (currentTabID + ' textarea').data('editor');
|
|
||||||
sel = {};
|
|
||||||
sel['start'] = editor.getCursor(true).line;
|
|
||||||
sel['end'] = editor.getCursor(false).line;
|
|
||||||
sel['data'] = '';
|
|
||||||
} else if (window.eamy) {
|
|
||||||
sel = {};
|
|
||||||
// not implemented
|
|
||||||
} else if (window.textarea) {
|
|
||||||
// passing offset, needs the text to calculate the line:
|
|
||||||
sel = editAreaLoader.getSelectionRange('body');
|
|
||||||
sel['data'] = getData();
|
|
||||||
}
|
|
||||||
return sel;
|
|
||||||
}
|
|
||||||
|
|
||||||
function doToggleBreakpoint(filename, url, sel) {
|
|
||||||
var currentTabID = '#' + jQuery('#edit_placeholder div.tab-pane.active').attr('id');
|
var currentTabID = '#' + jQuery('#edit_placeholder div.tab-pane.active').attr('id');
|
||||||
var editor = jQuery (currentTabID + ' textarea').data('editor');
|
var editor = jQuery (currentTabID + ' textarea').data('editor');
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSelectionRange() {
|
||||||
|
var editor = getActiveEditor();
|
||||||
|
var sel = {};
|
||||||
|
sel['start'] = editor.getCursor(true).line;
|
||||||
|
sel['end'] = editor.getCursor(false).line;
|
||||||
|
sel['data'] = '';
|
||||||
|
return sel;
|
||||||
|
}
|
||||||
|
|
||||||
|
function doToggleBreakpoint(filename, url, sel, editor) {
|
||||||
if (sel==null) {
|
if (sel==null) {
|
||||||
// use cursor position to determine the breakpoint line
|
// use cursor position to determine the breakpoint line
|
||||||
// (gutter already tell us the selected line)
|
// (gutter already tell us the selected line)
|
||||||
@@ -193,17 +147,14 @@ function doToggleBreakpoint(filename, url, sel) {
|
|||||||
if (json.error) {
|
if (json.error) {
|
||||||
window.location.href=json.redirect;
|
window.location.href=json.redirect;
|
||||||
} else {
|
} else {
|
||||||
if (json.ok==true && window.mirror) {
|
if (json.ok==true) {
|
||||||
// mark the breakpoint if ok=True
|
// mark the breakpoint if ok=True
|
||||||
editor.setMarker(json.lineno-1,
|
editor.setMarker(json.lineno-1,
|
||||||
"<span style='color: red'>●</span> %N%")
|
"<span style='color: red'>●</span> %N%")
|
||||||
} else if (json.ok==false && window.mirror) {
|
} else if (json.ok==false) {
|
||||||
// remove mark if ok=False
|
// remove mark if ok=False
|
||||||
editor.setMarker(json.lineno-1, "%N%")
|
editor.setMarker(json.lineno-1, "%N%")
|
||||||
} else {
|
}
|
||||||
// do nothing if ok = null
|
|
||||||
}
|
|
||||||
// alert(json.ok + json.lineno);
|
|
||||||
}
|
}
|
||||||
} catch(e) { on_error(); }
|
} catch(e) { on_error(); }
|
||||||
},
|
},
|
||||||
@@ -234,16 +185,13 @@ function doListBreakpoints(filename, url) {
|
|||||||
if (json.error) {
|
if (json.error) {
|
||||||
window.location.href=json.redirect;
|
window.location.href=json.redirect;
|
||||||
} else {
|
} else {
|
||||||
var currentTabID = '#' + jQuery('#edit_placeholder div.tab-pane.active').attr('id');
|
var editor = getActiveEditor();
|
||||||
var editor = jQuery (currentTabID + ' textarea').data('editor');
|
for (i in json.breakpoints) {
|
||||||
if (window.mirror) {
|
lineno = json.breakpoints[i];
|
||||||
for (i in json.breakpoints) {
|
// mark the breakpoint if ok=True
|
||||||
lineno = json.breakpoints[i];
|
editor.setMarker(lineno-1, "<span style='color: red'>●</span> %N%");
|
||||||
// mark the breakpoint if ok=True
|
}
|
||||||
editor.setMarker(lineno-1, "<span style='color: red'>●</span> %N%");
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(e) { on_error(); }
|
} catch(e) { on_error(); }
|
||||||
},
|
},
|
||||||
error: function(json) { on_error(); }
|
error: function(json) { on_error(); }
|
||||||
|
|||||||
@@ -33,17 +33,14 @@
|
|||||||
<script src="{{=cm}}/emmet.min.js"></script>
|
<script src="{{=cm}}/emmet.min.js"></script>
|
||||||
<script language="Javascript" type="text/javascript" src="{{=URL('static','js/ajax_editor.js')}}"></script>
|
<script language="Javascript" type="text/javascript" src="{{=URL('static','js/ajax_editor.js')}}"></script>
|
||||||
<script language="Javascript" type="text/javascript">
|
<script language="Javascript" type="text/javascript">
|
||||||
jQuery(document).ready(function(){
|
|
||||||
doListBreakpoints({{=XML("'%s','%s://%s%s'" % ('currentFilenameJS',
|
|
||||||
request.env['wsgi_url_scheme'], request.env['http_host'],
|
|
||||||
URL(c='debug', f='list_breakpoints')))}});
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery(document).on('shown click', 'a[data-toggle="tab"]', function (e) {
|
jQuery(document).on('shown click', 'a[data-toggle="tab"]', function (e) {
|
||||||
var tab_id = jQuery(this).attr('href');
|
var tab_id = jQuery(this).attr('href');
|
||||||
var editor = jQuery(tab_id + " textarea").data('editor');
|
var editor = jQuery(tab_id + " textarea").data('editor');
|
||||||
editor.setSize(jQuery(tab_id).width(), jQuery(tab_id).height());
|
if (editor) {
|
||||||
editor.refresh();
|
editor.setSize(jQuery(tab_id).width(), jQuery(tab_id).height());
|
||||||
|
editor.refresh();
|
||||||
|
}
|
||||||
//jQuery(function(){jQuery('.CodeMirror-scroll').css("height","auto").css("overflow-x","auto");});
|
//jQuery(function(){jQuery('.CodeMirror-scroll').css("height","auto").css("overflow-x","auto");});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -70,7 +67,6 @@ jQuery(document).on('click', '#restore', function (e) {
|
|||||||
load_file(jQuery(this).attr("href"));
|
load_file(jQuery(this).attr("href"));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// open the selected file
|
// open the selected file
|
||||||
jQuery(document).on('click', 'a.editor_filelink', function (e) {
|
jQuery(document).on('click', 'a.editor_filelink', function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
{{def shortcut(combo, description):
|
{{def shortcut(combo, description):
|
||||||
return XML('<li><span class="teletype-text">%s</span><span>%s</span></li>' % (combo, description))
|
return XML('<li><span class="teletype-text">%s</span><span>%s</span></li>' % (combo, description))
|
||||||
|
|
||||||
##TODO
|
|
||||||
#eseguire dolistbreakpoint ogni volta che si fa una load
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
<form action="{{=URL('edit', args=filename)}}" method="post" name="editform" id="editform" class="form-inline">
|
<form action="{{=URL('edit', args=filename)}}" method="post" name="editform" id="editform" class="form-inline">
|
||||||
@@ -26,7 +23,7 @@
|
|||||||
{{pass}}
|
{{pass}}
|
||||||
<p class="formfield">
|
<p class="formfield">
|
||||||
{{if functions:}}
|
{{if functions:}}
|
||||||
<span style="text-align:left;" id="exposed">
|
<span style="text-align:left;" class="exposed">
|
||||||
{{=B(T('exposes:'))}} {{=XML(', '.join([A(f,_target="_blank", _href=URL(a=app,c=controller,f=f)).xml() for f in functions]))}}
|
{{=B(T('exposes:'))}} {{=XML(', '.join([A(f,_target="_blank", _href=URL(a=app,c=controller,f=f)).xml() for f in functions]))}}
|
||||||
</span>
|
</span>
|
||||||
{{if editviewlinks:}}<br/>
|
{{if editviewlinks:}}<br/>
|
||||||
@@ -75,6 +72,11 @@
|
|||||||
jQuery("#{{=id}} textarea").data('editor', editor);
|
jQuery("#{{=id}} textarea").data('editor', editor);
|
||||||
var hlLine = editor.setLineClass(0, "activeline");
|
var hlLine = editor.setLineClass(0, "activeline");
|
||||||
window.mirror = editor; //backward compatibility
|
window.mirror = editor; //backward compatibility
|
||||||
|
|
||||||
|
doListBreakpoints({{=XML("'%s','%s://%s%s'" % (filename,
|
||||||
|
request.env['wsgi_url_scheme'], request.env['http_host'],
|
||||||
|
URL(c='debug', f='list_breakpoints')))}}, editor);
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="editor-bar-bottom" style="margin-top:9px;">
|
<div class="editor-bar-bottom" style="margin-top:9px;">
|
||||||
|
|||||||
Reference in New Issue
Block a user