Ver Mensaje Individual
  #4 (permalink)  
Antiguo 08/12/2011, 12:49
dksoft
 
Fecha de Ingreso: octubre-2010
Mensajes: 123
Antigüedad: 13 años, 6 meses
Puntos: 10
Respuesta: 140 Caracteres y URL acortada

Todo el Codigo:

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  4. <title>Twitter</title>
  5. .warp{
  6.     width: 450px;
  7.     background: #999;
  8.     font-family: "Century Gothic";
  9. }
  10. #caracteres {
  11.     font-weight: bold;
  12. }
  13. .texto {
  14.     color: #FFF;   
  15.     font-weight: bold;
  16. }
  17. <script src="http://code.jquery.com/jquery-1.7.1.min.js" type="text/javascript"></script>
  18. <script type="text/javascript">
  19. var actual = 140;
  20. function press() {
  21. car = $("#input").val();
  22. total = actual - car.length;
  23. $("#caracteres").html(total);
  24. if(total > 20) { $("#caracteres").css("color", "#090"); }
  25. if(total <= 20) { $("#caracteres").css("color", "#903"); }
  26. if(total < 0) { $("#caracteres").css("color", "#F00"); }
  27. }
  28. function enviar() {
  29. texto = $("#input").val();
  30. if(confirm("Estas seguro de enviar el TWEET?")) {
  31. $("#boton").attr("disabled", true);
  32. $("#input").attr("disabled", true);
  33. $.post("enviar.php", { texto: texto }, function(data){
  34. if(data == "ok") { $("#input").val(""); alert("Twet enviado exitosamente"); } else { $("#resultado").html(data);  }
  35. $("#boton").attr("disabled", false);
  36. $("#input").attr("disabled", false);
  37. });
  38. }
  39. }
  40. $(document).ready(function(){
  41. car = $("#input").val();
  42. total = actual - car.length;
  43. $("#caracteres").html(total);
  44. if(total > 20) { $("#caracteres").css("color", "#090"); }
  45. if(total <= 20) { $("#caracteres").css("color", "#903"); }
  46. if(total < 0) { $("#caracteres").css("color", "#F00"); }});
  47. </head>
  48.  
  49. <div class="warp">
  50. <form onsubmit="enviar(); return false;" >
  51. <p><textarea cols="50" rows="3" id="input" onkeypress="press();" onkeydown="press();" onkeyup="press();"></textarea><br />
  52. <input type="submit" value="Tweet" id="boton" />
  53. </p>
  54. </form>
  55. <p><span id="caracteres"></span> <span class="texto">Caracteres Restantes</span></p>
  56. <div id="resultado"></div>
  57. </div>
  58. </body>
  59. </html>