Link to home
Start Free TrialLog in
Avatar of gpchicago08
gpchicago08

asked on

Time is slipping through my hands!!

We have a portion of our website that is acting weird.  The time seems to get parsed in IE versus FFOX or Safari.  Funny thing is this parsing doesn't occur at the end of the text string.  Please see the attached images from IE and FFOX.
MSIE--BAD.jpg
FFOX--GOOD.jpg
Avatar of Big Monty
Big Monty
Flag of United States of America image

nice title :)

can we see some code that writes out that line of html?
Avatar of gpchicago08
gpchicago08

ASKER

Thanks ;-p

I'm not very adept at HTML but I think it could be this:

<script language="javascript">
var serverStartTime = new Date(Date.parse("Thu Feb 13 2014 07:50:53"));
var offset = 1
serverStartTime.setTime(serverStartTime.getTime() + offset * 60 * 60 * 1000);
currenttime = serverStartTime;
calctime();
</script> 

Open in new window


I don't know what file to look for the calctime() function.
it looks like you're going to need to dig around for that function, the code you posted doesn't format the time to whats showing.  without the actual code, I can't help you.
Is there a reason you can't just do this in asp?  You will have more control over how it is sent to the browser since the html is created before the browser loads.
<%
currentTime=now()
iDay=day(currentTime)
iMonth=MonthName(month(currentTime))
iYear=left(year(currentTime),2)
iTime=formatDateTime(currentTime)
fullDate= iDay&" "&iMonth&" "&iYear&" "&iTime

response.write fullDate
%>

Open in new window

By your comment, I'm guessing we can use asp.  I just don't know how to code it.  This is a very old website that was jerry-rigged a few years ago to remove flash.  Now I'm looking into the remaining thorns.

This is a functioning clock - it counts seconds.


OOOPS.  I posted after you posted time code.  I will try to find our code.
<%
function makeTime()
currentTime=now()
iDay=day(currentTime)
iMonth=MonthName(month(currentTime))
iYear=left(year(currentTime),2)
iTime=formatDateTime(currentTime)
fullDate= iDay&" "&iMonth&" "&iYear&" "&iTime
makeTime= fullDate
end function
%>

<span id="timer"><%=makeTime%></span>

Open in new window

I'm going to step back and let Scott finish helping you, as no doubt we would both come up with similar, if not the same, answers, and I don't want to confuse you.

Scott, it looks like there's an offset value being added to the hour, I'm guessing they're trying to display EST when they're in another time zone, so make sure you add 1 to your hour when calculating it
If you need a clock that moves and shows real time... check these out


http://momentjs.com/  (very cool)

http://keith-wood.name/timeEntry.html (an old stand by)

http://flipclockjs.com/
2 heads are better than one!!!
I'm giving up.  This is an old CMS style system that has been beat on.  I can find most templates and modules but I cannot find this line.  AND I don't know how to change it...
Is it DNN?  Can you provide a link to the page?  What options can you enter in the CMS?
www.gpchicago.com

I don't know what CMS it is.  Probably at or over 10yrs old.

The CMS doesn't work with any of this new HTML.  It was controlling a lot of flash info.
>CMS doesn't work with any of this new HTML

There are a number of things wrong besides the js.  For one, this seems to be a mix of html5 and html4.  The doc type is set for <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> and the coding appears to be html5.

Because I have added the javascript topic, that should bring in some other experts more versed in js.  I ran the js code through jslint and uncovered some possible issues.  

The direction I was heading before with serverside asp was wrong for this type of clock
The funny thing is it do this only with IE9 (tested with compatibility mode...)
Not IE9- and IE9+...
Inside commonjs.asp

We have :
function calctime()
{
if(typeof(currenttime) == "undefined")
	return;
currenttime.setTime(currenttime.getTime() + 1000);

//define array with month names
var monthname=new Array("january","february","march","april","may","june","july","august", "september","october","november","december");

var days = currenttime.getDate();
var months = currenttime.getMonth();
var years =  String(currenttime.getYear());
var ns = (navigator.appName.indexOf("Netscape") != -1);

var hours = currenttime.getHours();
var minutes = currenttime.getMinutes();
var seconds = currenttime.getSeconds();
var timesuffix = "am";
if (hours > 11)
{
timesuffix = "pm";
hours = hours - 12;
}
if (hours == 0)
{
hours = 12;
}
if (hours < 10)
{
hours = "0" + hours;
}
if (minutes < 10)
{
minutes = "0" + minutes;
}
if (seconds < 10)
{
seconds = "0" + seconds;
}
//extract the month name from the array
months = monthname[months];
if (ns) {
years = years.substr(1,2)
} else {
years = years.substr(2,2)
}
var clocklocation = document.getElementById('timer');
if(null != clocklocation)
{
	clocklocation.innerHTML = days+"  "+months+"  "+years+" &nbsp; &nbsp; "+ hours + ":" + minutes + ":" + seconds + " " + timesuffix;
}
setTimeout("calctime()", 1000);
}

Open in new window


replace it by (check line 12 and line 35) :
function calctime() {
	if(typeof(currenttime) == "undefined") {
		return;
	}
	currenttime.setTime(currenttime.getTime() + 1000);

	//define array with month names
	var monthname=new Array("january","february","march","april","may","june","july","august", "september","october","november","december");

	var days = currenttime.getDate();
	var months = currenttime.getMonth();
	var years = currenttime.getFullYear();

	var hours = currenttime.getHours();
	var minutes = currenttime.getMinutes();
	var seconds = currenttime.getSeconds();
	var timesuffix = "am";
	if (hours > 11) {
		timesuffix = "pm";
		hours = hours - 12;
	}

	var d2 = function(n) {
		return n*1>9?n:"0"+n;
	}

	if (hours == 0) {
		hours = 12;
	}
	hours = d2(hours);
	minutes = d2(minutes);
	seconds = d2(seconds);
	//extract the month name from the array
	months = monthname[months];
	years = (""+years).substr(2,2); // remove this line if you want to display the four number for the year
	var clocklocation = document.getElementById('timer');
	if(null != clocklocation) {
		clocklocation.innerHTML = days+"  "+months+"  "+years+" &nbsp; &nbsp; "+ hours + ":" + minutes + ":" + seconds + " " + timesuffix;
	}
	setTimeout("calctime()", 1000);
}

Open in new window

So, all I have to do is replace the whole calctime() function with yours?
Now, after opening my common.js file, I'm seeing brackets that aren't closed.

I can't seem to figure out which is which.

Can you please review it if I post the whole common.js?

Aside from the points, I'd buy you a drink/coffee if you were in Chicago.  heehee.
I think the screw up is here somewhere.  Forgive me, I don't know js that well...

Any help would be appreciated!

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.....

hmmmmm....


On a somewhat side note....

How do you have access to view this file? (forgive my ignorance)
I retrieve it from your FTP using the ultimate password !

>:o)
can you elaborate?

I would like to fix this if I can.

Oh - and BTW - your commonjs worked!!
Does anyone else think this unauthorized access is creepy?  I'm trying to figure out what to do about it.
there's no fail in your web server
anyone can load the rendered page, javascript, images, resources just because your web browser download them to build and display the page.

you can start by do a right click on a page and choose view source or, if available, click on inspect element.

there's so much thing to say about this... I did not come on your question to talk about this, I apologize.
Thanks for the clarification.
>Does anyone else think this unauthorized access is creepy?

He was joking!  If you view the source of your html file online, it shows the links to your css, js and images.  Those are all surfable (is that  a word?).  They are very easily viewed.  Your javascript runs on the client (the browser of the person viewing).  This means whatever you put in  your javascript should not be sensitive data.  Primarily you  use javascript for things like front end math calculations, moving things around the browser, timers etc.    Anything that has to do with a password and sensitive data should be done over ssl and handled by your serverside language. In this case, it is your asp code.

Nothing to worry about for THAT, but there are other concerns with the site.
leakim971 is the JS rockstar
The other concerns you mentioned earlier?
hey leakim971
I've got another challenge for you in this new question.