diff options
Diffstat (limited to 'web/utiles.js')
-rw-r--r-- | web/utiles.js | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/web/utiles.js b/web/utiles.js new file mode 100644 index 0000000..7d88de3 --- /dev/null +++ b/web/utiles.js @@ -0,0 +1,130 @@ + + function popup(popup_url,name,popup_width,popup_height) { + var tmp = window.open(popup_url,name,'resizable=no,menubar=no,location=no,toolbar=no,status=yes,scrollbars=yes,directories=no,width='+popup_width+',height='+popup_height); + } + + function mostrar(symbol,nombre,name,peso,numero,wiki) { + if (!mostrado) { + mostrado = true; + document.elementData.elementName.value = nombre; + document.elementData.editedText.value = readTextElement(nombre); + $("#textPopup").html("<p>"+ + "<b>Elemento:</b> "+nombre+" "+ + "(en inglés: "+name+")<br/>"+ + "<b>Símbolo:</b> "+symbol+" "+ + "<b>Peso atómico:</b> "+peso+" "+ + "<b>Número atómico:</b> "+numero+"<br/>"+ + "<a href='javascript:openWiki(\""+wiki+"\")'>Wikipedia</a>"+ + "</p>" ); + $("#pop").fadeIn('slow'); + } + } + + function popupText(text) { + $("#textPopup").html(text); + $("#pop").fadeIn('slow'); + mostrado = true; + } + + function openWiki(url) { + document.getElementById("wikiBody").src = url; + $("#wiki").fadeIn('slow'); + } + + function cerrarWiki() { + $("#wiki").fadeOut('slow'); + } + + function cerrarMisNotas() { + $("#misNotas").fadeOut('slow'); + } + + function verMisNotas() { + misNotasText = ""; + for (i = 0;i < textos.length; i++) { + textoElemento = textos[i]; + misNotasText = misNotasText + "<b>"+textoElemento[0]+"</b><br/>"+textoElemento[1]+"<br/><br/>"; + } + $("#textMisNotas").html(misNotasText); + $("#misNotas").fadeIn('slow'); + } + + + + function cerrar() { + $("#pop").fadeOut('slow'); + mostrado = false; + if (document.elementData.editedText.value != '') { + writeTextElement(document.elementData.elementName.value,document.elementData.editedText.value); + } + } + + function readTextElement(element) { + for(var i=0; i<textos.length; i++){ + textoElemento = textos[i]; + if(textoElemento[0] == element) { + return textoElemento[1]; + } + } + return ''; + } + + function writeTextElement(element,text) { + existe = false; + for(var i=0; i<textos.length; i++){ + textoElemento = textos[i]; + if(textoElemento[0] == element) { + existe = true; + textoElemento[1] = text; + } + } + if (!existe) { + textos.push(new Array(element,text)); + } + } + + + function debug(element) { + debugText = ''; + for(var i=0; i<textos.length; i++){ + textoElemento = textos[i]; + debugText = debugText+ ' ' +textoElemento[0]+'='+textoElemento[1]; + } + popupText(debugText); + } + + + XO.register('read', function(content) { + // Your code to consume the supplied content + /* + if (content != '') { + try { + eval("textos = "+content); + } catch(err) { + textos = new Array(); + } + } + $("#loading").fadeOut('slow'); + mostrado = false; + */ + + }) + + + XO.register('write', function() { + // Your code to return the content to save + persistent = "textos = new Array("; + for(var i=0; i<textos.length; i++){ + textoElemento = textos[i]; + persistent = persistent+"new Array('"+textoElemento[0]+"','"+textoElemento[1]+"')"; + if (i < (textos.length -1) ) { + persistent = persistent +","; + } else { + persistent = persistent +");"; + } + } + return persistent; + }) + + + |