Changeset ad4243e in Git for target/classes/static/js
- Timestamp:
- 02/07/22 21:26:03 (3 years ago)
- Branches:
- main
- Children:
- 0226942
- Parents:
- 7f36551 (diff), 3c0f9a9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Mato-77 <56981531+Mato-77@…> (02/07/22 21:26:03)
- git-committer:
- GitHub <noreply@…> (02/07/22 21:26:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
target/classes/static/js/sharedScript.js
r7f36551 rad4243e 4 4 var elements = $(".elements") 5 5 var elementGrade; 6 7 8 $("#button-add").on("click", function (){ 9 itemInput = $("#pageInput") 10 itemInput.val(Number(itemInput.val()) + 1); 11 $("#button-submit-page").click() 12 }) 13 14 $("#button-sub").on("click", function (){ 15 itemInput = $("#pageInput") 16 if(Number(itemInput.val()) > 1){ 17 itemInput.val(Number(itemInput.val()) - 1); 18 $("#button-submit-page").click() 19 } 20 }) 21 22 $("#searchTitle").on("keyup", function() { 23 var value = $(this).val().toLowerCase(); 24 console.log(value) 25 $(".elements div a .title").filter(function() { 26 console.log($(this).text()) 27 if($(this).text().toLowerCase().indexOf(value) <= -1) 28 $(this).parent().parent().parent().addClass("visibility") 29 else 30 $(this).parent().parent().parent().removeClass("visibility") 31 }); 32 }); 33 34 6 35 7 36 … … 37 66 38 67 39 $(".search-button-title").on("click",function (){68 /*$(".search-button-title").on("click",function (){ 40 69 let filter = $("#searchTitle").val() 41 70 console.log(elements) … … 50 79 } 51 80 } 52 53 }) 81 })*/ 54 82 55 83 56 84 $(".search-button").on("click",function () { 57 85 let filter = $("#searchGenre").val() 58 console.log(elements)59 60 86 for (let item of elements) { 61 87 let genre = $(item).find(".card-genre") … … 64 90 for (let g of genre) { 65 91 66 if ( $(g).text().toLowerCase() === filter.toLowerCase()) {92 if (( $(g).text().toLowerCase() === filter.toLowerCase() && !$(g).hasClass("visibility") && filter.trim().length != 0)) { 67 93 visible = true 68 $(item). css("display","block")94 $(item).removeClass("visibility") 69 95 break; 70 96 } 71 97 } 72 if (!visible) 73 $(item).css("display","none") 98 if (!visible && filter.trim().length != 0) 99 $(item).addClass("visibility") 100 else 101 $(item).removeClass("visibility") 102 74 103 } 75 104 }); … … 117 146 let url = "api/movies/unlike/"+ $(this).attr("movie-id")+"?userId="+ $(this).attr("user-id") 118 147 ajaxCallLike(url,button,'unlike','Немате оставено допаѓање на филмот!') 148 }) 149 $(document.body).on("click",".button-add-genre-liked-list",function (){ 150 let button = $(this) 151 let url = "api/genres/like/"+ $(this).attr("genre-id") + "?userId="+ $(this).attr("user-id") 152 ajaxCallLikeGenre(url,button,'like','Веќе ви се допаѓа жанрот!') 153 }) 154 $(document.body).on("click",".button-remove-genre-liked-list",function (){ 155 let button = $(this) 156 let url = "api/genres/unlike/"+ $(this).attr("genre-id")+"?userId="+ $(this).attr("user-id") 157 ajaxCallLikeGenre(url,button,'unlike','Немате оставено допаѓање на жанрот!') 119 158 }) 120 159 $(".discussion-type").change(function (){ … … 157 196 158 197 } 198 $(button).remove() 159 199 } 160 200 else { … … 180 220 }) 181 221 } 222 223 224 225 function ajaxCallLikeGenre(url,button,type,message){ 226 $.ajax({ 227 url:url, 228 success:function (data){ 229 if (data){ 230 let el = $(button).parent().siblings().eq(3) 231 console.log(el) 232 if (type=="like") { 233 $(el).html(parseInt($(el).text()) + 1) 234 console.log("da") 235 } 236 else 237 $(el).html(parseInt($(el).text()) - 1) 238 $(button).css("display","none") 239 let userId = $(button).attr("user-id") 240 let genreId=$(button).attr("genre-id") 241 if (type==='like') { 242 $(button).parent().append("<a class='btn btn-danger button-remove-genre-liked-list' genre-id=" + genreId + " user-id=" + userId + ">💔</a>") 243 console.log("da") 244 } 245 else{ 246 $(button).parent().append("<a class='btn btn-success button-add-genre-liked-list' genre-id=" + genreId + " user-id=" + userId + ">❤</a>") 247 } 248 let likes_sibling = $("#"+genreId+"genre") 249 value_likes = Number(likes_sibling.text()) 250 if(type=="like") 251 value_likes+=1 252 else 253 value_likes-=1 254 likes_sibling.text(value_likes) 255 $(button).remove() 256 } 257 else { 258 $(button).parent().append("<div>" + message +" <button class='button-confirm'>Ок</button></div>") 259 } 260 } 261 }) 262 } 263 264 182 265 function ajaxCallRating(url,button,type){ 183 266 model = {
Note:
See TracChangeset
for help on using the changeset viewer.