1$(document).ready(() => { 2 $(document).on('click', '.wl-item', function (e) { 3 e.preventDefault(); 4 const animeId = $(this).data('animeid'); 5 if (!animeId) { 6 console.error('Anime ID not found'); 7 return; 8 } 9 10 if (!user.is_logged_in || !user.rest_url) { 11 toastr.error('You must be logged in to add to watchlist.'); 12 return; 13 } 14 15 let status = $(this).data('type'); 16 17 let requestData = { 18 anime_id: animeId, 19 }; 20 21 if (status !== undefined && status !== null && status !== '') { 22 requestData.status = status; 23 } 24 25 $.ajax({ 26 url: user.rest_url + 'watchlist', 27 type: 'POST', 28 contentType: 'application/json', 29 data: JSON.stringify(requestData), 30 success: function (response) { 31 if (response && response.success) { 32 toastr.success(response.message); 33 if ($(this).closest('.profile-list-fav').length > 0 && response.action !== 'remove') { 34 window.location.reload(); 35 } else if ($(this).hasClass('dropdown-item') && response.action !== 'remove') { 36 $(this).siblings().removeClass('active'); 37 $(this).parent().find('.fa-check').remove(); 38 $(this).addClass('active').prepend('<i class="fas fa-check mt-2"></i>'); 39 let removeItem = $(this).parent().find('.wl-item[data-type="0"]'); 40 if (removeItem.length === 0) { 41 $(this).parent().append('<a class="wl-item dropdown-item text-danger" data-page="detail" data-animeid="' + animeId + '" href="javascript:;" data-type="0">Remove</a>'); 42 } 43 $(this).closest('.dr-fav').find('[data-toggle="dropdown"]').html('<i class="fas fa-edit mr-2"></i> Edit Watch List'); 44 $(this).closest('#watch-list-content').find('[data-toggle="dropdown"]').html('<i class="fas fa-edit mr-2"></i> Edit Watch List'); 45 $(this).closest('.dr-tip-fav').find('[data-toggle="dropdown"]').html('<i class="fas fa-edit"></i>'); 46 } else if ($(this).closest('.profile-list-fav').length > 0 && response.action === 'remove') { 47 window.location.reload(); 48 } else if ($(this).hasClass('dropdown-item')) { 49 $(this).siblings().removeClass('active') 50 $(this).siblings().find('.fa-check').remove(); 51 $(this).closest('.dr-fav').find('a[data-toggle="dropdown"]').html('<i class="fas fa-plus mr-2"></i> Add to List'); 52 $(this).closest('##watch-list-content').find('a[data-toggle="dropdown"]').html('<i class="fas fa-plus mr-2"></i> Add to List'); 53 $(this).closest('.dr-tip-fav').find('a[data-toggle="dropdown"]').html('<i class="fas fa-plus"></i>'); 54 $(this).parent().find('.wl-item[data-type="0"]').remove(); 55 } else{ 56 57 } 58 } else { 59 toastr.error((response && response.message) || 'Failed to update watchlist.'); 60 } 61 }.bind(this), 62 error: function (xhr) { 63 let msg = 'Failed to update watchlist.'; 64 if (xhr && xhr.responseJSON && xhr.responseJSON.message) { 65 msg = xhr.responseJSON.message; 66 } 67 toastr.error(msg); 68 } 69 }); 70 }); 71 72 $(document).on('click', '.remove-cw', function (e) { 73 e.preventDefault(); 74 const animeId = $(this).data('animeid'); 75 if (!animeId) { 76 console.error('Anime ID not found'); 77 return; 78 } 79 80 if (!user.is_logged_in || !user.rest_url) { 81 toastr.error('You must be logged in to remove anime from your watch list.'); 82 return; 83 } 84 85 $.ajax({
86 url: user.rest_url + 'continue-watching/' + encodeURIComponent(animeId), 87 type: 'DELETE', 88 success: function (response) { 89 if (response && response.success) { 90 toastr.success(response.message); 91 $(this).closest('.flw-item').remove(); 92 if ($('.film_list-continue .flw-item').length === 0) { 93 $('.film_list-continue').html('<p class="text-center">No items in your watch list.</p>'); 94 } 95 } else { 96 toastr.error((response && response.message) || 'Failed to remove item.'); 97 } 98 }.bind(this), 99 error: function (xhr, status, error) { 100 console.error('REST error:', status, error); 101 toastr.error('Failed to remove item.'); 102 } 103 }); 104 }) 105 106 $(".quick-settings-toggle").click(function () { 107 $(this).toggleClass("active"); 108 const option = $(this).data("option"); 109 const isActive = $(this).hasClass("active"); 110 updateUserSetting(option, isActive ? 1 : 0); 111 }); 112}); 113 114function updateUserSetting(key, value) { 115 if (!user.is_logged_in || !user.rest_url) { 116 return; 117 } 118 119 if (!key || value === undefined || value === null || value === '') { 120 return; 121 } 122 123 let requestData = { 124 [key]: value, 125 }; 126 127 $.ajax({
128 url: user.rest_url + 'user/settings', 129 type: 'POST', 130 contentType: 'application/json', 131 data: JSON.stringify(requestData), 132 success: function (response) { 133 if (response && response.success) { 134 if (response.message) { 135 toastr.success(response.message); 136 } 137 } 138 }, 139 error: function (xhr) { 140 let msg = 'Failed to update setting.'; 141 if (xhr && xhr.responseJSON && xhr.responseJSON.message) { 142 msg = xhr.responseJSON.message; 143 } 144 toastr.error(msg); 145 } 146 }); 147} 148 149function updateLocalStorageSetting(key, value) { 150 if (!key || !value) { 151 return; 152 } 153 154 let settings = JSON.parse(window.localStorage.getItem('settings')) || {}; 155 settings[key] = value; 156 window.localStorage.setItem('settings', JSON.stringify(settings)); 157 updateUserSetting(key, value); 158} 159 160function toggleSetting(key) { 161 let currentValue = JSON.parse(window.localStorage.getItem('settings'))?.[key] || '0'; 162 let newValue = currentValue === '1' ? '0' : '1'; 163 164 updateLocalStorageSetting(key, newValue); 165} 166 167function getUserSetting(key, defaultValue) { 168 if (!key) { 169 return null; 170 } 171 172 let settings = JSON.parse(window.localStorage.getItem('settings')) || {}; 173 return settings[key] || defaultValue; 174}
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.