Solved

Time is slipping through my hands!!

Posted on 2014-02-13
32
292 Views
Last Modified: 2014-02-13
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
0
Comment
Question by:gpchicago08
  • 13
  • 9
  • 6
  • +1
32 Comments
 
LVL 33

Expert Comment

by:Big Monty
ID: 39856205
nice title :)

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

Author Comment

by:gpchicago08
ID: 39856216
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
 
LVL 33

Expert Comment

by:Big Monty
ID: 39856270
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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39856288
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39856307
<%
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
 

Author Comment

by:gpchicago08
ID: 39856310
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39856314
<%
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
 
LVL 33

Expert Comment

by:Big Monty
ID: 39856329
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39856337
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39856342
2 heads are better than one!!!
0
 

Author Comment

by:gpchicago08
ID: 39856385
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39856529
Is it DNN?  Can you provide a link to the page?  What options can you enter in the CMS?
0
 

Author Comment

by:gpchicago08
ID: 39856674
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39856860
>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
 
LVL 82

Expert Comment

by:leakim971
ID: 39856949
The funny thing is it do this only with IE9 (tested with compatibility mode...)
Not IE9- and IE9+...
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39856968
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
 

Author Comment

by:gpchicago08
ID: 39857227
So, all I have to do is replace the whole calctime() function with yours?
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39857297
yes
0
 

Author Comment

by:gpchicago08
ID: 39857305
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
 

Author Comment

by:gpchicago08
ID: 39857335
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
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39857348
A drink ? A coffee ? I take the next plane to Chicago !
commonjs.txt
0
 

Author Comment

by:gpchicago08
ID: 39857353
Thanks.....

hmmmmm....


On a somewhat side note....

How do you have access to view this file? (forgive my ignorance)
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39857363
I retrieve it from your FTP using the ultimate password !

>:o)
0
 

Author Comment

by:gpchicago08
ID: 39857375
can you elaborate?

I would like to fix this if I can.

Oh - and BTW - your commonjs worked!!
0
 

Author Comment

by:gpchicago08
ID: 39857576
Does anyone else think this unauthorized access is creepy?  I'm trying to figure out what to do about it.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 39857592
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
 

Author Comment

by:gpchicago08
ID: 39857600
Thanks for the clarification.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39857620
>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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 39857624
leakim971 is the JS rockstar
0
 

Author Comment

by:gpchicago08
ID: 39857626
The other concerns you mentioned earlier?
0
 

Author Comment

by:gpchicago08
ID: 39857672
hey leakim971
I've got another challenge for you in this new question.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question