Changeset 0226942 in Git for target/classes/static/js
- Timestamp:
- 02/08/22 22:07:07 (3 years ago)
- Branches:
- main
- Children:
- 967b414
- Parents:
- ad4243e (diff), c02189f (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/08/22 22:07:07)
- git-committer:
- GitHub <noreply@…> (02/08/22 22:07:07)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
target/classes/static/js/sharedScript.js
rad4243e r0226942 4 4 var elements = $(".elements") 5 5 var elementGrade; 6 6 var first_time = true; 7 7 8 8 $("#button-add").on("click", function (){ … … 56 56 $(".button-add-grade-movie").on("click",function (){ 57 57 elementGrade = $(this) 58 urlRating =" api/movies/grade/"+$(this).attr("movie-id")58 urlRating ="/api/movies/grade/"+$(this).attr("movie-id") 59 59 $("#dialog-rating").dialog("open") 60 60 }) 61 61 $(".button-add-grade-person").on("click",function (){ 62 62 elementGrade = $(this) 63 urlRating =" api/persons/grade/"+$(this).attr("person-id")63 urlRating ="/api/persons/grade/"+$(this).attr("person-id") 64 64 $("#dialog-rating").dialog("open") 65 65 }) … … 81 81 })*/ 82 82 83 $("#button_toggle_filters").on("click", function (){ 84 if(first_time){ 85 $("#filters_div").removeClass("invisible-search") 86 first_time=false 87 } 88 else 89 $("#filters_div").fadeToggle(); 90 }) 83 91 84 92 $(".search-button").on("click",function () { 85 let filter = $("#searchGenre").val() 93 elements = $(".elements") 94 let filter = $("#searchGenre").val() 95 console.log('\''+filter+'\'') 96 console.log(elements) 97 if(filter.length==0){ 98 console.log("HERE") 99 for (let item of elements) { 100 $(item).removeClass("visibility") 101 } 102 } 86 103 for (let item of elements) { 87 let genre = $(item).find(".card-genre") 104 $(item).removeClass("visibility") 105 let genre = $(item).children(".card-genre") 88 106 let visible = false; 89 107 console.log(genre.length) 90 108 for (let g of genre) { 91 92 if (( $(g).text().toLowerCase() === filter.toLowerCase() && !$(g).hasClass("visibility") && filter.trim().length != 0)) {109 if (( $(g).text().toLowerCase() === filter.toLowerCase())){ 110 console.log(item.text + ' ' + $(g).text()) 93 111 visible = true 94 112 $(item).removeClass("visibility") … … 96 114 } 97 115 } 98 if (!visible && filter.trim().length != 0)116 if(!visible){ 99 117 $(item).addClass("visibility") 100 else 101 $(item).removeClass("visibility") 118 } 102 119 103 120 } … … 106 123 $(".button-delete-movie").on("click",function (){ 107 124 let button = $(this) 108 let url = " api/movies/delete/" + $(button).attr("movie-id")125 let url = "/api/movies/delete/" + $(button).attr("movie-id") 109 126 ajaxCallDelete(url,button) 110 127 }) 111 128 $(".button-delete-actor").on("click",function (){ 112 129 let button = $(this) 113 let url = " api/persons/delete/" + $(button).attr("person-id")130 let url = "/api/persons/delete/" + $(button).attr("person-id") 114 131 ajaxCallDelete(url,button) 115 132 }) 116 133 $(".button-delete-discussion").on("click",function (){ 117 134 let button = $(this) 118 let url = " api/discussions/delete/" + $(button).attr("discussion-id")135 let url = "/api/discussions/delete/" + $(button).attr("discussion-id") 119 136 ajaxCallDelete(url,button) 120 137 }) … … 139 156 $(document.body).on("click",".button-add-favourite-list",function (){ 140 157 let button = $(this) 141 let url = " api/movies/like/"+ $(this).attr("movie-id") + "?userId="+ $(this).attr("user-id")158 let url = "/api/movies/like/"+ $(this).attr("movie-id") + "?userId="+ $(this).attr("user-id") 142 159 ajaxCallLike(url,button,'like','Веќе е филмот допаднат!') 143 160 }) 144 161 $(document.body).on("click",".button-remove-favourite-list",function (){ 145 162 let button = $(this) 146 let url = " api/movies/unlike/"+ $(this).attr("movie-id")+"?userId="+ $(this).attr("user-id")163 let url = "/api/movies/unlike/"+ $(this).attr("movie-id")+"?userId="+ $(this).attr("user-id") 147 164 ajaxCallLike(url,button,'unlike','Немате оставено допаѓање на филмот!') 148 165 }) 149 166 $(document.body).on("click",".button-add-genre-liked-list",function (){ 150 167 let button = $(this) 151 let url = " api/genres/like/"+ $(this).attr("genre-id") + "?userId="+ $(this).attr("user-id")168 let url = "/api/genres/like/"+ $(this).attr("genre-id") + "?userId="+ $(this).attr("user-id") 152 169 ajaxCallLikeGenre(url,button,'like','Веќе ви се допаѓа жанрот!') 153 170 }) 154 171 $(document.body).on("click",".button-remove-genre-liked-list",function (){ 155 172 let button = $(this) 156 let url = " api/genres/unlike/"+ $(this).attr("genre-id")+"?userId="+ $(this).attr("user-id")173 let url = "/api/genres/unlike/"+ $(this).attr("genre-id")+"?userId="+ $(this).attr("user-id") 157 174 ajaxCallLikeGenre(url,button,'unlike','Немате оставено допаѓање на жанрот!') 175 }) 176 $(document.body).on("click",".button-like-discussion",function (){ 177 let button = $(this) 178 let url = "/api/discussions/like/"+ $(this).attr("discussion-id")+"?userId="+ $(this).attr("user-id") 179 ajaxCallLikeDiscussion(url,button,'like','Веќе имате оставено допаѓање на дискусијата!') 180 }) 181 $(document.body).on("click",".button-unlike-discussion",function (){ 182 let button = $(this) 183 let url = "/api/discussions/unlike/"+ $(this).attr("discussion-id")+"?userId="+ $(this).attr("user-id") 184 ajaxCallLikeDiscussion(url,button,'unlike','Немате оставено допаѓање на дискусијата!') 185 }) 186 $(document.body).on("click",".button-like-discussion-alt",function (){ 187 let button = $(this) 188 let url = "/api/discussions/like/"+ $(this).attr("discussion-id")+"?userId="+ $(this).attr("user-id") 189 ajaxCallLikeDiscussionAlternative(url,button,'like','Веќе имате оставено допаѓање на дискусијата!') 190 }) 191 $(document.body).on("click",".button-unlike-discussion-alt",function (){ 192 let button = $(this) 193 let url = "/api/discussions/unlike/"+ $(this).attr("discussion-id")+"?userId="+ $(this).attr("user-id") 194 ajaxCallLikeDiscussionAlternative(url,button,'unlike','Немате оставено допаѓање на дискусијата!') 158 195 }) 159 196 $(".discussion-type").change(function (){ … … 189 226 let movieId=$(button).attr("movie-id") 190 227 if (type==='like') { 191 $(button).parent().append("<a class='b ottom-heart btn btn-danger button-remove-favourite-list' movie-id=" + movieId + " user-id=" + userId + ">💔</a>")228 $(button).parent().append("<a class='btn btn-danger button-remove-favourite-list' movie-id=" + movieId + " user-id=" + userId + ">💔</a>") 192 229 console.log("da") 193 230 } 194 231 else{ 195 $(button).parent().append("<a class='bottom-heart btn btn-success button-add-favourite-list' movie-id=" + movieId + " user-id=" + userId + ">❤</a>") 196 197 } 232 $(button).parent().append("<a class='btn btn-success button-add-favourite-list' movie-id=" + movieId + " user-id=" + userId + ">❤</a>") 233 } 234 likes_count = $("#movie_likes_count") 235 count = Number($(likes_count).text()) 236 if(type==="like") 237 count++ 238 else 239 count-- 240 likes_count.text(count) 198 241 $(button).remove() 199 242 } … … 263 306 264 307 308 309 310 function ajaxCallLikeDiscussion(url,button,type,message){ 311 $.ajax({ 312 url:url, 313 success:function (data){ 314 if (data){ 315 let el = $(button).parent().siblings().eq(3) 316 console.log(el) 317 if (type=="like") { 318 $(el).html(parseInt($(el).text()) + 1) 319 console.log("da") 320 } 321 else 322 $(el).html(parseInt($(el).text()) - 1) 323 $(button).css("display","none") 324 let userId = $(button).attr("user-id") 325 let discussionId=$(button).attr("discussion-id") 326 if (type==='like') { 327 $(button).parent().append("<a class='btn btn-danger button-unlike-discussion' discussion-id=" + discussionId + " user-id=" + userId + ">💔</a>") 328 console.log("da") 329 } 330 else{ 331 $(button).parent().append("<a class='btn btn-success button-like-discussion' discussion-id=" + discussionId + " user-id=" + userId + ">❤</a>") 332 } 333 var likes_count = $("#likes_count") 334 var count = Number($(likes_count).text()) 335 if(type==='like') 336 count += 1 337 else 338 count -= 1 339 $(likes_count).text(count); 340 $(button).remove() 341 } 342 else { 343 $(button).parent().append("<div>" + message +" <button class='button-confirm'>Ок</button></div>") 344 } 345 } 346 }) 347 } 348 349 350 351 function ajaxCallLikeDiscussionAlternative(url,button,type,message){ 352 $.ajax({ 353 url:url, 354 success:function (data){ 355 if (data){ 356 let el = $(button).parent().siblings().eq(3) 357 console.log(el) 358 if (type=="like") { 359 $(el).html(parseInt($(el).text()) + 1) 360 console.log("da") 361 } 362 else 363 $(el).html(parseInt($(el).text()) - 1) 364 $(button).css("display","none") 365 let userId = $(button).attr("user-id") 366 let discussionId=$(button).attr("discussion-id") 367 if (type==='like') { 368 $(button).parent().append("<a class='btn btn-danger button-unlike-discussion-alt' discussion-id=" + discussionId + " user-id=" + userId + ">💔</a>") 369 console.log("da") 370 } 371 else{ 372 $(button).parent().append("<a class='btn btn-success button-like-discussion-alt' discussion-id=" + discussionId + " user-id=" + userId + ">❤</a>") 373 } 374 var likes_count = $(button).parent().siblings(".likes_count").first() 375 var count = Number(likes_count.text()) 376 if(type==='like') 377 count += 1 378 else 379 count -= 1 380 $(likes_count).text(count); 381 $(button).remove() 382 } 383 else { 384 $(button).parent().append("<div>" + message +" <button class='button-confirm'>Ок</button></div>") 385 } 386 } 387 }) 388 } 389 390 265 391 function ajaxCallRating(url,button,type){ 266 392 model = {
Note:
See TracChangeset
for help on using the changeset viewer.