1/** 2 * Created by wizard on 12/19/18. 3 */ 4(function (window, $) { 5 if (!!window.JSSideBarManager) return; 6 7 window.JSSideBarManager = function (params) { 8 console.log('sidebar started'); 9 if (typeof params !== 'undefined') { 10 params = JSON.parse(params); 11 this.elementID = params.id; 12 this.elementType = params.type; 13 this.elementUrl = params.url; 14 15 this.dataset = [{ 16 id: this.elementID, 17 type: this.elementType 18 }]; 19 20 $('#recommend input[name="ids"]').val(JSON.stringify(this.dataset)); 21 } 22 this.subscribeBtn = $('.get-access._access'); 23 this.items = $('input[name="article-choise"]'); 24 25 $('input[name="article-choise"]').on('change', $.proxy(this.processChoice, this)); 26 27 this.subscribeBtn.on('click', $.proxy(this.subscribeTo, this)); 28 29 $('#recommend form').on('submit', $.proxy(this.recommendSubmit, this)); 30 } 31 32 window.JSSideBarManager.prototype.recommendSubmit = function (event) { 33 event.preventDefault(); 34 35 var data = $(event.target).serialize(); 36 37 if (data.length > 0) { 38 $.proxy(this.sendRequest( 39 $(event.target).attr('action'), 40 data, 41 function (res) { 42 $('#recommend .close').click(); 43 alert('ÐÑ Ð¿Ð¾Ñекомендовали'); 44 } 45 ), this); 46 } 47 48 return false; 49 } 50 51 window.JSSideBarManager.prototype.processChoice = function () { 52 this.disableBtn(); 53 this.countAndTypes(); 54 this.processQuote(); 55 } 56 57 window.JSSideBarManager.prototype.processQuote = function () { 58 var text = ""; 59 $.each(this.items.filter(':checked'), function (index, item) { 60 var element = $('.entity-item[data-id="' + $(item).val() + '"]'); 61 if ($(element).find('.itemName').length > 0) { 62 text += $(element).find('.itemName').text() + "<br>"; 63 } else { 64 var releaseName = $('.issue-line._number[data-id="' + $(item).val() + '"] .issue-num').text(); 65 var journalName = $('#journalName').text(); 66 text += journalName + '. ' + releaseName + "<br>"; 67 } 68 }); 69 $('#quote ._text').html(text); 70 } 71 72 window.JSSideBarManager.prototype.countAndTypes = function () { 73 var recommendArrayIds = $('#recommend input[name="ids"]'); 74 recommendArrayIds.val(''); 75 /** 76 * jsonData has to be like "[{id:id, type:type}]" 77 */ 78 var idByType = []; 79 $.each(this.items.filter(':checked'), function (index, element) { 80 idByType[index] = {id: $(element).val(), type: $(element).data('type')}; 81 }); 82 recommendArrayIds.val(JSON.stringify(idByType)); 83 } 84 85 window.JSSideBarManager.prototype.disableBtn = function () { 86 if (this.items.filter(':checked').length > 1) { 87 this.subscribeBtn.addClass('disabled').removeClass('accent'); 88 } else { 89 this.subscribeBtn.addClass('accent').removeClass('disabled'); 90 } 91 } 92 93 window.JSSideBarManager.prototype.subscribeTo = function (event) { 94 event.preventDefault(); 95 if (this.items.filter(':checked').data('type') === 'article') { 96 let id = this.items.filter(':checked').val(); 97 CartManager.addToCart('electronic', 'article', id); 98 return; 99 } 100 if (this.items.filter(':checked').data('type') === 'journal') { 101 window.location = this.items.filter(':checked').data('linkSubscribe'); 102 return; 103 } 104 if (typeof this.elementUrl != 'undefined') { 105 window.location = this.elementUrl + '#subscribe'; 106 window.location.reload(); 107 return; 108 } 109 let locale = localStorage.getItem('currentLocale'); 110 if (locale === null) { 111 locale = 'ru'; 112 } 113 if (locale === 'ru') { 114 toastr.error('ÐÑбеÑеÑе жÑÑнал к коÑоÑÐ¾Ð¼Ñ Ñ Ð¾ÑиÑе полÑÑиÑÑ Ð´Ð¾ÑÑÑп', 'Error'); 115 } else { 116 toastr.error('Select the journal you want to get access to', 'Error'); 117 } 118 //var journal = this.items.filter(':checked').val(); 119 //window.location = $('._magazine.magazine-item[data-id="' + journal + '"]').data('link-subscribe'); 120 } 121 122 window.JSSideBarManager.prototype.sendRequest = function (url, data, successCallback, completeCallback) { 123 $.ajax({ 124 headers: { 125 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') 126 }, 127 url: url, 128 method: 'POST', 129 data: data, 130 success: successCallback, 131 complete: completeCallback 132 }); 133 } 134})(window, jQuery)
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.