This repository was archived by the owner on Apr 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy patheditar_ajax.js.php
More file actions
125 lines (109 loc) · 4.52 KB
/
Copy patheditar_ajax.js.php
File metadata and controls
125 lines (109 loc) · 4.52 KB
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
<?php
/* ===========================
sabros.us monousuario version 1.8
http://sabros.us/
sabros.us is a free software licensed under GPL (General public license)
=========================== */
header("Content-type: application/x-javascript");
include("include/functions.php");
include("include/config.php");
include("include/conex.php");
?>
function editar_cancelar(id){
<?php /*Volvemos a mostrar el enlace*/?>
document.getElementById('enlace'+id).style.visibility="visible";
document.getElementById('enlace'+id).style.position="relative";
<?php /*Ocultamos el formulario de edición para el enlace*/?>
document.getElementById('editar'+id).style.visibility="hidden";
document.getElementById('editar'+id).style.position="absolute";
<? /*Efecto*/?>
efectoEnlaceCancelar = new Fx.Color('enlace'+id, 'background-color');
efectoEnlaceCancelar.fromColor('#FF0000');
}
function editar_guardar(id){
title = document.getElementById('_title'+id).value;
enlace = document.getElementById('_enlace'+id).value;
descripcion = document.getElementById('_descripcion'+id).value;
tags = document.getElementById('_tags'+id).value;
ajax = xmlhttp();
ajax.onreadystatechange=function(){
if(ajax.readyState==1){
document.getElementById('editar'+id).innerHTML='<p class="ajax_msg"><img src="images/ajax-loading.gif" alt="<?=__("Saboreando...")?>"/><?=__(" Saboreando...")?></p>';
}
if(ajax.readyState==4){
<?php /*Ocultamos la caja donde estaba el formulario y msg de Guardando... */?>
document.getElementById('editar'+id).style.position="absolute";
document.getElementById('editar'+id).style.visibility="hidden";
<?php /*Mostramos enlace*/?>
ver_enlace(id);
document.getElementById('enlace'+id).style.position="relative";
document.getElementById('enlace'+id).style.visibility="visible";
<? /*Efecto*/?>
efectoEnlaceGuardar = new Fx.Color('enlace'+id, 'background-color');
efectoEnlaceGuardar.fromColor('#00FF00');
}
}
ajax.open("POST","modifica.php",true);
ajax.setRequestHeader("Content-type","application/x-www-form-urlencoded");
ajax.send(''+
'id_enlace='+(id)+
'&title='+encodeURIComponent(title)+
'&enlace='+encodeURIComponent(enlace)+
'&descripcion='+encodeURIComponent(descripcion)+
'&etiquetas='+encodeURIComponent(tags)+
'&accion=editar'
);
}
function ver_enlace(id){
_ajax = xmlhttp()
_ajax.onreadystatechange=function(){
if(_ajax.readyState==1)
document.getElementById('enlace'+id).innerHTML='<p class="ajax_msg"><img src="images/ajax-loading.gif" alt="<?=__(" Saboreando...")?>"/><?=__(" Saboreando...")?></p>';
if(_ajax.readyState==4)
document.getElementById('enlace'+id).innerHTML=_ajax.responseText;
}
_ajax.open("GET","editar_ajax.php?id="+id+"&enlace",true);
_ajax.send(null);
}
function xmlhttp(){
<?php /* Esta funcion crea el retorna un objeto para manipular xmlhttprequest en los navegadores */?>
<?php /* Si existe alguna otra función mejor que esta, ya estas aturizado de modificar o sustituir sin ningún problema :D */?>
var xmlhttp;
try{xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){
try{xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){
try{xmlhttp = new XMLHttpRequest();}
catch(e){
xmlhttp = false;
}
}
}
if (!xmlhttp)
return null;
else
return xmlhttp;
}
function editar_ajax(id){
<?php /*Ocultamos enlace*/?>
document.getElementById('enlace'+id).style.visibility="hidden";
document.getElementById('enlace'+id).style.position="absolute";
<?php /*Mostramos formulario de edición para el enlace*/?>
A = document.getElementById('editar'+id);
A.style.position="relative";
A.style.visibility="visible";
ajax = xmlhttp();
ajax.onreadystatechange=function(){
if(ajax.readyState==1){
A.innerHTML = '<p class="ajax_msg"><img src="images/ajax-loading.gif" alt="<?=__(" Saboreando...")?>"/><?=__("Saboreando...")?></p>';
}
if(ajax.readyState==4){
A.innerHTML = ajax.responseText;
A.innerHTML += '<span class="ajax_opcion"><a href="javascript:editar_guardar('+ id +')"><?=__("Guardar")?></a></span>';
A.innerHTML += '<span class="ajax_opcion"><a href="javascript:editar_cancelar('+ id +')"><?=__("Cancelar")?></a></span>';
}
}
ajax.open("GET","<?=$Sabrosus->sabrUrl;?>/editar_ajax.php?id="+id,true);
ajax.send(null);
return false;
}