Ciao ragazzi sto cercando di scrivere un framework ajax pensato per soluzioni light,
dove la maggior parte del lavoro è svolto dal client.
Le features principali sono:
-Fornire un'ampia serie di elementi gui dinamici
-Content managment (un database json o xml ed un paio di servlet di
caricamento/scrittura di tali fogli).
-Fornire un interfaccia per tali servlet, (un foglio xml) così che ciascuno possa sviluppare
la propria nel proprio linguaggio lato server preferito.
-Supporto crosswbrowser spinto.
Ho aperto un progetto, con licenza lgpl, su source forge, a breve uploaderò il tutto e vi fornirò l'url e i miei dati su sf.
Comincio con postarvi cosa ho cominciato a scrivere.
La prima cosa che vorrei fare è sostituire le funzioni di test ed inizializzazione con un paio di oggetti, ma ancora so poco della programmazione ad oggetti in javascript .
Per compensare sto leggendo libri sui pattern in javascript.
Chiunque volesse aiutarmi e partecipare joinando sul progetto su sourceforge, posti qui sotto la sua intenzione.
Grazie a tutti.
codice:/* * Jenexis - an Ajax framework * @version 0.0.1 */ //TEST AREA //This displays infromations about browser DOM Level function cr_displayDOMTest(){ toPrint = "DOM TEST"+'\n'+'\n'; testRes = cr_DOMTest(); for (var i = 0; i < testRes.length; i+=2) toPrint+=testRes[i]+" "+testRes[i+1]+'\n'; alert(toPrint); } //This function estabilish browser DOM Level //TODO - FIND A WAY TO AVOID ARRAY INITIALIZATION EVERYTIME!!!! function cr_DOMTest(){ var DOMTest_res; if (DOMTest_res==null){ DOMTest_res=new Array(); //Select an element by his Id //W3C way if(document.getElementById){ DOMTest_res[0] = "document.getElementById"; DOMTest_res[1] = "ok"; } //Other ways else if(document.all){ DOMTest_res[0] = "document.all"; DOMTest_res[1] = "ok"; } else if(document.layers){ DOMTest_res[0] = "document.layers"; DOMTest_res[1] = "ok"; } else { DOMTest_res[0] = "undefined"; DOMTest_res[1] = "ko"; } //Select by tag name //W3C way if(document.getElementsByTagName){ DOMTest_res[2] = "document.getElementsByTagName"; DOMTest_res[3] = "ok"; } //Other ways else { DOMTest_res[2] = "undefined"; DOMTest_res[3] = "ko"; } } return DOMTest_res; } //This function estabilish how to call the method XMLHttpRequest function cr_AJAXTest(){ } //CORE //Pick an element by is Id function cr_getElementById(elemId){ if ((cr_DOMTest())[1]=="ok") //alert(elemId); return eval((cr_DOMTest())[0]+"('"+elemId+"')"); else err_fatal("getEelementById() not supported"); } //Pick elements by their tagname into the container specified by the Id elemId function cr_getElementsByTagName(elemId,tagName){ if ((cr_DOMTest())[3]=="ok") if(elemId!=null) return eval(cr_getElementById(elemId)+"."+(cr_DOMTest())[2]+"('"+tagName+"')"); else return eval((cr_DOMTest())[2]+"('"+tagName+"')"); else err_fatal("getElementsByTagName() not supported"); } //Modify the HTML code into the tag with the selected id replacing it with the string newCode function cr_modifyInnerHTML(elemId,newCode){ if(elemId!=null && newCode !=null){ currElem=cr_getElementById(elemId); currElem.innerHTML=newCode; } } //Modify the HTML code into the tags with the selected tagName replacing wit with the strings in newCode[] function cr_modifyInnerHTMLS(elemId,tagName,newCode){ currElem=cr_getElementsByTagName(elemId,tagName); for (var i = 0; i < currElem.length; i++) currElem[i].innerHTML=newCode[i]; } //Repeat an action regularry a specified number of times function cr_timeredActionLoop(action, times, interval){ eval(action); if(times>0) setTimeout(function(){cr_timeredActionLoop(action, times-1, interval);},interval); } //ERROR MESSAGES //Fatal error, displayed when occour an error at core level function err_fatal(msg){ FATAL_ERROR = new Array(); FATAL_ERROR[0]='<DIV ID="ERROR_BOX"><H1>FATAL ERROR</H1></DIV>'; cr_modifyInnerHTMLS(null,'BODY',FATAL_ERROR); alert("FATAL ERROR OCCURRED: "+msg); } //DATA STRUCTURES CORE //GRAPHIC INTERFACE CORE function gicr_getElementDim(elemId){ currElem=cr_getElementById(elemId); return new Array(currElem.offsetWidth,currElem.offsetHeight); } function gicr_getElementPos(elemId){ currElem=cr_getElementById(elemId); return new Array(currElem.offsetLeft,currElem.offsetTop); } function gicr_mooveTo(elemId, endX, endY){ currElem=cr_getElementById(elemId); currElem.style.position="absolute"; currElem.style.left=endX; currElem.style.top=endY; } function gicr_mooveBy(elemId, endX, endY){ currElem=cr_getElementById(elemId); currElem.style.position="absolute"; currElem.style.left=endX+(gicr_getElementPos(elemId))[0]; currElem.style.top=endY+(gicr_getElementPos(elemId))[1]; } function gicr_resizeTo(elemId, endX, endY){ currElem=cr_getElementById(elemId); currElem.style.width=endX; currElem.style.height=endY; } function gicr_resizeBy(elemId, endX, endY){ currElem=cr_getElementById(elemId); currElem.style.width=endX+(gicr_getElementDim(elemId))[0]; currElem.style.height=endY+(gicr_getElementDim(elemId))[1]; } function gicr_show(elemId){ currElem=cr_getElementById(elemId); currElem.style.visibilty="visible"; } function gicr_hide(elemId){ currElem=cr_getElementById(elemId); currElem.style.visbility="hidden"; } //GRAPHIC FUNCTIONS

Rispondi quotando