NativeProcess in AIR using JavaScript - air

I am running the following from inside of Aptana:
<html>
<head>
<title>New Adobe AIR Project</title>
<script type="text/javascript" src="lib/air/AIRAliases.js"></script>
<script>
function init() {
if(air.NativeProcess.isSupported) {
alert("NativeProcess is supported.");
} else {
alert("NativeProcess not supported.");
}
};
</script>
</head>
<body onload="init()">
</body>
</html>
And it says that NativeProcess not supported.
Do I need to compile this in order for it to work?
I thought I would be able to test it from inside of Aptana.

i've never used Aptana, although i assume the solution will be the same, but in Flash CS5 you can test native processes with ADL by selecting only the Extended Desktop profile in the AIR settings.
native process only work for desktop applications packaged as native installers.
Update
you need to have this somewhere in your code or descriptor file
<supportedProfiles>extendedDesktop</supportedProfiles>
read this for more info about device profiles for AIR: Device Profiles

Related

Forced to browser-sniff Safari version

Can someone tell me the "best" way to detect Safari and then its version number?
Look, I don't want to do it but I can't find a way to pin down a WORKING version of speechSynthesis on Safari
See below for an example that works on iOS 7.1.2 IF you don't add the onEnd listener. Apart from that everything is peachy.
In my real world full blown example it talks but still won't deliver the at end event.
On iOS 8 there is no issue.
Please offer a best-of-breed agent/version sniffer or a better working-feature-detector.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function fini()
{
alert("end");
}
function talk()
{
if (!('speechSynthesis' in window)) {
alert("Unsupported browser");
return;
}
alert("Getting ready.");
var utterance = "Hello World";
var chat = new SpeechSynthesisUtterance(utterance);
chat.addEventListener('end', fini, false);
speechSynthesis.speak(chat);
}
</script>
</head>
<body>
<p>On Safari this example won't fire any known events<br />
onend, onerror, even onended: -</p>
<input type="button" value="Talk" onclick="talk()" />
<br /><br />
No probs on Chrome or Opera. Spewin!
</body>
</html>
For the record, the addEventListener was throwing an exception on 7.2.1 that could be trapped to signify unsupported speech synthesis.
Opera mobile has laryngitis
Different problem same topic: -
You (and I) may question the correctness of this behaviour in Opera but it appears to be as simple as there are no known/registered/available voices for Opera Mobile on my Android phone :-(
"Sing for me Christine! Sing my angel, SING!" Sorry couldn't help it.
So are there any files I have to download?
FYI on Safari, apparently, the speechSynthesis.getVoices method is synchronous which makes life easy. Elsewhere it is asynchronous and will return an array of length 0 on first call.
We need to register an event such as: -
speechSynthesis.onvoiceschanged = function() {
voices = window.speechSynthesis.getVoices();
alert("Voices " + voices.length);
if (!done) theWork();
};
This never fires on Opera Mobile. Curious!
Why don't I get a error from the synthesis specification like "language-unavailable" or "voice-unavailable"?
Because I didn't explicitly specify a language and a voice?
And why does Chrome deliver onvoiceschanged 3 times?

epub.js not loading properly on IE11

I'm trying to load an epub on my page using epub.js library and its not working on IE 11, it works perfrectly on chrome and Firefox though.
I'm not getting a script error, I don't get a message in the console log, fiddler says all scripts (including zip.js and my epub) are downloaded properly.
It just doesn't load, the iframe embedded has a src="" property and an empty html body. as in the following snapshot.
Here is my html page content:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="content/epubjs/epub.js"></script>
<script src="content/epubjs/libs/zip.min.js"></script>
</head>
<body>
<span onclick="Book.prevPage();">Prev</span>
<span onclick="Book.nextPage();">Next</span>
<div style="height: 700px; border: 5px solid red" id="area"></div>
<script type="text/javascript">
EPUBJS.filePath = "content/epubjs/libs/";
</script>
<script type="text/javascript">
var Book = ePub("content/aliceDynamic.epub", {
version: 4,
restore: false, // Skips parsing epub contents, loading from localstorage instead
storage: false, // true (auto) or false (none) | override: 'ram', 'websqldatabase', 'indexeddb', 'filesystem'
spreads: false, // Displays two columns
fixedLayout: true, //-- Will turn off pagination
styles: {}, // Styles to be applied to epub
width: false,
height: '700px'
});
Book.renderTo("area");
</script>
</body>
</html>
I tried to play around with the options parameter, set things to false and true here and there but it didn't help.
It looks like it is a problem with the current version of epub.js and internet explorer 11. If you try and load the moby dick page you should see the same problem.
Try setting a break on all exceptions (even handled ones) in the javascript engine of IE, and you will see that the javascript throws an exception saying that "'XPathResult' is undefined".
Common recommendations to correct that seem to be installing the wicked-good-xpath library in order to sidestep ie11 lack of XPath support. Install the library and initialize it before trying to load you epub.
If this doesn't correct your problem, you may have to wait until the issues are solved since you don't seem to be the only person who encounters it.

IBM Worklight - How to bypass WP's " Unable to add dynamic content" warning?

I have tried to run a Windows Phone 8 App written in Sencha Touch in Worklight. I used sencha in the following way:
<script src="//Microsoft.WinJS.1.0/js/base.js"></script><script src="//Microsoft.WinJS.1.0/js/ui.js"></script><script>
// Define WL namespace.
var WL = WL ? WL : {};
/**
* WLClient configuration variables.
* Values are injected by the deployer that packs the gadget.
*/
WL.StaticAppProps = {
"APP_DISPLAY_NAME": "Cockpit",
"APP_ID": "Cockpit",
"APP_SERVICES_URL": "http:\/\/192.168.99.11:10080\/CockpitProj\/apps\/services\/",
"APP_VERSION": "1.2.1",
"ENVIRONMENT": "windows8",
"LOGIN_DISPLAY_TYPE": "embedded",
"WORKLIGHT_PLATFORM_VERSION": "6.1.0.00.20131219-1900",
"WORKLIGHT_ROOT_URL": "http:\/\/192.168.99.11:10080\/CockpitProj\/apps\/services\/api\/Cockpit\/windows8\/"
};</script>
<script src="worklight/cordova.js"></script>
<script src="worklight/wljq.js"></script>
<script src="worklight/worklight.js"></script>
</head>
<body>
<div class="loadingSpinner bigLoad" id="appLoadingIndicator"></div>
<script src="js/initOptions.js" type="text/javascript"></script>
<script src="js/sencha-touch-all.js" type="text/javascript"></script>
<script src="js/app.js" type="text/javascript"></script>
<script src="js/messages.js" type="text/javascript"></script>
</body>
</html>
If I run this code, I get an exception:
Unable to add dynamic content. A script attempted to inject dynamic
content, or elements previously modified dynamically, that might be
unsafe. For example, using the innerHTML property to add script or
malformed HTML will generate this exception. Use the toStaticHTML
method to filter dynamic content, or explicitly create elements and
attributes with a method such as createElement. For more information,
see http://go.microsoft.com/fwlink/?LinkID=247104.
This can be solved by every sencha call inside the sencha-touch-all into a
MSApp.execUnsafeLocalFunction(function () {}
This can only be a workaround, as there are too many of these sencha calls.
What is the general concept of using Sencha for Windows Phone, like
these steps from Phonegap:
IMO there is no good way around it in Windows Phone development. Doesn't matter if it is a pure Cordova app, or a Worklight-based app.
See the second option in the following discussion. Perhaps you could set it in a way that it will work for all code parts required by your app:
http://social.msdn.microsoft.com/Forums/windowsapps/en-US/e35017b4-e21b-4807-8668-fc3c332c6b32/javascript-runtime-error
Copy-paste:
The host enforcement code will throw an access denied exception in the
event that you try to set the innerHTML (and outerHTML and a couple of
others) of an element to HTML which doesn't conform to a whitelist of
known safe HTML. You can get around this in a couple of ways:
call toStaticHTML() on your string first which should strip out everything which is disallowed
use WinJS.Utilities.setInnerHTMLUnsafe(element, text), this allows you to set innerHTML to anything you like
use msWWA.execUnsafeLocalFunction, for instance:
msWWA.execUnsafeLocalFunction(function () { element.innerHTML = text; })
Option 2 is implemented in terms of 3. Be aware that if you set
innerHTML of an element to html that you don't control (e.g. something
you downloaded off the web like an RSS feed) it may contain script
which will be able to access the WinRT and do bad things which is why
the names of the functions in 2) and 3) are purposefully a little
scary.

jquery-ui progressbar not showing

I'm trying to add a simple progress bar to my application in rails using jquery-ui. I'm following this example: http://jqueryui.com/progressbar/
I create the div
<div id="progressbar"></div>
and in my JS I have
$(document).ready( function() {
$("#progressbar").progressbar({
value: 37
});
});
But nothing happens to the div in the html - it remains empty and unstyled(ie no additional CSS is applied to it).
I have checked that I have jquery-ui included in my application - in particular, I have made certain the jquery-ui css file is included.
However, I am willing to bet the problem has something to do with jquery-ui not working properly in my app, because I was having another issue with it and the tooltip function, which I asked about over here: positioning jQuery tooltip
This is driving me nuts, does anyone have any ideas?
I had the same problem right now.
It seems like the referenced libaries in the example do not work.
The error i get from the "Firefox - Developer Tools - Browser Console" is:
ReferenceError: $ is not defined
(I tested on Firefox 32.0.3 and IE 11)
If you just copy the example html/jquery source from "http://jqueryui.com/progressbar/" to a local file (lets call it: "testJqueryProgressBar.html") and double click it, you will see no progress bar!
Source of "testJqueryProgressBar.html":
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery UI Progressbar - Default functionality</title>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>
<link rel="stylesheet" href="//jqueryui.com/resources/demos/style.css">
<script>
$(function()
{
$( "#progressbar" ).progressbar({ value: 37 });
});
</script>
</head>
<body>
<div id="progressbar"></div>
</body>
</html>
Therefore i checked the links in the header of the example and all reference something.
So the links are valid!
I even tried to reference the jquery libs from another provider, f.e. : https://developers.google.com/speed/libraries/devguide?hl=de#jquery-ui.
Same problem!
Then i went to http://jqueryui.com/download/
Selected Version : 1.11.1 (Stable, for jQuery1.6+)
Selected a different UI theme at the bottom
Downloaded the zip and referenced these unziped jquery sources in my local example testJqueryProgressBar.html and it worked.

Using external plugins in Sencha Touch

I want to use a simple Sencha Touch keypad plugin.
The plugin code can be found over here.
The keypad can be created in an html file under tags as follows:
<script>
Ext.setup({
onReady: function () {
var basic = new Ext.ux.Keypad();
basic.render('keypad');
}
});
</script>
<div id="keypad"/>
Alternatively, it can be used in a Sencha container as follows too:
...
items:[
{
xtype: 'keypad'
}
]
However, I am not able to get it to work the latter way. I'm new to Sencha and I think I'm not placing the files at the right places or not including them properly. I have already included the following in my index.html:
<script type="text/javascript" charset="utf-8" src="js/sencha-touch-1.1.1/sencha-touch.js"></script>
<link rel="stylesheet" type="text/css" href="js/sencha-touch-1.1.1/resources/css/sencha-touch.css">
<script src="js/Keypad.js" type="text/javascript" charset="utf-8"></script>
Can someone let me know what modifications are necessary in which files so that I can use the keypad plugin directly in a container?
in your app.js file you need to set path for the plugin folder in the loader...
put the ux (plugin)folder where your app.js is located...
in app.js set the following
Ext.Loader.setPath('Ext.ux', 'ux');
On the view where you are using the numpad you need to specify a
requires: ['Ext.ux.NumPad' ...] //All plugin related files
Also ensure that the CSS files are in the proper location...
Hope it helps...