Skip to content

Commit 1b241a3

Browse files
committed
Improved library handling
1 parent e45f792 commit 1b241a3

File tree

8 files changed

+100
-73
lines changed

8 files changed

+100
-73
lines changed

easycoder/easycoder-min.js

Lines changed: 16 additions & 16 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

easycoder/easycoder.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3888,7 +3888,8 @@ const EasyCoder = {
38883888
script.type = `text/javascript`;
38893889
let location = document.scripts[0].src;
38903890
location = location.substring(0, location.indexOf(`/easycoder.js`));
3891-
script.src = `${location}/${src}?ver=${EasyCoder.version}`;
3891+
// script.src = `${location}/${src}?ver=${EasyCoder.version}`;
3892+
script.src = `${src}?ver=${EasyCoder.version}`;
38923893
script.onload = function () {
38933894
console.log(`${Date.now() - EasyCoder.timestamp} ms: Plugin ${src} loaded`);
38943895
onload();
@@ -3920,16 +3921,21 @@ const EasyCoder = {
39203921
},
39213922

39223923
loadPluginJs: function(path) {
3923-
let location = path;
3924-
if (!location) {
3925-
location = document.scripts[0].src;
3926-
location = location.substring(0, location.indexOf(`/easycoder.js`));
3924+
if (!path) {
3925+
path = document.scripts[0].src;
3926+
path = path.substring(0, path.indexOf(`/easycoder.js`));
39273927
}
3928-
console.log(`${Date.now() - this.timestamp} ms: Load ${location}/plugins.js`);
3928+
this.path = path;
3929+
let src = `${path}/easycoder/plugins.js?ver=${this.version}`
3930+
console.log(`${Date.now() - this.timestamp} ms: Load ${src}`);
39293931
const script = document.createElement(`script`);
3930-
script.src = `${location}/plugins.js?ver=${this.version}`;
3932+
script.src = src;
39313933
script.type = `text/javascript`;
39323934
script.onload = () => {
3935+
let path = this.path.substr(window.location.origin.length);
3936+
if (path.endsWith(`/`)) {
3937+
path = path.slice(0, -1);
3938+
}
39333939
EasyCoder_Plugins.getGlobalPlugins(
39343940
this.timestamp,
39353941
path,
@@ -3954,14 +3960,16 @@ const EasyCoder = {
39543960
start: function(source) {
39553961
this.source = source;
39563962
this.scriptIndex = 0;
3957-
let pathname = window.location.pathname;
3963+
let pathname = window.location.href;
3964+
let q = pathname.indexOf('?');
3965+
if (q > 0) {
3966+
pathname = pathname.substr(0, q);
3967+
}
39583968
if (pathname.endsWith(`/`)) {
39593969
pathname = pathname.slice(0, -1);
3960-
} else {
3961-
pathname = ``;
3962-
}
3970+
}
39633971
if (typeof EasyCoder_Plugins === `undefined`) {
3964-
this.loadPluginJs(`${window.location.host}`);
3972+
this.loadPluginJs(pathname);
39653973
} else {
39663974
this.pluginsPath = pathname;
39673975
EasyCoder_Plugins.getGlobalPlugins(

easycoder/easycoder.zip

73.9 KB
Binary file not shown.

easycoder/plugins.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -19,37 +19,37 @@ const EasyCoder_Plugins = {
1919
setPluginCount(6); // *** IMPORTANT *** the number of plugins you will be adding
2020

2121
getPlugin(`browser`,
22-
`plugins/browser.js`,
22+
`easycoder/plugins/browser.js`,
2323
function () {
2424
addPlugin(`browser`, EasyCoder_Browser);
2525
});
2626

2727
getPlugin(`json`,
28-
`plugins/json.js`,
28+
`easycoder/plugins/json.js`,
2929
function () {
3030
addPlugin(`json`, EasyCoder_Json);
3131
});
3232

3333
getPlugin(`rest`,
34-
`plugins/rest.js`,
34+
`easycoder/plugins/rest.js`,
3535
function () {
3636
addPlugin(`rest`, EasyCoder_Rest);
3737
});
3838

3939
getPlugin(`svg`,
40-
`plugins/svg.js`,
40+
`easycoder/plugins/svg.js`,
4141
function () {
4242
addPlugin(`svg`, EasyCoder_SVG);
4343
});
4444

4545
getPlugin(`showdown`,
46-
`plugins/showdown.js`,
46+
`easycoder/plugins/showdown.js`,
4747
function () {
4848
addPlugin(`showdown`, EasyCoder_Showdown);
4949
});
5050

5151
getPlugin(`vfx`,
52-
`plugins/vfx.js`,
52+
`easycoder/plugins/vfx.js`,
5353
function () {
5454
addPlugin(`vfx`, EasyCoder_VFX);
5555
});
@@ -61,48 +61,55 @@ const EasyCoder_Plugins = {
6161
/*
6262
* This lets you add a plugin before launching a script, using the 'plugin' command.
6363
* You must provide a case for every plugin you will be adding;
64-
* use any one of them as the pattern to follow.
64+
* use 'ckeditor' as the pattern to follow.
6565
*/
6666

6767
switch (name) {
6868
case `codemirror`:
6969
getPlugin(name,
70-
`plugins/codemirror.js`,
70+
`easycoder/plugins/codemirror.js`,
7171
function () {
7272
addPlugin(name, EasyCoder_CodeMirror, callback);
7373
});
7474
break;
7575
case `ckeditor`:
7676
getPlugin(name,
77-
`plugins/ckeditor.js`,
77+
`easycoder/plugins/ckeditor.js`,
7878
function () {
7979
addPlugin(name, EasyCoder_CKEditor, callback);
8080
});
8181
break;
8282
case `ui`:
8383
getPlugin(name,
84-
`plugins/ui.js`,
84+
`easycoder/plugins/ui.js`,
8585
function () {
8686
addPlugin(name, EasyCoder_UI, callback);
8787
});
8888
break;
8989
case `anagrams`:
9090
getPlugin(name,
91-
`plugins/anagrams.js`,
91+
`easycoder/plugins/anagrams.js`,
9292
function () {
9393
addPlugin(name, EasyCoder_Anagrams, callback);
9494
});
9595
break;
9696
case `gmap`:
9797
getPlugin(name,
98-
`plugins/gmap.js`,
98+
`easycoder/plugins/gmap.js`,
9999
function () {
100100
addPlugin(name, EasyCoder_GMap, callback);
101101
});
102102
break;
103+
case `life`:
104+
getPlugin(name,
105+
`easycoder/plugins/life.js`,
106+
function () {
107+
addPlugin(name, EasyCoder_Life, callback);
108+
});
109+
break;
103110
case `wof`:
104111
getPlugin(name,
105-
`plugins/wof.js`,
112+
`easycoder/plugins/wof.js`,
106113
function () {
107114
addPlugin(name, EasyCoder_WOF, callback);
108115
});

js/EasyCoder-ST.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
EasyCoder.version = `2.6.1`;
22
EasyCoder.timestamp = Date.now();
3+
console.log(`EasyCoder loaded; waiting for page`);
34

45
function EasyCoder_Startup() {
6+
console.log(`${Date.now() - EasyCoder.timestamp} ms: Page loaded; reset timer & start EasyCoder`);
57
EasyCoder.timestamp = Date.now();
68
EasyCoder.scripts = {};
79
window.EasyCoder = EasyCoder;

js/easycoder/Main.js

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@ const EasyCoder = {
389389
script.type = `text/javascript`;
390390
let location = document.scripts[0].src;
391391
location = location.substring(0, location.indexOf(`/easycoder.js`));
392-
script.src = `${location}/${src}?ver=${EasyCoder.version}`;
392+
// script.src = `${location}/${src}?ver=${EasyCoder.version}`;
393+
script.src = `${src}?ver=${EasyCoder.version}`;
393394
script.onload = function () {
394395
console.log(`${Date.now() - EasyCoder.timestamp} ms: Plugin ${src} loaded`);
395396
onload();
@@ -421,16 +422,21 @@ const EasyCoder = {
421422
},
422423

423424
loadPluginJs: function(path) {
424-
let location = path;
425-
if (!location) {
426-
location = document.scripts[0].src;
427-
location = location.substring(0, location.indexOf(`/easycoder.js`));
425+
if (!path) {
426+
path = document.scripts[0].src;
427+
path = path.substring(0, path.indexOf(`/easycoder.js`));
428428
}
429-
console.log(`${Date.now() - this.timestamp} ms: Load ${location}/plugins.js`);
429+
this.path = path;
430+
let src = `${path}/easycoder/plugins.js?ver=${this.version}`
431+
console.log(`${Date.now() - this.timestamp} ms: Load ${src}`);
430432
const script = document.createElement(`script`);
431-
script.src = `${location}/plugins.js?ver=${this.version}`;
433+
script.src = src;
432434
script.type = `text/javascript`;
433435
script.onload = () => {
436+
let path = this.path.substr(window.location.origin.length);
437+
if (path.endsWith(`/`)) {
438+
path = path.slice(0, -1);
439+
}
434440
EasyCoder_Plugins.getGlobalPlugins(
435441
this.timestamp,
436442
path,
@@ -455,14 +461,16 @@ const EasyCoder = {
455461
start: function(source) {
456462
this.source = source;
457463
this.scriptIndex = 0;
458-
let pathname = window.location.pathname;
464+
let pathname = window.location.href;
465+
let q = pathname.indexOf('?');
466+
if (q > 0) {
467+
pathname = pathname.substr(0, q);
468+
}
459469
if (pathname.endsWith(`/`)) {
460470
pathname = pathname.slice(0, -1);
461-
} else {
462-
pathname = ``;
463-
}
471+
}
464472
if (typeof EasyCoder_Plugins === `undefined`) {
465-
this.loadPluginJs(`${window.location.host}`);
473+
this.loadPluginJs(pathname);
466474
} else {
467475
this.pluginsPath = pathname;
468476
EasyCoder_Plugins.getGlobalPlugins(

js/plugins/json.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ const EasyCoder_Json = {
317317
content.domain = source;
318318
}
319319
if (content.domain.endsWith(`/`)) {
320-
content.domain = content.domain.substr(0, content.domain.length - 1);
320+
content.domain = content.domain.slice(0, -1);
321321
}
322322
n = content.domain.indexOf(`/`);
323323
if (n > 0) {

resources/ecs/codex.ecs

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -292,45 +292,46 @@ L2:
292292
create HelpInner in HelpOuter
293293
set the style of HelpInner to `width:100%;line-height:1.5em`
294294

295-
create HelpPanel in HelpInner
296-
set the style of HelpPanel to `display:none;width:100%;height:100%`
297-
create ReferencePanel in HelpInner
298-
set the style of ReferencePanel to `display:none;width:100%;height:100%`
295+
create HelpPanel in HelpInner
296+
set the style of HelpPanel to `display:none;width:100%;height:100%`
297+
create ReferencePanel in HelpInner
298+
set the style of ReferencePanel to `display:none;width:100%;height:100%`
299299

300-
gosub to ShowHelpPage
301-
rest get Script from `/resources/ecs/docman.ecs`
302-
run Script with ReferencePanel as DocManModule
303-
put empty into storage as `.ref`
300+
gosub to ShowHelpPage
301+
rest get Script from `/resources/ecs/docman.ecs`
302+
run Script with ReferencePanel as DocManModule
303+
put empty into storage as `.ref`
304304

305-
get Item from storage as `.ref`
305+
get Item from storage as `.ref`
306306
if Item
307307
begin
308308
set style `display` of ReferencePanel to `block`
309309
set style `display` of HelpButtons to `none`
310310
end
311311
else set style `display` of HelpPanel to `block`
312312

313-
on click Back go to StepBack
314-
on click Forward go to StepForward
313+
on click Back go to StepBack
314+
on click Forward go to StepForward
315315
on click Contents go to ShowContents
316-
on click Reference
316+
on click Reference
317317
begin
318318
set style `display` of ReferencePanel to `block`
319319
set style `display` of HelpPanel to `none`
320320
set style `display` of HelpButtons to `none`
321321
put `y` into storage as `.ref`
322322
end
323-
on click Tools
323+
on click Tools
324324
begin
325325
put `tools` into Step
326326
gosub to ShowHelpPage
327327
end
328-
on click Exit
328+
on click Exit
329329
begin
330-
stop DocManModule
330+
stop DocManModule
331331
remove element Body
332-
send `restore` to parent
333-
exit
332+
send `restore` to parent
333+
history set url `.`
334+
exit
334335
end
335336

336337
on message
@@ -509,6 +510,7 @@ L2:
509510
begin
510511
put from 2 of Arg into Step
511512
gosub to SHP2
513+
history set url `.`
512514
end
513515

514516
set ready
@@ -680,7 +682,7 @@ SHP1:
680682
SHP2:
681683
put Step into storage as `.step`
682684
put `/resources/codex/code/` cat Step cat `.ecs` into Item
683-
rest get Fragment from Item or begin end
685+
rest get Fragment from Item or put empty into storage as `.step`
684686
put property Step of Pages into Page
685687
if property `prev` of Page is empty set style `visibility` of Back to `hidden`
686688
else set style `visibility` of Back to `visible`
@@ -1016,4 +1018,4 @@ GetPassword:
10161018

10171019
SetPasswordValid:
10181020
set PasswordValid
1019-
return
1021+
return

0 commit comments

Comments
 (0)