Include local JavaScript within PhoneGap on Windows Phone 7 - Windows Phone 7 Software Development

I have a PhoneGap application designed to work on multiple mobile platforms. I'm loading a dynamic HTML content from an external page on the Internet using jQuery Mobile. The problematic system is Windows Phone 7.
This is what I get from the external page, with the URL of the script tag already replaced to load from the phone instead of from the net to save bandwidth:
HTML:
<script type="text/javascript" charset="utf-8" src="x-wmapp1:/app/www/test.js"></script>
This works fine on Android, iPhone and even BlackBerry when I replaced the x-wmapp1: part by a respective counterpart (e.g. file:///android_asset/www/ on Android). However, on Windows Phone 7 it doesn't seem to work at all.
When I try to load the same URL via $.getScript function, it always returns a 404 eror, even if I try and load it with a relative path only.
Any suggestions?

Please don't post the same issue in multiple threads
Sent from my HD7 using Board Express

Sorry, I was instructed to post elsewhere, since my original post was not in the most appropriate forum - and thanks to that I have multiple responses. So I wouldn't see it as a problem is people from different areas of expertise can shed different kind of light on this issue, wouldn't you agree?

Seems is was an issue with old release of PhoneGap 1.8.1 - with 2.0 it works ok. Thanks for all your efforts

Related

Anyone able to get JavaFX on their Dash?

Hi People,
If you go here: Google "javafx for windows mobile download" you can DL the JavaFX update from SUN, which I did. It installed fine. (Sorry, my account is apparently too new to post the link).
It also comes with a few demo apps to try. But when I try to run it, I get an error:
"Calculated only a partial product UUID!This can cause problems with the correct device identification."
I called T-mobile and explained this, and that I had just updated the Dash to the latest T=Mobile/Windows CE OS version 5.2.1236, build 17741.0.2.1.
Of course they said they can't support any 2rd party apps. They also questioned whether the Dash was "too old" to run JavaFX. I have a hard time believing that last part. It runs plain old Java just fine.
I am hoping someone could try the DL I mention above and post the results, with the goal of getting JavaFX working on my/other peoples Dash.
As a footnote,I found this error posted a few other places with no answer.
likesjava said:
Hi People,
If you go here: Google "javafx for windows mobile download" you can DL the JavaFX update from SUN, which I did. It installed fine. (Sorry, my account is apparently too new to post the link).
It also comes with a few demo apps to try. But when I try to run it, I get an error:
"Calculated only a partial product UUID!This can cause problems with the correct device identification."
I called T-mobile and explained this, and that I had just updated the Dash to the latest T=Mobile/Windows CE OS version 5.2.1236, build 17741.0.2.1.
Of course they said they can't support any 2rd party apps. They also questioned whether the Dash was "too old" to run JavaFX. I have a hard time believing that last part. It runs plain old Java just fine.
I am hoping someone could try the DL I mention above and post the results, with the goal of getting JavaFX working on my/other peoples Dash.
As a footnote,I found this error posted a few other places with no answer.
Click to expand...
Click to collapse
i just downloaded it and it does work. my thoughts are that you probably need to upgrade your rom. your version 5.2.1236 is a bit dated and my guess is that's why it's not working for you. currently im running 3vo 6.5 and it's working just fine, overclocked to 274. try updating your OS/rom first, it should work after that.
btw there are plenty of forums around here that give good tutorials on updating your OS/rom if you've never done it before. study and up and take the plunge!
likesjava said:
I called T-mobile and explained this, and that I had just updated the Dash to the latest T=Mobile/Windows CE OS version 5.2.1236, build 17741.0.2.1.
Of course they said they can't support any 2rd party apps. They also questioned whether the Dash was "too old" to run JavaFX. I have a hard time believing that last part. It runs plain old Java just fine.
Click to expand...
Click to collapse
one more thing, tmobile isn't very tech savvy when it comes to this sort of thing. they have much info at their fingertips but they have to search to find it and most of them aren't that good at it. they are trained on newer phones but not the older ones. trust me i'd know, i used to work at a tech center. they have a decent database with logs on problems customers have had in the past and solutions, but the rep on the phone isn't always able to find the info. i was one of the better ones but they didnt want to move me to permanent tech even though that's what i was good at, and instead shuffled me to cust service to argue with people about their bills... so i quit
anyway, it's best to come here first and ask rather than ask them. we'll probably save you some time
Thank you Young!
I took the plunge and downloaded and flashed EXCA-3VOLUTION_WM65_3VO.3.00.112509. Along the way I applied the app unlock as instructed. I wonder - would the app unlock alone have been enough?
Well, in any case JavaFX is up and running! Yay! - thanks to you
I had no idea that there were people writing all sorts of new OS etc for these phones - I'm just a phone user.
Now - silly question but - none of these new ROMS allow free wifi or Internet access do they?
hey, what is JavaFx ??? Does it like JBed Java ?
It runs on any device that can run Java. Think of it as a prettier, fancier, high tech looking java. Its actually pretty fun to program as well. And its free (the development environment).
Here are some Google results for your question:
JavaFX is a software platform for creating and delivering rich Internet applications that can run across a wide variety of connected devices. ..
What is JavaFX?
JavaFX is a rich client platform for building cross-device applications and content. Designed to enable easy creation and deployment of rich internet applications (RIAs) with immersive media and content, the JavaFX platform ensures that RIAs look and behave consistently across diverse form factors and devices.
The JavaFX platform release includes the following components:
* JavaFX SDK which includes the JavaFX compiler and runtime tools, graphics, media, web services, and rich text libraries to create RIAs for the desktop, browser and mobile platforms.
* NetBeans IDE for JavaFX which provides a sophisticated integrated development environment for building, previewing, and debugging JavaFX applications. The editor features a drag-and-drop palette to quickly add JavaFX objects with transformations, effects and animation. This IDE also comes with its own set of Building Block samples and the JavaFX Mobile Emulator, a mobile phone simulator.
* JavaFX Production Suite is a suite of tools and plugins that enable designers to export graphical assets to JavaFX applications.
likesjava said:
Thank you Young!
I took the plunge and downloaded and flashed EXCA-3VOLUTION_WM65_3VO.3.00.112509. Along the way I applied the app unlock as instructed. I wonder - would the app unlock alone have been enough?
Well, in any case JavaFX is up and running! Yay! - thanks to you
I had no idea that there were people writing all sorts of new OS etc for these phones - I'm just a phone user.
Now - silly question but - none of these new ROMS allow free wifi or Internet access do they?
Click to expand...
Click to collapse
np, glad to be of help. it woulda been nice if my email program let me know i had a reply earlier though
anyway, about the free wifi and internet... no programs can do that, that i know of. there are ways to hack into other peeps networks for free bandwidth from pc's (as i've seen it done), but if you want free internet on the phone there's only a few simple options...
1. pay for it, either through a phone carrier ex: tmobile, at&t, etc. or get a router for your home network and at least then you can connect to your home wifi.
2. find a starbucks, local coffee house, hospital, or any place that is pumpin out free wifi and hop on the network.
anyway, even if there were those types of 'programs' you couldn't post about it here cuz it would get taken off immediately and the person posted would probably get banned. they're not too friendly about that stuff

Pocket Internet Explorer Redirect Limit?

Hello Everyone,
We have implemented in-application advertising in one of our company's latest applications and seem to have run across an "issue" in Pocket Internet Explorer. I wanted to see if anyone else has come across this and can help me confirm that I have correctly identified the issue.
The way that the advertising implementation works is that when a user clicks on an advertisment, the default web browser is launched as a new process and navigated to a URL. Often, that URL when then follow a chain of 1 or more redirections to eventually land on the actual advertisment page.
If Opera is the default browser, there never is any issue. With Opera, the browser follows the redirections and eventually lands on the target page.
With Internet Explorer however, some advertisments work and others do not. By not work, I mean the browser loads for a short while and then eventually displays a 404 File Not Found error. The address bar still displays the original URL. I believe that this occurs when a certain number of redirections are requested or perhaps it is a certain type of redirection. This was been tested on various models of Windows Mobile 6, 6.1, 6.5, and even 6.5.3 - all professional touch-screen models as this is what our application targets. It can be clearly seen in our application's advertisment statistics as well.
If anyone has any insight on this behavior it would be greatly appreciated.
Thank you,
Brian P. Hamachek
President & CEO
SynergeTech Solutions, Inc

[Q] Samsung Focus File Explorer

I've looked around on this forum and others, but I haven't found a tool yet which allows for file browsing and upload/download from a Samsung WP7 device. Most of the tools available seem to be for HTC phones.
The "Advanced Explorer for WP7" allows browsing, but the desktop client to copy files off doesn't seem to work - whenever I try, I get an unhandled exception. Looking at the source code for the app, it seems that only limited file access is enabled for non-HTC devices.
Does anyone know any tools or a way to get files off the device onto a computer?
Thanks!
not yet as of now, but here http://forum.xda-developers.com/showthread.php?t=1021135 claims that he will release one soon
I saw that one - the reg editor works better than any others I've tried, so I have high hopes for the file browser part.
Since I saw people posting on how they got the Diagnosis app off and REed it, I assumed there was tool already available >_<
sorcy said:
I saw that one - the reg editor works better than any others I've tried, so I have high hopes for the file browser part.
Since I saw people posting on how they got the Diagnosis app off and REed it, I assumed there was tool already available >_<
Click to expand...
Click to collapse
My webserver is limited (e.g. it doesn't go through device drivers to enable more access), but this is how one may easily pull files off the device for the sake of RE (or whatever).
http://forum.xda-developers.com/showthread.php?t=877782
The webserver allowed me to get the Diag app off, thanks!
This is going a bit OT, but some folders in Windows did come up with error accessing contents, any idea why? Also, I noticed some of the files had size zero when downloaded.

Include local JavaScript within PhoneGap on Windows Phone 7

I have a PhoneGap application designed to work on multiple mobile platforms. I'm loading a dynamic HTML content from an external page on the Internet using jQuery Mobile. The problematic system is Windows Phone 7.
This is what I get from the external page, with the URL of the script tag already replaced to load from the phone instead of from the net to save bandwidth:
HTML:
<script type="text/javascript" charset="utf-8" src="x-wmapp1:/app/www/test.js"></script>
This works fine on Android, iPhone and even BlackBerry when I replaced the x-wmapp1: part by a respective counterpart (e.g. file:///android_asset/www/ on Android). However, on Windows Phone 7 it doesn't seem to work at all.
When I try to load the same URL via $.getScript function, it always returns a 404 eror, even if I try and load it with a relative path only.
Any suggestions?
First of all, this type of question may be better suited to the Software Development or Apps and Games sub-forums, as a lot of the people who hang out here are more familiar with homebrew hacks. I'll give it a shot, though.
First of all, what kind of path are you trying to use? I haven't tried loading scripts or images in HTML or JS, but to dynamically load content within the app itself typically requires some care with regard to the path. For example, is the JS file being built into the assembly (as a resource) or included alongside it (as content)? How about the HTML page?
This is a kind of lame approach, but one option that's sure to work is just inlining the scripts in the page, directly. That won't increase the total app size or load time at all, although it might make maintaining the app take a little bit more effort.
Thanks for the reply, I will try to post this into the more appropriate forum.
With regards to paths - you can see the path in the HTML snippet I provided in the original question. It's all a bit specific and we cannot afford to load JS directly from page, since that does increase the size of the resulting HTML, sent from an external PHP page, thus increasing bandwidth. This is the first reason why we chose to have all JS and CSS files directly bundled with the application and load them internally rather than from Internet.
Also, all of JS files are included alongside the application as content. I'm using the same approach for all images, since if they were included as a resource, they would not show in the application.
GoodDayToDie said:
First of all, this type of question may be better suited to the Software Development or Apps and Games sub-forums, as a lot of the people who hang out here are more familiar with homebrew hacks. I'll give it a shot, though.
First of all, what kind of path are you trying to use? I haven't tried loading scripts or images in HTML or JS, but to dynamically load content within the app itself typically requires some care with regard to the path. For example, is the JS file being built into the assembly (as a resource) or included alongside it (as content)? How about the HTML page?
This is a kind of lame approach, but one option that's sure to work is just inlining the scripts in the page, directly. That won't increase the total app size or load time at all, although it might make maintaining the app take a little bit more effort.
Click to expand...
Click to collapse
First question: have you set the IsScriptEnabled proerty on the control to True? It defaults to False, preventing scripting within the control. Also, changing it only takes effect
on navigation, so if you already loaded the page and then set this property, it still won't work.
Anyhow, I missed that your HTML was coming externally, and only the scripts and stylesheets were local. That's... interesting, and seems reasonable enough, and I can't find any info online that exactly matches your use case. The way you're structuring the script src URI looks weird to me, but I haven't messed with the WebBrowserControl very much at all.
One solution, though a bit hacky:
Use the WebBrowserControl's InvokeScript function to dynamically load scripts into your pages. To do this, you would first need to load the script file content into a .NET String object. The GetResourceStream function is probably your best friend here, combined with ReadToEnd(). Then, just invoke the eval() JS function, which should be built-in, and pass it the JS file content. That will load the JS into the web page, creating objects (including functions) and executing instructions as the files are eval()ed.
Of course, you'd need to do this on every page navigation, but you can actually automate it such that the page itself requests that the app load those scripts. In your app, bind the script-loading function to the ScriptNotify event handler, probably with some parameter such as the name of the script to load. Then, on each page served from your server to the app, instead of including standard <script src=...> tags, use <script>window.external.notify('load localscript1.js')</script> and so on; this will trigger the app's ScriptNotify function for you.
I hope that helps. I can see your use case, but somewhat surprisingly, I couldn't find anybody else online who had either run into your problem or written a tutorial on doing it your way.
Thank you for your reply, it was very informative. One question though - why do you think the way I'm structuring the SCRIPT URI is wierd? I tried to mess around with relative URIs and the such, however those would load the JavaScript file from Internet rather than from the application itself.
The problem I'm running into with your proposed solutions, however is that:
1. the project is a PhoneGap/Cordova application, using its own components, so I have no idea where I would look for IsScriptEnabled here (although this all worked on an older PhoneGap release, so I'm guessing they have it set up correctly)
2. injecting a script programmatically on each navigation would require me to rewrite much of the code we already use for other platforms, not to mention those custom Cordova components, which I don't even know if they can handle such thing
As for my user case - I was surprised to be the only guy on the internet with this methodology in place as well. So it either works for everyone else or nobody really thought of doing it my way, since it's basically an Internet application (maybe the don't want to disclose their sources, who knows).
CyberGhost636 said:
1. the project is a PhoneGap/Cordova application, using its own components, so I have no idea where I would look for IsScriptEnabled here (although this all worked on an older PhoneGap release, so I'm guessing they have it set up correctly)
Click to expand...
Click to collapse
In the WebBrowser properties.
CyberGhost636 said:
As for my user case - I was surprised to be the only guy on the internet with this methodology in place as well.
Click to expand...
Click to collapse
Of course you not "the only guy". I've tried to port/run a few HTML java-script based games on WP7 (Digger and couple more) more then year ago; they runs well with one HUGE exception - touch screen events are freezing scripts execution and make games not playable.
The "x-wmapp1:" URI scheme was what I was referring to. Not sure where that comes from, but I haven't done anything really with the WebBrowser control.
I have no knowledge of PhoneGap or Cordova; I assume they're "we write your app for you" frameworks? One would assume that such tools would know to set IsScriptEnabled, but you may have to do so manually. A bit of web searching on that direction may be fruitful - maybe earlier versions enabled scripting by default, and now it's disabled by default so you have to specify an option somewhere?
Injecting the script on navigation really doesn't require any major change to the server-side code. I mean, is sending
<script>window.external.notify('load localscript1.js')</script>
really much different from sending
<script type="text/javascript" charset="utf-8" src="x-wmapp1:/app/www/test.js"></script>
? If that's too different, you could instead send
<script src="http://yourserver.com/LoadLocalScripts.js"></script>
and put "LoadLocalScripts.js" on your server with the following code:
window.external.notify('load localscript1.js');
This has only a trivial increase in server traffic and load time, but lets you continue using external scripts instead of inline ones. Very little server-side change needed at all.
Now, the additional client-side code to support the window.external.notify and call InvokeScript... normally I'd say that's dead easy, because it is if you have any experience with the .NET framework, but in your case I get the feeling that this isn't so? I code to the framework, or to the underlying native code, and I tend to code "raw" (very little auto-generated code), so I'm not going to be able to help you solve the problems with a "make me an app" wizard unless I can see the code it generates for you.
For what it's worth, here's the approximate raw code that I'd use (it's over-simplified, but close enough):
void HandleNotify (String param) {
String[] parts = param.split(" ");
if (parts[0] == "load") LoadScript(parts[1]);
}
void LoadScript (String script) {
String content = Application.GetResourceStream(new Uri(script, UriType.Absolute)).ReadToEnd();
theBrowserControl.InvokeScript("eval", content);
}
void theBrowserControl_Loaded (...event handler args here...) {
theBrowserControl.IsScriptEnabled = true;
theBrowserControl.ScriptNotify += HandleNotify;
theBrowserControl.Navigate("http://yoursite.com");
}
the URI comes from Windows Phone itself, with this code, you can see for yourself:
var a = document.createElement('a');
a.setAttribute('href', '.');
alert(a.href);
also, I've been informed that this works in Cordova 2.0, so it might be a 1.8.1 bug... will try and see how it goes
thanks for your help so far!
Looks like it was a problem with PhoneGap 1.8.1 - after upgading to Cordova 2.0 (PhoneGap got renamed) it all works now... thanks for all the help!

[Q] cant view my dvr cameras on windows rt

Hi all
I have purchased a windows Rt and love it. The only thing I can't figure out is I can't access my dvr cameras though internet explorer on my device through my ip address and port number. I can view it on my desktop pc.
Is there any app or way I can view my dvr host on windows rt??
steve.zdravko said:
Hi all
I have purchased a windows Rt and love it. The only thing I can't figure out is I can't access my dvr cameras though internet explorer on my device through my ip address and port number. I can view it on my desktop pc.
Is there any app or way I can view my dvr host on windows rt??
Click to expand...
Click to collapse
BUMP
How is the DVR content presented? If it's HTML(5), that should be no problem at all, so it's probably not. The next most likely is Flash, which RT supports but which may not work when specifying an IP address. You could try using the registry tweak that was previously required for Flash on unknown sites (see the EnableFlash script in my signature). If it's a Java applet, you're screwed (in more ways than one; if you've had the Java browser plugin enabled on your home PC for the last few months, there's an excellent chance that your machine has been infected through it; that thing has atrocious security bugs). If it's some other third-party plugin, for example an ActiveX control from the DVR manufacturer, it's probably not going to work on RT just because RT run on ARM chips and typical ActiveX controls are compiled for x86 (it's possible to make ARM ActiveX, but nobody does and you'd need to "jailbreak" the device before installing the plugin anyhow).
GoodDayToDie said:
How is the DVR content presented? If it's HTML(5), that should be no problem at all, so it's probably not. The next most likely is Flash, which RT supports but which may not work when specifying an IP address. You could try using the registry tweak that was previously required for Flash on unknown sites (see the EnableFlash script in my signature). If it's a Java applet, you're screwed (in more ways than one; if you've had the Java browser plugin enabled on your home PC for the last few months, there's an excellent chance that your machine has been infected through it; that thing has atrocious security bugs). If it's some other third-party plugin, for example an ActiveX control from the DVR manufacturer, it's probably not going to work on RT just because RT run on ARM chips and typical ActiveX controls are compiled for x86 (it's possible to make ARM ActiveX, but nobody does and you'd need to "jailbreak" the device before installing the plugin anyhow).
Click to expand...
Click to collapse
The DVR is set up with its own ip and port forwarding number, and that how I connect to it from other desktop PC's. Or it gives me an option to view it through a program called CMS lite which the Win RT doesn't allow me the download. I have jailbroken my RT as well.
What happens when you connect to that IP and port on your RT device? What do you see in the browser (if anything)? Does it connect, or does it say it couldn't find the site? You haven't actually explained the problem very well at all, even to the point of saying what device it is. We probably don't have your exact setup at home, so you'll need to be very precise describing it so that we know how to fix it.
You also didn't answer my question in the previous post. How is the content normally presented? Flash or HTML5 should be fine, but *might* take some tweaking. Java or a plugin are unlikely to work, although I suppose it's possible that the x86 emulator could be made to work with a plugin.
For that matter, have you tried the x86 emulator with your CMS Lite program? It's unlikely to work, but worth a shot.
GoodDayToDie said:
What happens when you connect to that IP and port on your RT device? What do you see in the browser (if anything)? Does it connect, or does it say it couldn't find the site? You haven't actually explained the problem very well at all, even to the point of saying what device it is. We probably don't have your exact setup at home, so you'll need to be very precise describing it so that we know how to fix it.
You also didn't answer my question in the previous post. How is the content normally presented? Flash or HTML5 should be fine, but *might* take some tweaking. Java or a plugin are unlikely to work, although I suppose it's possible that the x86 emulator could be made to work with a plugin.
For that matter, have you tried the x86 emulator with your CMS Lite program? It's unlikely to work, but worth a shot.
Click to expand...
Click to collapse
my device is a windows rt surface. when I open internet explorer and type in my ip and port number in the search engine it comes up with my login and password which I type in. after that the screen comes to a blank white screen which gives me the option. Webserver or CMS lite setup I always view them from webserver. Once I click webserver the screen just says on a blank white screen.
as for how the content present normally im not really sure.
A simple way to tell is to load the page in a desktop browser where it works, then right-click the video and see what menu comes up. If it's the Flashplayer menu, that's something that RT can handle. If it's something else (Silverlight or Java or a custom ActiveX), that may not be possible. Another way to tell would be to save that blank page to a file (I believe Ctrl+S works for this, at least on the desktop mode of IE, or you can do it from the Tools->File menu, or the File menu on the menu bar that is shown when you tap Alt). Send or post the HTML somewhere that we can read it, and we can tell you what it will take to view the page.
another question.. im still new to the windows rt group I have jail broken the RT surface. Is there any torrent client for downloads.
I wanna download movies from a website. thanks
Free Download Manager (it is in the ported apps thread) can be used as a torrent client. However discussion of piracy is prohibited so might want to zip it on the movies part.
Monotorrent was attempted on RT but I think ended up being buggy.
SixSixSevenSeven said:
Free Download Manager (it is in the ported apps thread) can be used as a torrent client. However discussion of piracy is prohibited so might want to zip it on the movies part.
Monotorrent was attempted on RT but I think ended up being buggy.
Click to expand...
Click to collapse
can u please send me the link
Read the forum rules, especially the first one. Then, read my signature. I don't mind helping people find obscure stuff, but this does not qualify. Please put forth at least a little effort on your own part...
I shouldn't have to share a link having told you where it is. Its easy to find, a) its in the list of ported applications in the RT development and hacking section. b) it has its own thread in that same section. c) it is listed on google. d) it is listed on forum search.

Categories

Resources