Geolocation with Dart in Firefox getCurrentPosition not a function - geolocation

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

Related

Cannot get Cordova text-to-speech plugin to work

I'm trying various plugins for TTS, including the one at https://github.com/vilic/cordova-plugin-tts, but cannot get any to work. For this one, for example, according to the docs, its usage should be:
TTS
.speak('hello, world!', function () {
alert('success');
}, function (reason) {
alert(reason);
});
but I get 'TTS not defined'. Also tried 'navigator.TTS....' but still no good. Also I'm unsure whether I need to include the tts.js in the package; if so I get 'exports not defined'. If anyone is successfully using this plugin, please can you put me in the correct direction? Or if there's an alternative plugin that works, I could use that, but many TTS plugins on GitHub appear unsupported for 3-4 years.
BTW other plugins I am using (e.g. geolocation) are working fine
Have now solved this. I didn't have <script src="cordova.js"></script> in my index.html. This was also stopping 'onDeviceReady' from firing, which is how I came about solving it.
So it seems you need this script included for some plugins but not for others. How confusing.
Can I claim back my 50 bonus points for solving it myself? ;)
Prefer with keyword window
window.TTS.speak({
text: 'hello world!!',
locale: 'en-GB',
rate: 1.3
}, function () {
// Do Something after success
}, function (reason) {
// Handle the error case
});
I tried the same way it worked for me.
Thanks,
Praveen

"SpeechSynthesisUtterance is not defined" in Chrome and Firefox

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.

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();}

jQuery UI 1.8.13 sudden error

We have been using Jquery from this link http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js for drag and drop. Suddenly we notice it is not working now and there is no code change done our side. We notice the error is pointing to these line and error is TypeError: a.curCSS is not a function? What will be solution to this problem?
e&&e.call(i)},g)}):this._focus.apply(this,arguments)},scrollParent:function(){var g;g=a.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter
This javascript error is caused by jQuery and jQueryUI being out of sync with each other. Rather than go back to an older version of jQuery, I would update jQuery UI. This link from the jQueryUI blog talks about support for the latest version jQuery. I experienced the same error before updating jQuery UI.
Base on another answer... I did something slightly different...
Instead of replacing:
$.curCSS(element, attrib, val);
with:
$(element).css(attrib, val);
I created a new function:
$.curCSS = function (element, attrib, val) {
$(element).css(attrib, val);
};
$.curCSS: This method is simply an alias for jQuery.css() from jQuery 1.3 onward. Although it has never been part of the documented API, some external code has been known to use it, perhaps thinking it was “more efficient.” Now it’s “more gone.” - from the page here.
This error can occur by using curCSS also.
replace:
$.curCSS(element, attrib, val);
with
$(element).css(attrib, val);
I had same problemm. Search for a link like this in your project:
https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
and change it with this:
https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js
It worked for me.

error on firefox: $.widget is not a function

I have a few multiselect boxes from the Jquery UI on a page that work perfectly well in Chrome & Safari but not in Firefox for some reason... when I load the Error Console in Firefox I see:
Error: $.widget is not a function
Source File: http://localhost:3000/javascripts/jquery.multiselect.js?1302660373
Line: 563
Any ideas why?
edit: the line itself is within the open function right where it says "// react to option changes after initialization"
// open the menu
open: function(e){
var self = this,
button = this.button,
menu = this.menu,
speed = this.speed,
o = this.options;
widget: function(){
return this.menu;
},
// react to option changes after initialization
_setOption: function( key, value ){
var menu = this.menu;
switch(key){
case 'header':
menu.find('div.ui-multiselect-header')[ value ? 'show' : 'hide' ]();
I am assuming you are using the jQuery Multiselect plugin… which depends on jQuery UI.
Sounds like you have not included enough of the jQuery UI library or just none of it. You need to include the core parts of jQuery UI (including Widget) if you build a custom download. Or just download the whole jQuery UI and include it instead.
For anyone else who is getting this but has the requirements; make sure you are including the Javascript files in the correct order. This error was being caused by my jquery-ui.js being included after the multiselect js file.
This answer is probably unrelated to the situation of the questioner, but I put it here for the sake of others Googling the question.
I got this error using Rails 3.2 and fixed it by deleting (renaming) the public/assets folder. It seems there are a lot of problems with the assets pipeline still. I don't know the details but have had other Javascript failures that are fixed this way.
Actually if you are getting this error then it's either
a) per #andyb answer - you haven't included the correct jQuery UI components
OR
b) your DOM is not loaded yet with the correct $.widget and therefore your function is attempting to call before $.widget has loaded. to fix the problem, ensure $.widget is called BEFORE your function

Resources