PageSourceSearch

https://www.educaweb.com/client/js/funciones.js

js educaweb.com collected 2026-09-24 09:21:14 UTC 12,355 bytes, 382 lines download raw bytes

1
2/////////////////////////////////////////////////////////////////////////////////////////////////////////
3/////////////////////////////////////////////////////////////////////////////////////////////////////////
4/////////////////////////////////////////////////////////////////////////////////////////////////////////
5
6/* check email*/
7function emailCheck (emailStr) {
8var emailPat=/^(.+)@(.+)$/
9var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
10var validChars="\[^\\s" + specialChars + "\]"
11var quotedUser="(\"[^\"]*\")"
12var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
13var atom=validChars + '+'
14var word="(" + atom + "|" + quotedUser + ")"
15var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
16var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
17
18var matchArray=emailStr.match(emailPat)
19if (matchArray==null) {
20	return false
21}
22var user=matchArray[1]
23var domain=matchArray[2]
24
25if (user.match(userPat)==null) {
26    return false
27}
28
29var IPArray=domain.match(ipDomainPat)
30if (IPArray!=null) {
31	  for (var i=1;i<=4;i++) {
32	    if (IPArray[i]>255) {
33		return false
34	    }
35    }
36    return true
37}
38
39var domainArray=domain.match(domainPat)
40if (domainArray==null) {
41    return false
42}
43
44var atomPat=new RegExp(atom,"g")
45var domArr=domain.match(atomPat)
46var len=domArr.length
47if (domArr[domArr.length-1].length<2 || 
48    domArr[domArr.length-1].length>3) {
49   return false
50}
51
52if (len<2) {
53   var errStr="This address is missing a hostname!"
54   return false
55}
56
57return true;
58}
59
60
61
62/////////////////////////////////////////////////////////////////////////////////////////////////////////
63/////////////////////////////////////////////////////////////////////////////////////////////////////////
64/////////////////////////////////////////////////////////////////////////////////////////////////////////
65
66/*AJAX*/
67function XHConn()
68{
69  var xmlhttp, bComplete = false;
70  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
71  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
72  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
73  catch (e) { xmlhttp = false; }}}
74  if (!xmlhttp) return null;
75  this.connect = function(sURL, sMethod, sVars, fnDone)
76  {
77    if (!xmlhttp) return false;
78    bComplete = false;
79    sMethod = sMethod.toUpperCase();
80
81    try {
82      if (sMethod == "GET")
83      {
84        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
85        sVars = "";
86      }
87      else
88      {
89        xmlhttp.open(sMethod, sURL, true);
90        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
91        xmlhttp.setRequestHeader("Content-Type",
92          "application/x-www-form-urlencoded");
93      }
94      xmlhttp.onreadystatechange = function(){
95        if (xmlhttp.readyState == 4 && !bComplete)
96        {
97          bComplete = true;
98          fnDone(xmlhttp);
99        }};
100      xmlhttp.send(sVars);
101    }
102    catch(z) { return false; }
103    return true;
104  };
105  return this;
106}
107
108function page(targetId,url,params) {
109target= document.getElementById(targetId);
110//target.innerHTML = '<div align="center" class="peq">Cargando ...</div>';
111//target.innerHTML = '';  
112var myConn = new XHConn();
113    if (!myConn) alert("XMLHTTP not available.");
114    var query = function (oXML) {  		     
115	     target.innerHTML = oXML.responseText;
116		 //target.outerHTML = oXML.responseText;
117    };
118    myConn.connect(url, "GET", params, query);
119}
120
121// vacia un innerHTML
122function clean(targetId) {
123   target= document.getElementById(targetId);
124   target.innerHTML='';
125}
126
127
128/////////////////////////////////////////////////////////////////////////////////////////////////////////
129/////////////////////////////////////////////////////////////////////////////////////////////////////////
130/////////////////////////////////////////////////////////////////////////////////////////////////////////
131
132// ************************
133// layer utility routines *
134// ************************
135
136function getStyleObject(objectId) {
137    // cross-browser function to get an object's style object given its id
138    if(document.getElementById && document.getElementById(objectId)) {
139	// W3C DOM
140	return document.getElementById(objectId).style;
141    } else if (document.all && document.all(objectId)) {
142	// MSIE 4 DOM
143	return document.all(objectId).style;
144    } else if (document.layers && document.layers[objectId]) {
145	// NN 4 DOM.. note: this won't find nested layers
146	return document.layers[objectId];
147    } else {
148	return false;
149    }
150} // getStyleObject
151
152function changeObjectVisibility(objectId, newVisibility) {
153    // get a reference to the cross-browser style object and make sure the object exists
154    var styleObject = getStyleObject(objectId);
155    if(styleObject) {
156	styleObject.visibility = newVisibility;
157	return true;
158    } else {
159	// we couldn't find the object, so we can't change its visibility
160	return false;
161    }
162} // changeObjectVisibility
163
164function moveObject(objectId, newXCoordinate, newYCoordinate) {
165    // get a reference to the cross-browser style object and make sure the object exists
166    var styleObject = getStyleObject(objectId);
167    if(styleObject) {
168	styleObject.left = newXCoordinate;
169	styleObject.top = newYCoordinate;
170	return true;
171    } else {
172	// we couldn't find the object, so we can't very well move it
173	return false;
174    }
175} // moveObject
176
177
178
179
180/* funciones para la creacion de ajax en layers*/
181
182// store variables to control where the popup will appear relative to the cursor position
183// positive numbers are below and to the right of the cursor, negative numbers are above and to the left
184var xOffset = 30;
185var yOffset = -5;
186
187function showPopup (targetObjectId, eventObj) {
188    if(eventObj) {
189	// hide any currently-visible popups
190	hideCurrentPopup();
191	// stop event from bubbling up any farther
192	eventObj.cancelBubble = true;
193	// move popup div to current cursor position 
194	// (add scrollTop to account for scrolling for IE)
195	var newXCoordinate = (eventObj.pageX)?eventObj.pageX + xOffset:eventObj.x + xOffset + ((document.body.scrollLeft)?document.body.scrollLeft:0);
196	var newYCoordinate = (eventObj.pageY)?eventObj.pageY + yOffset:eventObj.y + yOffset + ((document.body.scrollTop)?document.body.scrollTop:0);
197	moveObject(targetObjectId, newXCoordinate, newYCoordinate);
198	// and make it visible
199	if( changeObjectVisibility(targetObjectId, 'visible') ) {
200	    // if we successfully showed the popup
201	    // store its Id on a globally-accessible object
202	    window.currentlyVisiblePopup = targetObjectId;
203	    return true;
204	} else {
205	    // we couldn't show the popup, boo hoo!
206	    return false;
207	}
208    } else {
209	// there was no event object, so we won't be able to position anything, so give up
210	return false;
211    }
212} // showPopup
213
214function hideCurrentPopup() {
215    // note: we've stored the currently-visible popup on the global object window.currentlyVisiblePopup
216    if(window.currentlyVisiblePopup) {
217	changeObjectVisibility(window.currentlyVisiblePopup, 'hidden');
218	window.currentlyVisiblePopup = false;
219    }
220} // hideCurrentPopup
221
222
223
224// ***********************
225// hacks and workarounds *
226// ***********************
227
228// initialize hacks whenever the page loads
229window.onload = initializeHacks;
230
231// setup an event handler to hide popups for generic clicks on the document
232document.onclick = hideCurrentPopup;
233
234function initializeHacks() {
235    // this ugly little hack resizes a blank div to make sure you can click
236    // anywhere in the window for Mac MSIE 5
237    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
238	&& (navigator.platform.indexOf('Mac') != -1)
239	&& getStyleObject('blankDiv')) {
240	window.onresize = explorerMacResizeFix;
241    }
242    resizeBlankDiv();
243    // this next function creates a placeholder object for older browsers
244    createFakeEventObj();
245}
246
247function createFakeEventObj() {
248    // create a fake event object for older browsers to avoid errors in function call
249    // when we need to pass the event object to functions
250    if (!window.event) {
251	window.event = false;
252    }
253} // createFakeEventObj
254
255function resizeBlankDiv() {
256    // resize blank placeholder div so IE 5 on mac will get all clicks in window
257    if ((navigator.appVersion.indexOf('MSIE 5') != -1) 
258	&& (navigator.platform.indexOf('Mac') != -1)
259	&& getStyleObject('blankDiv')) {
260	getStyleObject('blankDiv').width = document.body.clientWidth - 20;
261	getStyleObject('blankDiv').height = document.body.clientHeight - 20;
262    }
263}
264
265function explorerMacResizeFix () {
266    location.reload(false);
267}
268
269
270function pagelayer(targetId,url,params) {
271   page(targetId,url,params);
272   return !showPopup(targetId, event);
273   alert(targetId.width);
274}
275
276function MM_findObj(n, d) { //v4.01
277  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
278    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
279  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
280  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
281  if(!x && d.getElementById) x=d.getElementById(n); return x;
282}
283
284function MM_showHideLayers() { //v6.0
285  var i,p,v,obj,args=MM_showHideLayers.arguments;
286  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
287    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
288    obj.visibility=v; }
289}
290
291
292/////////////////////////////////////////////////////////////////////////////////////////////
293// funciones para la previsualizacion
294// funcion que previsualza una imagen cuando esta está marcada
295
296function f_filterResults(n_win, n_docel, n_body) {
297	var n_result = n_win ? n_win : 0;
298	if (n_docel && (!n_result || (n_result > n_docel)))
299		n_result = n_docel;
300	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
301}
302
303function f_scrollTop() {
304	return f_filterResults (
305		window.pageYOffset ? window.pageYOffset : 0,
306		document.documentElement ? document.documentElement.scrollTop : 0,
307		document.body ? document.body.scrollTop : 0
308	);
309}
310
311// funcion que previsualza una imagen cuando esta está marcada
312function previsualizacion(id,fichero) {
313   page('previs_imagen2','big_img.php','id='+id+'&pd='+Math.floor(Math.random()*1001));
314   // posicionamos mas o menos en medio
315   x=f_scrollTop();
316   x=x+150;   // mas o menos lo centramos a 150 pixles del margen superior
317   document.getElementById('previs_imagen').style.top = x+'px';
318   MM_showHideLayers('previs_imagen','','show');	
319}
320
321
322// funcion que previsualza una imagen cuando esta está marcada
323function go_album(id) {
324   page('previs_album2','/extranet/aj_album.php','id='+id+'&pd='+Math.floor(Math.random()*1001));
325   // posicionamos mas o menos en medio
326   x=f_scrollTop();
327   x=x+150;   // mas o menos lo centramos a 150 pixles del margen superior
328   document.getElementById('previs_album').style.top = x+'px';
329   MM_showHideLayers('previs_album','','show');	
330}
331
332
333// funcion que muestra la ayuda
334function go_ayuda(id) {
335   page('previs_ayuda2','/extranet/ayuda.php','id='+id+'&pd='+Math.floor(Math.random()*1001));
336   // posicionamos mas o menos en medio
337   x=f_scrollTop();
338   x=x+150;   // mas o menos lo centramos a 150 pixles del margen superior
339   document.getElementById('previs_ayuda').style.top = x+'px';
340   MM_showHideLayers('previs_ayuda','','show');	
341}
342
343// funciones para la previsualizacion
344//////////////////////////////////////////////////////////////////////////////////////////////
345
346
347
348function borrar_imagen(id) { 
349   if(confirm('¿Seguro que deseas eliminar la imagen')) {
350	   location.href="borrar_imagen.php?pid="+id+"&chsum=6ffu36ffg3ljdhdlpoos";
351   }
352} 
353
354
355function doSubmit(e)
356{
357    var keynum;
358    if(window.event)
359    {
360        keynum = e.keyCode;
361    }
362    else if(e.which)
363    {
364        keynum = e.which;
365    }
366    if(keynum==13)
367    {
368        if (document.getElementById('user').value.length>0 && document.getElementById('pwd').value.length>0)
369        {
370            document.getElementById('form1').submit();
371        }
372    }
373    else
374    {
375        return true;
376    }
377    return true;
378}
379    
380   
381
382

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.