Go Back   MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Reply
 
Thread Tools Search this Thread Display Modes
Old Apr 15, 2013, 10:27 AM   #1
LazyBrush
macrumors newbie
 
Join Date: Jun 2012
Location: UK, (my heart is in the highlands)
 
Dashcode; Javascript; Nexus 7 Issue.

Hello there,

I've made a simple Dashcode app which works fine on iOS devices.
It works fine in the Android emulator running on OSX. Yet on the
actual Nexus 7 device with chrome it has a strange error.

I have a Password Field which when typed into calls a bit of Javascript
to do a change 'My Pass' -> '** Pass' -> '*******'.

On the Nexus device it does this '*' -> 'M*' -> 'My*' -> 'My Pas*'.

Any ideas what I'm doing wrong?

LB

Code:
function passwordCharChange(event)
{
    var newstr;
    
    //
    // txt - Text in edit box so far
    //
    var textFieldValue = document.getElementById("textField");
    var txt = textFieldValue.value;

    //
    // len - Length of Saved password so far
    //
    var len = g_pw.length;
    
    while ( txt.length > g_pw.length)
    {
      // 
      // There is (still) more text in the edit field than in Saved PW.
      //
      
      //console.log( "Change: g_pw " + g_pw + " text field " + txt );
      
      //
      // Add 1 char to the end of Saved PW.
      //
      g_pw = g_pw + txt.charAt(len);
      
      //
      // substr(start,length) returns a sub string.
      // Replace one character in the textField with '*'
      //
      newstr = txt.substr(0,len) + '*' + txt.substr(len+1);
      
      //
      // update temp values
      //
      txt = newstr;
      len = g_pw.length;
    }
    
    if (g_pw.length > txt.length)
    {
      //
      // Saved PW is bigger than in textField.  So truncate it.
      //
      g_pw = g_pw.substr(0, txt.length);
    }
    
    //
    // Set modified text back into textField
    //
    textFieldValue.value = txt;
    
}
LazyBrush is offline   0 Reply With Quote
Old Apr 16, 2013, 06:50 AM   #2
LazyBrush
Thread Starter
macrumors newbie
 
Join Date: Jun 2012
Location: UK, (my heart is in the highlands)
 
Got this working.

Added -

var lotsofstars="******************";

Changed line -

newstr = lotsofstars.substr(0,len) + '*' + txt.substr(len+1);

Worked but strangely on Nexus 7 doing a delete then caused
the password to be clear again, i.e. "****" ---delete--> "huh"

So looks like -
txt = textFieldValue.value;
... some other stuff ...
textFieldValue.value = txt;

Would actually put g_pw into textFieldValue.value.

Again fixed by setting txt to be *s of desired length and setting back
into textFieldValue.value.

So there is something weird in Android (different to iOS anyway) which
I don't quite understand but have to work round.

LB
LazyBrush is offline   0 Reply With Quote
Old Apr 16, 2013, 09:16 AM   #3
SrWebDeveloper
macrumors 68000
 
SrWebDeveloper's Avatar
 
Join Date: Dec 2007
Location: Alexandria, VA, USA
 
In your function as posted here you first reference g_pw as:

Code:
var len = g_pw.length;
Is it a global variable? If not, I'm darned confused as to what it stores, so length would be zero or an error as variable not defined on strict consoles. Thanks for posting what else you fixed, but I don't see how it works at all with this issue.
__________________
Jim Goldbloom
Sr. Web Developer, owner GoldTechPro, LLC
http://www.GoldTechPro.com
SrWebDeveloper is offline   0 Reply With Quote
Old Apr 18, 2013, 08:07 AM   #4
LazyBrush
Thread Starter
macrumors newbie
 
Join Date: Jun 2012
Location: UK, (my heart is in the highlands)
 
Hi,

Yes, it's a global variable, initialised to "".
(I didn't include all the code, just the call back function.)

g_pw (Global _ PassWord )

Basically we have -
The visible Text Field (input : from user typing)
The visible Text Field (output : change text to stars '*')
g_pw (global saved password for use later in the code)

This function is called for each new letter added to the field.

thanks

LB

Quote:
Originally Posted by SrWebDeveloper View Post
In your function as posted here you first reference g_pw as:

Code:
var len = g_pw.length;
Is it a global variable? If not, I'm darned confused as to what it stores, so length would be zero or an error as variable not defined on strict consoles. Thanks for posting what else you fixed, but I don't see how it works at all with this issue.
LazyBrush is offline   0 Reply With Quote

Reply
MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Tags
dashcode, nexus 7, password, textfield

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Newbie Javascript issue. Works when inline but not when using src= blodwyn Web Design and Development 4 Mar 10, 2014 10:53 AM
Rumor: Motorola Nexus 6, Asus Nexus 8 and HTC Nexus 10 kenypowa Alternatives to iOS and iOS Devices 4 Feb 10, 2014 04:57 AM
tablets: Nexus 7 (2013) Non Functional GPS Issue robert996 Alternatives to iOS and iOS Devices 3 Aug 9, 2013 04:31 PM
Google Announces $199 Nexus 7 Tablet, $299 Nexus Q Media Streamer MacRumors MacRumors.com News Discussion 553 Oct 23, 2012 11:13 PM
phones: So, I can pay $650 for just an iPhone or $550 for a Galaxy Nexus PLUS Nexus tablet?! Big.Mac.Daddy Alternatives to iOS and iOS Devices 181 Sep 14, 2012 04:42 PM

Forum Jump

All times are GMT -5. The time now is 06:23 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC