I have a phonegap application which will need to take a zip archive of a webpage, unzip it, and display the output.
I have been looking around for ways to zip/unzip with phonegap and have been coming up short. Since it's all Js it seems like JsZip might hold an answer but their test suite has nothing on unzipping.
Does anyone have any advice on how to achieve this?
Edit for posterity: I DID ultimately get javascript unzipping working with zip.js and a bunch of wrapper code. It worked fine but is quite processor intensive. Unzipping a 15mb zip file in chrome on a desktop took about 40 seconds. For anything where performance is a concern (most things), I would recommend stepping down a level and using a component directly from ios/android.
cordova-plugin-zip worked for me. It supports native unzipping for iOS and Android.
https://github.com/MobileChromeApps/cordova-plugin-zip
See this one: http://cheeso.members.winisp.net/Unzip-Example.htm
More info: Unzipping files
If the JavaScript approach does not work you can always just write a Plugin.
Related
I found a game online, or which the source code is here, and I wanted to mod it. However, after modding it online on Github for a while, I was being driven crazy, by the github pages load time and my browser cache, which seemed to defy all attempts at deletion.
Finally, I attempted to use NWjs to load it. But, now the audio doesn't play at all. How do I fix this?
Note, the sounds, like the ding and select noise play, but not the bgm. All of them are .ogg files.
I'm using windows 10.
Another note, I pushed my version to Github and then checked out the gh-pages, which worked. So it's probably a problem with NWjs or my computer or both.
You probably need proprietary codecs.
Easiest way:
Switch to the latest version supported by the prebuilts (currently 0.55.0)
https://github.com/iteufel/nwjs-ffmpeg-prebuilt/releases
Download the version you need, unzip, and place it with your NW.js files.
More details:
https://nwjs.readthedocs.io/en/latest/For%20Developers/Enable%20Proprietary%20Codecs/
I downloaded the files you linked. I put that folder inside another called "game". Made a game/package.json file with this:
{
"main": "c2-sans-fight-gh-pages/index.html",
"name": "example"
}
Downloaded the Win 64 SDK version of NW.js v0.55.0.
http://dl.nwjs.io/v0.55.0/nwjs-sdk-v0.55.0-win-x64.zip
Dumped those files into the game folder so nw.exe was next to package.json and then ran it, and it worked fine. All audio played normally. I did not need to pull in the modified ffmpeg at all.
I cleared all things I could find, so ~/AppData/Local/nwjs and ~AppData/Local/<projectname> and ~/AppData/Roaming/<projectname> all got deleted, then I ran it again and it worked.
EDIT: It seems that I have to re-delete the cache files again and again before each launch. Guess I'll write a python script to handle this.
I am attempting to create a javascript pdf reader that can work offline in the browser (it uses the browser but not the internet), and am using Mozilla's pdf.js to do it. Pdf.js has a main file of the same name, which uses the internet to inject script from a pdf.worker.js file. One obstacle to creating an offline version of pdf.js is to stop it from using the internet to do this, by either pasting the pdf.worker.js code into the parts of pdf.js code that ask for it, or to convert the pdf.worker.js into a Data URI and use that as the url that pdf.js asks for. Doing the former has not yielded any success, and doing the latter has only worked on Firefox. We want this to work any way we can make it work, so I have pretty much two questions pertaining to making pdf.js offline.
1) If I am going with the method of physically pasting pdf.worker.js code into the spots where pdf.js uses the internet to inject pdf.worker code in, how would I make it work? I tried doing it, and I couldn't get it to work. Are there any things I must pay attention to?
2) I have had more success with converting pdf.worker.js into a Data URI and having pdf.js use that instead of the url it was using to access worker.js. However, this process only works on Firefox. Any idea why? And, do you know of a way I can make this process work with the other browsers?
Any input is welcome. Thanks in advance!
Go to https://github.com/mozilla/pdf.js/
Follow the instructions in "Getting the Code" and "Building PDF.js"
Then run node make singlefile
Combined file will be in build\singlefile\build\pdf.combined.js
Worked for me on Windows. Should work on other platforms too.
I've been doing some research and I came across this little number: http://www.xpertdeveloper.com/2012/10/webpage-screenshot-with-html5-js/ that allows you to turn HTML into a blob (essentially as a screenshot)... HTML2Canvas does this, too, but not quite as well: http://html2canvas.hertzen.com/
However the problem is that's where I'm stuck. I'd ideally like to render HTML to an image (either as a blob or a local file) and upload it to Facebook via the Graph API.
My problems start with < 3.0 Android browsers not being able to accommodate blobs. Has anyone come up with a solution that would work on Phonegap Build that would allow me to do this? Since I'm on Build I'm probably limited to Javascript, HTML5, and whatever Android / Safari allows.
The question is old, but maybe the answer will help someone.
You can use the screenshot plugin for iOS and Android.
For details, read the Documentation on Github
I'm busy experimenting with TiddlyWiki and trying to get it to run on my Nokia E51, which uses S60v3. The browser is based on webkit, which should mean that I'd be able to get it to work, but no luck so far.
Does anyone have any experience with saving files locally on this platform?
I skimmed through the source of TiddlyWiki. For its file operations it is using the jQuery.twFile plugin which in turn uses a custom Java applet on Webkit-based browsers. The S60 browser does not support java applets so I'm afraid you're out of luck.
I may be wrong here but a quick look at the widget training course on forum Nokia makes it seem like file system access from JavaScript isn't available on S60.
http://www.forum.nokia.com/Tools_Docs_and_Code/Documentation/Web_Technologies/
It really look like you're supposed to retrieve persistent data from the network.
I would hope the web browser cache allows you to query remote data several times while only transfering it once.
On my E51 I am able do download files the old-fashion way: A simple link to a file with a fitting mimetype.
I have a number of users with multi-megabyte files that need to be processed before they can be uploaded. I am trying to find a way to do this without having to install any executable software on their machines.
If every machine shipped with, say, Python it would be easy. I could have a Python script do everything. The only scripting language I can think of that's on every machine is JavaScript. However I know there are security restrictions that prevent reading and writing local files from web browsers.
Is there any way to use this extremely pervasive scripting language for general purpose computing tasks?
EDIT: To clarify the requirements, this needs to be a cross platform, cross browser solution. I believe that HTA is an Internet Explorer only technology (or that the Firefox equivalent is broken).
Would Google Gears work here? Yes, users have to install something, but I think the experience is fairly frictionless. And once it's installed, no more worries.
The application that I maintain and develop for work is an HTML Application or HTA, linked with a SQL Server 2005 backend. This allows various security restrictions to be "avoided". All the client-side components in the application are done with javascript, including writing files to locally mapped network drives and loading data into screens/pages in an AJAXy way.
Perhaps HTA could be helpful for your situation.
For an example of javascript accessing a local file, you might try taking a look at the source of TiddlyWiki, specifically the saveFile, mozillaSaveFile, and ieSaveFile functions. Just click the download link, open the html file it sends you, and search for those functions.
Of course, tiddlywiki is supposed to be used as a local file, not served over the web, so the methods it uses may only work locally.. But it might be a start.
Why not use a flash uploader? http://swfupload.org/
Adobe Flex 4 lets you to open and process a file on a local machine:
http://livedocs.adobe.com/flex/3/langref/flash/net/FileReference.html#load()
It's not exactly JavaScript, but hope that helps.
I believe you can accomplish this using the HTML5 File API.
It is supported in Opera, IE, Safari, Firefox, and Chrome.
you can use fs module from nodeJS to manipulate with filesystem nowadays!