tuxmartin

js

Feb 22nd, 2014
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.88 KB | None | 0 0
  1. <script>
  2.     function fceUpload() {
  3.         console.log("nahravam obrazek");
  4.         document.form2.action = "/ppro/upload"
  5.         uploadJqueryForm();
  6.     }
  7.     function fcePost() {
  8.         document.form2.action= "/ppro/postSave"
  9.         document.form2.submit();
  10.     }
  11.  
  12.     function uploadJqueryForm() {
  13.         $('#result').html('');
  14.  
  15.         $("#form2").ajaxForm({
  16.             success: function(data) {
  17.                 var path = "get/" + data;
  18.                 var img=$("<img />").attr("src",path);
  19.                 img.appendTo($("#result"));  
  20.                 document.getElementById("imageId").value=data;
  21.             },
  22.             dataType: "text"
  23.         }).submit();
  24.     }  
  25. </script>
  26.  
  27. <%-- Nacitani novych prispevku na zed AJAXem --%>
  28. <script>
  29. /*
  30.  
  31. var divs = document.getElementsByClassName('post');
  32. console.log(divs.length, "divs with class *post*");
  33. for(var i=0; i<divs.length; i++) {
  34.     var id = divs[i].getAttribute('data-id');
  35.     console.log(id, "lastPostID");
  36. }
  37. */
  38.  
  39. //var lastPostID;
  40. $(document).ready(function(){                      
  41.                     setInterval(function(i) {
  42.                         var divs = document.getElementsByClassName('post'); // pomoci jQuery to nefunguje :-(
  43.                         var lastPostID = parseInt( divs[0].getAttribute('data-id') );
  44.                         var myurl = "/ppro/postJS/from/"+parseInt(lastPostID);
  45.                         console.log(myurl, "myurl");
  46.                         $.ajax({
  47.                             url: myurl,
  48.                             cache: true,
  49.                             success: function(html){
  50.                                 $("#post-new").html(html); // pomocny div
  51.                             //  j('#post-new').contents().hide().prependTo("#allPosts").slideDown("slow"); // bez hide() neskryje stare prispevky - nejak to nefunguje :-(
  52.                                 $("#post-new").prependTo("#allPosts"); // verze bez animace
  53.                         //      j("#post-new").empty(); // vymaze obsah pomocneho divu (je to vubec potreba?)
  54.                             }
  55.                         })
  56.                     }, 10000)
  57. });
  58.  
  59. </script>
  60.  
  61. <section id="top" class="one">
Advertisement
Add Comment
Please, Sign In to add comment