Page 1 of 1

Adding java script to templates?

Posted: Mon 28 Mar 2011 4:31 pm
by christer
Hello, I have installed Piwik Webanalyzer (http://piwik.org/) on my server. And this need taht some java script is in the html code to send usage of a certian page to Piwik.
However, I tried to add this script to the template "gaugesT.htm, but it seems that Cumules stripp out this script when uploading.
What to do? I vant to see how many (and often) my weather site is visited.
Here is the script (note that MY_SITE.se is an example):
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://MY_SITE.se/piwik/" : "http://MY_SITE.se/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://mfkjupiter.se/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->


Regards
Christer in Sweden

Re: Adding java script to templates?

Posted: Mon 28 Mar 2011 4:38 pm
by steve
Cumulus doesn't strip anything out of the files, javascript or otherwise. In fact, the standard gaugesT.htm file has javascript in it. I think that perhaps you have edited the wrong file, or made some other error. If you attach your edited file, I'll have a look.

Re: Adding java script to templates?

Posted: Mon 28 Mar 2011 6:09 pm
by christer
Hello Steve!
Here is my template:

Re: Adding java script to templates?

Posted: Mon 28 Mar 2011 7:07 pm
by steve
Works fine for me; here's the start of the processed file:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" src="wz_jsgraphics.js" type="text/javascript"></script>

<meta name="description" content="Test weather data">
<meta name="keywords" content="Cumulus, Test weather data, weather, data, weather station">
<title>Test weather</title>

<link href="weatherstyle.css" rel="stylesheet" type="text/css">
</head>

<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://mfkjupiter.se/piwik/" : "http://mfkjupiter.se/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));

</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script><noscript><p><img src="http://mfkjupiter.se/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->

<body>
<div id=content>
<h1>Test väder</h1>
<h2 style="text-align: left; text-transform: none;">&nbsp;Latitude&nbsp;N&nbsp;59&deg;&nbsp;06'&nbsp;02"&nbsp;&nbsp;&nbsp;&nbsp;Longitude&nbsp;W&nbsp;02&deg;&nbsp;11'&nbsp;23"&nbsp;&nbsp;&nbsp;&nbsp;Höjd 
ö.h.&nbsp;15&nbsp;ft</h2>

<p></p>
So I think you're doing something wrong, but I can't think what it would be (other than editing the wrong file, or looking at the wrong output file). The gauges.htm file you attached; that came from your PC, yes?

I don't think you want to be putting your code in 'no man's land' neither in the <head> nor the <body>, by the way; perhaps that's your problem. But Cumulus will process the file anyway; it doesn't understand HTML.

Re: Adding java script to templates?

Posted: Tue 29 Mar 2011 4:35 am
by christer
Thank you Steve!
Problem solved. Cumulus is running on a remote PC on another location. On that PC:s desktop I had a folder named Web. I thaugt that this was a shortcut o the folder inside Cumulus. Now it is. So I edited a backup file.
Everything works fine now.

Thank´s for your attension!
Christer