diff --git a/helloworld.js b/helloworld.js index 05300fa..db70825 100644 --- a/helloworld.js +++ b/helloworld.js @@ -1,5 +1,6 @@ var SYS = require("lib/system"); var HTTP = require("lib/http"); +//var Toolkit = require("lib/toolkit"); function main(args) { console.log("Hello world"); @@ -11,8 +12,10 @@ function main(args) { var web = HTTP.create(); console.log(web.userAgent); } catch (e) { - console.error("Something wrong"); + console.error("lib/http: Something wrong"); } + + //Toolkit.create(); } exports.main = main; \ No newline at end of file diff --git a/lib/toolkit.js b/lib/toolkit.js index 396ebb7..7e42fbb 100644 --- a/lib/toolkit.js +++ b/lib/toolkit.js @@ -1,25 +1,25 @@ -//////////////////////////////////////////////////////////////////////// -// WelsonJS.Toolkit API -//////////////////////////////////////////////////////////////////////// +// toolkit.js +// Namhyeon Go +// https://github.com/gnh1201/welsonjs -var ToolkitObject = function() { +function ToolkitObject() { this.interface = null; this.create = function() { try { this.interface = CreateObject("WelsonJS.Toolkit"); - return this; } catch (e) { console.info("WelsonJS.Toolkit not installed"); console.info("It could be download from https://github.com/gnh1201/welsonjs"); console.error(e.message); } + return this; }; this.getInterface = function() { return this.interface; }; - + this.create(); }; @@ -47,8 +47,8 @@ function sendFnKey(wName, num) { return getInterface().SendFnKey(wName, num); } +// [lib/toolkit] Implementation of User prompts (alert, confirm. prompt) #21 // https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html - function alert(message) { return getInterface().Alert(message); } @@ -61,6 +61,30 @@ function prompt(message, _default) { return getInterface().Prompt(message, _default); } +// [Toolkit] Access to a shared memory #96 +function NamedSharedMemory(name) { + var Toolkit = create().getInterface(); + + this.name = name; + this.isInitialized = false; + + this.open = function() { + this.isInitialized = Toolkit.OpenNamedSharedMemory(this.name); + }; + + this.readText = function() { + return Toolkit.ReadTextFromSharedMemory(this.name); + }; + + this.writeText = function(text) { + Toolkit.WriteTextToSharedMemory(this.name, text); + }; + + this.clear = function() { + Toolkit.ClearSharedMemory(this.name); + }; +} + exports.create = create; exports.getInterface = getInterface; exports.sendClick = sendClick; @@ -69,8 +93,9 @@ exports.sendFnKey = sendFnKey; exports.alert = alert; exports.confirm = confirm; exports.prompt = prompt; +exports.NamedSharedMemory = NamedSharedMemory; -exports.VERSIONINFO = "WelsonJS.Toolkit Native API version 0.3.1"; +exports.VERSIONINFO = "WelsonJS.Toolkit Native API version 0.3.2"; exports.AUTHOR = "abuse@catswords.net"; exports.global = global; exports.require = global.require;