1 2window.dateController = new (function() { 3 4 let instance = this; 5 6 this.state = { 7 schedule: { 8 work: [], 9 notWork: [], 10 } 11 }; 12 13 this.dateValidation = function(date) 14 { 15 let dateObject = new Date(date); 16 17 if (!isNaN(dateObject)) 18 { 19 return { 20 object: dateObject, 21 string: instance.dateToString(dateObject), 22 } 23 } 24 25 return false; 26 }; 27 28 function _initialize() 29 { 30 let err = () => console.log('dateController: schedule getting error'); 31 $.ajax({ 32 url: 'CMS/AJAX/calendar.php?q=schedule', 33 success: (response) => { 34 if (response.success) { 35 instance.state.schedule = response.data; 36 } 37 else { 38 err(); 39 } 40 }, 41 error: err, 42 }) 43 } 44 45 this.findNextWorkDate = function(date) 46 { 47 let _date = instance.dateValidation(date); 48 49 if (_date !== false) 50 { 51 let nextDate = _date.object; 52 for (let i = 0; i < 30; i++) 53 { 54 nextDate.setDate(nextDate.getDate() + 1); 55 if (instance.dateIsWork(nextDate)) 56 { 57 return nextDate; 58 } 59 } 60 } 61 62 return false; 63 }; 64 65 this.dateIsWork = function(date) { 66 67 let _date = instance.dateValidation(date); 68 69 if (_date !== false) 70 { 71 if (_date.object.getDay() > 0 && _date.object.getDay() < 6) 72 { 73 return instance.state.schedule.notWork.indexOf(_date.string) === -1; 74 } 75 else 76 { 77 return instance.state.schedule.work.indexOf(_date.string) !== -1; 78 } 79 } 80 81 console.log('dateController: invalid format date'); 82 console.log({date}); 83 return false; 84 }; 85 86 this.dateToString = function(dateObject, dots = false) { 87 let dateString = dateObject.toJSON().slice(0,10); 88 89 if (dots) 90 { 91 return dateString.split('-').reverse().join('.'); 92 } 93 94 return dateString; 95 }; 96 97 _initialize(); 98})(); 99 100 101window.BootstrapComponents = new (function() { 102 103 const randomString = function (size = 8) { 104 let text = ""; 105 let possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; 106 107 for (let i = 0; i < size; i++) 108 { 109 text += possible.charAt(Math.floor(Math.random() * possible.length)); 110 } 111 112 return text; 113 }; 114 115 let instance = this; 116 117 this.modal = function(opt = {}) { 118 119 let currentInstance = this; 120 121 let randomStr = randomString(); 122 this.opt = { 123 id: randomStr, 124 title: '', 125 is_static: false, 126 centered: false, 127 justify_buttons: 'end', 128 size: '', 129 content: '', 130 btn_ok: { 131 id: randomStr + '-btnOk', 132 text: 'ÐоÑово', 133 }, 134 btn_close: false, 135 136 ...opt, 137 }; 138 139 this.$element = {}; 140 141 const _initialize = function() { 142 143 let modalId = currentInstance.opt.id, 144 title = currentInstance.opt.title, 145 content = currentInstance.opt.content, 146 btn_text = currentInstance.opt.btn_ok.text; 147 148 let keyboard = currentInstance.opt.is_static ? 'data-keyboard="false"' : ''; 149 let backdrop = currentInstance.opt.is_static ? 'data-backdrop="static"' : ''; 150 151 let notBtnClose = currentInstance.opt.is_static; 152 153 if (currentInstance.opt.btn_close) 154 { 155 notBtnClose = false; 156 } 157 158 let btnClose = notBtnClose ? '' 159 : `<button type="button" class="close" data-dismiss="modal" aria-label="Close"> 160 <span aria-hidden="true">×</span> 161 </button>`; 162 163 let centered = currentInstance.opt.centered ? 'modal-dialog-centered' : ''; 164 165 let size = ''; 166 if (currentInstance.opt.size == 'lg') 167 { 168 size = 'modal-lg'; 169 } 170 171 let justifyButtons = 'end'; 172 if (currentInstance.opt.justify_buttons == 'start') 173 { 174 justifyButtons = 'start'; 175 } 176 else if (currentInstance.opt.justify_buttons == 'center') 177 { 178 justifyButtons = 'center'; 179 } 180 181 let btn_ok_id = currentInstance.opt.btn_ok.id; 182 183 let template = ` 184 <div id="${modalId}" class="modal fade" tabindex="-1" role="dialog" style="padding-right: 17px;" ${keyboard} ${backdrop}> 185 <div class="modal-dialog ${size} ${centered}" role="document">
186 <div class="modal-content rounded-0"> 187 <div class="modal-header"> 188 <h5 class="modal-title">${title}</h5>${btnClose} 189 </div> 190 <div class="modal-body border-box">${content}</div> 191 <div class="modal-footer" style="justify-content: ${justifyButtons};"> 192 <button type="button" class="btn btn-primary rounded-0" id="${btn_ok_id}">${btn_text}</button> 193 </div> 194 </div> 195 </div> 196 </div> 197 `; 198 199 if ($('body').append(template)) 200 { 201 currentInstance.$element = $(`#${modalId}`); 202 } 203 }; 204 205 _initialize(); 206 }; 207 208})(); 209 210 211 212let GeolocationModule = function() { 213 214 let instance = this; 215 216 this.data = { 217 cities: {}, 218 }; 219 220 this.selectors = { 221 change_city_btn: '.geoloc [id$="changeCityBtn"]', 222 change_city_modal: '#geolocation-changeCityModal', 223 select_city: '#geolocation-selectCity', 224 save_city_btn: '#geolocation-saveCityBtn', 225 }; 226 // change_city_btn: '#geoloÑation-changeCityBtn', 227 this.ajaxAction = function (action, options) { 228 229 return $.ajax({ 230 ...options, 231 type: 'POST', 232 url: 'CMS/AJAX/geolocation.php?action=' + action, 233 dataType: 'json', 234 235 }); 236 237 }; 238 239 this.components = {}; 240 241 const _initialize = function() { 242 const hasChangeCityButton = $(instance.selectors.change_city_btn).length > 0; 243 if (!hasChangeCityButton) { 244 return; 245 } 246// return; 247 instance.ajaxAction('getCities', { 248 success: (response) => { 249 if (response.success) 250 { 251 instance.data.cities = response.data; 252 253 let selectId = instance.selectors.select_city.replace(/^#/g, ''); 254 // let select =""; 255 // let select = `<select class="form-control rounded-0 js-example-basic-single" id="${selectId}">`; 256 let select = `<select class="js-example-basic-single" name="state" id="${selectId}">`; 257 for (let option of instance.data.cities) 258 { 259 // if (option.weight > 0) { 260 // select += `<option value="${option.id}" data-name="${option.name}" style="font-weight:bold;">${option.label}</option>`; 261 // } else { 262 // select += `<option value="${option.id}" data-name="${option.name}">${option.label}</option>`; 263 // } 264 if (option.weight > 0) { 265 select += `<option value="${option.id}" style="font-weight:bold;">${option.label}</option>`; 266 } else { 267 select += `<option value="${option.id}" >${option.label}</option>`; 268 } 269 } 270 select += '</select>'; 271 272 instance.components['modal'] = new window.BootstrapComponents.modal({ 273 id: instance.selectors.change_city_modal.replace(/^#/g, ''), 274 title: 'ÐÑбеÑиÑе гоÑод', 275 btn_ok: { 276 text: 'ÐеÑейÑи', 277 id: instance.selectors.save_city_btn.replace(/^#/g, '') 278 }, 279 content: select, 280 }); 281 282 $(instance.selectors.select_city).val(response.current_city_id); 283 $(instance.selectors.select_city).select2({ 284 dropdownParent: $('#geolocation-changeCityModal'), 285 width: "100%", 286 }); 287 288 $(instance.selectors.save_city_btn).on('click', function() { 289 instance.ajaxAction('changeCity', { 290 data: { 291 city_id: $(instance.selectors.select_city).val() 292 } 293 }).always(() => window.location.href = '/m:products'); 294 }); 295 } 296 297 // $(instance.selectors.save_city_btn).on('click', function() { 298 // instance.ajaxAction('changeCity', { 299 // data: { 300 // city_id: $(instance.selectors.select_city).val() 301 // } 302 // }).done(() => window.location.reload()) 303 // .fail(() => console.log('ÐÑибка ÑÐ¼ÐµÐ½Ñ Ð³Ð¾Ñода')); 304 // }); 305 // } 306 307 }, 308 error: () => { 309 console.log('ÐÑибка '); 310 } 311 }); 312 313 $(instance.selectors.change_city_btn).on('click', function() { 314 $(instance.selectors.change_city_modal).modal('show'); 315 }); 316 }; 317 318 _initialize(); 319}; 320 321 322 323/* App Instance */ 324let appInstance = new (function() { 325 326 let app = this; 327 328 this.options = { 329 head_update_delay: 12000, 330 head_update_timeout: 10000, 331 }; 332 333 this.data = { 334 head_update: {} 335 }; 336 337 this.getUser = function () { 338 return JSON.parse(JSON.stringify(app.data.user)); 339 }; 340 341 this.modules = {}; 342 343 this.timers = { 344 full_update: 0, 345 head_update: 0, 346 }; 347 this.flags = { 348 head_update_in_progress: false, 349 }; 350 351 const hasHeadUpdateTargets = function() { 352 const hasFinance = $('.head_menu_money[data=head_finance], .head_menu_money[data=head_bonus], .finance-user-money').length > 0; 353 const hasMessages = $('.head_menu_money[data=head_message]').length > 0; 354 return hasFinance || hasMessages; 355 }; 356 357 this.fullUpdate = function() { 358 clearTimeout(app.timers.full_update); 359 clearTimeout(app.timers.header); 360 361 const hasUserData = typeof app.data.user !== 'undefined' && app.data.user !== null; 362 if (!hasHeadUpdateTargets() && hasUserData) { 363 return; 364 } 365 366 if (typeof navigator !== 'undefined' && navigator.onLine === false) { 367 app.timers.header = setTimeout(app.fullUpdate, app.options.head_update_delay); 368 return; 369 } 370 371 if (typeof document !== 'undefined' && document.hidden) { 372 app.timers.header = setTimeout(app.fullUpdate, app.options.head_update_delay); 373 return; 374 } 375 376 app.headUpdate(); 377 }; 378 // this.fullUpdate = function() { 379 // clearTimeout(app.timers.full_update); 380 // clearTimeout(app.timers.header); 381 // app.headUpdate(); 382 // // clearTimeout(app.timers.full_update); 383 // // clearTimeout(app.timers.header); 384 // // // const hasUserData = typeof app.data.user !== 'undefined' && app.data.user !== null; 385 // // // if (!hasHeadUpdateTargets() && hasUserData) { 386 // // // return; 387 // // // } 388 // // 389 // // app.headUpdate(); 390 // }; 391 392 393 this.headUpdate = function() { 394 clearTimeout(app.timers.header); 395 if (app.flags.head_update_in_progress) { 396 return; 397 } 398 app.flags.head_update_in_progress = true; 399 400 $.ajax({ 401 type: 'POST', 402 data: {}, 403 url: "CMS/AJAX/headUpdate.php", 404 async: true, 405 dataType: 'json', 406 timeout: app.options.head_update_timeout, 407 success: function (response) { 408 if (!response || typeof response !== 'object') { 409 return; 410 } 411 if (!app.data.hasOwnProperty("user")) app.data.user = response.user; 412 app.data.head_update = response; 413 updateHeadInfo(response); 414 }, 415 complete: function () { 416 app.flags.head_update_in_progress = false;
417 app.timers.header = setTimeout(app.fullUpdate, app.options.head_update_delay); 418 } 419 }); 420 }; 421 // this.headUpdate = function() { 422 // clearTimeout(app.timers.header); 423 // 424 // $.ajax({ 425 // type: 'POST', 426 // data: {}, 427 // url: "CMS/AJAX/headUpdate.php", 428 // async: true, 429 // dataType: 'json', 430 // success: function (response) { 431 // if (!app.data.hasOwnProperty("user")) app.data.user = response.user; 432 // app.data.head_update = response; 433 // updateHeadInfo(response); 434 // 435 // app.timers.header = setTimeout(app.fullUpdate, app.options.head_update_delay); 436 // }, 437 // }); 438 // }; 439 const updateHeadInfo = function(data) { 440 // ÐбновлÑем оÑобÑажаемÑй Ð±Ð°Ð»Ð°Ð½Ñ 441 let balance = Number(data['Finance']) + Number(data['bonuse']); 442 // $('.head_menu_money[data=head_finance]').html(`${balance} ÑÑб.`); 443 const $headFinance = $('.head_menu_money[data=head_finance]'); 444 if ($headFinance.length) { 445 $headFinance.html(`${balance} ÑÑб.`); 446 } 447 let $advancedFinanceElement = $('.finance-user-money'); 448 if($advancedFinanceElement.length) 449 { 450 $advancedFinanceElement.html(`${balance} ÑÑб.`); 451 } 452 453 // ÐбновлÑем оÑобÑажаемое кол-во бонÑÑов 454 let bonuses = Math.trunc(data['bonusNEW']); 455 const $headBonus = $('.head_menu_money[data=head_bonus]'); 456 if ($headBonus.length) { 457 $headBonus.html(`${bonuses} ÑÑб.`); 458 } 459 // $('.head_menu_money[data=head_bonus]').html(`${bonuses} ÑÑб.`); 460 461 // ÐбновлÑем оÑобÑажаемое кол-во ÑообÑений 462 // $('.head_menu_money[data=head_message]').html(data['Messages'] > 0 ? `(${data['Messages']})` : ''); 463 const $headMessage = $('.head_menu_money[data=head_message]'); 464 if ($headMessage.length) { 465 $headMessage.html(data['Messages'] > 0 ? `(${data['Messages']})` : ''); 466 } 467 }; 468 469 const _initialize = function() { 470 471 $(document).ready(function() { 472 app.fullUpdate(); 473 if ($('.geoloc [id$="changeCityBtn"]').length > 0) { 474 app.modules.geolocation = new GeolocationModule(); 475 } 476 }); 477 478 }; 479 480 481 // const _initialize = function() { 482 // 483 // $(document).ready(function() { 484 // app.fullUpdate(); 485 // app.modules.geolocation = new GeolocationModule(); 486 // }); 487 // 488 // }; 489 490 _initialize(); 491 492})();
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.