1 2function playlist_delete_item(playlist_id, item_id, placeholder) { 3 if (confirm(pm_lang.playlist_delete_item_confirm)) { 4 ajax_request("playlists", "do=remove-item&video-id=" + item_id + "&playlist-id=" + playlist_id, "", "", false, "POST"); 5 $(placeholder).fadeOut('slow'); 6 } 7 return false; 8} 9 10function playlist_delete(playlist_id, btn) { 11 $(btn).attr('disabled', 'disabled'); 12 13 if (confirm(pm_lang.playlist_delete_confirm)) { 14 $('#playlist-modal-ajax-response').html('').hide(); 15 $('#modal-loading-gif').show(); 16 17 $.ajax({ 18 type: "POST", 19 url: MELODYURL2 + "/ajax.php", 20 data: { 21 "p" : "playlists", 22 "do": "delete-playlist", 23 "playlist-id" : playlist_id 24 }, 25 dataType: "json", 26 success: function(data) { 27 if ( ! data.success) { 28 $('#playlist-modal-ajax-response').html(data.html).show(); 29 $('#modal-loading-gif').hide(); 30 $(btn).removeAttr('disabled'); 31 } else { 32 window.location = MELODYURL2 + '/playlists.php'; 33 } 34 } 35 }); 36 } else { 37 $('#modal-loading-gif').hide(); 38 } 39 return false; 40} 41 42function playlist_save_settings(playlist_id, btn) { 43 $('#playlist-modal-ajax-response').html('').hide(); 44 $('#modal-loading-gif').show(); 45 46 $(btn).attr('disabled', 'disabled'); 47 48 $.ajax({ 49 type: "POST", 50 url: MELODYURL2 + "/ajax.php", 51 data: { 52 "p" : "playlists", 53 "do": "update-playlist", 54 "playlist-id" : playlist_id, 55 "title" : $('input[name="playlist_name"]').val(), 56 "visibility" : $('select[name="visibility"]').val(), 57 "sorting" : $('select[name="sorting"]').val() 58 }, 59 dataType: "json", 60 success: function(data) { 61 if ( ! data.success) { 62 $('#playlist-modal-ajax-response').html(data.html).show(); 63 $('#modal-loading-gif').hide(); 64 $(btn).removeAttr('disabled'); 65 } else { 66 location.reload(); 67 } 68 } 69 }); 70 71 return false; 72} 73 74function playlist_create(btn, ui) { 75 ui = (typeof ui !== 'undefined') ? ui : 'playlists-modal'; 76 77 var response_placeholder; 78 79 if (ui == 'video-watch') { 80 response_placeholder = '#playlist-create-ajax-response'; 81 $('#playlist-container').addClass('opac5'); 82 } else { 83 response_placeholder = '#playlist-modal-ajax-response'; 84 $('#modal-loading-gif').show(); 85 } 86 87 $(response_placeholder).hide().html(''); 88 $(btn).attr('disabled', true); 89 90 $.ajax({ 91 type: "POST", 92 url: MELODYURL2 + "/ajax.php", 93 data: { 94 "p" : "playlists", 95 "do": "create-playlist", 96 "title" : $('input[name="playlist_name"]').val(), 97 "visibility" : $('select[name="visibility"]').val(), 98 "sorting" : $('select[name="sorting"]').val(), 99 "video-id" : $('input[name="video_id"]').val(), 100 "ui" : ui 101 }, 102 dataType: "json", 103 success: function(data) { 104 if ( ! data.success) { 105 106 $(response_placeholder).html(data.html).show(); 107 $(btn).removeAttr('disabled'); 108 109 if (ui == 'video-watch') { 110 $('#playlist-container').removeClass('opac5'); 111 } else { 112 $('#modal-loading-gif').hide(); 113 } 114 } else { 115 $(response_placeholder).html(data.html).show(); 116 117 if (ui == 'video-watch') { 118 $('#playlist-container').replaceWith(data.html_content); 119 $('input[name="playlist_name"]').attr('value', ''); 120 $(btn).attr('disabled', true); 121 } else { 122 location.reload(); 123 } 124 } 125 } 126 }); 127 128 return false; 129} 130 131function playlist_add_item(playlist_id, video_id) { 132 $('#playlist-container').addClass('opac5'); 133 $('#playlist-ajax-response').hide().html(''); 134 135 $.ajax({ 136 type: "POST", 137 url: MELODYURL2 + "/ajax.php", 138 data: { 139 "p" : "playlists", 140 "do": "add-to-playlist", 141 "playlist-id" : playlist_id, 142 "video-id" : video_id 143 }, 144 dataType: "json", 145 success: function(data) { 146 if ( ! data.success) { 147 $('#playlist-ajax-response').html(data.html).show(); 148 $('#playlist-container').removeClass('opac5'); 149 } else { 150 $('#playlist-container').replaceWith(data.html); 151 } 152 } 153 }); 154} 155 156function playlist_remove_item(playlist_id, video_id) { 157 $('#playlist-container').addClass('opac5'); 158 $('#playlist-ajax-response').hide().html(''); 159 160 $.ajax({ 161 type: "POST", 162 url: MELODYURL2 + "/ajax.php", 163 data: { 164 "p" : "playlists", 165 "do": "remove-from-playlist", 166 "playlist-id" : playlist_id, 167 "video-id" : video_id 168 }, 169 dataType: "json", 170 success: function(data) { 171 if ( ! data.success) { 172 $('#playlist-ajax-response').html(data.html).show(); 173 $('#playlist-container').removeClass('opac5'); 174 } else { 175 $('#playlist-container').replaceWith(data.html); 176 } 177 } 178 }); 179} 180 181function watch_later_add(video_id) 182{
183 $('.watch-later-add-btn-'+ video_id).addClass('opac5'); 184 185 return watch_later(video_id, "watch-later-add"); 186} 187function watch_later_remove(video_id) 188{ 189 $('.watch-later-remove-btn-'+ video_id).addClass('opac5'); 190 191 return watch_later(video_id, "watch-later-remove"); 192} 193function watch_later(video_id, action) 194{ 195 $.ajax({ 196 type: "POST", 197 url: MELODYURL2 + "/ajax.php", 198 data: { 199 "p" : "playlists", 200 "do": action, 201 "video-id" : video_id 202 }, 203 dataType: "json", 204 success: function(data) { 205 if (action == 'watch-later-add') { 206 $('.watch-later-add-btn-'+ video_id).hide().removeClass('opac5'); 207 $('.watch-later-remove-btn-'+ video_id).show(); 208 } else { 209 $('.watch-later-add-btn-'+ video_id).show(); 210 $('.watch-later-remove-btn-'+ video_id).hide().removeClass('opac5'); 211 } 212 } 213 }); 214} 215 216 217// general.js 218function validateSearch(a){ 219 if (document.forms.search.keywords.value == "" || document.forms.search.keywords.value == "search") { 220 alert("You did not enter a search term. Please try again."); 221 if (a == "true") { 222 return false 223 } 224 } 225 else { 226 document.forms.search.submit() 227 } 228} 229 230function lookup(a){ 231 if (a.length == 0) { 232 $("#suggestions").hide() 233 } 234 else { 235 if (a.length > 2) { 236 $.post(MELODYURL2 + "/ajax-search.php", { 237 queryString: "" + a + "" 238 }, function(b){ 239 if (b.length > 0) { 240 $("#suggestions").show(); 241 $("#autoSuggestionsList").html(b) 242 } 243 }) 244 } 245 } 246} 247 248function fill(a){ 249 $("#inputString").val(a); 250 setTimeout("$('#suggestions').hide();", 200) 251} 252 253function ajax_request(f, e, c, d, a, call_type){ 254 var b = false;
255 256 call_type = (typeof call_type !== 'undefined') ? call_type : "GET"; 257 258 if (d.length == 0) { 259 d = "html" 260 } 261 if (c.length > 0) { 262 $(c).html('<img src="' + TemplateP + '/img/ajax-loading.gif" alt="Loading" id="loading" /> Loading...').fadeIn("normal") 263 } 264 $.ajax({ 265 type: call_type, 266 url: MELODYURL2 + "/ajax.php", 267 data: "p=" + f + "&" + e, 268 dataType: d, 269 success: function(g){ 270 if (c.length > 0) { 271 $(c).html(g); 272 if (a == true) { 273 $(c).show(); 274 if (f == 'comments') { 275 bind_comment_user_actions(); 276 } 277 } 278 } 279 b = true 280 } 281 }); 282 return b 283} 284 285// Video playback error and 404 reporting for FlowPlayer 286var arPlayer = null; 287var arDone = false; 288function reportNotFound(a){ 289 if (a.length > 0 && !arDone) { 290 ajax_request("video", "do=report&vid=" + a, "", "", false); 291 arDone = true 292 } 293} 294// --- 295 296// comment.js 297function onpage_delete_comment(e, d, a){ 298 var b = "You are about to delete this comment. Click 'Cancel' to stop, 'OK' to delete"; 299 var c = false; 300 if (confirm(b)) { 301 if (a.length > 0) { 302 ajax_request("comments", "do=onpage_delete_comment&cid=" + e + "&vid=" + d, "", "", false); 303 $(a).fadeOut("normal") 304 } 305 } 306} 307function comment_user_action(button, comment_id, user_id, action) { // TODO: Incorporate Gritter Notification/Confirmation Messages 308 309 var page = 'comments'; 310 if (action == 'ban' || action == 'allow') { 311 page = 'users'; 312 } 313 314 $.ajax({ 315 type: 'GET', 316 url: MELODYURL2 + "/ajax.php", 317 data: { 318 'comment_id': comment_id, 319 'uid' : user_id, 320 'p': page, 321 'do': action 322 }, 323 dataType: "json", 324 success: function(c){ 325 if (c.success) { 326 if(button.hasClass("active")) { 327 button.removeClass("active"); 328 } else { 329 button.addClass("active"); 330 if (action == 'like') { 331 $('#comment-dislike-' + comment_id).removeClass('active'); 332 } else if (action == 'dislike') { 333 $('#comment-like-' + comment_id).removeClass('active'); 334 } 335 } 336 337 if (action == 'allow' || action == 'ban') { 338 if (c.show_label == true) { 339 $('.label-banned-'+ user_id).removeClass('hide').show(); 340 $('.ban-'+ user_id).addClass("active"); 341 $('.unban-'+ user_id).addClass("active"); 342 } 343 if (c.hide_label == true) { 344 $('.label-banned-'+ user_id).hide(); 345 $('.ban-'+ user_id).removeClass("active"); 346 $('.unban-'+ user_id).removeClass("active"); 347 } 348 } else { 349 if (c.up_vote_count > 0) { 350 $('#comment-like-count-'+ comment_id).html(c.up_vote_count); 351 } else { 352 $('#comment-like-count-'+ comment_id).html(''); 353 } 354 if (c.down_vote_count > 0) { 355 $('#comment-dislike-count-'+ comment_id).html(c.down_vote_count); 356 } else { 357 $('#comment-dislike-count-'+ comment_id).html(''); 358 } 359 } 360 } 361 if ( ! c.success && (action == 'allow' || action == 'ban') && c.error != '') { 362 alert(c.error); 363 } 364 } 365 }); 366 return false; 367} 368 369function bind_comment_user_actions() { 370 // comment rating 371 $('button[id^="comment-like-"]').click(function(){ 372 var comment_id = $(this).attr('id').replace( /^\D+/g, ''); 373 comment_user_action($(this), comment_id, 0, 'like'); 374 return false; 375 }); 376 $('button[id^="comment-dislike-"]').click(function(){ 377 var comment_id = $(this).attr('id').replace( /^\D+/g, ''); 378 comment_user_action($(this), comment_id, 0, 'dislike'); 379 return false; 380 }); 381 $('button[id^="comment-flag-"]').click(function(){ 382 var comment_id = $(this).attr('id').replace( /^\D+/g, ''); 383 comment_user_action($(this), comment_id, 0, 'flag'); 384 return false; 385 }); 386 // ban/unban user 387 $('button[id^="unban-"]').click(function(){ 388 var classes = $(this).attr('class').split(' '); 389 var user_id = classes[0]; 390 user_id = user_id.replace( /^\D+/g, ''); 391 var comment_id = $(this).attr('id').replace( /^\D+/g, ''); 392 comment_user_action($(this), comment_id, user_id, 'allow'); 393 return false;
394 }); 395 $('button[id^="ban-"]').click(function(){ 396 var classes = $(this).attr('class').split(' '); 397 var user_id = classes[0]; 398 user_id = user_id.replace( /^\D+/g, ''); 399 var comment_id = $(this).attr('id').replace( /^\D+/g, ''); 400 comment_user_action($(this), comment_id, user_id, 'ban'); 401 return false; 402 }); 403} 404 405function confirm_action(confirm_message, action_goto_url) 406{ 407 if (confirm(confirm_message)) { 408 window.location = action_goto_url; 409 } 410 return false; 411} 412 413 414$(document).ready(function(){ 415 416 bind_comment_user_actions(); 417 418 // like/dislike video 419 $("#bin-rating-like").click(function(){ 420 var b = $(this); 421 var a = $("#bin-rating-dislike"); 422 $("#bin-rating-response").html("").hide(); 423 $.ajax({ 424 type: "GET", 425 url: MELODYURL2 + "/ajax.php", 426 data: { 427 vid: $('input[name="bin-rating-uniq_id"]').val(), 428 p: "video", 429 "do": "like" 430 }, 431 dataType: "json", 432 success: function(c){ 433 if (c.success) { 434 if (b.hasClass("active")) { 435 b.removeClass("active"); 436 $("#rating-bar-up-pct").width(c.up_pct + "%"); 437 $("#rating-bar-down-pct").width(c.down_pct + "%") 438 } 439 else { 440 b.addClass("active"); 441 a.removeClass("active"); 442 $("#rating-bar-up-pct").width(c.up_pct + "%"); 443 $("#rating-bar-down-pct").width(c.down_pct + "%"); 444 $("#bin-rating-dislike-confirmation").hide(); 445 $("#bin-rating-like-confirmation").slideDown("normal") 446 } 447 } 448 else { 449 if (c.msg != "") { 450 $("#bin-rating-response").html(c.msg).slideToggle("normal"); 451 $.notify({message: c.msg}, {type: 'warning'}); 452 } 453 } 454 } 455 }) 456 }); 457 $("#bin-rating-dislike").click(function(){ 458 var b = $($("#bin-rating-like")); 459 var a = $(this); 460 $("#bin-rating-response").html("").hide(); 461 $.ajax({ 462 type: "GET", 463 url: MELODYURL2 + "/ajax.php", 464 data: { 465 vid: $('input[name="bin-rating-uniq_id"]').val(), 466 p: "video", 467 "do": "dislike" 468 }, 469 dataType: "json", 470 success: function(c){ 471 if (c.success) { 472 if (a.hasClass("active")) { 473 a.removeClass("active"); 474 $("#rating-bar-up-pct").width(c.up_pct + "%"); 475 $("#rating-bar-down-pct").width(c.down_pct + "%") 476 } 477 else { 478 a.addClass("active"); 479 b.removeClass("active"); 480 $("#rating-bar-up-pct").width(c.up_pct + "%"); 481 $("#rating-bar-down-pct").width(c.down_pct + "%"); 482 $("#bin-rating-like-confirmation").hide(); 483 $("#bin-rating-dislike-confirmation").slideDown("normal"); 484 } 485 } 486 else { 487 if (c.msg != "") { 488 $("#bin-rating-response").html(c.msg).slideToggle("normal"); 489 $.notify({message: c.msg}, {type: 'warning'}); 490 } 491 } 492 } 493 }) 494 }); 495 496 497 var playlists_loaded = false; 498 499 $('#pm-vc-playlists').click(function() { 500 if ( ! playlists_loaded) { 501 $.ajax({ 502 type: "GET", 503 url: MELODYURL2 + "/ajax.php", 504 data: { 505 "p" : "playlists", 506 "do": "video-watch-load-my-playlists", 507 "video-id" : $(this).attr('data-video-id') 508 }, 509 dataType: "json", 510 success: function(data) { 511 $('#playlist-container').replaceWith(data.html); 512 playlists_loaded = true; 513 } 514 }); 515 } 516 }); 517 518 $('.pm-pro-playlists-btn').click(function(){ // profile playlists tab 519 if ( ! playlists_loaded) { 520 $.ajax({ 521 type: "GET", 522 url: MELODYURL2 + "/ajax.php", 523 data: { 524 "p" : "profile", 525 "do": "profile-load-playlists", 526 "uid" : $(this).attr('data-profile-id') 527 }, 528 dataType: "json", 529 success: function(data) { 530 $('#profile-playlists-container').replaceWith(data.html); 531 playlists_loaded = true; 532 } 533 }); 534 } 535 }); 536 537 $('input[name="playlist_name"]').keyup(function(){ 538 if ($(this).val().length > 0) { 539 $('#create_playlist_submit_btn').removeAttr('disabled'); 540 } else { 541 $('#create_playlist_submit_btn').attr('disabled', true); 542 } 543 }); 544 545 $("#pm-vc-share").click(function(){
546 $("#securimage-share").prop("src", MELODYURL2 + "/include/securimage_show.php?sid=" + Math.random()) 547 }); 548 $('form[name="sharetofriend"]').submit(function(){ 549 $("#share-confirmation").hide(); 550 $.ajax({ 551 type: "POST", 552 url: MELODYURL2 + "/ajax.php", 553 data: $(this).serialize(), 554 dataType: "json", 555 success: function(a){ 556 $("#share-confirmation").html(a.msg).show(); 557 if (a.success == true) { 558 $('form[name="sharetofriend"]').slideUp() 559 } 560 } 561 }); 562 return false 563 }); 564 $("#pm-vc-report").click(function(){ 565 $("#securimage-report").prop("src", MELODYURL2 + "/include/securimage_show.php?sid=" + Math.random()) 566 }); 567 $('form[name="reportvideo"]').submit(function(){ 568 $("#report-confirmation").hide(); 569 $.ajax({ 570 type: "POST", 571 url: MELODYURL2 + "/ajax.php", 572 data: $(this).serialize(), 573 dataType: "json", 574 success: function(a){ 575 $("#report-confirmation").html(a.msg).show(); 576 if (a.success == true) { 577 // $('form[name="reportvideo"]').slideUp() 578 } 579 } 580 }); 581 return false 582 }); 583 584 $('.pm-video-thumb').hover( 585 function(){ 586 var parent = $(this); 587 parent.find('.watch-later').show(0, function() { parent.find('.pm-label-duration').hide(); }); 588 }, 589 function() { 590 var parent = $(this); 591 parent.find('.watch-later').hide(0, function() { parent.find('.pm-label-duration').show(); }); 592 } 593 ); 594 595 $("#suggest-form").submit(function(){ 596 return false 597 }); 598 $('#suggest-form input[name="yt_id"]').bind("input propertychange", function(f){ 599 if ($(this).val() == "") { 600 return false 601 } 602 $("#loading-gif-top").show(); 603 $("#suggest-video-extra").slideUp(); 604 $("#ajax-error-placeholder").html("").hide(); 605 $("#ajax-success-placeholder").html("").hide(); 606 $.ajax({ 607 type: "POST", 608 url: MELODYURL2 + "/ajax.php", 609 data: { 610 p: "suggest", 611 "do": "getdata", 612 url: $(this).val() 613 }, 614 dataType: "json", 615 success: function(e){ 616 $("#loading-gif-top").hide(); 617 if (e.failed) { 618 $("#ajax-error-placeholder").html(e.message).show() 619 } 620 else { 621 if (e.success) { 622 $("#ajax-error-placeholder").hide(); 623 $("#suggest-video-extra").slideDown(); 624 $("#video-thumb-placeholder").html('<div class="suggest-video-placeholder"><img src="' + e.videodata.yt_thumb + '" title="" /></div>').show(); 625 $('#suggest-form input[name="video_title"]').val(e.videodata.video_title); 626 $('#suggest-form textarea[name="description"]').val(e.videodata.description); 627 $('#suggest-form input[name="tags"]').val(e.videodata.tags); 628 $('#suggest-form input[name="source_id"]').val(e.videodata.source_id); 629 } 630 } 631 } 632 }); 633 return false 634 }); 635 $('#suggest-form button[type="submit"]').click(function(){ 636 $("#ajax-error-placeholder").html("").hide(); 637 $("#ajax-success-placeholder").html("").hide(); 638 if ($('input[name="video_title"]').val() == "") { 639 $("#ajax-error-placeholder").html(pm_lang.validate_video_title).show(); 640 $('input[name="video_title"]').trigger('focus'); 641 return false 642 } 643 if ($('select[name="category"]').val() == "-1") { 644 $("#ajax-error-placeholder").html(pm_lang.choose_category).show(); 645 $('select[name="category"]').trigger('focus'); 646 return false 647 } 648 $("#loading-gif-bottom").show(); 649 var e = $("#suggest-form").serialize(); 650 $.ajax({ 651 type: "POST", 652 url: MELODYURL2 + "/ajax.php", 653 data: e, 654 dataType: "json", 655 success: function(f){ 656 $("#loading-gif-bottom").hide(); 657 if (f.failed) { 658 $("#ajax-error-placeholder").html(f.message).show() 659 } 660 else { 661 if (f.success) { 662 $("#ajax-error-placeholder").hide(); 663 $("#ajax-success-placeholder").html(f.message).show();
664 $("#suggest-video-extra").slideUp(); 665 $("#suggest-form").each(function(){ 666 this.reset() 667 }) 668 } 669 } 670 } 671 }); 672 return false 673 }); 674 675 $("#preview_comment").hide(); 676 var a = false; 677 $("#c_comment_txt").click(function(){ 678 if (!a && $("#c_user_id").val() == 0) { 679 $("#captcha-image").prop("src", MELODYURL2 + "/include/securimage_show.php?sid=" + Math.random()); 680 a = true 681 } 682 }); 683 $("#c_submit").click(function(){ 684 $("#mycommentspan").html('<img src="' + TemplateP + '/img/ajax-loading.gif" alt="Loading" id="loading" /> Posting...').show(); 685 var b = $("#c_user_id").val(); 686 var e = $("#c_vid").val(); 687 var d = $("#c_comment_txt").val(); 688 var f = $("#c_username").val(); 689 var c = $("#captcha").val(); 690 if (b == 0) { 691 $.post(MELODYURL2 + "/comment.php", { 692 username: f, 693 captcha: c, 694 vid: e, 695 user_id: b, 696 comment_txt: d 697 }, function(g){ 698 if (g.cond == true) { 699 $("#pm-post-form").slideUp("normal", function(){ 700 $("#mycommentspan").html(g.html).show(); 701 if (g.preview == true) { 702 $("#be_the_first").hide(); 703 $("#preview_comment").html(g.preview_html).fadeIn(700) 704 } 705 }) 706 } 707 else { 708 if (g.cond == false) { 709 $("#c_submit").show(); 710 $("#mycommentspan").html(g.html).show(); 711 } 712 } 713 }, "json") 714 } 715 else { 716 if (b > 0) { 717 $.post(MELODYURL2 + "/comment.php", { 718 vid: e, 719 user_id: b, 720 comment_txt: d 721 }, function(g){ 722 if (g.cond == true) { 723 $("#pm-post-form").slideUp("normal", function(){ 724 $("#mycommentspan").html(g.html).show(); 725 if (g.preview == true) { 726 $("#be_the_first").hide(); 727 $("#preview_comment").html(g.preview_html).fadeIn(700) 728 } 729 }) 730 } 731 else { 732 if (g.cond == false) { 733 $("#c_submit").show(); 734 $("#mycommentspan").html(g.html).show(); 735 } 736 } 737 }, "json") 738 } 739 } 740 return false 741 }); 742 743 if ($('#register-form').length) { 744 if ( ! $('input[name="website"]').is(":visible")) { 745 $('input[name="website"]').val(Math.floor(Date.now() / 1000)); 746 } 747 } 748 749 $('#autoplayonoff').change(function(){ 750 if ($(this).is(":checked")) { 751 pm_video_data.autoplay_next = true; 752 $.cookie('pm_autoplay_next', 'on', { path: '/' }); 753 } else { 754 pm_video_data.autoplay_next = false; 755 $.cookie('pm_autoplay_next', 'off', { path: '/' }); 756 } 757 }); 758});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.