Problem using other javascripts on index with CFI
 
 
Post new topic   Reply to topic   printer-friendly view    phpMiX.org Forum Index -> phpBB MODs -> DHTML Collapsible Forum Index
View previous topic :: View next topic  
Author Message
Robert Tetenman
Apprentice
Apprentice


Joined: 05 Dec 2004
Posts: 12

PostPosted: Fri Jan 21, 2005 4:23 pm    Post subject: Problem using other javascripts on index with CFI Reply with quote

Hi again,

I just want to say before I ask ths next question that despite the things I might want to change or customize, myself and my forum members really like CFI. It is one of the most handy functions (not a MOD really) added, especially for long forum lists and for members that selectively only visit or read particular categories or forums.

Now, on to my question. I first notice this problem as I tried t implement a few different javascripts. The first was a simple live clock. Once I added it the clock worked fine and so did everything else on the page, no error...BUT, the collapse and expand ( +, -) icons did not load. So I removed the clock because to me CFI was more important to have working.

Then at Christmas I wanted to install a little javascript that would make falling snowflakes appear on the page. The same problem occured. The snow script worked fine, the page was fine but no collapse/expand icons.

When I moved the script out of the header and to a specific page other than the index page the script worked fine, and then I backtracked some more and the clock script also worked fine on other pages.

So it would seem there is some conflict with adding other javascript to the page.

Is this something you are aware of? Is there some other way of adding or placing scripts to avoid this conflict?

If this is an isolated thing with just my site would it help you to see any portion of code?

Thanks,
Robert
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Fri Jan 21, 2005 5:56 pm    Post subject: Re: Problem using other javascripts on index with CFI Reply with quote

I tried to code the javascript of this MOD to avoid such conflicts with other javascripts.

One of the things is my code uses just one global variable: CFIG. So, another javascript could override this and break my MOD.

Another is the onload event of the page. I'm using this code:

Code:
function CFIG_onLoad()
{
   if( CFIG_oldOnLoad )
   {
      CFIG_oldOnLoad();
      CFIG_oldOnLoad = null;
   }
   if( CFIG && CFIG.IsEnabled() )
   {
      CFIG.restoreIndexState(CFIG.T['cookie']);
   }
}
var CFIG_oldOnLoad = window.onload;
window.onload = CFIG_onLoad;


So, my MOD will call any other onload event installed by others. However, another javascript could simply override the onload handler without taking into account old onload handlers, breaking my MOD and other javascripts in need of such resources.

The problem might come if other javascripts does not take into account this kind of things.

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Robert Tetenman
Apprentice
Apprentice


Joined: 05 Dec 2004
Posts: 12

PostPosted: Fri Jan 21, 2005 10:04 pm    Post subject: Re: Problem using other javascripts on index with CFI Reply with quote

Thanks or the response. My problem is that I don't know how to handle scripts and although I am sure your answer is a good one I just don't know what I can do with the information.

Can I show you the clock script, for instance ...will that tell you anything?

Thanks
Robert
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Fri Jan 21, 2005 10:20 pm    Post subject: Re: Problem using other javascripts on index with CFI Reply with quote

I do not have much time... being said that, post a link or something. I can try to see the reason.

.

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
MennoniteHobbit



Joined: 11 May 2004
Posts: 196
Location: Indiana, USA

PostPosted: Fri Jan 21, 2005 10:33 pm    Post subject: Re: Problem using other javascripts on index with CFI Reply with quote

If the problem is indeed, like markus said, dealing with another function called CFIG, then you should first back up the clock script, then edit the appropriate instances within the clock script, renaming the CFIG part with CLOCKCFIG or something. 
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Robert Tetenman
Apprentice
Apprentice


Joined: 05 Dec 2004
Posts: 12

PostPosted: Sat Jan 22, 2005 1:00 am    Post subject: Re: Problem using other javascripts on index with CFI Reply with quote

That does not seem to be the problem. Here is the clock script:
Code:
///////////////////////////////////////////////////////////
// "Live Clock Advanced" script - Version 1.0
// By Mark Plachetta (astroboy@zip.com.au)
//
// Get the latest version at:
// http://www.zip.com.au/~astroboy/liveclock/
//
// Based on the original script: "Upper Corner Live Clock"
// available at:
// - Dynamic Drive (http://www.dynamicdrive.com)
// - Website Abstraction (http://www.wsabstract.com)
// ========================================================
// CHANGES TO ORIGINAL SCRIPT:
// - Gave more flexibility in positioning of clock
// - Added date construct (Advanced version only)
// - User configurable
// ========================================================
// Both "Advanced" and "Lite" versions are available free
// of charge, see the website for more information on the
// two scripts.
///////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////
/////////////// CONFIGURATION /////////////////////////////

   // Set the clock's font face:
   var myfont_face = "";

   // Set the clock's font size (in point):
   var myfont_size = "";

   // Set the clock's font color:
   var myfont_color = "#000000";
   
   // Set the clock's background color:
   var myback_color = "";

   // Set the text to display before the clock:
   var mypre_text = "";

   // Set the width of the clock (in pixels):
   var mywidth = "";

   // Display the time in 24 or 12 hour time?
   // 0 = 24, 1 = 12
   var my12_hour = 1;

   // How often do you want the clock updated?
   // 0 = Never, 1 = Every Second, 2 = Every Minute
   // If you pick 0 or 2, the seconds will not be displayed
   var myupdate = 2;

   // Display the date?
   // 0 = No, 1 = Yes
   var DisplayDate = 0;

/////////////// END CONFIGURATION /////////////////////////
///////////////////////////////////////////////////////////

// Browser detect code
        var ie4=document.all
        var ns4=document.layers
        var ns6=document.getElementById&&!document.all

// Global varibale definitions:

   var dn = "";
   var mn = "th";
   var old = "";

// The following arrays contain data which is used in the clock's
// date function. Feel free to change values for Days and Months
// if needed (if you wanted abbreviated names for example).
   var DaysOfWeek = new Array(7);
      DaysOfWeek[0] = "Sunday";
      DaysOfWeek[1] = "Monday";
      DaysOfWeek[2] = "Tuesday";
      DaysOfWeek[3] = "Wednesday";
      DaysOfWeek[4] = "Thursday";
      DaysOfWeek[5] = "Friday";
      DaysOfWeek[6] = "Saturday";

   var MonthsOfYear = new Array(12);
      MonthsOfYear[0] = "January";
      MonthsOfYear[1] = "February";
      MonthsOfYear[2] = "March";
      MonthsOfYear[3] = "April";
      MonthsOfYear[4] = "May";
      MonthsOfYear[5] = "June";
      MonthsOfYear[6] = "July";
      MonthsOfYear[7] = "August";
      MonthsOfYear[8] = "September";
      MonthsOfYear[9] = "October";
      MonthsOfYear[10] = "November";
      MonthsOfYear[11] = "December";

// This array controls how often the clock is updated,
// based on your selection in the configuration.
   var ClockUpdate = new Array(3);
      ClockUpdate[0] = 0;
      ClockUpdate[1] = 1000;
      ClockUpdate[2] = 60000;

// For Version 4+ browsers, write the appropriate HTML to the
// page for the clock, otherwise, attempt to write a static
// date to the page.
   if (ie4||ns6) { document.write('<span id="LiveClockIE" style="width:'+mywidth+'px; background-color:'+myback_color+'"></span>'); }
   else if (document.layers) { document.write('<ilayer bgColor="'+myback_color+'" id="ClockPosNS" visibility="hide"><layer width="'+mywidth+'" id="LiveClockNS"></layer></ilayer>'); }
   else { old = "true"; show_clock(); }

// The main part of the script:
   function show_clock() {
      if (old == "die") { return; }
   
   //show clock in NS 4
      if (ns4)
                document.ClockPosNS.visibility="show"
   // Get all our date variables:
      var Digital = new Date();
      var day = Digital.getDay();
      var mday = Digital.getDate();
      var month = Digital.getMonth();
      var hours = Digital.getHours();

      var minutes = Digital.getMinutes();
      var seconds = Digital.getSeconds();

   // Fix the "mn" variable if needed:
      if (mday == 1) { mn = "st"; }
      else if (mday == 2) { mn = "nd"; }
      else if (mday == 3) { mn = "rd"; }
      else if (mday == 21) { mn = "st"; }
      else if (mday == 22) { mn = "nd"; }
      else if (mday == 23) { mn = "rd"; }
      else if (mday == 31) { mn = "st"; }

   // Set up the hours for either 24 or 12 hour display:
      if (my12_hour) {
         dn = "AM";
         if (hours > 12) { dn = "PM"; hours = hours - 12; }
         if (hours == 0) { hours = 12; }
      } else {
         dn = "";
      }
      if (minutes <= 9) { minutes = "0"+minutes; }
      if (seconds <= 9) { seconds = "0"+seconds; }

   // This is the actual HTML of the clock. If you're going to play around
   // with this, be careful to keep all your quotations in tact.
      myclock = '';
      myclock += '<font style="color:'+myfont_color+'; font-family:'+myfont_face+'; font-size:'+myfont_size+'pt;">';
      myclock += mypre_text;
      myclock += hours+':'+minutes;
      if ((myupdate < 2) || (myupdate == 0)) { myclock += ':'+seconds; }
      myclock += ' '+dn;
      if (DisplayDate) { myclock += ' on '+DaysOfWeek[day]+', '+mday+mn+' '+MonthsOfYear[month]; }
      myclock += '</font>';

      if (old == "true") {
         document.write(myclock);
         old = "die";
         return;
      }

   // Write the clock to the layer:
      if (ns4) {
         clockpos = document.ClockPosNS;
         liveclock = clockpos.document.LiveClockNS;
         liveclock.document.write(myclock);
         liveclock.document.close();
      } else if (ie4) {
         LiveClockIE.innerHTML = myclock;
      } else if (ns6){
         document.getElementById("LiveClockIE").innerHTML = myclock;
                }           

   if (myupdate != 0) { setTimeout("show_clock()",ClockUpdate[myupdate]); }
}
 
Back to top
View user's profile Send private message
markus
[Administrator]
[Administrator]


Joined: 28 Jul 2003
Posts: 1124

PostPosted: Sat Jan 22, 2005 1:32 am    Post subject: Re: Problem using other javascripts on index with CFI Reply with quote

I believe you have not posted all the code, anyway...

LiveClock seems to be at version 3.0, try it and see if that solves the problem.

http://www.zip.com.au/~astroboy/liveclock/

 
 
_________________
http://www.phpmix.org
 
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    phpMiX.org Forum Index -> phpBB MODs -> DHTML Collapsible Forum Index All times are GMT + 1 Hour
 
Page 1 of 1


 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum