jsobject

Javascript Object for Tic Tac Toe game

拜拜、爱过 提交于 2020-04-07 10:30:57
问题 Complete newbie here on the Javascript topic. I am trying to code out a Tic Tac Toe game, while using JS' Objects to save code space. I figured I might create a JS Object which will all 9 fields defined in the HTML code with ids 'one' to 'nine' as values, and then also have a custom method which can be used to swap value's textContent as follows: var fields = { one: document.querySelector('#one'), two: document.querySelector('#two'), three: document.querySelector('#three'), four: document

How to sort a JS object of objects?

走远了吗. 提交于 2019-12-29 06:59:27
问题 I have built an object in PHP, used JSON_encode function and send it as a JSON string to my JS script via ajax. Then I convert it back to an object. The problem I am having is that I wanted to keep the object in the order that it was originally created in. Please see this picture of what the object looks like once I get it into JS: When I created the object, it was sorted by the customer field alphabetically. The customer name starting with A would come first, B second, etc. As you can see,

Loop through Awesomium JSObject

徘徊边缘 提交于 2019-12-20 04:04:28
问题 I'm making an C# Windows Form Application with an Awesomium webbrowser inside it. I'm trying to get some rows from an table and parse them to an array. The JSPart is running inside the browser fine. Here's the code that i use inside C#: JSObject villageRows = view.ExecuteJavascriptWithResult("document.getElementById(\"production_table\").getElementsByTagName(\"tbody\")[0].getElementsByTagName(\"tr\");"); if (villageRows == null) { return; } That returns now 2 tr rows inside Chrome, but that

Does JavaFX8 WebEngine's executeScript(“window”) method refer to the JavaScript window object?

隐身守侯 提交于 2019-12-12 19:47:44
问题 I'm wondering about this code snippet I'm using: WebView webView = new WebView(); JSObject jsobj; webEngine = webView.getEngine(); try { webEngine.load(getClass().getResource("index.html").toExternalForm()); } catch (Exception e) { e.printStackTrace(); } try { jsobj = (JSObject) webEngine.executeScript("window"); jsobj.setMember("java", new DataModel()); } catch (Exception e) { e.printStackTrace() } This line webEngine.load(getClass().getResource("index.html").toExternalForm()); loads my

Accessing object properties where the property name is in a variable

别来无恙 提交于 2019-12-11 04:07:57
问题 I am trying to check if a certain item exists in a JS object. To do this, I need to use whatever ID is passed into my method. At the moment I'm struggling to actually use the variable's value. Here's what I'm doing: data.entries.id So I have my object setup as: var data = { "entries" : { } }; Therefore, the .id part will check if a certain ID exists. If it does, I do nothing, if it doesn't, I want to add it. At the moment, by using data.entries.id, every time I simply check if 'id' exists in

calling custom JavaScript function from codename one

给你一囗甜甜゛ 提交于 2019-12-10 12:24:57
问题 I recently came across the JSObject and JSFuntion, and it seemed really confusing. Can it be used to call custom JavaScript functions and return values back to my CN1 app? Or is it for some other function?. Thanks all 回答1: Check out the javadoc package overview for that: https://www.codenameone.com/javadoc/com/codename1/javascript/package-summary.html E.g. from that page: The following example shows an object with a simple add() method that just adds two numbers together: JSObject obj =

Get a JSObject or JSContext to run an applet

岁酱吖の 提交于 2019-12-08 06:18:53
问题 How to get a JSObject or JSContext to run an applet from Java? I'm trying to automate some procedure that consists in some link clicking in a web and then going through an applet, so what I do is to send some HTTPRequests through Java until I get a HTML with the tag from which, through JSoup, I extract all the parameters and codebase, etc. As I want to run the applet as well, I load the applet class with a ClassLoader, I set a custom stub that can give the parameters that I extracted

Java netscape.javascript.JSObject used for storing cookies

左心房为你撑大大i 提交于 2019-12-08 04:46:56
问题 I have a Java application running on the web through a Webswing server. A Webswing server translates Java to HTML5 for secure web usage. I use netscape.javascript.JSObject to store and read cookies from the Java application. // write String cookie = "name=userstuff; Expires.... "; JSObject global = JSObject.getWindow(null); global.eval("document.cookie=" + "\"" + cookie + "\""); //read Object cookies= global.eval("document.cookie"); I have not found a way to store passwords in the browser

Get a JSObject or JSContext to run an applet

放肆的年华 提交于 2019-12-06 20:38:31
How to get a JSObject or JSContext to run an applet from Java? I'm trying to automate some procedure that consists in some link clicking in a web and then going through an applet, so what I do is to send some HTTPRequests through Java until I get a HTML with the tag from which, through JSoup, I extract all the parameters and codebase, etc. As I want to run the applet as well, I load the applet class with a ClassLoader, I set a custom stub that can give the parameters that I extracted previously. The thing is that this applet has some javascript interaction with the browser, so at some point it

Java netscape.javascript.JSObject used for storing cookies

Deadly 提交于 2019-12-06 16:54:58
I have a Java application running on the web through a Webswing server. A Webswing server translates Java to HTML5 for secure web usage. I use netscape.javascript.JSObject to store and read cookies from the Java application. // write String cookie = "name=userstuff; Expires.... "; JSObject global = JSObject.getWindow(null); global.eval("document.cookie=" + "\"" + cookie + "\""); //read Object cookies= global.eval("document.cookie"); I have not found a way to store passwords in the browser password section. In Chrome the section is: chrome://settings/passwords Could you tell me if the