facebook

password protected page transition: CLOSED

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #327790 Reply

    will
    Member

    trying to have a a password protected screen. here is my javascript applied to the custom js file in the generated source codes library:

    phoneui.prePageTransition = function(currentPageId,targetPageId) {
    if(currentPageId == ‘#m1-salesperson_password_entry’ && $(‘#m1-salesperson_password_entry-passwordField1′).text==’password’)
    return true;
    }

    it doesn’t work, i think due to syntax errors. if anyone could neaten the javascript for me or support could provide a password implementation example, similar to the excellent custom and select list examples, that would be great.

    thanks

    #327844 Reply

    Max87
    Member

    Hi will
    I’ll try to help…
    Try to modificate your code like this:
    var enteredPassword = $(“#m1-salesperson_password_entry-passwordField1″).val();
    if(currentPageId == ‘#m1-salesperson_password_entry’ && enteredPassword ==”password”)
    {
    return true;
    }
    else
    {
    return false;
    }

    Can you please test it and let me know if it works?

    #327862 Reply

    will
    Member

    thanks for the help max unfortunately this doesn’t appear to work for me 🙁 upon transition the page changes irregardless of the password entered.

    #327888 Reply

    Hi will,

    I’ve tested the next code and is working fine for me:

    
    phoneui.prePageTransition = function(currentPageId,targetPageId) {
      // add custom pre-transition code here
      // return false to terminate transition
    
      var enteredPassword = $('#m1-home-textField1').val();
    if(currentPageId == '#m1-home' && targetPageId == '#m1-welcome')
    {
        if(enteredPassword !="123"){
        alert("invalid password");
        return false;    
        }
    } 
      return true;
    }

    Note that if you use this in webapps, anybody with javascript knowleadge could find the password.

    #327907 Reply

    will
    Member

    thanks for the help.

    the code works great however i am having a problem as code is in the pre transition area with some other codes :

    phoneui.prePageTransition = function(currentPageId,targetPageId) {
    // add custom pre-transition code here
    // return false to terminate transition
    {
    function();
    }

    if (currentPageId == ‘#m1-name’) {
    another function();
    }

    if(currentPageId == ‘#m1-salesperson_password_entry’ && targetPageId == ‘#m1-Contract_Summary’)
    {var enteredPassword = $(‘#m1-salesperson_password_entry-passwordField1’).val();
    if(enteredPassword !=”123″){
    alert(“invalid password”);
    return false;
    }

    }
    return true;
    }
    and this has caused the invalid password message to work but the page transition not to even if password is correct (all other functions perform fine). will i have to put the code elsewhere or is this a bug/syntax problem?

    #327939 Reply

    Hi will,

    I don’t think this is a bug. Could you check if this is a syntax error in DOM Inspector?

    Also, please try to move the condition for the login at the begin of phoneui.prePageTransition

    #328033 Reply

    will
    Member

    ive tried using the dom inspector and the debugger but as ive only been doing java for the last few weeks i havent found it really tells me anything. tried using an if true option contained in the code next to the if alert false but that didn’t work. also tried making it an function in the document readyhandler but nothing seems to work. will keep looking and post if i find out what i’m doing wrong.

    #328037 Reply

    will
    Member

    ive managed to get it to work by taking out the line that shows the alert I don’t know why this makes it work though
    for anyone else with this problem amended code:

    var enteredPassword = $(‘#m1-your page’).val();
    if(currentPageId == ‘#m1-your page’ && targetPageId == ‘#m1-yourpage2’)
    {
    if(enteredPassword !=”yourpassword”){
    return false;
    }

    #328055 Reply

    Hi will,

    Glad that you got that your functionality works.

Viewing 9 posts - 1 through 9 (of 9 total)
Reply To: password protected page transition: CLOSED

You must be logged in to post in the forum log in