Welcome, Guest. Please login or register.
Did you miss your activation email?


Login with username, password and session length

Search

 
Advanced search

8026 Posts in 1851 Topics- by 2099 Members - Latest Member: roi
Calendar Script CommunityCustomizationCustomizing CalendarScript (Moderators: scott, DanO, Marty)Javascript / comment technique not passed from template
Pages: [1]   Go Down
Print
Author Topic: Javascript / comment technique not passed from template  (Read 1197 times)
0 Members and 1 Guest are viewing this topic.
BrianP
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« on: November 27, 2001, 02:12:00 PM »

I have a website that uses javascript for support of some navigation menus. I put the Javascript (As do many others) within comment tags. When I use this technique in a template and then view the calendar my javascript code is not passed. Temporarily I have removed the comment tags from the template and the script is then passed. You can see an example of my code at http://www.lansdalepca.org/  click the calendar link to see how I intigrated your calendar.

Thank you for a great product. A check will be in the mail shortly!

Brian

Logged
BrianP2
Guest
« Reply #1 on: November 29, 2001, 04:30:00 PM »

For the benifit of others I will post your question and my response on the support board.

Anyway - I am not really a coder. I was just intigrating the calendar into a site somone else designed. So, as far as your code is concerned I cannot comment. What I can offer is this. 1 - Does your code work properly in a regular web page? 2 - are you inserting it in the right place in the correct template? Notice my Javascript is after the <STYLE> section, I don't know if this matters. I'm pretty sure it does matter that the javascript code is in the <HEAD> section. Keep in mind to that this template gets read by Perl which generated the .html the user sees. I would suspect (Being a non-coder) that if you have a variable or something that conflicts with some of the code Perl expects you could also have a problem. Also - What is with these references?  file://v3.0 They don't look right to me. Did you write this or did some tool, like Front Page, create it?

By the way, Seems like you are trying to do a similar thing as me, feel free to use my code instead.

Here is a spippet of my default template
<HTML><layer top="0" left="0">
<HEAD>
   <TITLE>Lansdale Presbyterian Church Calendar</TITLE>

<META HTTP-EQUIV="expires" CONTENT="now">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">

<STYLE>
A { text-decoration:none; }
A:hover { text-decoration:underline; }
.thinborder { border-color:#666666; border-style:solid; border-width:1px; }
.columnheader { color:<%=$_COLUMN_HEADER_TEXT_COLOR%>; }
.navigationtext { color:<%=$_NAVIGATION_TEXT_COLOR%>; }
.navigationselectedtext { color:<%=$_NAVIGATION_SELECTED_TEXT_COLOR%>; }
.commandtext { color:<%=$_COMMAND_OPTION_TEXT_COLOR%>; }
.gridtext { color:<%=$_GRID_CELL_TEXT_COLOR%>; }
.griddatetext { color:<%=$_GRID_DATE_TEXT_COLOR%>; }
.footertext { color:<%=$_FOOTER_TEXT_COLOR%>; }
.text { color:<%=$_TEXT_COLOR%>; }
</STYLE>
<script language='Javascript'>

 var browser = navigator.userAgent.substring(0,7); var version = parseInt(navigator.userAgent.substring(8,9));
 if ((browser == 'Mozilla') && (version >= 3)) {
   normal = new makeArray(9); hilite = new makeArray(9);
   for (var i = 1; i<=9; i++) {normal.src = '../images/menu'+i+'a.gif'; hilite.src = '../images/menu'+i+'b.gif';}}
 function makeArray(n) {this.length = n; for (var i = 1; i<=n; i++) {this = new Image();} return this;}
 function onImage(num) {if ((browser == 'Mozilla') && (version >= 3)) {document.images[num+2].src = hilite[num].src;}}
 function offImage(num) {if ((browser == 'Mozilla') && (version >= 3)) {document.images[num+2].src = normal[num].src;}}

</script>
</HEAD>

-----Original Message-----

> I like how you intergrated the Calendar with your
> website.  I'm having trouble integrating javascript
> with the calendar template.  I've seen your post and
> that you are using javascript by not including the
> comment tags.  I've not been able to do this.  Here's
> what I've been trying.
>
> My Code looks like this:
>
> <script language="JavaScript">
> <!--
> function MM_preloadImages() { file://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.indexOf("#")!=0){ d.MM_p[j]=new Image;
> d.MM_p[j++].src=a;}}
> }
>
> function MM_findObj(n, d) { file://v4.0
>   var p,i,x;  if(!d) d=document;
> if((p=n.indexOf("?"))>0&&parent.frames.length) {
>     d=parent.frames[n.substring(p+1)].document;
> n=n.substring(0,p);}
>   if(!(x=d[n])&&d.all) x=d.all[n]; for
> (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
>   for(i=0;!x&&d.layers&&i<d.layers.length;i++)
> x=MM_findObj(n,d.layers.document);
>   if(!x && document.getElementById)
> x=document.getElementById(n); return x;
> }
>
> function MM_nbGroup(event, grpName) { file://v3.0
>   var i,img,nbArr,args=MM_nbGroup.arguments;
>   if (event == "init" && args.length > 2) {
>     if ((img = MM_findObj(args[2])) != null &&
> !img.MM_init) {
>       img.MM_init = true; img.MM_up = args[3];
> img.MM_dn = img.src;
>       if ((nbArr = document[grpName]) == null) nbArr =
> document[grpName] = new Array();
>       nbArr[nbArr.length] = img;
>       for (i=4; i < args.length-1; i+=2) if ((img =
> MM_findObj(args)) != null) {
>         if (!img.MM_up) img.MM_up = img.src;
>         img.src = img.MM_dn = args[i+1];
>         nbArr[nbArr.length] = img;
>     } }
>   } else if (event == "over") {
>     document.MM_nbOver = nbArr = new Array();
>     for (i=1; i < args.length-1; i+=3) if ((img =
> MM_findObj(args)) != null) {
>       if (!img.MM_up) img.MM_up = img.src;
>       img.src = (img.MM_dn && args[i+2]) ? args[i+2] :
> args[i+1];
>       nbArr[nbArr.length] = img;
>     }
>   } else if (event == "out" ) {
>     for (i=0; i < document.MM_nbOver.length; i++) {
>       img = document.MM_nbOver; img.src =
> (img.MM_dn) ? img.MM_dn : img.MM_up; }
>   } else if (event == "down") {
>     if ((nbArr = document[grpName]) != null)
>       for (i=0; i < nbArr.length; i++) { img=nbArr;
> img.src = img.MM_up; img.MM_dn = 0; }
>     document[grpName] = nbArr = new Array();
>     for (i=2; i < args.length-1; i+=2) if ((img =
> MM_findObj(args)) != null) {
>       if (!img.MM_up) img.MM_up = img.src;
>       img.src = img.MM_dn = args[i+1];
>       nbArr[nbArr.length] = img;
>   } }
> }
> file://-->
> </script>
>
> I try to take out the comments and I think it should
> look like this:
>
> <script language="JavaScript">
>
> function MM_preloadImages() { file://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.indexOf("#")!=0){ d.MM_p[j]=new Image;
> d.MM_p[j++].src=a;}}
> }
>
> function MM_findObj(n, d) { file://v4.0
>   var p,i,x;  if(!d) d=document;
> if((p=n.indexOf("?"))>0&&parent.frames.length) {
>     d=parent.frames[n.substring(p+1)].document;
> n=n.substring(0,p);}
>   if(!(x=d[n])&&d.all) x=d.all[n]; for
> (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
>   for(i=0;!x&&d.layers&&i<d.layers.length;i++)
> x=MM_findObj(n,d.layers.document);
>   if(!x && document.getElementById)
> x=document.getElementById(n); return x;
> }
>
> function MM_nbGroup(event, grpName) { file://v3.0
>   var i,img,nbArr,args=MM_nbGroup.arguments;
>   if (event == "init" && args.length > 2) {
>     if ((img = MM_findObj(args[2])) != null &&
> !img.MM_init) {
>       img.MM_init = true; img.MM_up = args[3];
> img.MM_dn = img.src;
>       if ((nbArr = document[grpName]) == null) nbArr =
> document[grpName] = new Array();
>       nbArr[nbArr.length] = img;
>       for (i=4; i < args.length-1; i+=2) if ((img =
> MM_findObj(args)) != null) {
>         if (!img.MM_up) img.MM_up = img.src;
>         img.src = img.MM_dn = args[i+1];
>         nbArr[nbArr.length] = img;
>     } }
>   } else if (event == "over") {
>     document.MM_nbOver = nbArr = new Array();
>     for (i=1; i < args.length-1; i+=3) if ((img =
> MM_findObj(args)) != null) {
>       if (!img.MM_up) img.MM_up = img.src;
>       img.src = (img.MM_dn && args[i+2]) ? args[i+2] :
> args[i+1];
>       nbArr[nbArr.length] = img;
>     }
>   } else if (event == "out" ) {
>     for (i=0; i < document.MM_nbOver.length; i++) {
>       img = document.MM_nbOver; img.src =
> (img.MM_dn) ? img.MM_dn : img.MM_up; }
>   } else if (event == "down") {
>     if ((nbArr = document[grpName]) != null)
>       for (i=0; i < nbArr.length; i++) { img=nbArr;
> img.src = img.MM_up; img.MM_dn = 0; }
>     document[grpName] = nbArr = new Array();
>     for (i=2; i < args.length-1; i+=2) if ((img =
> MM_findObj(args)) != null) {
>       if (!img.MM_up) img.MM_up = img.src;
>       img.src = img.MM_dn = args[i+1];
>       nbArr[nbArr.length] = img;
>   } }
> }
>
> </script>
>
> Is this right?  Any advise would be great!
>
> Thanks a bunch,
> Justin

Logged
Scott
Guest
« Reply #2 on: November 29, 2001, 04:36:00 PM »

The template-processor actually removes all comments from the final template. So, if your javascript is embedded in comment tags, it will get stripped out.

If you look under calendarscript/lib/asp.inc you'll find these lines:

       # Take out all comments
       $template =~ s/<!--.*?-->//mgs;

You can comment that out to stop comments from being removed. I'll consider doing this for future releases, to avoid problems  

------------------
Scott
CalendarScript.com


Logged
newsgirl
Guest
« Reply #3 on: April 16, 2002, 06:22:00 PM »

So this is why my navigation header doesn't work!

How does one "comment out" those lines to stop comments from being removed?

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 221

Please don't PM me. Post in the open forum.


WWW
« Reply #4 on: April 16, 2002, 06:45:00 PM »

 
quote:
How does one "comment out" those lines to stop comments from being removed?

If I'm not mistaken, Matt changed that in version 3.1 so HTML comments in the template file now remain in the calendar's output. If you are still using 3.0, upgrade.

Dan O.

------------------

[This message has been edited by DanO (edited April 16, 2002).]

Logged
newsgirl
Guest
« Reply #5 on: April 17, 2002, 08:29:00 AM »

But I have version 3.1! I just started testing the script this month.

I have the javascript part below the style section between the head tags.

I have the images paths in the body and the images themselves in a folder outside the cgi-bin.

But the calendar appears as though I didn't modify the template file.

Hopefully it'll work when I try it without the comment tags.

Logged
UnleasheD
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #6 on: October 02, 2003, 01:10:00 PM »

Seems I am having the same sort of problem. In config.txt, I have a <script> reference in the <head> section pointing outside of the cgi-bin and I can't seem to get it to work.  So I tried to use an include <!--include file="file.html"--> and that didnt work either.  I can get lines and lines of html and even dhtml expressions to work but that one line pointing to the javascript in another directory isn't working.  

This doesn't work:
template_preference_default_header=<head><script type="text/javascript" language="JavaScript1.2" src="stm31.js"></script></head><body> blah blah blah

Neither does this:
template_preference_default_header=<!--include file="file.html"-->

The header that I would like is the header I use for the entire site. I would like to avoid using frames to load the calendar in to.

Can anyone help please?
Thanks!

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 221

Please don't PM me. Post in the open forum.


WWW
« Reply #7 on: October 02, 2003, 07:33:00 PM »

** This doesn't work:
template_preference_default_header=<head><script type="text/javascript" language="JavaScript1.2" src="stm31.js"></script> **

Where is the stm31.js file located in your directory structure? If in the web root directory, try using src="/stm31.js"

Modify the path accordingly from the root if elsewhere.

Dan O.

BTW. Isn't the <head> tag already printed by the script??

[This message has been edited by DanO (edited October 02, 2003).]

Logged
UnleasheD
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #8 on: October 03, 2003, 09:58:00 AM »

DanO,

Thanks for the reply.

To answer your question, yes. I have tried two things.  First I specified src="http://www.traconline.com/stm31.js" as well as copying stm31.js to the calendars/default/ directory where the default config for the calendar is.

The funny thing about this script is it requires the declaration initially to be in the <head>.  

Thanks

-UnleasheD

------------------

Logged
DanO
Moderator
Full Member
*****

Karma: 13
Offline Offline

Posts: 221

Please don't PM me. Post in the open forum.


WWW
« Reply #9 on: October 03, 2003, 01:52:00 PM »

** If in the web root directory, try using src="/stm31.js" **

Did you notice the leading "/" in my previous suggestion?

** it requires the declaration initially to be in the <head>. **

Then you may need to edit the default.html template file and add the JavaScript tag in the appropriate place there (while using the correct path to the file).

Dan O.

------------------

Logged
UnleasheD
New Member
*

Karma: 0
Offline Offline

Posts: 0


WWW
« Reply #10 on: October 07, 2003, 01:06:00 PM »

I found out what the source of my problem was with your help!  What I was doing was trying to use html elements that were already in the default.html file. So I moved all of my html and script references out of config.txt. Upon doing so, I removed the header information. So now it wouldn't print a header at all and for some reason my template didnt print anything either. So I put an empty <p></p> in the config.txt under template_preference_default_header to look exactly like this

template_preference_default_header=<p></p>

This helped tremendously because the header printed and everything is great!

Thanks Dan0 for all your help. You pointed me in the right direction.

-UnleasheD

------------------

Logged
Pages: [1]   Go Up
Print
Jump to: