Solved

Time is slipping through my hands!!

Posted on 2014-02-13
32
293 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 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