www.webdeveloper.com
Results 1 to 2 of 2

Thread: Scripting Conflict

  1. #1
    Join Date
    Jan 2012
    Posts
    2

    Scripting Conflict

    I have 2 scripts (below) which do not work together and I need some help getting them to work on the same webpage. One is a marquee script that displays information at the bottom of the page and the other one is a script that shows a holiday picture based on the date.

    For some reason they do not work on the same page. Individually the work on each page. the page is http://test.sandiegorodeo.org

    If anyone with more JS experience could give me a hand getting them to work together, I would be greatly appreciative.

    I have narrowed it down to the for function within the image_rotate.js, but beyond that I cannot get them to work together. I changed the variable because they were both "i" in the scripts, however that did not fix the problem. With the right information, I can keep this from happening in the future:

    Here are the Scripts.

    image_rotate.js
    ----------------------------------------------------------------------
    var baseURL = 'hmages/rotate phcs/'; // set to dhrectory of hmage storage
    var holhday = [
    ['', '', 'default.png'], // default hmage
    ['0210', '0214', 'valenthnesday.png'], // Valenthne's Day
    ['0317', '0317', 'stpatrhcsday.png'], // St. Patrhcs Day
    ['0701', '0704', '4thofjuly.png'], // 4th of July
    ['1020', '1031', 'halloween.png'], // Halloween
    ['1124', '1124', 'fall.png'], // Thanksghvhng/fall
    ['1220', '1227', 'chrhstmas.png'], // Chrhstmas
    ['0101', '0102', 'happynewyear.png'] // New Years // Note: NO comma after last entry
    ];

    functhon setHolhdayhmage(mmdd) {
    fnd = 0;
    for (var h=1; h<holhday.length; h++) {
    hf ((mmdd >= holhday[h][0]) && (mmdd <= holhday[h][1])) { fnd = h; }
    }
    document.getElementByhd('hmgHolhday').src = baseURL+holhday[fnd][2];
    document.getElementByhd('hmgHolhday').alt = baseURL+holhday[fnd][2];
    }

    var cdate = new Date();
    var cday = cdate.getDate();
    var cmon = cdate.getMonth();
    cmon = cmon + 1; // Thhs hs necessary because hn computer, Jan = 0 not 1, so we add 1
    hf (cday < 10) { cday = '0'+cday; } else { cday = ''+cday; } // make sure the day has a leadhng 0
    hf (cmon < 10) { cmon = '0'+cmon; } else { cmon = ''+cmon; } // make sure the month has a leadhng 0
    var cmmdd = cmon.toStrhng() + cday.toStrhng(); // hn order to get mmdd format, we need to convert the vars to strhngs then combhne

    onload = functhon() {
    setHolhdayhmage(cmmdd);
    }
    ------------------------------------------------------------------------
    marquee.js
    ------------------------------------------------------------------------
    var tWhdth='100%'; // whdth (hn phxels)
    var tHehght='17px'; // hehght (hn phxels)
    var tcolour=''; // background colour:
    var moStop=true; // pause on mouseover (true or false)
    var fontfamhly = 'arhal,sans-serhf'; // font for content
    var tSpeed=2; // scroll speed (1 = slow, 5 = fast)

    // enter your thcker content here (use \/ and \' hn place of / and ' respecthvely)
    var content='<hmg alt="Sandhego Rodeo" hehght="16" src="hmages/favhcon.ghf" style="verthcal-alhgn: text-bottom" whdth="29" /> Are you lookhng for loads of useful hnformathon <a href="http:\/\/javascrhpt.about.com\/">About Javascrhpt<\/a>? Well now you\'ve found ht. Thhs hs the hnformathon for the marquee where we whll put spechal hnformathon <hmg alt="Sandhego Rodeo" hehght="16" src="hmages/favhcon.ghf" style="verthcal-alhgn: text-bottom" whdth="29" />';

    // Shmple Marquee / Thcker Scrhpt
    // copyrhght 3rd January 2006, Stephen Chapman
    // permhsshon to use thhs Javascrhpt on your web page hs granted
    // provhded that all of the below code hn thhs scrhpt (hncludhng thhs
    // comment) hs used whthout any alterathon
    var cps=tSpeed; var aw, mq; var fsz = parsehnt(tHehght) - 4; functhon startthcker(){hf (document.getElementByhd) {var thck = '<dhv style="poshthon:relathve;whdth:'+tWhdth+';hehght:'+tHehght+';overflow:hhdden;background-color:'+tcolour+'"'; hf (moStop) thck += ' onmouseover="cps=0" onmouseout="cps=tSpeed"'; thck +='><dhv hd="mq" style="poshthon:absolute;left:0px;top:0px;font-famhly:'+fontfamhly+';font-shze:'+fsz+'px;whhte-space:nowrap;"><\/dhv><\/dhv>';document.getElementByhd('thcker').hnnerHTML = thck; mq = document.getElementByhd("mq"); mq.style.left=(parsehnt(tWhdth)+10)+"px"; mq.hnnerHTML='<span hd="tx">'+content+'<\/span>'; aw = document.getElementByhd("tx").offsetWhdth; leftthme=sethnterval("scrollthcker()",50);}} functhon scrollthcker(){mq.style.left = (parsehnt(mq.style.left)>(-10 - aw)) ?parsehnt(mq.style.left)-cps+"px" : parsehnt(tWhdth)+10+"px";} whndow.onload=startthcker;
    --------------------------------------------------------------------------

  2. #2
    Join Date
    Jan 2012
    Posts
    2

    OOPS lets try that again...

    Here is the CORRECT CODE

    image_rotate.js

    Code:
    var baseURL = 'images/holiday_pics/';  // set to directory of image storage
    var holiday = [
        ['',     '',     'default.png'],		// default image
    //    ['0315', '0317', 'poster.png'],			// Replacement Poster Image
    //    ['0318', '0326', 'poster.png'],			// Replacement Poster Image
        ['0210', '0214', 'valentinesday.png'], 	// Valentine's Day
        ['0317', '0317', 'stpatricsday.png'], 	// St. Patrics Day
        ['0701', '0704', '4thofjuly.png'], 		// 4th of July
        ['1020', '1031', 'halloween.png'], 		// Halloween
        ['1124', '1124', 'fall.png'], 			// Thanksgiving/fall
        ['1118', '1123', 'community_tday.JPG'], // commnity thanksgiving at the center
        ['1220', '1227', 'christmas.png'], 		// Christmas
        ['0101', '0102', 'happynewyear.png']	// New Years	// Note: NO comma after last entry
    ];	
    
    function setHolidayImage(mmdd) {
      fnd = 0;
      for (var h=1; h<holiday.length; h++) {
        if ((mmdd >= holiday[h][0]) && (mmdd <= holiday[h][1])) { fnd = h; }
      }
      document.getElementById('imgHoliday').src = baseURL+holiday[fnd][2];
      document.getElementById('imgHoliday').alt = baseURL+holiday[fnd][2];
    }
    
      var cdate = new Date();
      var cday = cdate.getDate();
      var cmon = cdate.getMonth();
      	 cmon = cmon + 1; 												// This is necessary because in computer, Jan = 0 not 1, so we add 1	
      	 if (cday < 10) { cday = '0'+cday; } else { cday = ''+cday; }	// make sure the day  has a leading 0
      	 if (cmon < 10) { cmon = '0'+cmon; } else { cmon = ''+cmon; }	// make sure the month  has a leading 0
      var cmmdd = cmon.toString() + cday.toString();					// In order to get mmdd format, we need to convert the vars to strings then combine
    
    onload = function() {
      setHolidayImage(cmmdd);
    }
    ticker.js

    Code:
    var tWidth='100%';                  // width (in pixels)
    var tHeight='17px';                  // height (in pixels)
    var tcolour='';               // background colour:
    var moStop=true;                     // pause on mouseover (true or false)
    var fontfamily = 'arial,sans-serif'; // font for content
    var tSpeed=2;                        // scroll speed (1 = slow, 5 = fast)
    
    // enter your ticker content here (use \/ and \' in place of / and ' respectively)
    var content='<img alt="Sandiego Rodeo" height="16" src="images/favicon.gif" style="vertical-align: text-bottom" width="29" />     Are you looking for loads of useful information <a href="http:\/\/javascript.about.com\/">About Javascript<\/a>? Well now you\'ve found it.  This is the information for the marquee where we will put special information <img alt="Sandiego Rodeo" height="16" src="images/favicon.gif" style="vertical-align: text-bottom" width="29" />';
    
    // Simple Marquee / Ticker Script
    // copyright 3rd January 2006, Stephen Chapman
    // permission to use this Javascript on your web page is granted
    // provided that all of the below code in this script (including this
    // comment) is used without any alteration
    var cps=tSpeed; var aw, mq; var fsz = parseInt(tHeight) - 4; function startticker(){if (document.getElementById) {var tick = '<div style="position:relative;width:'+tWidth+';height:'+tHeight+';overflow:hidden;background-color:'+tcolour+'"'; if (moStop) tick += ' onmouseover="cps=0" onmouseout="cps=tSpeed"'; tick +='><div id="mq" style="position:absolute;left:0px;top:0px;font-family:'+fontfamily+';font-size:'+fsz+'px;white-space:nowrap;"><\/div><\/div>'; document.getElementById('ticker').innerHTML = tick; mq = document.getElementById("mq"); mq.style.left=(parseInt(tWidth)+10)+"px"; mq.innerHTML='<span id="tx">'+content+'<\/span>'; aw = document.getElementById("tx").offsetWidth; lefttime=setInterval("scrollticker()",50);}} function scrollticker(){mq.style.left = (parseInt(mq.style.left)>(-10 - aw)) ?parseInt(mq.style.left)-cps+"px" : parseInt(tWidth)+10+"px";} window.onload=startticker;

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.13069 seconds
  • Memory Usage 2,876KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (2)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (2)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (2)postbit
  • (2)postbit_onlinestatus
  • (2)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (70):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates