1var reasonQuestions = { 2 type: 'reason', 3 question: "ÐожалÑйÑÑа, подÑкажиÑе пÑиÑÐ¸Ð½Ñ Ð½Ð°Ð¶Ð°ÑиÑ?", 4 answers: [ 5 '<button type="button" class="btn btn-outline-primary reason-btn" id="quality">Ðе ÑÑÑÑоило каÑеÑÑво видео</button>', 6 '<button type="button" class="btn btn-outline-primary reason-btn" id="speed">Ðе ÑÑÑÑоила ÑкоÑоÑÑÑ Ð²Ð¸Ð´ÐµÐ¾</button>', 7 '<button type="button" class="btn btn-outline-primary reason-btn" id="fun">ÐÑоÑÑо из лÑбопÑÑÑÑва</button>', 8 ] 9}; 10 11var resultQuestions = { 12 type: 'result', 13 question: "ÐÑоблема ÑÑÑÑанена?", 14 answers: [ 15 '<button type="button" class="btn btn-outline-success result-btn" id="ok">Ðа</button>', 16 '<button type="button" class="btn btn-outline-danger result-btn" id="support">ÐеÑ, оÑпиÑаÑÑ Ð² ÑÐµÑ Ð¿Ð¾Ð´Ð´ÐµÑжкÑ</button>', 17 '<button type="button" class="btn btn-outline-primary result-btn" id="back">ÐеÑнÑÑÑÑÑ Ð½Ð° ÑÑаÑÑй плееÑ</button>', 18 ] 19}; 20 21var VH_SPEED_COOKIE_NAME = 'vh-speed'; 22 23function upgradeCdn(data) { 24 var url = '/pl/fileservice/video/upgrade-cdn'; 25 var xhr = new XMLHttpRequest(); 26 xhr.open("POST", url, false); 27 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 28 xhr.send(JSON.stringify({'video-hash': data.videoHash})); 29} 30 31function feedbackCdn(data) { 32 var url = '/pl/fileservice/video/feedback-cdn'; 33 var xhr = new XMLHttpRequest(); 34 xhr.open("POST", url, false); 35 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 36 xhr.send(JSON.stringify({'reason': data.reason, 'result': data.result})); 37} 38 39function closeFeedback() { 40 var url = '/pl/fileservice/video/close-feedback'; 41 var xhr = new XMLHttpRequest(); 42 xhr.open("POST", url, false); 43 xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); 44 xhr.send(JSON.stringify({'reason': 'close', 'result': 'close'})); 45} 46 47function buildQuestion(data) { 48 var question = data.question; 49 var answers = ''; 50 51 data.answers.forEach(function (answer) { 52 answers += answer; 53 }); 54 55 return question + answers; 56} 57 58function show(el) { 59 el.style.display = 'block'; 60} 61 62function close(el) { 63 el.style.display = 'none'; 64} 65 66function remove(el) { 67 el.parentNode.removeChild(el); 68} 69 70 71/** 72 * @param {HTMLElement} vheChangeEl 73 */ 74function showAlternativePlayerBtn(vheChangeEl) { 75 var link = vheChangeEl.querySelector('.disclaimer-url'); 76 var feedbackReason = vheChangeEl.querySelector('.feedback#reason'); 77 var feedbackResult = vheChangeEl.querySelector('.feedback#result'); 78 var feedbackClose = vheChangeEl.querySelector('.feedback#close'); 79 80 var feedbackStatus = vheChangeEl.dataset['feedbackStatus']; 81 var currentCdn = vheChangeEl.dataset['currentCdn']; 82 83 vheChangeEl.style.display = 'block'; 84 feedbackReason.style.display = 'none'; 85 feedbackResult.style.display = 'none'; 86 87 if (currentCdn === 'integros' || currentCdn === '') { 88 //change.style.height = '35px'; 89 link.innerHTML = window.tt('common', 'Speed problem'); 90 } else { 91 feedbackReason.innerHTML = buildQuestion(reasonQuestions); 92 feedbackResult.innerHTML = buildQuestion(resultQuestions); 93 94 link.innerHTML = window.tt('common', 'ÐеÑнÑÑÑÑÑ Ð½Ð° оÑновной плееÑ'); 95 96 switch (feedbackStatus) { 97 case 'noFeedback' : 98 remove(feedbackReason); 99 remove(feedbackResult); 100 break; 101 case 'hasReason' : 102 remove(feedbackResult); 103 remove(feedbackReason); 104 break; 105 case 'hasResult' : 106 //change.style.height = '35px'; 107 remove(feedbackReason); 108 remove(feedbackResult); 109 break; 110 } 111 } 112 113 feedbackClose.addEventListener('click', function (e) { 114 e.preventDefault(); 115 closeFeedback(); 116 close(vheChangeEl); 117 }); 118 119 var btns = vheChangeEl.querySelectorAll('.btn'); 120 btns.forEach(function (btn) { 121 btn.addEventListener('click', function (e) { 122 if (btn.classList.contains('reason-btn')) { 123 vheChangeEl.dataset.reason = btn.id; 124 125 show(feedbackResult); 126 close(feedbackReason); 127 } 128 129 if (btn.classList.contains('result-btn')) { 130 vheChangeEl.dataset.result = btn.id; 131 feedbackCdn(vheChangeEl.dataset); 132 feedbackResult.innerHTML = 'СпаÑибо!'; 133 134 if (btn.id === 'back') { 135 upgradeCdn(vheChangeEl.dataset); 136 window.location.reload(); 137 } 138 139 setTimeout(function () { 140 remove(feedbackReason); 141 remove(feedbackResult); 142 143 //change.style.height = 'auto'; 144 }, 2000); 145 } 146 }); 147 }); 148 149 link.addEventListener('click', function (e) { 150 e.preventDefault(); 151 upgradeCdn(vheChangeEl.dataset); 152 window.location.reload(); 153 }); 154} 155 156// /** 157// * 158// * @param {string} currentCdn 159// * 160// * @returns {Promise} 161// */ 162// function checkUserSpeed(currentCdn) { 163// var url = 'https://{url}/speed/speed.bin?rnd=' + Math.random() + '&host=vh-06';
164// if (currentCdn === 'integros') { 165// url = url.replace('{url}', 'vh-06-78293b36.cdn.integros.com'); 166// } else { 167// url = url.replace('{url}', 'vh-06.gcdn.co'); 168// } 169// 170// return new Promise(function (resolve, reject) { 171// var xhr = new XMLHttpRequest(); 172// xhr.timeout = 20000; 173// xhr.open('GET', url, true); 174// var downloadStartTime = window.performance.now(); 175// 176// xhr.onloadend = function (event) { 177// var fileSize = event.lengthComputable ? event.loaded : 1048576; 178// var duration = window.performance.now() - downloadStartTime; 179// var speedKb = fileSize / duration; 180// resolve(speedKb, duration); 181// }; 182// xhr.ontimeout = function () { 183// reject(); 184// }; 185// xhr.onerror = function () { 186// reject(); 187// }; 188// 189// xhr.send(null); 190// }); 191// } 192 193(function () { 194 var vheCdnChangeElList = document.querySelectorAll('.vhe-cdn-change'); 195 // ÐÑли блоков Ñо Ñмной CDN не найдено, Ñо вÑÑ Ð¾Ð´Ð¸Ð¼ 196 if (vheCdnChangeElList.length === 0) { 197 return; 198 } 199 200 vheCdnChangeElList.forEach(function (change) { 201 change.style.display = 'none'; 202 }); 203 204 /** @var {HTMLElement} vheCdnChangeEl */ 205 var vheCdnChangeEl = vheCdnChangeElList[0]; 206 207 // ÐÑли ÑÑо User Gc или полÑзоваÑÐµÐ»Ñ Ð¿Ð¾Ð´ ÑÑблогином, Ñо вÑегда оÑобÑажаем ÐºÐ½Ð¾Ð¿ÐºÑ 208 if (window.accountUserId === -2 || window.isSublogined) { 209 showAlternativePlayerBtn(vheCdnChangeEl); 210 return; 211 } 212 213 // ÐÑли полÑзоваÑÐµÐ»Ñ Ð½Ðµ авÑоÑизован, Ñо вÑÑ Ð¾Ð´Ð¸Ð¼ 214 if (window.accountUserId === -1) { 215 return; 216 } 217 218 showAlternativePlayerBtn(vheCdnChangeEl); 219 220 // 221 // /** @var {string} currentCdn */ 222 // var currentCdn = vheCdnChangeEl.dataset['currentCdn']; 223 // /** @var {string} speedCookie */ 224 // var speedCookie = gcGetCookie(VH_SPEED_COOKIE_NAME); 225 // var speedCookieKey = window.requestIp + '_' + currentCdn; 226 // // ÐÑли Ð¼Ñ Ð´ÐµÐ»Ð°Ð»Ð¸ замеÑ, Ñо вÑÑ Ð¾Ð´Ð¸Ð¼ 227 // if (speedCookie === speedCookieKey) { 228 // return; 229 // } 230 // 231 // // ÐамеÑÑем ÑкоÑоÑÑÑ Ð¸Ð½ÐµÑа 232 // checkUserSpeed(currentCdn).then(function (speedKb) { 233 // // СÑавим кÑÐºÑ Ð½Ð° неделÑ, ÑÑÐ¾Ð±Ñ Ð¿Ð¾Ð²ÑоÑно не пÑовеÑÑÑÑ 234 // gcSetCookie(VH_SPEED_COOKIE_NAME, speedCookieKey, {expires: 60 * 60 * 24 * 7, path: '/'}); 235 // if (speedKb < 1000) { 236 // showAlternativePlayerBtn(vheCdnChangeEl); 237 // } 238 // }).catch(function () { 239 // showAlternativePlayerBtn(vheCdnChangeEl); 240 // }); 241})();
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.