1SZR.profileView = { 2 3 gallery: false, 4 photoViewerPatched: [], 5 photoRequestLayer: undefined, 6 7 notAllowedLayer: null, 8 9 user: { 10 user_id: null, 11 }, 12 13 init: function() { 14 const $congratulationsLayer = $("#collect-game-collected-layer"); 15 if ($congratulationsLayer.length > 0) { 16 const layer = new Layer(); 17 if ($congratulationsLayer.hasClass("was-not-efi")) { 18 layer.closeListener = function () { 19 window.location.reload(); 20 }; 21 } 22 layer.init($($congratulationsLayer)); 23 layer.open(); 24 } 25 this.initNotAllowedLayer(); 26 this.bindEvents(); 27 }, 28 29 likeUser: function() { 30 var data = { 31 'callback': '', 32 'visitedID': $('.profile-view').data('user-id') 33 }; 34 35 var callback = new AjaxCallback(); 36 callback.addSuccessCallback(function(response) { 37 if(response.result === "success" && typeof response.data.success === "boolean" && response.data.success) { 38 var button = $('.profile-view .header-menu .like-user'); 39 40 if(response.data.res === 0) { 41 button.find('i').removeClass('fas').addClass('far'); 42 button.removeClass('liked pulsate'); 43 } else { 44 button.find('i').removeClass('far').addClass('fas'); 45 button.addClass('liked pulsate'); 46 } 47 } else if (typeof response.data.res === "string" && response.data.res === "message") { 48 SZR.LayerHandler.showFlashMessage(response.data.msg); 49 } 50 }); 51 52 Ajax.processByParams('user', 'iFavorited', data, null, callback); 53 }, 54 55 openHeaderMenu: function() { 56 var menu = $('.profile-view .header-menu-items'); 57 58 if(menu.hasClass('animating')) return; 59 menu.addClass('animating'); 60 61 menu.removeClass('closed'); 62 menu.slideDown(function() { 63 menu.removeClass('animating'); 64 }); 65 }, 66 67 closeHeaderMenu: function() { 68 var menu = $('.profile-view .header-menu-items'); 69 70 if(menu.hasClass('animating')) return; 71 menu.addClass('animating'); 72 73 menu.addClass('closed'); 74 menu.slideUp(function() { 75 menu.removeClass('animating'); 76 }); 77 }, 78 79 toggleBox: function(box) { 80 if(box.hasClass('animating')) return; 81 box.addClass('animating'); 82 83 if(box.hasClass('closed')) { 84 box.removeClass('closed'); 85 box.find('.box-content').slideDown(function() { 86 box.removeClass('animating'); 87 }); 88 } else { 89 box.addClass('closed'); 90 box.find('.box-content').slideUp(function() { 91 box.removeClass('animating'); 92 }); 93 } 94 }, 95 96 showPhotoSlider: function(list) { 97 var photos = list.find('img'); 98 var lastPhoto = photos.last(); 99 100 if(parseInt(photos.first().css('margin-left')) < 0) { 101 list.find('.slide-left').show(); 102 } else { 103 list.find('.slide-left').hide(); 104 } 105 106 if(lastPhoto.offset().left + lastPhoto.innerWidth() - 5 > list.offset().left + list.innerWidth()) { 107 list.find('.slide-right').show(); 108 } else { 109 list.find('.slide-right').hide(); 110 } 111 }, 112 113 hidePhotoSlider: function(list) { 114 list.find('.slide-left').hide(); 115 list.find('.slide-right').hide(); 116 }, 117 118 slidePhotosLeft: function(list) { 119 var self = this; 120 121 if(list.hasClass('animating')) return; 122 123 var listWidth = list.innerWidth(); 124 var photos = list.find('img'); 125 var firstPhoto = photos.first(); 126 var currentLeft = parseInt(firstPhoto.css('margin-left')); 127 128 if(currentLeft == 0) return; 129 130 var left = currentLeft + listWidth; 131 if(left > -30) left = 0; 132 133 list.addClass('animating'); 134 firstPhoto.animate({ 'margin-left': left + 'px' }, 400, function() { 135 list.removeClass('animating'); 136 self.showPhotoSlider(list); 137 }); 138 }, 139 140 slidePhotosRight: function(list) { 141 var self = this; 142 143 if(list.hasClass('animating')) return; 144 145 var listWidth = list.innerWidth(); 146 var photos = list.find('img'); 147 var firstPhoto = photos.first(); 148 var lastPhoto = photos.last(); 149 150 var maxWidth = lastPhoto.offset().left + lastPhoto.innerWidth() - (list.offset().left + listWidth); 151 if(listWidth > maxWidth) listWidth = maxWidth; 152 153 var left = parseInt(firstPhoto.css('margin-left')) - listWidth; 154 155 list.addClass('animating'); 156 firstPhoto.animate({ 'margin-left': left + 'px' }, 400, function() { 157 list.removeClass('animating'); 158 self.showPhotoSlider(list); 159 }); 160 }, 161 162 showPhoto: function(index) { 163 var self = this; 164 165 if($('.pswp').length == 0) return; 166 167 var pswpElement = $('.pswp')[0]; 168 169 var thumbnails = $('.profile-view .photos .thumbnail'); 170 171 var items = []; 172 thumbnails.each(function() { 173 var item = $(this); 174 175 var data = { 176 'src': item.data('url'), 177 'w': item.data('width'), 178 'h': item.data('height') 179 }; 180 181 if(item.data('title') != '') { 182 data['title'] = item.data('title'); 183 } 184 185 items.push(data); 186 }); 187 188 var options = { 189 index: index, 190 captionEl: true, 191 shareEl: false, 192 history: false 193 }; 194 195 this.gallery = new PhotoSwipe(pswpElement, PhotoSwipeUI_Default, items, options); 196 197 this.gallery.listen('imageLoadComplete', function(index, item) { 198 if($.inArray(index, self.photoViewerPatched) == -1) { 199 var img = new Image(); 200 img.onload = function() { 201 item.w = img.width;
202 item.h = img.height; 203 self.gallery.invalidateCurrItems(); 204 self.gallery.updateSize(true); 205 }; 206 img.src = item.src; 207 self.photoViewerPatched.push(index); 208 } 209 }); 210 211 this.gallery.listen('close', function() { 212 self.photoViewerPatched = []; 213 }); 214 215 this.gallery.init(); 216 }, 217 218 showPhotoRequestLayer: function() { 219 if(typeof this.photoRequestLayer == 'undefined') { 220 var layer = $('#private-photo-request-layer'); 221 layer.find('.avatar').attr('src', $('.profile-view .avatar img').attr('src')); 222 layer.find('.title .nick').html($('.profile-view .basics h2').html()); 223 224 this.photoRequestLayer = new Layer(); 225 this.photoRequestLayer.init(layer); 226 } 227 228 this.photoRequestLayer.open(); 229 }, 230 231 askPhotoRequest: function() { 232 var data = { 233 'visitedID': $('.profile-view').data('user-id') 234 }; 235 236 if(typeof this.photoRequestLayer != 'undefined') { 237 this.photoRequestLayer.close(); 238 } 239 240 var callback = new AjaxCallback(); 241 callback.addSuccessCallback(function(response) { 242 if(typeof response.data.flashMessage != 'undefined') { 243 SZR.LayerHandler.showFlashMessage(response.data.flashMessage); 244 } 245 const self = SZR.profileView; 246 if (typeof response.data.action !== "undefined" && response.data.action === "show_looking_for_layer") { 247 if (self.notAllowedLayer === null) { 248 SZR.LayerHandler.showFlashMessage(lang['profile.view.privatePhotoRequest.notAllowed.error.propertiesChange']); 249 return; 250 } 251 self.notAllowedLayer.open(); 252 } 253 254 if(typeof response.data.info != 'undefined') { 255 if($('.profile-view .avatar').hasClass('private')) { 256 $('.profile-view .avatar').addClass('disabled').attr('title', response.data.info); 257 } 258 $('.profile-view .photos.private .list').addClass('disabled').attr('title', response.data.info); 259 $('.profile-view .photos.private .button-container').fadeOut('fast'); 260 } 261 }); 262 263 Ajax.processByParams('photo', 'privatePhotoRequest', data, null, callback); 264 }, 265 266 allowPrivatePhotos: function(enable) { 267 var data = { 268 'visitedID': $('.profile-view').data('user-id') 269 }; 270 271 var action = enable ? 'privatePhotoEnable': 'privatePhotoDisable'; 272 273 var callback = new AjaxCallback(); 274 callback.addSuccessCallback(function(response) { 275 if(typeof response.data.result != 'undefined' && response.data.result == 'ok') { 276 if(enable) { 277 $('.profile-view .allow-private-photos').addClass('cancel'); 278 } else { 279 $('.profile-view .allow-private-photos').removeClass('cancel'); 280 } 281 } 282 }); 283 284 Ajax.processByParams('photo', action, data, null, callback); 285 }, 286 287 voteUser: function(points) { 288 var data = { 289 'point': points, 290 'visitedID': $('.profile-view').data('user-id'), 291 'responseType': 'json' 292 }; 293 294 var callback = new AjaxCallback(); 295 callback.addSuccessCallback(function(response) { 296 if(typeof response.data.res != 'undefined' && response.data.res == 'message') { 297 SZR.LayerHandler.showFlashMessage(response.data.msg); 298 return; 299 } 300 301 $('.profile-view .points .rate').addClass('voted'); 302 303 $('.profile-view .points .rate i').removeClass('checked'); 304 for(var i=1; i<=points; i++) { 305 $('.profile-view .points .rate i[data-points="' + i + '"]').addClass('checked'); 306 } 307 308 $('.profile-view .points .avg .n').text(Math.round(response.data.avg * 10) / 10); 309 }); 310 311 Ajax.processByParams('user', 'postVote', data, null, callback); 312 313 }, 314 315 reportUser: function() { 316 var menuItem = $('.profile-view .header-menu-items li[data-action="report"]'); 317 location.href = menuItem.data('url') + $('.profile-view').data('user-id'); 318 }, 319 320 banUser: function() { 321 var self = this; 322 323 var menuItem = $('.profile-view .header-menu-items li[data-action="ban"]'); 324 325 if(menuItem.hasClass('banned')) { 326 var confirmMessage = lang['confirm.revokeUserBan']; 327 var acceptButton = lang['userBann.button.unBann']; 328 } else { 329 var confirmMessage = lang['confirm.userBann']; 330 var acceptButton = lang['userBann.button.bann']; 331 } 332 333 SZR.LayerHandler.showConfirmMessage(confirmMessage, function() {}, function() { 334 var data = { 335 'visitedID': $('.profile-view').data('user-id'), 336 'mode': 'profile' 337 }; 338 339 var callback = new AjaxCallback(); 340 341 callback.addSuccessCallback(function(response) { 342 if(typeof response.data.data_banned !== 'undefined') { 343 var status = response.data.data_banned; 344 345 switch(status) { 346 case 0: 347 menuItem.removeClass('banned'); 348 break; 349 case 1: 350 menuItem.addClass('banned'); 351 break; 352 } 353 354 if(typeof response.data.modalMessage != 'undefined') { 355 SZR.LayerHandler.showFlashMessage(response.data.modalMessage); 356 } 357 } 358 }); 359 360 Ajax.processByParams('user', 'iBanned', data, null, callback); 361 }, lang['common.cancel'], acceptButton); 362 }, 363 364 bindEvents: function() { 365 var self = this; 366 367 $('.profile-view .avatar img').click(function() { 368 var avatar = $(this).closest('.avatar'); 369 if ($(this).data('sfw') == 2){ 370 $('.openNSFWOption').click(); return; 371 } 372 373 if(avatar.hasClass('disabled')) { 374 var title = avatar.attr('title'); 375 if(typeof title != 'undefined') { 376 SZR.LayerHandler.showFlashMessage(title); 377 } 378 return; 379 } 380 381 if($(this).hasClass('no-sub')) { 382 location.href = $('.profile-view .avatar').data('redirect'); 383 return; 384 } 385 386 if(avatar.hasClass('private')) { 387 self.showPhotoRequestLayer(); 388 return; 389 } 390 391 self.showPhoto(0); 392 }); 393
394 $('.profile-view .photos .list').mouseenter(function() { 395 var list = $(this); 396 list.addClass('hover'); 397 self.showPhotoSlider(list); 398 }); 399 400 $('.profile-view .photos .list').mouseleave(function() { 401 var list = $(this); 402 list.removeClass('hover'); 403 self.hidePhotoSlider(list); 404 }); 405 406 $('.profile-view .photos .list .slide-left').click(function() { 407 self.slidePhotosLeft($(this).closest('.list')); 408 }); 409 410 $('.profile-view .photos .list .slide-right').click(function() { 411 self.slidePhotosRight($(this).closest('.list')); 412 }); 413 414 $('.profile-view .photos .list img').click(function() { 415 var photo = $(this); 416 417 if(photo.hasClass('disabled')) return; 418 if (photo.data('sfw') == 2){ 419 $('.openNSFWOption').click(); return; 420 } 421 422 var list = $(this).closest('.list'); 423 if(list.hasClass('disabled')) { 424 var title = list.attr('title'); 425 if(typeof title != 'undefined') { 426 SZR.LayerHandler.showFlashMessage(title); 427 } 428 return; 429 } 430 431 if(photo.hasClass('no-sub')) { 432 location.href = $('.profile-view .avatar').data('redirect'); 433 return; 434 } 435 436 var photos = photo.closest('.photos'); 437 438 if(photos.hasClass('deneid')) { 439 self.showPhotoRequestLayer(); 440 return; 441 } 442 443 var index = photo.data('index'); 444 if(typeof index == 'undefined') index = 0; 445 446 self.showPhoto(index); 447 }); 448 449 $('#private-photo-request-layer .request').click(function() { 450 self.askPhotoRequest(); 451 }); 452 453 $('.profile-view .allow-private-photos').click(function() { 454 var enable = $(this).hasClass('cancel') === false; 455 self.allowPrivatePhotos(enable); 456 }); 457 458 $('.profile-view .photos.private .request').click(function() { 459 self.askPhotoRequest(); 460 }); 461 462 $('.profile-view .points .rate i').mouseenter(function() { 463 if($('.profile-view .points .rate').hasClass('voted') || 464 $('.profile-view .points .rate').hasClass('disabled')) return; 465 466 var points = $(this).data('points'); 467 $('.profile-view .points .rate i').removeClass('hover'); 468 for(var i=1; i<=points; i++) { 469 $('.profile-view .points .rate i[data-points="' + i + '"]').addClass('hover'); 470 } 471 }); 472
473 $('.profile-view .points .rate').mouseleave(function() { 474 if($('.profile-view .points .rate').hasClass('voted') || 475 $('.profile-view .points .rate').hasClass('disabled')) return; 476 477 $('.profile-view .points .rate i').removeClass('hover'); 478 }); 479 480 $('.profile-view .points .rate i').click(function() { 481 if($('.profile-view .points .rate').hasClass('voted') || 482 $('.profile-view .points .rate').hasClass('disabled')) return; 483 484 var points = $(this).data('points'); 485 self.voteUser(points); 486 }); 487 488 $('.profile-view .header-menu .like-user').click(function() { 489 if($(this).hasClass('disabled')) return; 490 self.likeUser(); 491 }); 492 493 $('.profile-view .header-menu-opener').click(function() { 494 if($(this).hasClass('disabled')) return; 495 self.openHeaderMenu(); 496 }); 497 498 $('.profile-view .header-menu-items .close').click(function() { 499 self.closeHeaderMenu(); 500 }); 501 502 $('.profile-view .header-menu-items li').click(function() { 503 switch($(this).data('action')) { 504 case 'report': 505 self.reportUser(); 506 break; 507 case 'ban': 508 self.banUser(); 509 break; 510 default: 511 return; 512 } 513 self.closeHeaderMenu(); 514 }); 515 516 $('.profile-view .box .closable').click(function() { 517 self.toggleBox($(this).closest('.box')); 518 }); 519 520 $('*').click(function(e) { 521 if(!$('.profile-view .header-menu-items').hasClass('closed')) { 522 if($(e.target).closest('.profile-view .header-menu-items').length == 0) { 523 self.closeHeaderMenu(); 524 } 525 } 526 }); 527 }, 528 529 initNotAllowedLayer: function () { 530 const $layer = $("#not-allowed-action-settings-layer"); 531 if ($layer.length === 0) { 532 return; 533 } 534 this.notAllowedLayer = new Layer(); 535 this.notAllowedLayer.init($layer); 536 const callback = new AjaxCallback(); 537 $("#not-allowed-action-settings-layer-accept").on("click", function () { 538 SZR.profileView.notAllowedLayer.open(); 539 Ajax.processByParams("user", "extendLookingFor", { 540 user_id: SZR.profileView.user.user_id, 541 sex: $(this).data("sex"), 542 }, {}, callback); 543 }); 544 callback.addSuccessCallback(function (res) { 545 if (typeof res.data.success === "boolean" && res.data.success) { 546 SZR.profileView.notAllowedLayer.close(); 547 } 548 }); 549 }, 550 551};
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.