Lost Password?

Go Back   CodeCall Programming Forum > Web Development Forum > JavaScript and CSS

JavaScript and CSS Extensible Markup Language, Java Script, and CSS questions here.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-03-2008, 08:17 PM
Grandmaster Flash Grandmaster Flash is offline
Newbie
 
Join Date: Jan 2008
Posts: 3
Rep Power: 0
Grandmaster Flash is on a distinguished road
Default Getting mayan long count from date

Hey, so basically I got this javascript that turns the current date into a mayan long count. I tied it to an xul file that pops up the date in firefox(it's a frefox extension). Everything works fine but the javascript code won't work. Here it is:
Code:
function LongCount()
{
	var curDate = new Date();
	var endCycle = new Date(2012,11,21);
	var milsDay = 1000*60*60*24;
	var diff = Math.ceil((endCycle.getTime() - curDate.getTime())/milsDay);
	
	var LongCount = new Array();
	LongCount[0] = 13;
	LongCount[1] = 0;
	LongCount[2] = 0;
	LongCount[3] = 0;
	LongCount[4] = 0;
	
	var i = 0;
	
	for (i = 1; i = diff; )
	{
		if (LongCount[4] - 1 < 0)
		{
			if (LongCount[3] - 1 < 0)
			{
				if (LongCount[2] - 1 < 0)
				{
					if (LongCount[1] - 1 < 0)
					{
						if (LongCount[0] - 1 < 0)
						{
							LongCount[0] = 20;	
							LongCount[1] = 0;	
							LongCount[2] = 0;	
							LongCount[3] = 0;	
							LongCount[4] = 0;	
						}	
						else
						{
							LongCount[1] = 20;
							LongCount[0] -= 1;	
						}
					}
					else
					{
						LongCount[2] = 20;
						LongCount[1] -= 1;	
					}
				}
				else
				{
					LongCount[3] = 20;
					LongCount[2] -= 1;	
				}	
			}
			else
			{
				LongCount[4] = 20;
				LongCount[3] -= 1;	
			}	
		}
		else
		{
			LongCount[4] -= 1;	
		}	
	}
	
	return LongCount[0] + "." + LongCount[1] + "." + LongCount[2] + "." LongCount[3] + "." + LongCount[4];
}
Can anyone tell me what I'm doing wrong?

Thanks in advance =]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Sponsored Links
  #2 (permalink)  
Old 01-04-2008, 11:32 AM
Lop's Avatar   
Lop Lop is offline
Speaks fluent binary
 
Join Date: May 2006
Posts: 1,135
Rep Power: 16
Lop is on a distinguished road
Default

That is a lot of if/else statements. You should consider using switch/case. FF has a JavaScript debugger addon. Search for that and add it. It will let you go through the JavaScript step by step and then you will be able to find the error. Sometimes I use IE to determine what the error is. While FF will say nothing about the error IE will at least give some general (usually useless) error description.
__________________
Lop
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-04-2008, 03:37 PM
Grandmaster Flash Grandmaster Flash is offline
Newbie
 
Join Date: Jan 2008
Posts: 3
Rep Power: 0
Grandmaster Flash is on a distinguished road
Default

Quote:
Originally Posted by Lop View Post
That is a lot of if/else statements. You should consider using switch/case. FF has a JavaScript debugger addon. Search for that and add it. It will let you go through the JavaScript step by step and then you will be able to find the error. Sometimes I use IE to determine what the error is. While FF will say nothing about the error IE will at least give some general (usually useless) error description.
I used that addon and I got it working I just a while loop instead. =] thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
How to add My program to Startup ? kresh7 Visual Basic Programming 47 08-31-2008 11:51 PM
Java:Tutorial - Tic-Tac-Toe John Java Tutorials 25 02-27-2008 06:41 PM
SecurityAudit vinay Visual Basic Programming 27 01-07-2008 12:14 PM
buttons with effect ikkeugh Visual Basic Programming 21 10-04-2007 10:24 AM
PHP:Tutorial The Date John PHP Tutorials 0 01-10-2007 06:10 PM


All times are GMT -5. The time now is 11:59 PM.

Contest Stats

John ........ 223.00000
dargueta ........ 168.00000
Xav ........ 164.00000
LogicKills ........ 20.00000
gaylo565 ........ 18.00000
WingedPanther ........ 15.00000
|pH| ........ 15.00000
Johnnyboy ........ 3.00000
navghost ........ 1.00000

Contest Rules

CodeCall Goal

Goal: 100,000 Posts
Complete: 67%

Ads