I have a Chrome App that displays slideshow/dashboard on the screen. Right now all of the website files (html and .js) are stored in the app. So when the application starts, it can be used completely offline because all of the files it needs are stored internally.
I'm looking for a way to host the dashboard's files (.js files) on a web server, that the app will query, pull down, and cache fresh copies of at startup. This will make it easier to update the dashboard but still allow it to be (mostly) offline.
I have been able to have the app query the server successfully and pull down the Javascript files as strings. Normally, I would just inject the JavaScript into the page but that's not allowed with Chrome Apps. My question is, how can I take the JavaScript (pulled down from the server) and load it in the page?
Related
I want to create an app to estimate engineering costs: lots of tables, forms, a sidebar with a tree structure and so on. You can access a database in the cloud and create table structures according to records in the database.
Naturally that would be a website, however, if the user does not always have an access to the Internet, he/she can download a copy of that database (precisely, a copy of the current version of the database), so that it would be possible to get data from it and work locally. That is why an offline desktop app is needed.
Would it be possible to develop such a hybrid application without first creating a web app and then doing the same with a desktop app?
Previously i have looked into JavaFX, but we saw that it's too difficult to create a website out of that. Then we saw Electron, but i'm not sure if it is the right choice, because it seams that Electron is only used for desktop.
I'm lost as to why you feel you need a website/desktop hybrid. There are many APIs available to let you access a cloud database. All you have to do is find an API with web hooks, or APIs that specifically target the database type you are using (sql, mongo, or whatever). Then just cache a local copy once you've pulled down the database.
Work on the copy then push back to the database when they save, or try to do a push/pull every 5 minutes or something.
You can make a HTML page, which would:
Use AJAX calls if connected
Add relative <script> tag, thinking that HTML file lies in a folder on PC, and that script is somewhere nearbly.
In both cases, user will get same results.
Downloads are:
HTML file with inline script
JS file with database
or
zipped folder with HTML, database JS files and all scripts, images, css, etc. requred for HTML file to show properly.
Our web application is built on AngularJS and Ruby on Rails. Sometimes we find a bug in the JS and need to patch it immediately. We push up an update to Heroku and the new JS files are then live. However, users on the site (who are currently on the site) and do not refresh their page, are still using the old JS file.
Is there a way to force refresh of the assets on deployment with Heroku? Or, is there a better way to handle this type of problem?
I am thinking of using web sockets to possibly handle the scenario.
Backstory:
I am creating a development tool for web development. This tool loads a users webpage into an iframe, this allows the program to resize the iframe and simulate mobile screen sizes. I also want to build in a tool that automatically refreshes the iframe when local content is changed. To do this I am going to use Ajax to load files in and every 5 seconds or so compare the file to its previous version from 5 seconds ago. I currently have it working with just one file.
Question:
Is there a way to get all the files in a directory with Ajax. The little javascript same origin rule does not apply because the user is running this tool locally from the same directory as the project, no files from a server are being pulled.
Javascript which runs on the client machine can't access the local disk file system due to security restrictions.
If you want to access the client's disk file system then look into an embedded client application which you serve up from your webpage, like an Applet, Silverlight or something like that. If you like to access the server's disk file system, then look for the solution in the server side corner using a server side programming language like Java, PHP, etc, whatever your webserver is currently using/supporting.
I am making a html5 web app based on an existing ios app. It targets most recent two versions of ios Safari browser. For this web app to work, I need to use an api that handles communication between current ios app and php backend.
The very first hurdle is that api config files (gzipped) needs to be downloaded from server on a regular basis (for example each time app starts) to keep itself updated. Then I need to unzip to get config files, which basically contains key-value pairs of command name and http address. When I need certain command, e.g. display a user's profile pic, I lookup the config files by command number to find the corresponding request address so that I could make request to server.
To summerize the steps:
Download (gziped) configuration files by ajax
I don't think html anchor tag (with or without download attribute) is an option. Because in that way Safari will prompt user to open the downloaded file using file handling apps (e.g. FilesApp). The download must happen in the dark.
Unzip the downloaded file
I know a few js library promise to do this work. I haven't tested them yet for step one is not solved. Any recommandatio is welcomed.
Lookup http address in those files whenever making a api call
It should be no problem though.
For ios app, I can simply download the config files into app sandbox and do whatever I want with it. But for web app, even newest ios Safari don't suppor HTML5 file system api. What can I do?
Step 1.
Safari should support HTTP compression. Your best best is to leverage this, as opposed to figuring out a way to unzip a file using JavaScript. It looks like there are a few options with PHP:
http://php.net/manual/en/zlib.configuration.php
http://php.net/manual/en/function.ob-gzhandler.php
Or even at the server level:
http://httpd.apache.org/docs/2.2/mod/mod_deflate.html
Step 2.
Use sessionStorage to cache the configuration settings. The data will be cleared out each time a user closes their browser.
Step 3.
The PHP handler that is called by the AJAX request should take care of parsing the config files and send JavaScript-friendly JSON to the browser. Use JSON.parse() and JSON.stringify() to serialize/de-serialize data as you read/save to sessionStorage.
I'm developing an application which runs on a localhost server.! In this application I do ajax calls and get items from a local h2 DB! Using the response I create dynamic elements using jQuery. The elements use an item image as background and the requirement is that I should get the images from a local folder. ( The folder is created when the server is first started and the images are synchronized from a main server over the intranet. ) The folder hierarchy is shown below.
c:/----
|
zharaimages/ -----
|
[item id]/-----
|
[image].jpg
The image can contain any name for it but will be a jpg. How can I read the file system using jQuery to get the necessary image file when the item is dynamically loaded. I thought of this method but for that I can only read a file with a static name. I want to write a method where the image name can be anything.
clone.css('background-image','c:/zharaimages/' + items[i].itemId + '/image.jpg');
Any ideas or plugins are welcome.
Thank you.
update
This is a deployable application which uses an embedded jetty server. The folders are in the same computer as the application is!
Unfortunately a big NOOOOOO...
javaScripts cannot read or write files on users' computers (File API - not currently supported by many browsers - allows files to be read by scripts if the user specifically chooses to allow it),
though they can cause the browser to load remote pages and resources like scripts or images, which the browser may choose to cache locally.
They cannot create files on the server (except by communicating with a server side script that creates files for them).
You have to make a server request(many ways...) for the resources.
I'm not sure weather its possible with HTML5 or not
jQuery runs on the browser.
The files are on the server.
The only way that jQuery can read the files on the server is if it makes an AJAX call to the server, and your web server enumerates them.