Ver Mensaje Individual
  #9 (permalink)  
Antiguo 03/10/2012, 05:19
edie8
 
Fecha de Ingreso: noviembre-2011
Mensajes: 516
Antigüedad: 13 años, 5 meses
Puntos: 10
Respuesta: etiquetado en fotos

bien os agradezco la ayuda que me disteis pero ahora tengo otro problema con el mismo proyecto, resulta que cada vez que hago el click se etiqueta de nuevo pero me gustarian tres cosas:
1- que al hacer click me de opcion de meter el nombre de alguno de mis amigos para etiquetarlo a el, y nose como hacerlo, ya que yo no se mucho de javascript.
2- poner un tooltip como el de facebook que es un restangulito negro con una flecha, que el la web de jquery no me deja bajarlo porque dice que esta de mantenimiento y no se como se hace.
3- que no me deje etiquetarme dos veces en la misma foto, es decir que me valide si ese id existe en la base ono y e googleado pero no se como hacerlo, este codigo es el que yo tengo ahora:
Código Javascript:
Ver original
  1. <?php  
  2. session_start();
  3. include("header.php");
  4. if (!isset($_SESSION['logueado_usuario'])) {
  5.     include ("login.php");  
  6. }
  7.     else {  
  8.     $nombre =$_SESSION['logueado_nombre'];
  9.     $id_usuario=$_SESSION['logueado_id'];
  10. $obejeto=$_REQUEST['objeto'];
  11.  
  12. }
  13. if(!empty($_SESSION['logueado_nombre']))
  14.  
  15. {
  16. include("privados/config.php");
  17. $id=$_GET['id'];
  18. if($_POST)    
  19. {
  20.     set_time_limit(0);      
  21.     /*header("Edge-control: no-store");*/  
  22.     sleep(0);
  23.     include('config.php');
  24.     $notificaciones=mysql_query("select * from comentario where id_foto='$id'",$conexion);
  25.     while($rs=mysql_fetch_assoc($notificaciones))
  26.     {?><div id="cacao"><?php  $coment_foto=utf8_decode($rs['comentario']);
  27.     echo   $coment_foto."<br>";
  28.     ?></div><?php }  
  29.      //echo $rs['id_logueado']."<br>";
  30.     mysql_close($conexion);    
  31.     exit();  
  32. }
  33. $resultados=mysql_query("select * from imagenes where id='$id' and id_logueado='1'",$conexion) or
  34.   die("Problemas en el select:".mysql_error());
  35.  $a = mysql_query("select max(id) from imagenes where id <".$id. " and id_logueado='1'");
  36. $ida = mysql_result($a,0);
  37. mysql_free_result($a);
  38. $b = mysql_query("select min(id) from imagenes where id >".$id. " and id_logueado='1'");
  39. $idb = mysql_result($b,0);
  40. mysql_free_result($b);
  41. $a1 = mysql_query("select max(id) from imagenes where id_logueado='1'");
  42. $ida1 = mysql_result($a1,0);
  43. mysql_free_result($a1);
  44. $b1 = mysql_query("select min(id) from imagenes where id_logueado='1'");
  45. $idb1 = mysql_result($b1,0);
  46. mysql_free_result($b1);
  47. ?><div align="center"><div align="right" id="pasar"><a href="galeria.php?id=<?php echo $id; ?>" >Volver</a></div>
  48. <?php
  49. /*$fotos=mysql_query("select * from imagenes where id='$id'",$conexion);
  50. while($fot=mysql_fetch_array($fotos))
  51. {
  52. echo '<img src="'.$fot['nombre'].'"';
  53. }*/
  54.  
  55. ?>
  56.  
  57. <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js'></script>
  58.         <script src='js/jquery.autosize.js'></script>
  59.         <script>
  60.             $(function(){
  61.                 $('textarea').autosize();
  62.             });
  63.         </script>
  64. <script language="JavaScript" type="text/javascript" src="ajax.js"></script>
  65. <script language="JavaScript">
  66. function nuevoAjax(){
  67.                     var xmlhttp=false;
  68.                      try {
  69.                       xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  70.                      } catch (e) {
  71.                       try {
  72.                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  73.                       } catch (E) {
  74.                        xmlhttp = false;
  75.                       }
  76.                      }
  77.  
  78.                     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  79.                       xmlhttp = new XMLHttpRequest();
  80.                     }
  81.                     return xmlhttp;
  82.                     }
  83. function presionado(e)
  84. {
  85.   if (window.event) //es ie?
  86.   {
  87. divResultado = document.getElementById('resultado');
  88.     var foto = "<?php echo $id; ?>" ;
  89.    
  90.     ajax=nuevoAjax();
  91.    
  92.     ajax.open("GET","etiquetar.php?x="+window.event.clientX+"&y="+window.event.clientY+"&id="+foto,true);
  93.     ajax.onreadystatechange=function(){
  94.         if(ajax.readyState==4){
  95.             alert("Se ha etiquetado con exito.");
  96.         }
  97.     }
  98.     ajax.setRequestHeader("Conten-Type","application/x-www-form-urlencoded");
  99.     ajax.send("x="+window.event.clientX+"&y="+window.event.clientY)
  100.  
  101.    
  102.   }
  103.   else
  104.   {
  105.   var x1=e.clientX;
  106.   var y1=e.clientY;
  107.   divResultado = document.getElementById('resultado');
  108.    
  109.     ajax=nuevoAjax();
  110.    
  111.     ajax.open("GET","etiquetar.php?x="+e.clientX+"&y="+e.clientY,true);
  112.     ajax.onreadystatechange=function(){
  113.         if(ajax.readyState==4){
  114.             divResultado.innerHTML = ajax.responseText
  115.         }
  116.     }
  117.     ajax.setRequestHeader("Conten-Type","application/x-www-form-urlencoded");
  118.     ajax.send("x="+e.clientX+"&y="+e.clientY)
  119.  
  120. }
  121.  
  122. }
  123.  
  124. </script>
  125. <html>
  126. <head>    
  127. </head>
  128. <body>
  129.  
  130.  
  131.  
  132.    
  133. <script type="text/javascript" src="js/comet.js"></script>
  134. <style type="text/css">
  135. #cacao{background-color: #EEEFF0;
  136.     padding: 5px;
  137.     width: 500px;
  138.     margin: auto;
  139.     border-top:2px double #91969B ;
  140.     border-left:2px double #91969B ;
  141.     border-right:2px double #91969B ;
  142.     border-bottom:2px double #91969B ;
  143.     }
  144.     div.mapa_imagen {
  145.     position:static;
  146. }
  147. ul.notas li {
  148.   list-style: none;
  149.   display: none;
  150.   position: absolute;
  151. /*  border: medium solid white;*/
  152.   background: url("esta_imagen_no_existe");
  153. }
  154. div.mapa_imagen:hover ul.notas li {
  155.   display: block;
  156. }
  157. ul.notas li p {
  158.   margin: 10px 0 0 0;
  159.   padding: .3em;
  160.   display: none;
  161.   background: #FFF;
  162.   /*opacity: 0.65;*/
  163.   position: absolute;
  164.   top: 100%;
  165. }
  166. ul.notas li:hover p {
  167.   display: block;
  168. }
  169.    
  170. </style> <?php
  171. $con=mysql_query("select * from etiqueta where id_foto='$id'",$conexion);
  172. $i=1;
  173. echo '<div class="mapa_imagen">';
  174. while($ima=mysql_fetch_array($con))
  175. {
  176. ?><style>ul.notas li#nota<?php echo $i; ?> {
  177.   width: 100px; height: 100px; top: <?php echo $ima['y']."px"?>; left: <?php echo $ima['x']."px"?>;
  178. }</style><?php
  179. $consulta=mysql_query("select * from usuarios where id='$ima[id_logueado]'",$conexion);
  180. while($cons=mysql_fetch_array($consulta))
  181. {
  182.     echo '<ul class="notas">';
  183.     echo '<li id="nota'.$i.'"><p>'.$cons['nombre'].'</p></li>';
  184.     echo '</ul>';
  185.    
  186.     }$i++;
  187. }
  188.  
  189. $comentarios=mysql_query("select * from comentario where id_foto='$id'",$conexion);
  190. while($comen=mysql_fetch_array($comentarios))
  191. {
  192.     $comentario=utf8_decode($comen['comentario']);
  193. }
  194.   while($fot=mysql_fetch_assoc($resultados))
  195. {
  196. $foto_nombre=$fot['nombre'];
  197. $titulo=$fot['titulo'];
  198. $fecha=$fot['fecha'];
  199. if(isset($idb) && !empty($idb))
  200. {
  201.  echo '<img src="'.$foto_nombre.'" onclick="presionado(event);" "usemap="#Map" style="z-index:0">';
  202.  echo '<br>';
  203.  /*echo $comentario;*/
  204. }
  205. else
  206. {
  207. echo '<img src="'.$foto_nombre.'" onclick="presionado(event);" usemap="#Map" style="z-index:0">';
  208. echo '<br>';
  209. /*echo $comentario;*/
  210. }
  211. }
  212. echo "<br>";
  213. ?><div align="right" id="pasar" style="margin-top:-48%; position:relative"><?php echo $titulo."<br>"; echo $fecha;  ?></div><?php
  214. ?>
  215.  
  216. <script type="text/javascript">
  217. function sapeartextarea(){
  218.     var nav=(document.all)?"%0D":"%0A"
  219.     var ref=document.getElementById("textarea")
  220.     textoarea=escape(ref.value)
  221.     lineas=textoarea.split(nav)
  222.     lin=lineas.length
  223.     if(lin>4){
  224.         ref.rows=lin
  225.         document.getElementById("clin").innerHTML=lin
  226.     }
  227. }
  228. document.onkeyup = function(){sapeartextarea()}
  229. </script>
  230. <div id="respuesta"></div><?php }?>
  231. </body>
  232. </html>
  233. <br /></div>
  234. </body>
  235. </html>
gracias un saludo.

Última edición por edie8; 03/10/2012 a las 05:47