Moestress
Android Fan
Profile
Posts: 91
Reg: Feb 12, 2012
Lynwood
4,110
01/04/14 10:36 PM (11 years ago)

Still cant figure this out. Javascript | Eclipse | Custom HTML / Text

Android/Eclipse/BT 3.0 Hello, firstly thanks so much for all the help that has been shot my way. I am stuck on somethings that seems so simple yet I cant work my fingers around it. I am using the Custom HTML / Text plug-in [not html Docs or url.]Everything seems to be working swiftly. I have a javascript file that randomizes text/quotes. When I copy and paste the full html/css/javascript anywhere online etc the randomize link is clickable and the quotes are randomized. However when I add it to the BT control panel, everything is visible but when I click randomize, it does nothing. Here is a sample code of exactly what I want to accomplish. <meta content="width=device-width; initial-scale=1.0; maximum-scale=2.0; user-scalable=1;" name="viewport" /> <html> <head> <title>Mr T's Quote Box</title> <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> <script type="text/javascript"> function getQuote() { var quotes = new Array("I pity the FOOL!", "I aint gettin on no plane!", "Quit yo Jibba Jabba!", "Shut up, fool!", "Life's tough, but I'm tougher!", "Do some prep!", "I'm on a real short leash here", "Don't make me mad, Arrr!", "You're gonna meet my friend, PAIN!", "You aint hurt, you pathetic!"); var randomChoice = Math.floor(Math.random()* quotes.length) $("#myBox").html(quotes[randomChoice]); } </script> <style type="text/css"> #mybox { position: absolute; left: 460px; top: 100px; z-index: 1; width:320px; height:130px; background-color: transparent; display: block; font-size: 30px; text-align: center; } p{ width: 200px; height: 50px; background-color: #ff0000; text-align: center; padding: 9px; font-size: 20px; font-family: arial; border: 2px solid #000; } a:link {color:#000000; text-decoration: none;} a:visited {color:#000000; text-decoration: none;} /* visited link */ a:hover {color:#000000; text-decoration: none;} /* mouse over link */ a:active {color:#000000; text-decoration: none;} </style> </head> <body> <div style="position: absolute; z-index: -1;"> <img src="mrt.jpg"> </div> <div id="myBox"> You're gonna meet my friend, PAIN! </div> <P> <a href="javascript:getQuote()">Next quote, FOOL!</a> </p> </body> </html> Ii have used html validators etc to fix any html errors, but they come out pretty clean. Is there something I am missing to make button clickable?
 
mysps
Code is Art
Profile
Posts: 2082
Reg: May 14, 2011
Palma
33,320
like
01/05/14 02:27 AM (11 years ago)
Have you tested on your device?
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/05/14 02:29 AM (11 years ago)
Is there a button? I see a link to the javascript… Maybe something like this might work…? <form> <INPUT TYPE="button" NAME="button" Value="Click" onClick="getQuote()"> </form> I haven't tested this, and it's been a while, so your mileage may vary... Cheers! -- Smug
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
01/05/14 05:41 AM (11 years ago)
I tested this out by on my PC, then by adding it to an IOS test app, both as custom/html and a url - both worked, which suggests a) it isn't a syntax issue. b) it isn't a custom html plugin issue. c) It could be an Android specific issue. My suspicion would be that the way way you detect the click isn't liked in the Android browser?
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
01/05/14 10:41 AM (11 years ago)
Yeah I tested it but it didn't work until I added @Smug's suggestion. Either way, funny stuff! LA
 
Moestress
Android Fan
Profile
Posts: 91
Reg: Feb 12, 2012
Lynwood
4,110
like
01/05/14 01:10 PM (11 years ago)
@Mysp, heres the thing. Its already connecting to my website with the code working perfectly[ url plug-in]. Its really beautiful and simple [ but I want it to be available offline as well.] When I try to test the html/text screen with the same code the words are there, but when I click on the link to randomize the content nothing happens. As I said it works pretty much everywhere else. I will check out smugs suggestion and see if that will work for me. Thank you. @LA, Oh that is a sample script that I used to generate my random quotes. I didnt come up with those Mr. T quotes, but thought they would be funny to share with my example.
 
LA
Aspiring developer
Profile
Posts: 3280
Reg: Aug 16, 2012
Jerseyville, IL
42,900
like
01/05/14 01:14 PM (11 years ago)
Where did you get the javascript? LA
 
Moestress
Android Fan
Profile
Posts: 91
Reg: Feb 12, 2012
Lynwood
4,110
like
01/05/14 01:34 PM (11 years ago)
Here is where I found the code. Book marked of course...http://codeboom.wordpress.com/sweet-resources/random-quote-generator/
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
01/05/14 02:16 PM (11 years ago)
Please could you confirm if this works on an android browser from your website?
 
Moestress
Android Fan
Profile
Posts: 91
Reg: Feb 12, 2012
Lynwood
4,110
like
02/13/14 02:08 PM (11 years ago)
Hello Alan, this works on my website on Chrome android browser. I actually have the url plugin pointing for now. My main goal is to allow the user to be off line and press a button to refresh new sentences/ quotes.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
02/13/14 04:07 PM (11 years ago)
Hi@Moestress If you were to use @chris1's html pro plugin, I believe it will cache the json from your website so that the app works offline. If you update your json quotes, a standard buzztouch refresh could update your quotes. I can test that theory as I have a quotes app for F1 / motorsport fans, I am using that plugin and I'm in the process of updating it at the moment.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/13/14 04:22 PM (11 years ago)
Just for giggles, I tried that page (linked from http://codeboom.wordpress.com/sweet-resources/random-quote-generator/) in my Smug AndroidHTML and it works fine. I did not try it from URL; only locally (within the project) Not to say you have to buy my plugin; I suspect if you already purchased Chris' HTMLPro plugin, it will probably display the same way. You do have to tap 'on the text' and not just 'in the red' to get it functional, but it works fine. Cheers! -- Smug
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.