Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/web/utiles.js
blob: 7d88de332b0fe5cd0d06da93b3ae6e9deddfb73a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
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>&nbsp;"+nombre+" "+
							"(en inglés:&nbsp;"+name+")<br/>"+
							"<b>S&iacute;mbolo:</b>&nbsp;"+symbol+" "+
							"<b>Peso at&oacute;mico:</b>&nbsp;"+peso+" "+
							"<b>N&uacute;mero at&oacute;mico:</b>&nbsp;"+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;
    })