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

    [MX 2004] strano load di XML

    Ciao ho un swf con il componente spark calendar. Ho costruito un foglio XML che carico e va tutto bene, ma se metto tutto on line, non legge il foglio XML.

    Chiaro che ho controllato ed è tutto on line correttamente.

    Codice
    codice:
    var daysOfWeek_array = ["Domenica", "Lunedi'", "Martedi'", "Mercoledi'", "Giovedi'", "Venerdi'", "Sabato"];
    var monthsOfYear_array = ["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"]
    
    // 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 i = 0;
    	while (i < 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() < 10) out += "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() < 10) out += "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() < 10) out += "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 (eventsData, dateObj) {
    	var event_str = "<font color='#FF0099'>" + dateObj.dateTimeFormat("dddd, d mmmm yyyy") + "</font>
    
    ";
    	for (var i=0; i<eventsData.length; i++) {
    		// create a pointer to the eventdata to save typing!
    		var d = eventsData[i];
    		// output the title of the event
    		event_str += "<font color='#FF0099'>" + d.title + "</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.allDay) event_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 = "Ogni " + ((d.pattern.attributes.recur > 1) ? d.pattern.attributes.recur + " " : "") + "settimana" + ((d.pattern.attributes.recur > 1) ? "" : "") + " del ";
    			var days_array = new Array();
    			for (var q=0; q<daysOfWeek_array.length; q++) {
    				if (d.pattern.attributes[daysOfWeek_array[q].substr(0,3)]) days_array.push(daysOfWeek_array[q]);
    			}
    			if (days_array.length == 7) {
    				output_str += "ogni giorno";
    			} else if (days_array[0] == "Lunedi'" && days_array[1] == "Martedi'" && days_array[2] == "Mercoledi'" && days_array[3] == "Giovedi'" && days_array[4] == "Venerdi'") {
    				  output_str += "weekdays";
    			} else if (days_array[0] == "Domenica" && days_array[1] == "Sabato") {
    				  output_str += "Fine settimana";
    			} else {
    				for (var q=0; q<days_array.length; q++) {
    					if (days_array.length > 1 && q == days_array.length - 1) {	
    						output_str += " e ";
    					} else if (q > 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 = "Giorno " + d.pattern.attributes.date + " di ogni " + ((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:"Domenica",mon:"Lunedi'",tue:"Martedi'",wed:"Mercoledi'",thu:"Giovedi'",fri:"Venerdi'",sat:"Sabato"};
    					var patternDay = days_obj[d.pattern.attributes.day];
    				} else if (d.pattern.attributes.day == "day") {
    					var patternDay = "giorno";
    				} else if (d.pattern.attributes.day == "weekday") {
    					var patternDay = "settimanale";
    				} else if (d.pattern.attributes.day == "weekendday") {
    					var patternDay = "fine settimana";
    				}
    				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.length) event_str += d.description + "
    ";
    		// if there are more events output a line break
    		if (i < eventData_array.length - 1) event_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'>" + dateObj.dateTimeFormat("dddd, d mmmm yyyy") + "</font>
    
    ";
    	events_txt.htmlText += "Per questo giorno non ci sono eventi registrati.";
    }
    
    // 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 d = this.split(" ")[0].split("-");
    	var t = 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=0; q<qNodes.length; q++) {
    		var d = 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});
    	}
    	// passo l' array del calendario
    	calendar_ec.setDataProvider(calendar_array);
    	// show the calendar now it is ready
    	calendar_ec._visible = true;
    	// simulo il click su ogni giorno del calendario
    	calendar_ec.getDayByDate(new Date().getDate()).onRelease();
    }
    // Carico il file XML
    getEvents.load("calendario.xml");
    non capisco perchè funziona in locale e non in rete, se la cartella è identica. Io in locale lavoro con IIS e in rete dominio Aruba che supporta ASP.

  2. #2
    il sito è antica regina sotto nella mia firma.
    sono 300 k da caricare a chi fosse interessato.

    PS è un WIP non voglio critiche sul sito ma sul codice che ho postato.
    Grazie

    :tongue:

  3. #3
    Allora il problema è che non carica il file XML quando è on line ...

    codice:
    // 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=0; q<qNodes.length; q++) {
    		var d = 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});
    	}
    	// passo l' array del calendario
    	calendar_ec.setDataProvider(calendar_array);
    	// show the calendar now it is ready
    	calendar_ec._visible = true;
    	// simulo il click su ogni giorno del calendario
    	calendar_ec.getDayByDate(new Date().getDate()).onRelease();
    }
    // Carico il file XML
    getEvents.load("calendario.xml");
    
    Il calendario diventa visible, quindi nell' onLoad ci passa, ma in rosso ho segnato quello che a parere mio, forse non è corretto!!

    Che ne dite?

  4. #4
    Allora quando sono on line non trova il file XML, perchè??


    getEvents.onLoad = function (success) {
    if (success){
    // 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=0; q<qNodes.length; q++) {
    var d = qNodes[q].attributes;
    calendar_array.push({title:d.title,description:d.d escription,startDate:d.startDate.parseDate(),endDa te:d.endDate.parseDate(),allDay:Boolean(d.allDay), eventType:d.eventType,pattern:qNodes[q].firstChild});
    }
    // passo l' array del calendario
    calendar_ec.setDataProvider(calendar_array);
    // show the calendar now it is ready
    calendar_ec._visible = true;
    // simulo il click su ogni giorno del calendario
    calendar_ec.getDayByDate(new Date().getDate()).onRelease();
    }else{

    // Carico il file XML
    getEvents.load("calendario.xml");

  5. #5
    Allora quando sono on line non trova il file XML, perchè??

    codice:
    getEvents.onLoad = function (success) {
    if (success){
    	// 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=0; q<qNodes.length; q++) {
    		var d = 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});
    	}
    	// passo l' array del calendario
    	calendar_ec.setDataProvider(calendar_array);
    	// show the calendar now it is ready
    	calendar_ec._visible = true;
    	// simulo il click su ogni giorno del calendario
    	calendar_ec.getDayByDate(new Date().getDate()).onRelease();
    }else{
    events_txt.htmlText = "non trvo il file XML"
    }
    }
    // Carico il file XML
    getEvents.load("calendario.xml");
    in fatti non lo trova, ma è su, come mai? Cosa puo' essere? Servono diritti particolari o robe simili per leggere on line un file XML??

  6. #6
    Ho risolto, io carico il swf in una POP up fuori dalla root e quindi il percorso del file XML cambiava, tutto qui ...

    Che coglions ...



  7. #7
    ma fammi capire, ho visto il calendario e gli eventi nelle date in cui ci sono, cos'è che non và?
    "...non è detto che sia tardi se non guardi che ora è..."

  8. #8
    ho postato senza aver visto che hai risolto.
    Ciao.
    "...non è detto che sia tardi se non guardi che ora è..."

  9. #9
    di niente raffa io mi sono tirato matto due ore senza guardare che sbagliavo il percorso in rete, mentre off line testavo il player dalla cartela e trovava il file ...


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.