Solved

Time is slipping through my hands!!

Posted on 2014-02-13
32
280 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 32

Expert Comment

by:Big Monty
Comment Utility
nice title :)

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

Author Comment

by:gpchicago08
Comment Utility
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 32

Expert Comment

by:Big Monty
Comment Utility
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
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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
Comment Utility
<%
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
Comment Utility
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
Comment Utility
<%
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 32

Expert Comment

by:Big Monty
Comment Utility
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
Comment Utility
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
Comment Utility
2 heads are better than one!!!
0
 

Author Comment

by:gpchicago08
Comment Utility
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
Comment Utility
Is it DNN?  Can you provide a link to the page?  What options can you enter in the CMS?
0
 

Author Comment

by:gpchicago08
Comment Utility
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
Comment Utility
>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
Comment Utility
The funny thing is it do this only with IE9 (tested with compatibility mode...)
Not IE9- and IE9+...
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 82

Expert Comment

by:leakim971
Comment Utility
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
Comment Utility
So, all I have to do is replace the whole calctime() function with yours?
0
 
LVL 82

Expert Comment

by:leakim971
Comment Utility
yes
0
 

Author Comment

by:gpchicago08
Comment Utility
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
Comment Utility
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
Comment Utility
A drink ? A coffee ? I take the next plane to Chicago !
commonjs.txt
0
 

Author Comment

by:gpchicago08
Comment Utility
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
Comment Utility
I retrieve it from your FTP using the ultimate password !

>:o)
0
 

Author Comment

by:gpchicago08
Comment Utility
can you elaborate?

I would like to fix this if I can.

Oh - and BTW - your commonjs worked!!
0
 

Author Comment

by:gpchicago08
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks for the clarification.
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
>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
Comment Utility
leakim971 is the JS rockstar
0
 

Author Comment

by:gpchicago08
Comment Utility
The other concerns you mentioned earlier?
0
 

Author Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
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 style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

762 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now