"SpeechSynthesisUtterance is not defined" in Chrome and Firefox - dart

The following Dart code does not work on Chrome or Firefox.
import 'dart:html';
void main() {
SpeechSynthesisUtterance speechSynthesisUtterance = new SpeechSynthesisUtterance();
speechSynthesisUtterance.lang = 'en-US';
speechSynthesisUtterance.rate = 1;
DivElement div = querySelector("#text");
querySelector('#read').onClick.listen((e) {
speechSynthesisUtterance.text = div.text;
window.speechSynthesis.speak(speechSynthesisUtterance);
});
}
The browser's console displays this error:
Uncaught ReferenceError: SpeechSynthesisUtterance is not defined
This was tested on:
Chromium Version (31.0.1650.63) & Firefox (26.0) on Ubuntu 13.10 x64
Any idea what is going wrong?

This is not a Dart-specific problem. If you try the equivalent JavaScript it will also not work in those browsers since this API does not seem to be fully supported yet. It does work in Dartium though.

Related

Mozilla Add-on SDK - OS.File.read (The system cannot find the file specified.)

I created an add-on following Mozilla's tutorials. cfx test and cfx run worked perfectly. I put the folder on my desktop and installed the add-on into Firefox using cfx xpi and Ctrl+o (the xpi file).
Now the add-on gives this error in the console log:
Win error 2 during operation open on file purls.txt (The system cannot
find the file specified.)
Here is the relevant code in main.js:
const {TextEncoder, TextDecoder, OS} = Cu.import("resource://gre/modules/osfile.jsm", {});
let decoder = new TextDecoder();
let promise = OS.File.read("purls.txt").then(
function onSuccess(array) {
// Do stuff
},
function onReject(reason) {
console.error("Couldn't read from purls.txt:\n"+reason);
}
);
Please help me figure out what is going on. When I use cfx run the add-on finds the purls.txt file and opens it/reads from it without problem.
You didn't give it a path to purls.txt, so it was probably looking for purls.txt on your drive. Is it on the desktop? Then create a path to the desktop. See pathToPurls;
const {TextEncoder, TextDecoder, OS} = Cu.import("resource://gre/modules/osfile.jsm", {});
let decoder = new TextDecoder();
let pathToPurls = OS.Path.join(OS.Constants.Path.desktopDir, "purls.txt");
console.log('pathToPurls:', pathToPurls);
let promise = OS.File.read(pathToPurls).then(
function onSuccess(array) {
// Do stuff
},
function onReject(reason) {
console.error("Couldn't read from purls.txt:\n"+reason);
}
);

How to get dart2js javascript that uses canvas.context2D to work on firefox or safari?

I have program that seems to compile with dart2js enough for UI such as checkbox working, and even can do
CanvasRenderingContext2D context=canvas.context2D;
context
..setFillColorRgb(200,200,250,1)
..beginPath()
..fillRect(0,0,width, height)
..closePath();
on firefox, ( not Safari).
But it won't do
context
..setStrokeColorRgb(255,0,255)
..lineWidth=10
..beginPath()
..arc(w/2,h/2, r, 0, math.PI*2, false)
..closePath()
..stroke()
It works on Chrome, and chromium ( native dart).
How to fix ?
I used context.resetTranform() , after removing this statement, it worked on
Safari chrome and firefox.

Prototype 1.7.1 observe in IE8 (and ruby on rails)

Here ruby code:
template.javascript_include_once "phonejs"
...
template.javascript_tag "document.on('dom:loaded', function() { $('#{options[:id]}').observe('click', respondToClick, false); });"
respondToClick in "phonejs" file, but in IE8 'respondToClick' - missing operand
It's work fine in any other brousers (firefox, opera, chrome).
I think IE can't find function, but I can't resolve this problem.
Help please :)
And sorry for my english.
change respondToClick on function(){ respondToClick();}

Geolocation with Dart in Firefox getCurrentPosition not a function

I have written this code in Dart
window.navigator.geolocation.getCurrentPosition((Geoposition position) {
window.alert(position.coords.latitude.toString());
});
When I run it in Dantium or Google Chrome it works fine, but if I try running this in Firefox, I get this JavaScript error
Timestamp: 15/11/12 21:36:19
Error: TypeError: getCurrentPosition$1 is not a function
This is wierd as if I just wrote this using html5 JavaScript
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
}
function showPosition(position) {
var latlon=position.coords.latitude+","+position.coords.longitude;
alert(latlon);
}
It works perfectly fine in Firefox.
The Firefox version is 16.0.2, Dart Editor version is 0.2.3_r14669 and Dart SDK version is 0.2.3.0_r14669.
Is this a bug or am I doing something wrong?
EDIT:
It was a bug http://code.google.com/p/dart/issues/detail?id=6733&q=getCurrentPosition&colspec=ID%20Type%20Status%20Priority%20Area%20Milestone%20Owner%20Summary, but it is marked as fixed now, by #Pete Blois shown below.
Issue has been fixed, as well as an issue causing it to not work on IE10.
Please file a bug, and we'll get it taken care of. Thanks!
http://dartbug.com/new

JqGrid not working on Firefox 3.6.3 (Ubuntu 10.04 LTS)

I am using Ubuntu 10.04 LTS version which has Firefox 3.6.3 version installed. I have a JqGrid in my web application which I am accessing from Firefox on Ubuntu system. But I do not see the navbar icons. Also the jQuery tabs do not work. What might be the problem?
OS : Ubuntu 10.04 LTS
JqGrid : version 4.1.2
FireFox : Version 3.6.3
Tabs : jquery-ui-1.8.1
The grid is displayed but the navbar icons (Add / Edit / Delete / Search / Reload) do not show. When we click on the tab it does not change the tabs.
#Update:
I do not have a link :( sorry about that. But on debugging the javascript on FireFox it was found that the functions which we are calling on events are not getting resolved.
Here is a snippet of the code:
$("#userList").jqGrid('navGrid',"#pager1",{add:true,edit:true,del:true,search:true,refresh:true,
beforeRefresh: function(){
$("#userList").jqGrid('setGridParam',{datatype:'xml'}).trigger('reloadGrid', [{page:1}]);
}},
{ recreateForm:true,
beforeShowForm:checkCookieExpireForUser
},{
recreateForm:true,
beforeShowForm:checkCookieExpireForUser
},{
recreateForm:true,
beforeShowForm:checkCookieExpireForUser
});
function checkCookieExpireForUser(formid) {
var currentdate = new Date();
var currentTime = currentdate.getTime();
if(currentTime > cookiInfo[6]) {
window.location.href = '<%=request.getContextPath()%>/jsp/index.jsp';
}
}
When this code is executed in Firefox it says that checkCookieExpireForUser is undefied.
The problem is solved.
Here is how I solved the problem. This might be useful to any one who is facing same problem.
In Firefox you need to add the function definition before the call. When I moved the definition before the call. JqGrid icons where displayed and it is working fine.

Resources