Visualizzazione dei risultati da 1 a 6 su 6
  1. #1

    [MX] Componente Spark Calendar

    Ciao a tutti oggi ho scaricato un componente calendar che vorrei utilizzare.
    Ho fatto diverse prove anche basandomi sui tutorial forniti, ma mi manca ancora qualcosa per costruire il foglio XML che lo gestirà.
    Qualcuno puo' aiutarmi?

    Qui di seguito alcuni eventi

    codice:
    //un evento, il 1 di aprile
    event1 = new Object(); 
    event1.startDate = new Date(2002,3,1);
    event1.endDate = new Date(2002,3,1);
    event1.eventType = "once";
    // ultimo giorno della settimana per mese
    event2 = new Object(); 
    event2.startDate = new Date(2003,0,1);
    event2.endDate = new Date(2003,11,31);
    event2.eventType = "monthly";
    event2.pattern = new XML('<pattern recur="1" day="weekday" week="5" />').firstChild; 
    //evento annuale tipo compleanno
    event3 = new Object(); 
    event3.startDate = new Date(1976,8,27);
    event3.endDate = new Date(2070,11,31);
    event3.eventType = "yearly";
    event3.pattern = new XML('<pattern date="27" month="8" />').firstChild;//ogni 27 settembre 
    // stabilisco il range delle date
    myEvents = new Array(event1, event2, event3);
    myCalendar.setDataProvider(myEvents);
    myCalendar.setDisplayRange({begin:new Date(1999,0),end:new Date(2005,11)});
    Qui sotto elenco gli eventi e le proprietà disponibili per questo componente.

    . . . Methods
    . . . . . . getDataByDate
    . . . . . . getDayByDate
    . . . . . . setDataProvider
    . . . . . . setDate
    . . . . . . setDisplayRange
    . . . . . . setEnabled
    . . . Events
    . . . . . . onChangeMonth
    . . . . . . onDisplayEvent
    . . . . . . onHideEvent
    . . . . . . onSelectDate

  2. #2
    Utente di HTML.it L'avatar di negatyve
    Registrato dal
    Feb 2001
    Messaggi
    9,479
    Allora, ho visto il tuo messaggio. Partendo dall'inizio, cosa non torna con i tutorial? (cosa non ti spiega)

  3. #3
    In pratica ho capito che struttura devo dare al foglio XML ma il comando load dove lo devo assegnare?

    event3.pattern qui?

    :tongue:

  4. #4
    Utente di HTML.it L'avatar di negatyve
    Registrato dal
    Feb 2001
    Messaggi
    9,479
    codice:
    //un evento, il 1 di aprile
    event1 = new Object(); 
    event1.startDate = new Date(2002,3,1);
    event1.endDate = new Date(2002,3,1);
    event1.eventType = "once";
    // ultimo giorno della settimana per mese
    event2 = new Object(); 
    event2.startDate = new Date(2003,0,1);
    event2.endDate = new Date(2003,11,31);
    event2.eventType = "monthly";
    event2.pattern = new XML('<pattern recur="1" day="weekday" week="5" />').firstChild; 
    //evento annuale tipo compleanno
    event3 = new Object(); 
    event3.startDate = new Date(1976,8,27);
    event3.endDate = new Date(2070,11,31);
    event3.eventType = "yearly";
    event3.pattern = new XML();
    event3.pattern.path = this;
    event3.pattern.ignoreWhite = true;
    event3.pattern.onLoad = function(success)
    {
    	if(success){
    		// stabilisco il range delle date
    		this.path.myEvents = new Array(this.path.event1, this.path.event2, this);
    		this.path.myCalendar.setDataProvider(this.path.myEvents);
    		this.path.myCalendar.setDisplayRange({begin:new Date(1999,0),end:new Date(2005,11)}); 		
    	} else {
    		trace("FILE XML NOT FOUND");
    	}
    };
    event3.pattern.load("file.xml");

  5. #5
    Molto piu' semplice di quel che pensavo ...

    if(success){
    // stabilisco il range delle date
    this.path.myEvents = new Array(this.path.event1, this.path.event2, this);
    this.path.myCalendar.setDataProvider(this.path.myE vents);
    this.path.myCalendar.setDisplayRange({begin:new Date(1999,0),end:new Date(2005,11)});
    } else {
    trace("FILE XML NOT FOUND");
    }
    };
    event3.pattern.load("file.xml");


    Grazie ora fo delle prove, thanks ...
    Ho provato quello fornito con flash ma non ti danno neanche uno straccio di tut ...


    NOTA: la news è on line

  6. #6
    Fatto alcune modifiche e inserito due funzioni tramite Aiutino

    Codice ActionScript

    Codice PHP:

    var daysOfWeek_array = ["Sunday""Monday""Tuesday""Wednesday""Thursday""Friday""Saturday"];
    var 
    monthsOfYear_array = ["January","February","March","April","May","June","July","August","September","October","November","December"]

    // questa funzione edita il testo e la data
    // passando da una maschera: 
    // "dddd, d mmmm yyyy" which would return "Tuesday, 4 February 2003" --> esempio
    Date.prototype.dateTimeFormat = function (mask) {
        var 
    out "";
        var 
    0;
        while (
    mask.length) {
            
    // escaped characters
            
    if (mask.substr(i,1) == "*") {
                
    out += mask.substr(i+1,1);
                
    i=i+2;
            
    // year
            
    } else if (mask.substr(i,4) == "yyyy") {
                
    out += this.getFullYear().toString();
                
    i=i+4;
            } else if (
    mask.substr(i,2) == "yy") {
                
    out += this.getFullYear().toString().substr(2,2);
                
    i=i+2;
            
    // month
            
    } else if (mask.substr(i,4) == "mmmm") {
                
    out += monthsOfYear_array[this.getMonth()];
                
    i=i+4;
            } else if (
    mask.substr(i,3) == "mmm") {
                
    out += monthsOfYear_array[this.getMonth()].substr(0,3);
                
    i=i+3;
            } else if (
    mask.substr(i,2) == "mm") {
                if (
    this.getMonth() < 10out += "0";
                
    out += (this.getMonth() + 1);
                
    i=i+2;
            } else if (
    mask.substr(i,1) == "m") {
                
    out += (this.getMonth() + 1);
                
    i++;
            
    // date
            
    } else if (mask.substr(i,4) == "dddd") {
                
    out += daysOfWeek_array[this.getDay()];
                
    i=i+4;
            } else if (
    mask.substr(i,3) == "ddd") {
                
    out += daysOfWeek_array[this.getDay()].substr(0,3);
                
    i=i+3;
            } else if (
    mask.substr(i,2) == "dd") {
                if (
    this.getDate() < 10out += "0";
                
    out += this.getDate();
                
    i=i+2;
            } else if (
    mask.substr(i,1) == "d") {
                
    out += this.getDate();
                
    i++;
            
    // hours
            
    } else if (mask.substr(i,2) == "HH") {
                if (
    this.getHours() < 10out += "0";
                
    out += this.getHours();
                
    i=i+2;
            } else if (
    mask.substr(i,2) == "hh") {
                if ((
    this.getHours() < 10 and this.getHours() > 0) or (this.getHours() < 22 and this.getHours() > 12)) {
                    
    out out "0";
                }
                if (
    this.getHours() > 12) {
                    
    out += (this.getHours() - 12);
                } else if (
    this.getHours() == 0) {
                    
    out += "12";
                } else {
                    
    out += this.getHours();
                }
                
    i=i+2;
            } else if (
    mask.substr(i,1) == "H") {
                
    out out this.getHours();
                
    i++;
            } else if (
    mask.substr(i,1) == "h") {
                if (
    this.getHours() > 12) {
                    
    out += (this.getHours() - 12);
                } else if (
    this.getHours() == 0) {
                    
    out += "12";
                } else {
                    
    out += this.getHours();
                }
                
    i++;
            
    // minutes
            
    } else if (mask.substr(i,2) == "nn") {
                if (
    this.getMinutes() < 10) {
                    
    out += "0";
                }
                
    out += this.getMinutes();
                
    i=i+2;
            } else if (
    mask.substr(i,1) == "n") {
                
    out += this.getMinutes();
                
    i++;
            
    // seconds
            
    } else if (mask.substr(i,2) == "ss") {
                if (
    this.getSeconds() < 10) {
                    
    out += "0";
                }
                
    out += this.getSeconds();
                
    i=i+2;
            } else if (
    mask.substr(i,1) == "s") {
                
    out += this.getSeconds();
                
    i++;
            
    // am - pm
            
    } else if (mask.substr(i,2) == "tt") {
                if (
    this.getHours() < 12) {
                    
    out += "am";
                } else {
                    
    out += "pm";
                }
                
    i=i+2;
            } else if (
    mask.substr(i,1) == "t") {
                if (
    this.getHours() < 12) {
                    
    out += "a";
                } else {
                    
    out += "p";
                }
                
    i++;
            } else if (
    mask.substr(i,2) == "TT") {
                if (
    this.getHours() < 12) {
                    
    out += "AM";
                } else {
                    
    out += "PM";
                }
                
    i=i+2;
            } else if (
    mask.substr(i,1) == "T") {
                if (
    this.getHours() < 12) {
                    
    out += "A";
                } else {
                    
    out += "P";
                }
                
    i++;
            
    // anything else
            
    } else {
                
    out += mask.substr(i,1);
                
    i++
            }
        }
        return 
    out;
    }

    // funzione che mostra l' evento per la data scelta
    calendar_ec.onDisplayEvent = function (eventsDatadateObj) {
        var 
    event_str "<font color='#FF0099'>[b]" dateObj.dateTimeFormat("dddd, d mmmm yyyy") + "[/b]</font>

    "
    ;
        for (var 
    i=0i<eventsData.lengthi++) {
            
    // create a pointer to the eventdata to save typing!
            
    var eventsData[i];
            
    // output the title of the event
            
    event_str += "<font color='#FF0099'>[b]" d.title "[/b]</font>
    "
    ;
            
    // if the start and end date are different dates display the range
            
    if (d.startDate.getDate() <> d.endDate.getDate()) {
                
    event_str += "<font color='#FF0099'>" d.startDate.dateTimeFormat("d/m/yyyy") + " - " d.endDate.dateTimeFormat("d/m/yyyy") + "</font>
    "
    ;
            }
            
    // output the start and end time of the events (contained within startDate and endDate)
            
    if (!d.allDayevent_str += "<font color='#FF0099'>" d.startDate.dateTimeFormat("h:nntt") + " - " d.endDate.dateTimeFormat("h:nntt") + "</font>
    "
    ;
            
    // for weekly events
            
    if (d.eventType == "weekly") {
                
    // the following outputs the pattern information for the recurring event
                
    var output_str "Every " + ((d.pattern.attributes.recur 1) ? d.pattern.attributes.recur " " "") + "week" + ((d.pattern.attributes.recur 1) ? "s" "") + " on ";
                var 
    days_array = new Array();
                for (var 
    q=0q<daysOfWeek_array.lengthq++) {
                    if (
    d.pattern.attributes[daysOfWeek_array[q].substr(0,3)]) days_array.push(daysOfWeek_array[q]);
                }
                if (
    days_array.length == 7) {
                    
    output_str += "every day";
                } else if (
    days_array[0] == "Monday" && days_array[1] == "Tuesday" && days_array[2] == "Wednesday" && days_array[3] == "Thursday" && days_array[4] == "Friday") {
                      
    output_str += "weekdays";
                } else if (
    days_array[0] == "Sunday" && days_array[1] == "Saturday") {
                      
    output_str += "weekends";
                } else {
                    for (var 
    q=0q<days_array.lengthq++) {
                        if (
    days_array.length && == days_array.length 1) {    
                            
    output_str += " and ";
                        } else if (
    0) {
                            
    output_str += ", ";
                        }
                        
    output_str += days_array[q];
                    }
                }
                
    event_str += "<font color='#FF0099'>" output_str "</font>
    "
    ;
            
    // the event type is monthly
            
    } else if (d.eventType == "monthly") {
                
    // the following outputs the pattern information for the recurring event
                
    var numString_array = ["First","Second","Third","Fourth","Last"];
                if (
    d.pattern.attributes.date) {
                    
    output_str "Day " d.pattern.attributes.date " of every " + ((d.pattern.attributes.recur 1) ? d.pattern.attributes.recur " " "") + "month" + ((d.pattern.attributes.recur 1) ? "s" "");
                } else {
                    if (
    "sun,mon,tue,wed,thu,fri,sat".indexOf(d.pattern.attributes.day) > 0) {
                        var 
    days_obj = {sun:"Sunday",mon:"Monday",tue:"Tuesday",wed:"Wednesday",thu:"Thursday",fri:"Friday",sat:"Saturday"};
                        var 
    patternDay days_obj[d.pattern.attributes.day];
                    } else if (
    d.pattern.attributes.day == "day") {
                        var 
    patternDay "day";
                    } else if (
    d.pattern.attributes.day == "weekday") {
                        var 
    patternDay "weekday";
                    } else if (
    d.pattern.attributes.day == "weekendday") {
                        var 
    patternDay "weekend day";
                    }
                    
    output_str numString_array[d.pattern.attributes.week 1] + " " patternDay " " + ((d.pattern.attributes.recur 1) ? "every " d.pattern.attributes.recur " " "of every ") + "month" + ((d.pattern.attributes.recur 1) ? "s" ""
                }
                
    event_str += "<font color='#FF0099'>" output_str "</font>
    "
    ;
            }
            
    // output the description
            
    if (d.description.lengthevent_str += d.description "
    "
    ;
            
    // if there are more events output a line break
            
    if (eventData_array.length 1event_str += "
    "
    ;
        }
        
    // output the generated string to the text box
        
    events_txt.htmlText event_str;
    }

    // onSelectDate is called when a day with no events is clicked
    calendar_ec.onSelectDate = function (dateObj) {
        
    events_txt.htmlText "<font color='#FF0099'>[b]" dateObj.dateTimeFormat("dddd, d mmmm yyyy") + "[/b]</font>

    "
    ;
        
    events_txt.htmlText += "This day has no events and this event was triggered by the onSelectDate event.";
    }

    // onHideEvent removes any events information
    calendar_ec.onHideEvent = function () {
        
    events_txt.htmlText "";    
    }

    // parse date prototype
    // takes a string formatted as: "yyyy-mm-dd HH:mm:ss" and converts it to a date object
    String.prototype.parseDate = function () {
        var 
    this.split(" ")[0].split("-");
        var 
    this.split(" ")[1].split(":");
        return new 
    Date(d[0],d[1]-1,d[2],t[0],t[1],t[2]);
    }

    // hide the calendar while we populate it
    calendar_mc._visible false;
    getEvents = new XML();
    getEvents.ignoreWhite true;
    // when the data has been loaded
    getEvents.onLoad = function () {
        
    // calendar_array will hold the calendar data that has been loaded
        
    var calendar_array = new Array();
        var 
    minStartDate this.firstChild.attributes.startDate.parseDate();
        var 
    maxEndDate this.firstChild.attributes.endDate.parseDate();
        
    // minStartDate and maxEndDate are used to set the displayRange
        
    calendar_ec.setDisplayRange({begin:minStartDate,end:maxEndDate});
        
    // loop over the event nodes in the xml
        // and stores the record as an object inside calendar_array
        
    var qNodes this.firstChild.childNodes;
        for (var 
    q=0q<qNodes.lengthq++) {
            var 
    qNodes[q].attributes;
            
    calendar_array.push({title:d.title,description:d.description,startDate:d.startDate.parseDate(),endDate:d.endDate.parseDate(),allDay:Boolean(d.allDay),eventType:d.eventType,pattern:qNodes[q].firstChild});
        }
        
    // pass the data array to the calendar
        
    calendar_ec.setDataProvider(calendar_array);
        
    // show the calendar now it is ready
        
    calendar_ec._visible true;
        
    // simulate a click on today's date to show any events that happen today
        
    calendar_ec.getDayByDate(new Date().getDate()).onRelease();
    }
    // load the SparkEventsCalendar_example2.txt into the XML object
    getEvents.load("Calendario.xml"); 
    Foglio XML

    codice:
    <events startDate="2002-01-01" endDate="2004-12-31">
    	<event title="Test Event 1" description="once on 10 february" startDate="2003-02-10 17:30:00" endDate="2003-02-10 19:30:00" allDay="0" eventType="once" />
    	<event title="Test Event 2" description="once on 1 march" startDate="2003-03-01 09:30:00" endDate="2003-03-01 11:00:00" allDay="0" eventType="once" />
    	<event title="Test Event 3" description="once on 15 march" startDate="2003-03-15 09:30:00" endDate="2003-03-15 15:30:00" allDay="0" eventType="once" />
    	<event title="Test Event 4" description="once on 1 april" startDate="2003-04-01" endDate="2003-04-01" allDay="1" eventType="once" />
    	<event title="Test Event 5" description="every second tuesday" startDate="2003-01-01" endDate="2003-12-31" allDay="1" eventType="weekly">
    		<pattern sun="0" sat="0" fri="0" thu="0" wed="0" tue="1" mon="0" recur="2" />
    	</event>
    	<event title="Test Event 6" description="third wednesday of each month, see &lt;u&gt; &lt;a href='http://www.sparkos.com/'&gt;sparkos.com&lt;/a&gt; &lt;/u&gt;" startDate="2003-01-01" endDate="2003-12-31" allDay="1" eventType="monthly">
    		<pattern day="wed" week="3" recur="1" />
    	</event>
    	<event title="Test Event 7" description="last friday of april" startDate="2003-01-01" endDate="2003-12-31" allDay="1" eventType="yearly">
    		<pattern day="fri" week="5" month="3" />
    	</event>
    </events>

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.