- This topic has 12 replies, 4 voices, and was last updated 10 years, 9 months ago by support-octavio.
-
AuthorPosts
-
living.horsesMemberI don’t know why, but i cannot get the code to work in simulator nor when I build the android app. i also lose the place holder text.
I did have the calculators working previously. The only changes i have made to my app, is add extra pages, no new functions created.
i am wondering if the file is reading the wrong custom.js file. if so, how do i link it to the correct one?
my code is; (as per Home_custom.js)
**
* Notification that the UI is about to transition to a new screen.
* Perform custom prescreen-transition logic here.
* @param {String} currentScreenId
* @param {String} targetScreenId
* @returns {boolean} true to continue transtion; false to halt transition
*/
phoneui.prePageTransition = function(currentScreenId,targetScreenId) {
// add custom pre-transition code here
// return false to terminate transition
return true;
}/**
* Notification that the UI has transitioned to a new screen.
*
* @param {String} newScreenId
*/
phoneui.postPageTransition = function(newScreenId) {}
/**
* Notification that the page’s HTML/CSS/JS is about to be loaded.
* Perform custom logic here, f.e. you can cancel request to the server.
* @param {String} targetScreenId
* @returns {boolean} true to continue loading; false to halt loading
*/
phoneui.prePageLoad = function(targetScreenId) {
// add custom pre-load code here
// return false to terminate page loading, this cancels transition to page as well
return true;
}/**
* Notification that device orientation has changed.
*
* @param {String} newOrientation
*/
phoneui.postOrientationChange = function(newOrientation) {
if (Math.abs(newOrientation) == 90) {
alert(‘Landscape orientation not supported. ‘ +
‘Please use portrait orientation.’);}
/**
* Called when document is loaded.
*/
phoneui.documentReadyHandler = function() {
}function calculatekg() {
var girth1_value = document.getElementById(‘m1-weightcalc-girth1’).value;
var length1_value = document.getElementById(‘m1-weightcalc-length1’).value;
var unitkg = ” kg”;
document.getElementById(‘m1-weightcalc-resultkg’).value = (girth1_value*length1_value*girth1_value/11877).toFixed(2) + unitkg;
}function calculatelb() {
var girth2_value = document.getElementById(‘m1-weightcalc-girth2’).value;
var length2_value = document.getElementById(‘m1-weightcalc-length2’).value;
var unitlb = ” lb”;
document.getElementById(‘m1-weightcalc-resultlb’).value = (girth2_value*length2_value*girth2_value/328.71).toFixed(2) + unitlb;
}function calculatecm() {
var hh1_value = document.getElementById(‘m1-heightconv-hh1’).value;
var in1_value = document.getElementById(‘m1-heightconv-in1’).value;
var unitcm = ” cm”;
document.getElementById(‘m1-heightconv-resultcm’).value = (hh1_value*10.16+in1_value*2.54).toFixed(1) + unitcm;
}function calculatehh() {
var cm1_value = document.getElementById(‘m1-heightconv-cm1’).value;
var unithh = ” hh”;
document.getElementById(‘m1-heightconv-resulthh’).value = (cm1_value*0.0984252).toFixed(2) + unithh;
}I am stuck. My home page is Home using Home_custom.js and my calculators are on two pages: heightconv & weightcalc .
I just don’t understand why it suddenly won’t work, and I have working like mad to add the extra pages to upload the APK to google 🙁
Once again, i am probably missing some minor but obvious detail
BrandonMemberthere are several errors I can see without running it, including missing } in the orientation change function.
Use an online javascript validator or the mobione javascript editor and you should be able to find them
living.horsesMemberthank you CincyPlanet 🙂
I have tried to clean the script up, but still no luck.
I have two versions for the app. one for iPhone, and the other for Android.
The code works in the simulator for for the iPhone, but I have no luck in the Android version.
Here is the code as it works for one, but not the other
/** * Notification that the UI is about to transition to a new screen. * Perform custom prescreen-transition logic here. * @param {String} currentScreenId * @param {String} targetScreenId * @returns {boolean} true to continue transtion; false to halt transition */ phoneui.prePageTransition = function(currentScreenId, targetScreenId) { // add custom pre-transition code here // return false to terminate transition return true; } /** * Notification that the UI has transitioned to a new screen. * * @param {String} newScreenId */ phoneui.postPageTransition = function(newScreenId) { } /** * Notification that the page's HTML/CSS/JS is about to be loaded. * Perform custom logic here, f.e. you can cancel request to the server. * @param {String} targetScreenId * @returns {boolean} true to continue loading; false to halt loading */ phoneui.prePageLoad = function(targetScreenId) { // add custom pre-load code here // return false to terminate page loading, this cancels transition to page as well return true; } /** * Called when document is loaded. */ phoneui.documentReadyHandler = function() { } function calculatekg() { var girth1_value = document.getElementById('m1-weightcalc-girth1').value; var length1_value = document.getElementById('m1-weightcalc-length1').value; var unitkg = " kg"; document.getElementById('m1-weightcalc-resultkg').value = (girth1_value*length1_value*girth1_value/11877).toFixed(2) + unitkg; } function calculatelb() { var girth2_value = document.getElementById('m1-weightcalc-girth2').value; var length2_value = document.getElementById('m1-weightcalc-length2').value; var unitlb = " lb"; document.getElementById('m1-weightcalc-resultlb').value = (girth2_value*length2_value*girth2_value/328.71).toFixed(2) + unitlb; } function calculatecm() { var hh1_value = document.getElementById('m1-heightconv-hh1').value; var in1_value = document.getElementById('m1-heightconv-in1').value; var unitcm = " cm"; document.getElementById('m1-heightconv-resultcm').value = (hh1_value*10.16+in1_value*2.54).toFixed(1) + unitcm; } function calculatehh() { var cm1_value = document.getElementById('m1-heightconv-cm1').value; var unithh = " hh"; document.getElementById('m1-heightconv-resulthh').value = (cm1_value*0.0984252).toFixed(2) + unithh; } /** * Notification that device orientation has changed. * * @param {String} newOrientation */ phoneui.postOrientationChange = function(newOrientation) { }
living.horsesMemberneedles to say, I must learn javascript, and fast,
as this is completely doing my head in 🙂
BrandonMemberCan you post the one that doesnt work?
living.horsesMemberHi Brandon,
The previous code above is the same one i used in the android version, but there it doesn’t work.
My pages are all named the same in both versions (different folders obviously) , so nothing there should change. The only difference is one is has a layout for android, the other for iphone.
Thank you for taking the time to look at this by the way 🙂
BrandonMemberIm not seeing anything that jumps out at me in the code.
support-octavioMemberHi living.horses,
>The only changes i have made to my app, is add extra pages, no new functions created.
Have you changed the main screen? If you’re runing a new screen as main screen Mobione codegen will create a new folder and a new _custom.js file, so the code of the old _custom.js file won’t be executed.>The code works in the simulator for for the iPhone, but I have no luck in the Android version.
You’re testing both apps in SIM, right?If both apps are the same and the testing environment is also the same, I could say that something is wrong and it is NOT the same as it is on the iOS app. I’d suggest you to look for js errors on the javascript console and then start comparing both apps, f.e. it could be that the button that should fire the action doesn’t contain the call for it.
Hope this is helpful.
living.horsesMemberHi Octavio,
>The only changes i have made to my app, is add extra pages, no new functions created.
Have you changed the main screen? If you’re runing a new screen as main screen Mobione codegen will create a new folder and a new _custom.js file, so the code of the old _custom.js file won’t be executed.I have tried all kinds of options, including creating a new folder, copying just the design screens/pages, generating new files, and then copying the functions code into the new_custom.js file
>The code works in the simulator for for the iPhone, but I have no luck in the Android version.
You’re testing both apps in SIM, right?I am testing both through MobiOne Mobile Web Simulator. I have built the iPhone version, and had other people test it for me – it works. I have built the android version and tested on my phone – doesn’t work.
If both apps are the same and the testing environment is also the same, I could say that something is wrong and it is NOT the same as it is on the iOS app. I’d suggest you to look for js errors on the javascript console and then start comparing both apps, f.e. it could be that the button that should fire the action doesn’t contain the call for it.
I have also checked all the ID’s and that buttons on change execute the required function. SIlly question, how do I open/view the javascript console?
I will try again in about 1 hour and see how i go.
Could I maybe send you my files for double checking?
Thank you again
EDIT:
sorry, I am a little stressed, as my app is a finalist, and calculations were working, until I updated the app with minor aethetic changes, and now the calculations don’t work, so am trying everything I can to get it working again. 🙁
DaveClarkParticipantto open the javescript editor:
when in simulator, right mouse click and pick inspect element, when it opens pick sources, then hit ctrl O to open all the source code on the page, then you can scroll down and pick your custom.js file. then it will open in the editor and you can look around
living.horsesMemberthank you again daveclark
will check it out tonight 🙂
living.horsesMemberI have it working!!!
HUGE thank you to everyone, especially daveclark for talking me through options and what issues it might have been.
As a result, I think it had something to do with me deleting the Media Accessory item 004_blueArrow from a Widget button which was used to run my javascript code on clicking.
I have not yet tried to see if this is actually the case, but when I do, I will advise here. I am just thrilled to finally have the app working again, so that it is functioning properly, and might still be in with a chance to win the category. Here’s hoping at least 🙂
support-octavioMember>I have it working!!!
Great news living.horses! Hope everything goes well now. Let us know if you need further assistance. -
AuthorPosts