Notices

Water Fountain General Chit/Chat

Reply
 
LinkBack Thread Tools
Old 04-29-07, 10:52 PM   #1 (permalink)
Aximsite Hall of Fame
 
aximbigfan's Avatar
 
Join Date: May 2005
Posts: 9,195
Thanked 0 Times in 0 Posts
Blog Entries: 1
javascript hell...

ug....

im trying to desgin a new web ui for my hp mediavault and right now i am doing the javascript part of the ui.

heres my problem.
im putting a function in to erase the NVRAM, HOWEVER i dont want users to simply be able to click it and clear it without confirmation. i dont like the idea of a simple confirm() box becouse it would be too easy to click ok without thinkign about it, so i want to do this.

function conf()
{
var conf=prompt("WARNING really clear nvram? enter "understand" to continue.")
if (conf =="understand")
{
document.location.href="commandp/nvramclear.asp"
}
else
{
alert("invalid confirm code. ")
}
else if (conf ==null)
{
}
}


now, IF the user enters the confirm code wrong, i want the script to loop back to the top and keep on going until the user enters the correct code. HOWEVER, IF the user clicks cancel (and returns null) i want the script to stop.

i have yet to find a (good) way of doing this.

any ideas?


chris
aximbigfan is online now   Reply With Quote
Sponsor Ads
Old 04-29-07, 11:08 PM   #2 (permalink)
Aximsite Minor League
 
Join Date: Jul 2006
Location: Washington
Posts: 157
Device: Moto Q 9m
Carrier: Verison!
Thanked 0 Times in 0 Posts
What's wrong with creating a while loop?

You could also use labels like:
top:
// Code here
// if bad command then
goto top;
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- My Website

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


I don't believe in atheists therefore atheists don't exist.
Clegs is offline   Reply With Quote
Old 04-29-07, 11:22 PM   #3 (permalink)
Aximsite Hall of Fame
 
aximbigfan's Avatar
 
Join Date: May 2005
Posts: 9,195
Thanked 0 Times in 0 Posts
Blog Entries: 1
Originally Posted by Clegs View Post
What's wrong with creating a while loop?

You could also use labels like:
top:
// Code here
// if bad command then
goto top;
you can use a goto command?

huh.... i thought of that, but i didn't think javascript had a goto command...


chris
aximbigfan is online now   Reply With Quote
Old 04-29-07, 11:26 PM   #4 (permalink)
Aximsite Veteran
 
star882's Avatar
Uber Member
 
Join Date: Oct 2004
Posts: 1,858
Thanked 3 Times in 3 Posts

Awards Showcase
Aximsite Active Bronze Member 
Total Awards: 1

What about:

String temp;
do
{
temp=input.get();
}
while(!(temp.equals("understand")||temp.equals("") );
if(temp.equals("understand"))
{
nvram.clear();
}

Obviously, modify it to your needs.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

TCPA would take your freedom! Say NO!
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

HDTV the way it should be:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Originally Posted by A friend of mine who has a Linux kernel named after his girlfriend.
If I was VirtualBox, I could load my virtualization module into Hannah and boot up another kernel in the same address space.
star882 is offline   Reply With Quote
Old 04-29-07, 11:32 PM   #5 (permalink)
Aximsite Minor League
 
Join Date: Jul 2006
Location: Washington
Posts: 157
Device: Moto Q 9m
Carrier: Verison!
Thanked 0 Times in 0 Posts
ya, that works, I guess javascript doesn't have that goto command rrgh....

Remember don't declare your variable
String temp; // This doesn't work
var temp = new String(); // That's how I would do it but you don't need the 'new String() part it's just the c++ programmer in me :)

Also, with that code you can only type "understand" or else you are in an infinite loop.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- My Website

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


I don't believe in atheists therefore atheists don't exist.
Clegs is offline   Reply With Quote
Old 04-29-07, 11:41 PM   #6 (permalink)
Aximsite Hall of Fame
 
aximbigfan's Avatar
 
Join Date: May 2005
Posts: 9,195
Thanked 0 Times in 0 Posts
Blog Entries: 1
Originally Posted by Clegs View Post
ya, that works, I guess javascript doesn't have that goto command rrgh....

Remember don't declare your variable
String temp; // This doesn't work
var temp = new String(); // That's how I would do it but you don't need the 'new String() part it's just the c++ programmer in me :)

Also, with that code you can only type "understand" or else you are in an infinite loop.
ok, well here is my new code.
@star, one of the reasons i am doing this is so i can learn js, your post is a bit too advanced for what i am at now. i will save it however an look at it in a few days, when i can understand it a bit better. unfortunately, i only learned a little bit of js when i was younger, so now i am catching up.

here is my new code:
//this is a special function that prompts a confim code.
function conf()
{
do
{
var conf=prompt("WARNING really clear nvram? enter 'understand' to continue.")
if (conf =="understand")
{
document.location.href="commandp/nvramclear.asp"
}
else
{
alert("invalid confirm code.")
}
}
while (conf !="understand" && conf !=null)
}

the only problem with this is that it you exit, you get the alert message, but i think i can fix that on my own.


chris
aximbigfan is online now   Reply With Quote
Old 04-29-07, 11:45 PM   #7 (permalink)
Aximsite Hall of Fame
 
aximbigfan's Avatar
 
Join Date: May 2005
Posts: 9,195
Thanked 0 Times in 0 Posts
Blog Entries: 1
sorry for the double post, but i got it working now....

//this is a special function that prompts a confim code.
function conf()
{
do
{
var conf=prompt("WARNING really clear nvram? enter 'understand' to continue.")
if (conf =="understand")
{
document.location.href="commandp/nvramclear.asp"
}
else if (conf !=null)
{
alert("invalid confirm code.")
}
}
while (conf !="understand" && conf !=null)
}

all i added to get it to work was on line 11, i added on to else... with "if (conf !=null)

thanks to all who helped.

chris
aximbigfan is online now   Reply With Quote
Old 04-29-07, 11:45 PM   #8 (permalink)
Aximsite Minor League
 
Join Date: Jul 2006
Location: Washington
Posts: 157
Device: Moto Q 9m
Carrier: Verison!
Thanked 0 Times in 0 Posts
What if in the else statement you did something like:
else if(conf!=null)

Then you will not get that message.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- My Website

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


I don't believe in atheists therefore atheists don't exist.
Clegs is offline   Reply With Quote
Old 04-29-07, 11:46 PM   #9 (permalink)
Aximsite Hall of Fame
 
aximbigfan's Avatar
 
Join Date: May 2005
Posts: 9,195
Thanked 0 Times in 0 Posts
Blog Entries: 1
Originally Posted by Clegs View Post
What if in the else statement you did something like:
else if(conf!=null)

Then you will not get that message.
see the above post. you were just a few seconds late...


chris
aximbigfan is online now   Reply With Quote
Old 04-30-07, 12:29 AM   #10 (permalink)
Aximsite Minor League
 
Join Date: Jul 2006
Location: Washington
Posts: 157
Device: Moto Q 9m
Carrier: Verison!
Thanked 0 Times in 0 Posts
oh, now I don't feel useful... lol

Great minds think alike :)

Last edited by Clegs; 04-30-07 at 12:29 AM. Reason: fixed spelling
Clegs is offline   Reply With Quote
Old 04-30-07, 12:34 AM   #11 (permalink)
Aximsite Hall of Fame
 
aximbigfan's Avatar
 
Join Date: May 2005
Posts: 9,195
Thanked 0 Times in 0 Posts
Blog Entries: 1
Originally Posted by Clegs View Post
oh, now I don't feel useful... lol

Great minds think alike :)
true that. there were a few other ways i could have done it i think, but that popped into my head first.

now, i just have to code a js library to convert strings into human readable strings, but that shouldn't be hard at all....


chris
aximbigfan is online now   Reply With Quote
Old 04-30-07, 12:39 AM   #12 (permalink)
Aximsite Minor League
 
Join Date: Jul 2006
Location: Washington
Posts: 157
Device: Moto Q 9m
Carrier: Verison!
Thanked 0 Times in 0 Posts
Your strings aren't already human-readable?

Why don't you just change the strings in the code?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
- My Website

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


I don't believe in atheists therefore atheists don't exist.
Clegs is offline   Reply With Quote
Old 04-30-07, 12:49 AM   #13 (permalink)
Aximsite Hall of Fame
 
aximbigfan's Avatar
 
Join Date: May 2005
Posts: 9,195
Thanked 0 Times in 0 Posts
Blog Entries: 1
Originally Posted by Clegs View Post
Your strings aren't already human-readable?

Why don't you just change the strings in the code?
no, im talking about the strings generated by the device (im working on a new web ui for a embedded file server).


im talking mostly about little things. like for example, the server will generate dhcp_client when quired about the net mode, however, to look nice (and to be short) this needs ot be converted to just plain old "dhcp".

so, i create a variable in my js file that would read "var dhcp_client="dhcp"":)

chris
aximbigfan is online now   Reply With Quote
Old 04-30-07, 12:49 AM   #14 (permalink)
Noiro
Guest
 
Posts: n/a
Mine is more work friendly :p It is my office line.

GeorgeGRW

EDIT: Aww hell, worng thread :p, OMG I need to sleep...

Last edited by Noiro; 04-30-07 at 01:07 AM.
  Reply With Quote
Old 04-30-07, 12:54 AM   #15 (permalink)
Aximsite Hall of Fame
 
aximbigfan's Avatar
 
Join Date: May 2005
Posts: 9,195
Thanked 0 Times in 0 Posts
Blog Entries: 1
well, now that i have accomplished something, its time to go to bed, night all!


chris
aximbigfan is online now   Reply With Quote
Reply

Tags
hell, javascript

Sponsor Ads

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with javascript, please! artmustel Windows Mobile 2003 3 02-09-07 02:31 PM
JavaScript BarrieB2 X50 / X51 Forums 3 12-03-06 09:40 AM
javascript student101 X50 / X51 Forums 16 08-03-06 11:28 AM
No Javascript on PIE? Ehien Windows Mobile 2003 18 06-30-05 10:03 AM
Javascript joedoe101 Water Fountain 8 06-14-05 08:15 PM


All times are GMT -5. The time now is 08:52 PM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Copyright © 2003-09 LeckMedia, LLC