cleanup inline scripts and centralize editor theme
This commit is contained in:
parent
dc577e167d
commit
777685f5e3
@ -40,7 +40,7 @@ const devbug = {
|
|||||||
json(data){
|
json(data){
|
||||||
return JSON.stringify(JSON.rmref(JSON.decycle(data)));
|
return JSON.stringify(JSON.rmref(JSON.decycle(data)));
|
||||||
},
|
},
|
||||||
breakpoint(name, exception = false){
|
breakpoint(except = false, name){
|
||||||
var e = new Error();
|
var e = new Error();
|
||||||
this.libs(() => {
|
this.libs(() => {
|
||||||
var s = e.stack.split('at'); var caller = '';
|
var s = e.stack.split('at'); var caller = '';
|
||||||
@ -66,4 +66,4 @@ const devbug = {
|
|||||||
|
|
||||||
window.devbug = devbug;
|
window.devbug = devbug;
|
||||||
window.out = window.devbug.out.bind(window.devbug);
|
window.out = window.devbug.out.bind(window.devbug);
|
||||||
window.breakpoint = window.devbug.breakpoint.bind(window.devbug);
|
window.breakpoint = window.devbug.breakpoint.bind(window.devbug);
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
// ===========================================================
|
|
||||||
// DEVBUG INLINE DEBUGGING HELPER - FOR USE WITH DEVBUG SERVER
|
|
||||||
// TODO: REMOVE BEFORE COMMITTING
|
|
||||||
let outs = {}
|
|
||||||
let devbug_url = 'http://localhost:8000/'
|
|
||||||
let project_api_key = 'CHANGEME'
|
|
||||||
const out = (key, what, group="") => {
|
|
||||||
if ( group ){
|
|
||||||
if ( Object.keys(outs).includes(group) ) outs[group][key] = what
|
|
||||||
else outs[group] = {}; outs[group][key] = what
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
outs[key] = what
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const breakpoint = (html = false, name = null) => {
|
|
||||||
var e = new Error();
|
|
||||||
(function() {
|
|
||||||
// Load better json
|
|
||||||
var js_decycle = document.createElement("script");
|
|
||||||
js_decycle.src = devbug_url+"assets/cycle.js";
|
|
||||||
js_decycle.type = 'text/javascript';
|
|
||||||
js_decycle.onload = () => {
|
|
||||||
// Load the script
|
|
||||||
var script = document.createElement("script");
|
|
||||||
script.src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js';
|
|
||||||
script.type = 'text/javascript';
|
|
||||||
script.onload = () => {
|
|
||||||
var $ = window.jQuery;
|
|
||||||
$(() => {
|
|
||||||
var s = e.stack.split('at'); var caller = '';
|
|
||||||
if ( s.length < 3 ) s = e.stack.split('@')
|
|
||||||
if ( s.length > 2 ) caller = s[2].trim()
|
|
||||||
else if ( s.length > 1 ) caller = s[1]
|
|
||||||
else caller = 'Unable to determine stacktrace'
|
|
||||||
var data = new FormData();
|
|
||||||
console.log(JSON.decycle({brief: (name ? name : 'Breakpoint: ')+caller,data: outs}))
|
|
||||||
data.append('data', JSON.stringify(JSON.rmref(JSON.decycle({brief: (name ? name : 'Breakpoint: ')+caller,data: outs}))))
|
|
||||||
$.ajax({
|
|
||||||
url: devbug_url+'api/v1/out/'+project_api_key,
|
|
||||||
data: data, cache: false, contentType: false, processData: false, method: 'POST', type: 'POST',
|
|
||||||
success: (res) => { console.log('DevBug POST Completed'); console.log(res) }
|
|
||||||
})
|
|
||||||
});
|
|
||||||
};
|
|
||||||
document.getElementsByTagName("head")[0].appendChild(script);
|
|
||||||
}
|
|
||||||
document.getElementsByTagName("head")[0].appendChild(js_decycle);
|
|
||||||
})();
|
|
||||||
}
|
|
||||||
window.out = out; window.breakpoint = breakpoint;
|
|
||||||
// ===========================================================
|
|
@ -39,4 +39,6 @@ window.onscroll = () => {
|
|||||||
else {
|
else {
|
||||||
navbar.classList.remove('sticky')
|
navbar.classList.remove('sticky')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.devbug_editor_theme = 'ace/theme/idle_fingers'
|
||||||
|
@ -29,4 +29,5 @@ html
|
|||||||
if show_back
|
if show_back
|
||||||
li.navbar-right
|
li.navbar-right
|
||||||
a#navbar-back(href='javascript:window.history.back()') Back
|
a#navbar-back(href='javascript:window.history.back()') Back
|
||||||
block scripts
|
script(src="/assets/dash_v1.js")
|
||||||
|
block scripts
|
||||||
|
@ -6,6 +6,6 @@ block scripts
|
|||||||
script(src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.5/ace.js")
|
script(src="https://cdnjs.cloudflare.com/ajax/libs/ace/1.4.5/ace.js")
|
||||||
script.
|
script.
|
||||||
const editor = ace.edit('editor');
|
const editor = ace.edit('editor');
|
||||||
editor.setTheme('ace/theme/cobalt');
|
editor.setTheme(window.devbug_editor_theme);
|
||||||
editor.session.setMode('ace/mode/json');
|
editor.session.setMode('ace/mode/json');
|
||||||
editor.setOption('readOnly', true);
|
editor.setOption('readOnly', true);
|
||||||
|
@ -96,7 +96,7 @@ block scripts
|
|||||||
const readonly = #{!!readonly}
|
const readonly = #{!!readonly}
|
||||||
const preset_mode = document.getElementById('preset_mode').value
|
const preset_mode = document.getElementById('preset_mode').value
|
||||||
const editor = ace.edit('editor');
|
const editor = ace.edit('editor');
|
||||||
editor.setTheme('ace/theme/cobalt');
|
editor.setTheme(window.devbug_editor_theme);
|
||||||
console.log('preset mode: ', preset_mode);
|
console.log('preset mode: ', preset_mode);
|
||||||
editor.session.setMode(preset_mode);
|
editor.session.setMode(preset_mode);
|
||||||
document.getElementById('snippet_mode').value = preset_mode
|
document.getElementById('snippet_mode').value = preset_mode
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
extends ../template
|
extends ../template
|
||||||
block content
|
block content
|
||||||
h3 DevBug supports ECMAscript on the web.
|
h3 DevBug supports ECMAScript on the web.
|
||||||
p To use the client, include the ECMAscript client file in your application, as early as possible. This file is hosted by your local DevBug server, and is available <a href="/assets/agents/web.js" target="_blank">here.</a> Then, set the project API key and server addresses (see the code snippet below). This gives you access to the global <code>out()</code> and <code>breakpoint()</code> functions. Here's how to use them:
|
p To use the client, include the ECMAScript client file in your application, as early as possible. This file is hosted by your local DevBug server, and is available <a href="/assets/agents/ecma5.js" target="_blank">here.</a> Then, set the project API key and server addresses (see the code snippet below). This gives you access to the global <code>out()</code> and <code>breakpoint()</code> functions. Here's how to use them:
|
||||||
h4 <code>out(<i>info</i>, <i>data</i>)</code> - output data to DevBug
|
h4 <code>out(<i>info</i>, <i>data</i>)</code> - output data to DevBug
|
||||||
p This function is similar to logging data. It stores data to be outputted to DevBug. The first parameter should be a string with a brief description of the data, and the second is the data to be outputted. Note that the info string should be unique and multiple outputs with the same name will overwrite their predecessors. It's important to note that calling this function doesn't actually <i>send</i> any data to DevBug. Instead, it stores it to be sent.
|
p This function is similar to logging data. It stores data to be outputted to DevBug. The first parameter should be a string with a brief description of the data, and the second is the data to be outputted. Note that the info string should be unique and multiple outputs with the same name will overwrite their predecessors. It's important to note that calling this function doesn't actually <i>send</i> any data to DevBug. Instead, it stores it to be sent.
|
||||||
h4 <code>breakpoint(<i>continue = false</i>, <i>name = ""</i>)</code> - send the outputted data to DevBug
|
h4 <code>breakpoint(<i>continue = false</i>, <i>name = ""</i>)</code> - send the outputted data to DevBug
|
||||||
p This is the magic of the operation. When this function is called, any data that has been passed to the output function will be sent to the DevBug server and stored under the configured project. There are several things you can change about this function. The <code>continue</code> parameter determines whether or not program execution continues, or if the interpreter's exit method is called. The <code>name</code> parameter allows you to change the name of the breakpoint. This can be useful to help distinguish multiple breakpoints in the DevBug dashboard. Note that the continuation parameter is non-functional in browser-based ECMAscript.
|
p This is the magic of the operation. When this function is called, any data that has been passed to the output function will be sent to the DevBug server and stored under the configured project. There are several things you can change about this function. The <code>continue</code> parameter determines whether or not program execution continues, or if the interpreter's exit method is called. The <code>name</code> parameter allows you to change the name of the breakpoint. This can be useful to help distinguish multiple breakpoints in the DevBug dashboard. Note that the continuation parameter is non-functional in browser-based ECMAScript. Instead, the breakpoint throws an exception.
|
||||||
pre#editor.inline // Run the following as early in your application as your can: devbug_url="http://localhost:8000/"; project_api_key="CHANGEME";
|
pre#editor.inline // Run the following as early in your application as your can: devbug_url="http://localhost:8000/"; project_api_key="CHANGEME";
|
||||||
|
|
||||||
block scripts
|
block scripts
|
||||||
|
Loading…
Reference in New Issue
Block a user