Convert Javascript app into Windows app - javascript

Is there any solutions except Adobe Air?
I have heard that V8 kinda have something there.
Just don't have time for now, to write on another language whole app and then write 2x more code.

Maybe you could use jsc: Compiling JScript Code from the Command Line.
But you will have to replace browser-related objects by WinForms objects, which involves learning a new API, or use the .NET WebBrowser object (a browser widget showing only the content of a page, without bars except scrollbars) in a main window (Form object) and program it to load a URL to the page with your JS code.
Here is an excerpt from MSDN:
The WebBrowser control also lets you display content that you create in your application or you retrieve from a database or resource file. Use the DocumentText or DocumentStream property to get or set the contents of the current document as a string or data stream.
You can also manipulate the contents of a Web page through the Document property, which contains an HtmlDocument object that provides managed access to the HTML document object model (DOM) for the current page. This property is useful, when used in combination with the ObjectForScripting property, to implement two-way communication between your (Windows) application code and dynamic HTML (DHTML) code in a Web page, letting you combine Web-based controls and Windows Forms controls in a single user interface. You can use the Document property to call scripting code methods from your application(Windows code). Your scripting code can access your application through the window.external object, which is a built-in DOM object provided for host access, and which maps to the object that you specify for the ObjectForScripting property.
The WebBrowser control is a managed wrapper for the ActiveX WebBrowser control, and uses whichever version of the control is installed on the user's computer.

You can make a normal HTML file become a Windows App simply by changing the file's extension into ".hta"
Windows will treat your *.hta file like a winform application. This is called "html application" - HTA.
More documentations herer :
Html application
And of course, you can attach as much Javascript as you want in that HTA file, or even use external *.js file by doing like this :
<script src="your file.js"></script>

Well, your could try something like
Chromeless.
This way, you could keep your code, and it at least would kinda look like a desktop app.

http://www.adobe.com/products/air/
http://gears.google.com/
So far, i'd go with adobe air since it's portability and robustness (doesn't make it errorless, tho)

Related

Adding a custom method/object to Javascript in Electron

I'm developing a custom application that might need to use a proprietary low-level library, I'm looking into the Electron platform to see if it has entry points for extensions plugins that work as if they were native JS objects.
I've tried using Electron's <webview src="..." nodeintegration> tag, unfortunately the tag does not support transparencies when overlayed on top of each other so direct node integration was discarded. The second option is to use iframes and have the script inside the iframe call custom JS/native methods on a
custom object (think the window object).
I'm exploring the electron code base but I've just started and hoped that maybe someone more familiar with it could point me in the right direction, the ideal way would be for me to be able to create a shared library (be it linked dynamically or statically) and to be able to use the new methods on the JS code that runs as part of a web page rather than as part of Node.

Scraping a dynamically loaded, javascript lidded website using Pythons BeautifulSoup [duplicate]

I need to scrape a site with python. I obtain the source html code with the urlib module, but I need to scrape also some html code that is generated by a javascript function (which is included in the html source). What this functions does "in" the site is that when you press a button it outputs some html code. How can I "press" this button with python code? Can scrapy help me? I captured the POST request with firebug but when I try to pass it on the url I get a 403 error. Any suggestions?
In Python, I think Selenium 1.0 is the way to go. It’s a library that allows you to control a real web browser from your language of choice.
You need to have the web browser in question installed on the machine your script runs on, but it looks like the most reliable way to programmatically interrogate websites that use a lot of JavaScript.
Since there is no comprehensive answer here, I'll go ahead and write one.
To scrape off JS rendered pages, we will need a browser that has a JavaScript engine (e.i, support JavaScript rendering)
Options like Mechanize, url2lib will not work since they DO NOT support JavaScript.
So here's what you do:
Setup PhantomJS to run with Selenium. After installing the dependencies for both of them (refer this), you can use the following code as an example to fetch the fully rendered website.
from selenium import webdriver
driver = webdriver.PhantomJS()
driver.get('http://jokes.cc.com/')
soupFromJokesCC = BeautifulSoup(driver.page_source) #page_source fetches page after rendering is complete
driver.save_screenshot('screen.png') # save a screenshot to disk
driver.quit()
I have had to do this before (in .NET) and you are basically going to have to host a browser, get it to click the button, and then interrogate the DOM (document object model) of the browser to get at the generated HTML.
This is definitely one of the downsides to web apps moving towards an Ajax/Javascript approach to generating HTML client-side.
I use webkit, which is the browser renderer behind Chrome and Safari. There are Python bindings to webkit through Qt. And here is a full example to execute JavaScript and extract the final HTML.
For Scrapy (great python scraping framework) there is scrapyjs: an additional downloader handler / middleware handler able to scraping javascript generated content.
It's based on webkit engine by pygtk, python-webkit, and python-jswebkit and it's quite simple.

Cross Browser, Object Persistence Library for Client Application

I'm creating a client based application in HTML Application (HTA) and I would like to know if there's a object persistent library similar to python's shevle that meets the following criteria:
Should be able to read and write on file
Cross browser: should work at least on both HTA and on Firefox (through XULRunner) so that I'll be not tied to any vendor.
Written in JavaScript form
TiddyWiki is able to save itself, regardless of the browser used, though the codes that saves and retrieves files has to be refactored to meet my need.
Well, I wasn't aware that TiddyWiki has a github repository, and they organized the files by module.
I could just take the FileSystem.js file and build a nice api on top of it to simulate shelve functionality.

Interacting with webpage from C++ Application

i have a sitation where i want to access HTML DOM object from within my application to update certain parts of web page through javascript commands at run time.
It is a local webpage opened in FireFox which would be accessed by my application, so that the final output is always shown at the webpage which is updated by appliation.
It would be great if you could give me some idea about how this can be accomplished.
I have similar requirement like the webmonkey extension of firefox but need to do it outside of browser from my application.
You can try QtWebKit from the Qt framework, it provides an OO set of classes to interact with webpages from basic actions to very complicated and advanced stuff. I believe you may find your answer there, a link is provided below...
Good Luck
see Here

Is there a way to use jQuery.getScript inside the AIR application sandbox?

I 'm trying to build an AIR application using the HTML/JS engine (not flex nor flash), but I'm facing an issue while trying to load dynamically a JS file form the application directory.
Once the application has launched, if I try to load a script using jQuery.getScript method, the script is never interpreted and no error is thrown.
I've read about the security model of AIR and found that, in the Application sandbox, once the application is launched, nearly no new script can be added BUT the ones form the application directory.
So, I'm wondering why my script isn't interpreted. Is it due to the fact that jQuery append the script to the DOM and that this is prohibited? Is there a jQuery alternative? Or am I force do use the crappy AIR native API?
You should use the native API to retreive the text then eval() the text.. this will have the same general effect... probably want to do eval.call(window, scriptText) to make sure your namespacing/encapsulation is correct.

Categories