[android-developers] Re: Trying to get Javascript on Android
[SOLVED] Found the answer here: http://rossboucher.com/2008/08/19/iphone-touch-events-in-javascript/comment-page-1/#comment-14391 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
Um... hello? Is there anyone who has any idea how to implement a touchmove event? Anyone, anywhere? I have looked around the internet and asked on a few different forums, and got zero response. Zero. Nothing. Not even people telling me to "RTFM" or what's wrong with my question. I've tried finding examples, tutorials, and documentation. Is the a decent FM to R? Surely the Android developer list would be the place to get advice on how to get something to work on Android... Any help would be much appreciated. *Any* help... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
After much looking around on the subject, it is far from clear how I can get my slider to respond to a touch event. I have attempted to modify the YUI slider code as follows. What might be going wrong? Also, please note, I am a total JavaScript beginner. Not only is the code cobbled together from online examples, but if you can help me to alter it, please explain as you would to a child. Don't assume any prior knowledge, because I have almost none. Much appreciated! Thank you for any advice. (function() { var Event = YAHOO.util.Event var Dom = YAHOO.util.Dom var lang= YAHOO.lang var bg = "slider-bg" var thumb = "slider-thumb" var slider; // Determines starting point of slider var topConstraint = -20; // Determines end point of slider var bottomConstraint = 280; // Custom scale factor for converting the pixel offset into a real value var scaleFactor = 1.5; // The amount the slider moves when the value is changed with the arrow // keys var keyIncrement = 3; Event.onDOMReady(function() { slider = YAHOO.widget.Slider.getHorizSlider(bg, thumb, topConstraint, bottomConstraint, 3); // Sliders with ticks can be animated without YAHOO.util.Anim slider.animate = true; slider.getRealValue = function() { return Math.round(this.getValue() * scaleFactor); } slider.subscribe("change", function(offsetFromStart) { // This will get called each time the slider changes. // The offsetFromStart value is the pixel offset horizontally of the current slider position. //alert("slider value = " + slider.getValue()); }); slider.subscribe("slideStart", function() { // this will be done when the slider starts //alert("slider start"); }); slider.subscribe("slideEnd", function() { // this will be done when the slider ends }); var thumb = document.getElementById('slider-thumb'); thumbStyle = thumb.style; thumb.addEventListener('touchmove', function(event) { event.preventDefault(); console.info("touch move :"+ event.targetTouches); if (event.targetTouches[0] == thumb) { var oldPos = thumbStyle.left; var changePos = event.targetTouches[0].pageX - oldPos; thumb.setValue(thumb.getValue() + changePos, true, false, false); } }); }); })(); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
John, Fred, and "Streets Of Boston", Sorry I stepped away from this conversation for a bit. Work has a nasty habit of getting in the way sometimes. Thank you for replying and explaining the situation to me a little more. I can now see how touch events might diverge from mouse events in certain circumstances. A mouse in and mouse out won't work with touch screens. I guess the art is in determining when you want similar behaviours, and when you don't. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
One other thing... I've found differences between the way iPhone and Android handle events. Mouse events on the iPhone are handled differently on Android, so keep that in mind as well. -John Coryat "What Zip Code?" "Radar Now!" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
>"There's nothing about touching with a finger which, as far as I can see, is >operationally different from the things I do with my mouse"< It *is* a little different. E.g. you won't have corresponding finger- events for mouseover, mouseout, etc. The phone cannot quite detect your finger hovering over the screen without your finger touching the screen. This may affect the functionality of some javascript libraries if they (partially) rely on these events. And some javascript libraries may not have been tested (at all) on Android's WebKit. On Sep 20, 9:35 am, ebisudave wrote: > John, > > Thank you for the reply. > > Hmm... seems a little odd to me that they went and made a whole > different set of events for using fingers on a touch screen when they > are duplicates of what I do with a mouse. There's nothing about > touching with a finger which, as far as I can see, is operationally > different from the things I do with my mouse. > > In any case, is there not a way to simply add a script to say: > > touchscreen = mouse click and hold down > touchmove = dragging with mouse > touchend = release mouse button > > ...? > > It would be lame to have to declare the same functions twice or have > to replace one for another between mobile and desktop versions. > > Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
It probably will work, mouse and touch events won't happen simultaneously. As for touch, you can have multiple finger touches (think iPhone) which can be interpreted differently than anything that can be done with a mouse. Android doesn't (I believe) support "gestures" at this point but may in the future. -John Coryat "What Zip Code?" "Radar Now!" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
John, Thank you for the reply. Hmm... seems a little odd to me that they went and made a whole different set of events for using fingers on a touch screen when they are duplicates of what I do with a mouse. There's nothing about touching with a finger which, as far as I can see, is operationally different from the things I do with my mouse. In any case, is there not a way to simply add a script to say: touchscreen = mouse click and hold down touchmove = dragging with mouse touchend = release mouse button ...? It would be lame to have to declare the same functions twice or have to replace one for another between mobile and desktop versions. Dave --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
The reason they don't work on the Android browser (or webkit for that matter) is that they are using mouse events. If you want to use that code on the Android you have to use touch events instead. Try reading up on the following: touchstart - finger touches the screen touchmove - finger is moving touchend - finger leaves the screen It looks to me like the first example you listed should be fairly easy to update to touch. If you use these events, you should get better results. There's some good documentation for this in the iPhone docs. You'll have to search for it, but they have code examples as well. -John Coryat "What Zip Code?" "Radar Now!" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
Shawn, > This is much easier than the stuff I know you fiddle with in you linux > box No... no it's not. Let's not get into broad statements about what my environment is like or how I handle it. Linux is fine, it's me who has different abilities, so please leave it for me to decide what I can and can't do. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
Here's what I have learned so far: The following scripts all behave the same on my Android device: http://developer.yahoo.com/yui/examples/slider/slider-ticks.html http://developer.yahoo.com/yui/examples/slider/slider_dual_thumb_clean.html http://www.extjs.com/deploy/dev/examples/slider/slider.html ... which is that they display okay, but the functionality is only half there. One can click somewhere in the slider area, and the pointer will move to that position. However, one can't grab the pointer and move it directly. On my page, one can't get the pointer to move by either method, indicating I may have lost something when I modified from the original JavaScript. However, since none of the above original examples work perfectly either, it's hard to know what I should be shooting for. So, I think my question has become more basic and general: Has anyone got a JavaScript slider to work on an Android device, ever? Has anyone seen one? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
Hi, > * http://www.nanaze.com/2009/01/debugging-javascript-on-android.html * > Thank you for the link, however, that article went way, way over my > head, at commercial airliner altitudes. Maybe not. Just: 1) get the sdk http://developer.android.com/sdk/1.6_r1/index.html 2) set your path http://developer.android.com/sdk/1.6_r1/installing.html 3) hook up your phone via usb -- turn on Settings/Application/developement/USB debugging 4) run (in a shell on your linux box) $adb logcat WebCore:V *:S 5) stick logging in your javascript on your web page console.error('oops damn'); console.info(' I am here'); console.log('3'); console.warn(' eeeh uuum'); This is much easier than the stuff I know you fiddle with in you linux box -- fonts, encodings etc etc. You may want to find a cross browser js solution that is targeted at (among others) Android/iPhone and let me know. Extjs may be one but I am not sure about their mobile support. Shawn --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
ebisudave wrote: > > On the whole, yes. Bear in mind that Android uses WebKit, so where you > > see browser-specific instructions for Javascript libraries, follow those > > for iPhone, Safari, or perhaps Chrome. > > If only Chrome were available on Linux... but that's another issue. I'm reading this group using Chromium on Ubuntu Jaunty. Chromium dailies for Ubuntu are available at https://launchpad.net/~chromium-daily/+archive/ppa --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
In a word: YES! Implementations of JavaScript vary across all the major platforms, you have to be very careful about testing, test and more testing each time you make a change to any code on a web page. The worst offenders are IE6 and IE7. Safari has plenty of quirks and as the iPhone is a variant of Safari, you'll have to have an actual device (or the emulator at least) to test on as well. The most compliant is FireFox, and the Android browser will work pretty well if it works in FF, however, the events are different. Search for "touch" events to see how to handle them in regard to "mouse" events. GWT has solved a lot of these issues but if you want to code in raw JavaScript, then you'll need to be very careful. -John Coryat "What Zip Code?" "Radar Now!" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
> > Is Android *supposed* to run JavaScript > > like any other JavaScript capable browser? > > On the whole, yes. Bear in mind that Android uses WebKit, so where you > see browser-specific instructions for Javascript libraries, follow those > for iPhone, Safari, or perhaps Chrome. If only Chrome were available on Linux... but that's another issue. Hmm... I looked around on the web, and I don't see any instructions that are different for browsers, at least not for anything I'm doing. Ultimately I'm aspiring to create some JavaScript that is usable on Android, iPhone, and most modern desktop browsers. Does JavaScript have the same cross-browser compatibility issues that CSS does? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
ebisudave wrote: > Is there no reference that outlines any special considerations for how > JavaScript runs on Android? Not that I have seen. > Is Android *supposed* to run JavaScript > like any other JavaScript capable browser? On the whole, yes. Bear in mind that Android uses WebKit, so where you see browser-specific instructions for Javascript libraries, follow those for iPhone, Safari, or perhaps Chrome. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Need help for your Android OSS project? http://wiki.andmob.org/hado --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
Thank you everyone for the helpful information. What I have learned so far: * Android devices are limited in speed and power, so don't expect all the same functionality of a computer.* I understand this concept, and my initial suspicion is that this is not the issue. I have one (1) slider on the page, and nothing else. *setJavaScriptEnabled is relevant to webkit widgets, not web pages* Okay, good to know I can remove that as a potential source of the problem. * http://www.nanaze.com/2009/01/debugging-javascript-on-android.html * Thank you for the link, however, that article went way, way over my head, at commercial airliner altitudes. *If you can run a Google Map API on the phone, you should be able to handle most JavaScript applications.* I tested with the supplied URL, and it works fine on my phone. If this elaborate map thing works on my phone, surely my slider should. *It is a high enough probability that I am in Tokyo that Shawn is willing to make wagers about that fact.* That would be a safe bet. *Testing can be done on the emulator* ... Which is nifty, but setting up the debugger part was, again, way over the head of a web page making guy like me. In the end, thank you all for the information. I've learned a little more. But I don't know if I'm much closer to a solution yet. Maybe if I get this debugger thing worked out... but I'd rather be making web pages. Is there no reference that outlines any special considerations for how JavaScript runs on Android? Is Android *supposed* to run JavaScript like any other JavaScript capable browser? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
EbisuDave, I bet you are in Tokyo ! Have you tried: http://www.nanaze.com/2009/01/debugging-javascript-on-android.html Shawn --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
Oh certainly, but as I said, it works in the emulator. So currently I don't think my problem is due to heavy javascript usage. I don't want to steal the thread from ebisudave, but as an example of the kind I have trouble with, take a look at the top chart here (animated jquery sparkline example): http://omnipotent.net/jquery.sparkline/ It work in Firefox etc. as well as the emulator, but not on my physical Magic device. /Casper On 18 Sep., 21:59, "Maps.Huge.Info (Maps API Guru)" wrote: > I think a lot of developers, especially ones from the web world, > forget that these mobile devices are like desktop computers of the > mid-90's in power and speed. Trying to get a complex JavaScript > application to run on the phone is probably going to be disappointing. > Just because it runs on FF with your quad core monster doesn't mean it > will do anything but cry for momma on the actual mobile device. > > -John Coryat > > "What Zip Code?" > > "Radar Now!" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
You can easily test your device's browser JavaScript capabilities by calling up a Google Map API (v3 is best on mobile) application. Here's one you can try: http://www.usnaviguide.com/v3maps/ProjectedOverlayTest.htm If this map works, you have JavaScript enabled. -John Coryat "What Zip Code?" "Radar Now!" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
I think a lot of developers, especially ones from the web world, forget that these mobile devices are like desktop computers of the mid-90's in power and speed. Trying to get a complex JavaScript application to run on the phone is probably going to be disappointing. Just because it runs on FF with your quad core monster doesn't mean it will do anything but cry for momma on the actual mobile device. -John Coryat "What Zip Code?" "Radar Now!" --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
I asked a similar question a few weeks ago with no answer. I am using JQuery for some animation on a 1 sec timer which also fails in the Android browser. The only thing I can imagine is that we run into some kind of JavaScript speed limitation, exhausted javascript message pump or something like that. I plan to look more into this over the weekend. My JQuery code also works fine in the emulator, does yours? /Casper On 18 Sep., 10:31, ebisudave wrote: > Hello Android developers, > > By way of introduction, please know that I'm a complete newbie when it > comes to JavaScript. I'm a web designer who can program a little. But > I've only just started playing with JavaScript about four days ago. > > I made a JavaScript slider with Yahoo's User Interface > library:http://developer.yahoo.com/yui/slider/ > > My version of the slider is here on this page:http://karamoh.com > > All I did was change the graphics a bit. > > It works in FireFox so I assumed it would just magically work in > Android. But it doesn't. > > I found this thread in this > forum:http://groups.google.com/group/android-developers/browse_thread/threa... > > Which says that JavaScript should just work. But it also says that > "setJavaScriptEnabled" set to true. > > As a total JavaScript newbie, I don't quite get what that means. (I > don't think it means the device's browser settings, which, by the way, > I have triple-checked to ensure that I have my Android device set to > use JavaScript. My testing device is an NTT DoCoMo HT-03A, called the > HTC Magic in other countries). > > Is that a setting that needs to be called in the JavaScript or the web > page itself? Seems odd that you might need a call within a script to > allow the script to be called. > > I think I'm missing a basic concept here. Can anyone enlighten me? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---
[android-developers] Re: Trying to get Javascript on Android
ebisudave wrote: > By way of introduction, please know that I'm a complete newbie when it > comes to JavaScript. I'm a web designer who can program a little. But > I've only just started playing with JavaScript about four days ago. > > I made a JavaScript slider with Yahoo's User Interface library: > http://developer.yahoo.com/yui/slider/ > > My version of the slider is here on this page: > http://karamoh.com > > All I did was change the graphics a bit. > > It works in FireFox so I assumed it would just magically work in > Android. But it doesn't. > > I found this thread in this forum: > http://groups.google.com/group/android-developers/browse_thread/thread/9a369edf59dd9097 > > Which says that JavaScript should just work. But it also says that > "setJavaScriptEnabled" set to true. That thread is referring to applications that embed a WebKit widget. It is not relevant for applications you are viewing through the built-in Browser application. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Looking for Android opportunities? http://wiki.andmob.org/hado --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~--~~~~--~~--~--~---