Results 1 to 5 of 5

Thread: script to load one archive every 1 of month

  1. #1
    Join Date
    Jan 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb script to load one archive every 1 of month

    Hi. Please, I need a script to load one archive every 1 of month in my web site. thx. OL

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thx. In this script three types of inclusion are supported:

    Daily 1 ("dailyw"): The script will include a different file for each day of the week (Monday, Tuesday, etc).
    Daily 2 ("dailym"): The script will include a different file for each day of the month (1st to 31st).
    Random ("random"): The script will randomly pick one from the list of files to include.

    But, I need to change every month. No daily. No weekly. But monthly. I have 12 files to load in one year. Can you to adapt the script?

    <script type="text/javascript">

    /***********************************************
    * Ajax Rotating Includes script- Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/

    //To include a page, invoke ajaxinclude(files_array, "ROTATETYPE") in the BODY of page.
    //* file_array is the name of the array containing your list of files to include.
    //* For "ROTATETYPE", valid values are "dailyw", "dailym", and "random", for each day of the week, each day of the month, and random, respectively.
    //* Included file MUST be from the same domain as the page displaying it.

    //Enter path to list of files to display.
    //For rotatetype="dailyw", there must be 7 files, and for "dailym", 31 files. Otherwise, no restriction:

    var includefiles=["ajaxfiles/file.htm", "ajaxfiles/file2.htm", "ajaxfiles/file3.htm", "ajaxfiles/file4.htm", "ajaxfiles/file5.htm", "ajaxfiles/file6.htm", "ajaxfiles/file7.htm"]

    var rootdomain="http://"+window.location.hostname

    function ajaxinclude(files_array, rotatetype){
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")
    }
    catch (e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (e){}
    }
    }
    else
    return false
    var url=choosefile(files_array, rotatetype)
    if (typeof files_array[url]=="undefined"){
    document.write("Error: No file for this day has been found.")
    return
    }
    else
    url=files_array[url]
    page_request.open('GET', url, false) //get page synchronously
    page_request.send(null)
    writecontent(page_request)
    }

    function writecontent(page_request){
    if (window.location.href.indexOf("http")==-1 || page_request.status==200)
    document.write(page_request.responseText)
    }

    function choosefile(files_array, rotatetype){
    var today=new Date()
    var selectedfile=(rotatetype=="dailyw")? today.getDay() : rotatetype=="dailym"? today.getDate() : Math.floor(Math.random()*files_array.length)
    if (rotatetype=="dailyw" && selectedfile==0) //if display type=="week days" and today is Sunday
    selectedfile=7
    if (rotatetype=="dailyw" || rotatetype=="dailym")
    selectedfile-- //remove 1 to sync with array index
    return selectedfile
    }

    </script>






    Thank you!

  4. #4
    Join Date
    Jan 2006
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thx. In this script three types of inclusion are supported:

    Daily 1 ("dailyw"): The script will include a different file for each day of the week (Monday, Tuesday, etc).
    Daily 2 ("dailym"): The script will include a different file for each day of the month (1st to 31st).
    Random ("random"): The script will randomly pick one from the list of files to include.

    But, I need to change every month. No daily. No weekly. But monthly. I have 12 files to load in one year. Can you to adapt the script?

    <script type="text/javascript">

    /***********************************************
    * Ajax Rotating Includes script- &#169; Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * This notice MUST stay intact for legal use
    * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
    ***********************************************/

    //To include a page, invoke ajaxinclude(files_array, "ROTATETYPE") in the BODY of page.
    //* file_array is the name of the array containing your list of files to include.
    //* For "ROTATETYPE", valid values are "dailyw", "dailym", and "random", for each day of the week, each day of the month, and random, respectively.
    //* Included file MUST be from the same domain as the page displaying it.

    //Enter path to list of files to display.
    //For rotatetype="dailyw", there must be 7 files, and for "dailym", 31 files. Otherwise, no restriction:

    var includefiles=["ajaxfiles/file.htm", "ajaxfiles/file2.htm", "ajaxfiles/file3.htm", "ajaxfiles/file4.htm", "ajaxfiles/file5.htm", "ajaxfiles/file6.htm", "ajaxfiles/file7.htm"]

    var rootdomain="http://"+window.location.hostname

    function ajaxinclude(files_array, rotatetype){
    var page_request = false
    if (window.XMLHttpRequest) // if Mozilla, Safari etc
    page_request = new XMLHttpRequest()
    else if (window.ActiveXObject){ // if IE
    try {
    page_request = new ActiveXObject("Msxml2.XMLHTTP")
    }
    catch (e){
    try{
    page_request = new ActiveXObject("Microsoft.XMLHTTP")
    }
    catch (e){}
    }
    }
    else
    return false
    var url=choosefile(files_array, rotatetype)
    if (typeof files_array[url]=="undefined"){
    document.write("Error: No file for this day has been found.")
    return
    }
    else
    url=files_array[url]
    page_request.open('GET', url, false) //get page synchronously
    page_request.send(null)
    writecontent(page_request)
    }

    function writecontent(page_request){
    if (window.location.href.indexOf("http")==-1 || page_request.status==200)
    document.write(page_request.responseText)
    }

    function choosefile(files_array, rotatetype){
    var today=new Date()
    var selectedfile=(rotatetype=="dailyw")? today.getDay() : rotatetype=="dailym"? today.getDate() : Math.floor(Math.random()*files_array.length)
    if (rotatetype=="dailyw" && selectedfile==0) //if display type=="week days" and today is Sunday
    selectedfile=7
    if (rotatetype=="dailyw" || rotatetype=="dailym")
    selectedfile-- //remove 1 to sync with array index
    return selectedfile
    }

    </script>






    Thank you!

  5. #5
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Find this line in the script:

    Code:
    var selectedfile=(rotatetype=="dailyw")? today.getDay() : rotatetype=="dailym"? today.getDate() : Math.floor(Math.random()*files_array.length)
    Make it like so (additions red):

    Code:
    var selectedfile=(rotatetype=="dailyw")? today.getDay() : rotatetype=="monthly"? today.getMonth() : rotatetype=="dailym"? today.getDate() : Math.floor(Math.random()*files_array.length)
    Now you can use an array with 12 entries:

    Code:
    var includefiles=["ajaxfiles/file1.htm", "ajaxfiles/file2.htm", "ajaxfiles/file3.htm", "ajaxfiles/file4.htm", "ajaxfiles/file5.htm", "ajaxfiles/file6.htm", "ajaxfiles/file7.htm", ajaxfiles/file8.htm", "ajaxfiles/file9.htm", "ajaxfiles/file10.htm", "ajaxfiles/file11.htm", "ajaxfiles/file12.htm"]
    and the rotate type "monthly":

    Code:
    <script type="text/javascript">
    ajaxinclude(includefiles, "monthly")
    </script>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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