From 1f131a76b091d989a367337e28ee1a5b6dc68b5e Mon Sep 17 00:00:00 2001 From: deuce <> Date: Mon, 16 Nov 2015 21:03:43 +0000 Subject: [PATCH] Avoid the use of js.global, remove added load paths on exit. --- exec/dorkit/graphic.js | 2 +- exec/dorkit/jsexec_input.js | 2 +- exec/dorkit/local_console.js | 2 +- exec/dorkit/sbbs_console.js | 6 +++--- exec/dorkit/sbbs_input.js | 2 +- exec/dorkit/screen.js | 4 ++-- exec/dorkit/socket_input.js | 2 +- exec/load/dorkit.js | 19 +++++++++++-------- 8 files changed, 21 insertions(+), 18 deletions(-) diff --git a/exec/dorkit/graphic.js b/exec/dorkit/graphic.js index ac40459dab..063671da14 100644 --- a/exec/dorkit/graphic.js +++ b/exec/dorkit/graphic.js @@ -16,7 +16,7 @@ * */ -if (js.global.Attribute === undefined) +if (typeof(Attribute) === 'undefined') load("attribute.js"); function Graphic(w,h,attr,ch) diff --git a/exec/dorkit/jsexec_input.js b/exec/dorkit/jsexec_input.js index 4c872abbd3..793c8e5844 100644 --- a/exec/dorkit/jsexec_input.js +++ b/exec/dorkit/jsexec_input.js @@ -1,5 +1,5 @@ js.load_path_list.unshift(js.exec_dir+"dorkit/"); -if (js.global.system !== undefined) +if (typeof(system) !== 'undefined') js.load_path_list.unshift(system.exec_dir+"dorkit/"); load('ansi_input.js'); var k; diff --git a/exec/dorkit/local_console.js b/exec/dorkit/local_console.js index a8ce26afd7..e425f480c0 100644 --- a/exec/dorkit/local_console.js +++ b/exec/dorkit/local_console.js @@ -2,7 +2,7 @@ * Implements the local console using conio */ -if (js.global.Graphic === undefined) +if (typeof(Graphic) === 'undefined') load("graphic.js"); dk.console.local_io = { diff --git a/exec/dorkit/sbbs_console.js b/exec/dorkit/sbbs_console.js index 6aa55a89c2..eeecfb9b06 100644 --- a/exec/dorkit/sbbs_console.js +++ b/exec/dorkit/sbbs_console.js @@ -1,7 +1,7 @@ load("sbbsdefs.js"); -js.global.dk_old_ctrlkey_passthru = console.ctrlkey_passthru; -js.global.dk_old_pauseoff = bbs.sys_status & SS_PAUSEOFF; -js.on_exit("console.ctrlkey_passthru=js.global.dk_old_ctrlkey_passthru;bbs.sys_status=(bbs.sys_status &~ SS_PAUSEOFF)|js.global.dk_old_pauseoff"); +dk_old_ctrlkey_passthru = console.ctrlkey_passthru; +dk_old_pauseoff = bbs.sys_status & SS_PAUSEOFF; +js.on_exit("console.ctrlkey_passthru=dk_old_ctrlkey_passthru;bbs.sys_status=(bbs.sys_status &~ SS_PAUSEOFF)|dk_old_pauseoff"); console.ctrlkey_passthru=0x7fffffff; // Disable all parsing. /* diff --git a/exec/dorkit/sbbs_input.js b/exec/dorkit/sbbs_input.js index 8ebe15e7d9..9816bd2724 100644 --- a/exec/dorkit/sbbs_input.js +++ b/exec/dorkit/sbbs_input.js @@ -1,5 +1,5 @@ js.load_path_list.unshift(js.exec_dir+"dorkit/"); -if (js.global.system !== undefined) +if (typeof(system) !== 'undefined') js.load_path_list.unshift(system.exec_dir+"dorkit/"); load('ansi_input.js'); var q = new Queue("dorkit_input"); diff --git a/exec/dorkit/screen.js b/exec/dorkit/screen.js index 3beeb3dc80..b4f452603d 100644 --- a/exec/dorkit/screen.js +++ b/exec/dorkit/screen.js @@ -7,9 +7,9 @@ * all data should be provided using the print() method. */ -if (js.global.Graphic === undefined) +if (typeof(Graphic) === 'undefined') load("graphic.js"); -if (js.global.Attribute === undefined) +if (typeof(Attribute) === 'undefined') load("attribute.js"); function Screen(w, h, attr, fill) diff --git a/exec/dorkit/socket_input.js b/exec/dorkit/socket_input.js index b616a0231a..25acc0143b 100644 --- a/exec/dorkit/socket_input.js +++ b/exec/dorkit/socket_input.js @@ -1,5 +1,5 @@ js.load_path_list.unshift(js.exec_dir+"dorkit/"); -if (js.global.system !== undefined) +if (typeof(system) !== 'undefined') js.load_path_list.unshift(system.exec_dir+"dorkit/"); load('ansi_input.js'); var i; diff --git a/exec/load/dorkit.js b/exec/load/dorkit.js index 4c3a999329..feec34a9c2 100644 --- a/exec/load/dorkit.js +++ b/exec/load/dorkit.js @@ -1,6 +1,9 @@ js.load_path_list.unshift(js.exec_dir+"dorkit/"); -if (js.global.system !== undefined) +js.on_exit("js.load_path_list.shift()"); +if (typeof(system) !== 'undefined') { js.load_path_list.unshift(system.exec_dir+"dorkit/"); + js.on_exit("js.load_path_list.shift()"); +} load("screen.js"); // polyfill the String object with repeat method. @@ -716,13 +719,13 @@ var dk = { gen_dir:undefined, sysop_name:undefined, default_attr:new Attribute(7), - mode:(js.global.bbs !== undefined - && js.global.server !== undefined - && js.global.client !== undefined - && js.global.user !== undefined - && js.global.console !== undefined) ? 'sbbs' - : (js.global.jsexec_revision !== undefined ? 'jsexec' - : (js.global.jsdoor_revision !== undefined ? 'jsdoor' : undefined)) + mode:(typeof(bbs) !== 'undefined' + && typeof(server) !== 'undefined' + && typeof(client) !== 'undefined' + && typeof(user) !== 'undefined' + && typeof(console) !== 'undefined') ? 'sbbs' + : (typeof(jsexec_revision) !== 'undefined' ? 'jsexec' + : (typeof(jsdoor_revision) !== 'undefined' ? 'jsdoor' : undefined)) }, misc:{ event_time:undefined, -- GitLab