POS UI Cheatsheet
This page contains a range of quick tips and ways to do something. This is for User Interface used in PosGreen. These are the web pages and associated javascript that are used in front counter POS creation.
Detecting POS
If your webpage is being displayed inside POSGreen, then you can detect this as follows
if ( (typeof window.chrome !== 'undefined') && (typeof window.chrome.webview !== 'undefined')) { if (typeof window.chrome.webview.postMessage !== 'undefined') { sHaveWebView = 1; } }
This checks if the current webpage is inside a webview control, but this does not verify that the webview is from PosGreen, it is possible some other application using a webview is displaying your webpage
Translating Symbols/Settings
The POS uses symbols and settings to control its internal operation. When building a web page to interact with the POS you often need to retrieve these values.
// Register a listener to receive the settings values when done window.chrome.webview.addEventListener('message', function (msg) { if (msg.data.Type == "cmd:symbols:setup") { let cp = JSON.parse(msg.data.result); sSettings = cp; } }); // Request symbol translation. The above event will fire when symbol translation is complete window.chrome.webview.postMessage("cmd:symbols:setup," + JSON.stringify( { UserInterfaceUrlSelling: "%data.setting..UserInterfaceUrl.Selling%", PLevel: "%data.systemconfig.plevel%" } ));
Technically, what the above is doing is creating a Javascript object with symbols to be translated, and then passing that object to the POS to convert
all symbols. The pos then returns the object in the event handler. You do not need to use objects and can use simple strings. On the POS side, it
simply translates all raw text after the "cmd:symbols:setup," in the initial request.
The word "setup" is not used by the POS, this can be any value you want. This value allows your event handler to differentiate requests in case you
have multiple active.