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
gpchicago08Asked:
Who is Participating?
 
leakim971PluritechnicianCommented:
A drink ? A coffee ? I take the next plane to Chicago !
commonjs.txt
0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
nice title :)

can we see some code that writes out that line of html?
0
 
gpchicago08Author Commented:
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.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
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.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
<%
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

0
 
gpchicago08Author Commented:
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.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
<%
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

0
 
Big MontySenior Web Developer / CEO of ExchangeTree.org Commented:
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
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
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/
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
2 heads are better than one!!!
0
 
gpchicago08Author Commented:
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...
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
Is it DNN?  Can you provide a link to the page?  What options can you enter in the CMS?
0
 
gpchicago08Author Commented:
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.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
>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
0
 
leakim971PluritechnicianCommented:
The funny thing is it do this only with IE9 (tested with compatibility mode...)
Not IE9- and IE9+...
0
 
leakim971PluritechnicianCommented:
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

0
 
gpchicago08Author Commented:
So, all I have to do is replace the whole calctime() function with yours?
0
 
leakim971PluritechnicianCommented:
yes
0
 
gpchicago08Author Commented:
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.
0
 
gpchicago08Author Commented:
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

0
 
gpchicago08Author Commented:
Thanks.....

hmmmmm....


On a somewhat side note....

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

>:o)
0
 
gpchicago08Author Commented:
can you elaborate?

I would like to fix this if I can.

Oh - and BTW - your commonjs worked!!
0
 
gpchicago08Author Commented:
Does anyone else think this unauthorized access is creepy?  I'm trying to figure out what to do about it.
0
 
leakim971PluritechnicianCommented:
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.
0
 
gpchicago08Author Commented:
Thanks for the clarification.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
>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.
0
 
Scott Fell, EE MVEDeveloper & EE ModeratorCommented:
leakim971 is the JS rockstar
0
 
gpchicago08Author Commented:
The other concerns you mentioned earlier?
0
 
gpchicago08Author Commented:
hey leakim971
I've got another challenge for you in this new question.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.