1var JsStatistic = { 2 key_storage_key: 'statistic', 3 player: '', 4 5 page_read_time: 0, 6 page_online_time: 0, 7 page_class_id: 0, 8 page_article_id: 0, 9 page_category_id: 0, 10 page_player_count: 0, 11 page_player_time: 0, 12 page_player_time_total: 0, 13 page_popup_video_id: 0, 14 15 video_has_page_id: 0, 16 17 hello_id: '', 18 page_statistic_uid: '', 19 page_tag: '', 20 language: '', 21 screen_resolution: '', 22 exmoo_code: '', 23 page_serial_id: 0, 24 page_serial_id_switch: 0, 25 key_page_id_for_parent: 0, 26 key_page_serial_id: 'current_page_id', 27 key_statistic_id: 'statistic_uid', 28 key_page_class_id: 'page_class_id', 29 key_category_id: 'category_id', 30 key_article_id: 'article_id', 31 key_read_time: 'read_time', 32 key_online_time: 'online_time', 33 key_page_tag: 'tag', 34 key_language: 'language', 35 key_page: 'page', 36 key_video: 'video', 37 key_player_time: 'play_time', 38 key_player_count: 'play_count', 39 key_hello_id: 'hello_id', 40 key_http_current: 'http_current', 41 key_http_referer: 'http_referer', 42 key_exmoo_code: 'exmoo_code', 43 key_screen_resolution: 'screen_resolution', 44 key_popup_video_id: 'popup_video_id', 45 key_app: 'app', 46 http_current: '', 47 http_referer: '', 48 49 is_popup_video_mode: 0, 50 api_post_statistic_url: '', 51 52 set_read_time_to_zero: 0, 53 54 is_frontend_remove_local_storage: 0, //1=å端å é¤LSï¼0=å端å é¤LSï¼é»è®¤ï¼ 55 display_html_info: 1, 56 console_log_data: '', 57 mode_test: 0, 58 mode_test_value: '', 59 60 html_id_record_time_read: '.record-time-read', 61 html_id_record_time_online: '.record-time-online', 62 html_id_record_data: '.record-data', 63 html_id_record_key: '.record-key', 64 html_id_play_count: '.play-count', 65 html_id_play_time: '.play-time', 66 html_id_play_time_total: '.play-time-total', 67 html_id_console_log: '.console-log', 68 html_id_exmoo_code: '.md5', 69 70 page_app: 1, 71 72 window_current: 1, 73 window_current_in_first: 1, 74 window_current_out_first: 1, 75 76 timer_page_expire: 0, 77 78 generate_page_id: function () { 79 var max = 99999999999; 80 var min = 10000000000; 81 return Math.floor(Math.random() * (max - min + 1) + min); 82 }, 83 generate_popup_video_id: function () { 84 var max = 999999; 85 var min = 100000; 86 return Math.floor(Math.random() * (max - min + 1) + min); 87 }, 88 popup_video_mode_setting: function () { 89 if (this.is_popup_video_mode === 1) { 90 this.api_post_statistic_url = api_post_statistic_url_video; 91 this.display_html_info = 0; 92 this.key_page = this.key_video; 93 } else { 94 this.api_post_statistic_url = api_post_statistic_url_statistic; 95 //this.key_page = 'page'; 96 } 97 }, 98 popup_video_mode_setting_after: function () { 99 100 if (this.is_popup_video_mode === 1) { 101 this.page_serial_id_switch = this.key_page_id_for_parent; 102 } else { 103 this.page_serial_id_switch = this.page_serial_id; 104 } 105 }, 106 storage_key: function () { 107 return this.key_storage_key; 108 }, 109 save_data_page_id: function (data) { 110 111 //dataæ¯page_idéé¢ç 112 113 var org = this.get_data(); // orgå æ¬page,video 114 115 // åå¹¶åºå±æ°æ® 116 if (org && org[this.key_page] && org[this.key_page][this.page_serial_id]) { 117 data = $.extend(org[this.key_page][this.page_serial_id], data); 118 } 119 120 //å°è£ page_id级 121 var page_id = {}; 122 page_id[this.page_serial_id] = data; 123 124 //åå¹¶page_id级 125 if (org) { 126 page_id = $.extend(page_id, org[this.key_page]); 127 } 128 129 //å°è£ 顶级 130 var page = {}; 131 page[this.key_page] = page_id; //pageå·²æ¯é¡¶çº§ 132 133 //å并顶级 134 if (org) { 135 page = $.extend(org, page); 136 } 137 138 var key = this.storage_key(); 139 this.storage_set(key, page); 140 //statistic['page']['23423543435'][data] 141 //statistic['page']['23423543435'][data]['time'] 142 //statistic['page']['23423543435'][data]['id'] 143 }, 144 save_data_page_flush: function (data) { 145 //dataæ¯pageéé¢ç 146 var key = this.storage_key(); 147 this.storage_set(key, data); 148 //statistic = ['page']['23423543435'][data] 149 //statistic = ['page']['23423543435'][data]['time'] 150 //statistic = ['page']['23423543435'][data]['id'] 151 }, 152 get_data: function () { 153 var key = this.storage_key(); 154 var data = this.storage_get(key); // = ['page']['23423543435'][data]['id'] 155 return data; 156 }, 157 get_data_page: function () { 158 var data = this.get_data(); 159 if (data && data[this.key_page]) { 160 return data[this.key_page]; 161 } 162 return {}; 163 }, 164 has_data_page: function () { 165 var data = this.get_data_page(); 166 return data ? 1 : 0; 167 }, 168 get_data_current: function () { 169 var data = this.get_data(); 170 if (data == null) { 171 return null; 172 } 173 var page = data[this.key_page]; 174 var page_id = page[this.page_serial_id]; 175 return page_id; 176 }, 177 save_read_time: function () { 178 var data = {}; 179 180 if (this.set_read_time_to_zero === 1) { 181 this.page_read_time = 0; 182 data[this.key_read_time] = 0; 183 } else { 184 data[this.key_read_time] = this.page_read_time; 185 } 186 187 this.save_data_page_id(data); 188 }, 189 get_current_page_id_refresh: function () { 190 var data = this.get_data_page(); 191 if (typeof data === "undefined") { 192 return {}; 193 } 194 return data; 195 }, 196 get_current_read_time: function () { 197 var page_id = this.get_data_current(); 198 if (page_id == null) { 199 return 0; 200 } 201 if (page_id[this.key_read_time] === 'undefined' || page_id[this.key_read_time] == null) { 202 return 0; 203 } 204 return page_id[this.key_read_time]; 205 }, 206 save_online_time: function () { 207 var data = {}; 208 data[this.key_online_time] = this.page_online_time; 209 this.save_data_page_id(data); 210 }, 211 save_player_count: function () { 212 var data = {}; 213 this.page_player_count = Math.max(this.page_player_count, this.get_player_play_count()); 214 data[this.key_player_count] = this.page_player_count; 215 this.save_data_page_id(data); 216 }, 217 save_player_time: function () { 218 if (this.is_popup_video_mode === 0) { 219 //return; //æµè¯ç¨ 220 } 221 var data = {}; 222 this.page_player_time = Math.max(this.page_player_time, this.get_player_play_time()); 223 data[this.key_player_time] = this.page_player_time; 224 this.save_data_page_id(data); 225 }, 226 save_hello_id: function () { 227 var data = {}; 228 data[this.key_hello_id] = this.hello_id; 229 this.save_data_page_id(data); 230 }, 231 save_all: function () { 232 this.save_read_time(); 233 this.save_online_time(); 234 this.save_url(); 235 this.save_player_count(); 236 this.save_player_time(); 237 this.save_hello_id(); 238 this.save_exmoo_code(); 239 this.save_id(); 240 }, 241 get_player_count: function () { 242 var page_id = this.get_data_current(); 243 return page_id[this.key_player_count]; 244 }, 245 get_player_time: function () { 246 var page_id = this.get_data_current(); 247 return page_id[this.key_player_time]; 248 }, 249 save_id: function () { 250 var id = this.install_id(this.page_serial_id_switch, this.language, this.page_tag, this.page_statistic_uid, this.page_class_id, this.page_category_id, this.page_article_id, this.screen_resolution, this.page_popup_video_id, this.page_app) 251 var data = {}; 252 data = id; 253 this.save_data_page_id(data); 254 }, 255 install_id: function (page_serial_id, language, page_tag, page_statistic_uid, page_class_id, category_id, article_id, screen_resolution, page_popup_video_id, page_app) { 256 var id = {}; 257 id[this.key_page_serial_id] = page_serial_id; 258 id[this.key_page_class_id] = page_class_id; 259 id[this.key_category_id] = category_id; 260 id[this.key_article_id] = article_id; 261 id[this.key_statistic_id] = page_statistic_uid; 262 id[this.key_page_tag] = page_tag; 263 id[this.key_language] = language; 264 id[this.key_screen_resolution] = screen_resolution; 265 id[this.key_screen_resolution] = screen_resolution; 266 id[this.key_popup_video_id] = page_popup_video_id; 267 id[this.key_app] = page_app; 268 if (this.mode_test === 1) { 269 id['mode_test_value'] = this.mode_test_value; 270 } 271 return id; 272 }, 273 save_url: function () { 274 var data = {}; 275 data[this.key_http_current] = this.http_current; 276 data[this.key_http_referer] = this.http_referer; 277 this.save_data_page_id(data); 278 }, 279 save_exmoo_code: function () { 280 this.calculate_exmoo_code(); 281 var data = {}; 282 data[this.key_exmoo_code] = this.exmoo_code; 283 this.save_data_page_id(data); 284 }, 285 calculate_exmoo_code: function () { 286 var string = String(this.hello_id) + String(this.page_serial_id_switch) + String(this.page_read_time) + String(this.page_class_id) + String(this.page_category_id) + String(this.page_article_id) + String(this.page_online_time) + String(this.page_player_time) + String(this.http_current) + String(this.http_referer) + String(this.language) + String(this.page_tag) + String(this.page_popup_video_id) + String(this.page_app); 287 //console.log(string); 288 this.mode_test_value = string; 289 this.exmoo_code = hex_md5(string); 290 }, 291 reset_read_time: function (data) { 292 data[this.key_read_time] = 0; 293 this.save_data_page_id(data); 294 }, 295 get_data_page_id: function (page_id) { 296 var page = this.get_data_page(); 297 return page[page_id]; 298 }, 299 remove_page_id: function (page_id_array, console_log) { 300 301 return; //ä¸å¨è¿éå é¤ï¼å¼å¯å¦ä¸ä¸ªè¿ç¨å¤ç ââââââââââââââââââââââââââââ ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ âââââââââââââââââââââââââââââââââ 302 303 var $this = this; 304 var page = this.get_data_page(); 305 var save = {}; 306 var flush = {}; 307 308 if (JSON.stringify(page) === "{}") { 309 return; 310 } 311 312 $.each(page, function (page_id, data) { 313 314 //$this.reset_read_time(data); 315 316 data = $this.get_data_page_id(page_id); 317 //console.log(page_id, page_id_array); 318 //console.log($this.page_serial_id, parseInt(page_id)); 319 //console.log(page_id_array.indexOf(page_id)); 320 //console.log($this.page_serial_id === parseInt(page_id)); 321 322 var in_array = 0; 323 for (var i in page_id_array) { 324 if (page_id_array[i]['page_id'] === parseInt(page_id)) { //LSéçï¼ä¸å¨å é¤å表éç 325 alert(page_id_array[i]['page_id']) 326 in_array = 1; // å¨çï¼remove 327 } 328 } 329 330 var is_current = $this.page_serial_id === parseInt(page_id); // å½å页é¢ä¸å é¤ï¼save 331 332 if (in_array === 0 || is_current) { 333 save[page_id] = data; 334 $this.set_console_log(console_log + ' saveï¼' + page_id); 335 global_consloe_log_open ? console.log(console_log + ' saveï¼' + page_id) : null; 336 } else { 337 $this.set_console_log(console_log + ' removeï¼' + page_id); 338 global_consloe_log_open ? console.log(console_log + ' removeï¼' + page_id) : null; 339 } 340 341 }); 342 343 var len = 0; 344 for (var i in save) { 345 len++; 346 } 347 348 var key = this.storage_key(); 349 this.storage_remove(key); 350 $this.set_console_log('Clear LocalStorage'); 351 352 if (len > 0) { 353 flush[this.key_page] = save 354 this.save_data_page_flush(flush); 355 } 356 }, 357 storage_set: function (key, value) { 358 try { 359 var json = JSON.stringify(value); 360 window.localStorage.setItem(key, json); 361 } 362 catch (err) { 363 alert(err); 364 } 365 366 }, 367 storage_get: function (key) { 368 var json = window.localStorage.getItem(key); 369 return JSON.parse(json); 370 }, 371 storage_remove: function (key) { 372 return window.localStorage.removeItem(key); 373 }, 374 storage_clear: function (key) { 375 window.localStorage.removeItem(key); 376 this.storage_set(key, {}); 377 //this.reset_data(); 378 }, 379 reset_data: function () { 380 this.page_read_time = 0; 381 this.save_read_time(); 382 this.page_online_time = 0; 383 this.save_online_time(); 384 }, 385 read_time_plus: function () { 386 this.page_read_time++; 387 }, 388 online_time_plus: function () { 389 this.page_online_time++; 390 }, 391 display_storage_read_time: function () {
392 $(this.html_id_record_time_read).html(this.page_read_time + ' ç§'); 393 }, 394 display_storage_online_time: function () { 395 $(this.html_id_record_time_online).html(this.page_online_time + ' ç§'); 396 }, 397 display_storage_data: function () { 398 var data = this.get_data(); 399 var json = JSON.stringify(data); 400 $(this.html_id_record_data).html(json); 401 }, 402 display_storage_key: function () { 403 $(this.html_id_record_key).html(this.page_serial_id); 404 }, 405 display_player_count: function () { 406 $(this.html_id_play_count).html(this.get_player_play_count() + ' 次'); 407 }, 408 display_player_time: function () { 409 $(this.html_id_play_time).html(this.get_player_play_time() + ' ç§'); 410 }, 411 display_player_time_total: function () { 412 $(this.html_id_play_time_total).html(this.get_player_play_time_total() + ' ç§'); 413 }, 414 display_all: function () { 415 this.display_storage_read_time(); 416 this.display_storage_online_time(); 417 this.display_storage_data(); 418 this.display_storage_key(); 419 this.display_player_count(); 420 this.display_player_time(); 421 this.display_player_time_total(); 422 this.display_exmoo_code(); 423 }, 424 display_console_log: function () { 425 var html = $(this.html_id_console_log).html(); 426 $(this.html_id_console_log).html(html + this.console_log_data); 427 }, 428 display_exmoo_code: function () { 429 $(this.html_id_exmoo_code).html(this.exmoo_code); 430 }, 431 set_console_log: function (log) { 432 this.console_log_data = log + "<br>"; 433 this.display_console_log(); 434 }, 435 set_http_url: function (stat_http_current, stat_http_referer) { 436 this.http_current = stat_http_current; 437 this.http_referer = stat_http_referer; 438 }, 439 set_player_instance: function (player_instance) { 440 this.player = player_instance; // æ¿æ¢ææ¾å¨ // è·åå®ä¾ 441 }, 442 get_player_play_count: function () { 443 if (typeof this.player == 'string') { 444 return 0; 445 } 446 return this.player.get_play_count(); 447 }, 448 get_player_play_time: function () { 449 if (typeof this.player === 'string') { 450 return 0; 451 } 452 return this.player.get_play_time(); 453 }, 454 get_player_play_time_total: function () { 455 if (typeof this.player === 'string') { 456 return 0; 457 } 458 return this.player.get_play_time_total(); 459 }, 460 encode_popup_video_id: function (page_serial_id, page_class_id, page_category_id, page_article_id) { 461 return hex_md5(String(page_serial_id) + String(page_class_id) + String(page_category_id) + String(page_article_id)); 462 }, 463 init: function () { 464 465 if (this.page_serial_id === 0) { 466 this.page_serial_id = this.generate_page_id(); 467 } 468 469 var $this = this; 470 var page = this.get_current_page_id_refresh(); // åªè¿åvisit ævideo 471 var page_id = {}; 472 //var page_data; 473 474 if (this.video_has_page_id === 0) { // visitç 475 476 var $this = this; 477 $.each(page, function (key, value) { 478 if (value.http_referer === $this.http_referer && value.http_current === $this.http_current) { //åç°éå¤äºï¼å¦ä½å¤ææ¯åä¸ä¸ªé¡µé¢ï¼ 479 page_id = value; 480 } 481 }) 482 483 if (JSON.stringify(page_id) !== "{}") { 484 485 this.page_read_time = page_id[this.key_read_time]; 486 this.page_online_time = page_id[this.key_online_time]; 487 this.page_player_count = page_id[this.key_player_count]; 488 this.page_player_time = page_id[this.key_player_time]; 489 this.page_serial_id = page_id[this.key_page_serial_id]; 490 this.page_popup_video_id = page_id[this.key_popup_video_id]; 491 } else { 492 493 this.page_read_time = 0; 494 this.page_online_time = 0; 495 this.page_player_count = 0; 496 this.page_player_time = 0; 497 this.page_popup_video_id = 0; 498 499 } 500 501 } else { // videoç 502 503 if (JSON.stringify(page) !== "{}" && page[this.video_has_page_id]) { // visitä»»ä½ç¶æåvideoçrunç¶æ 504 this.page_serial_id = this.video_has_page_id; // apiæäº¤ç¨ 505 this.page_popup_video_id = page[this.video_has_page_id][this.key_popup_video_id]; // 506 this.page_read_time = 0; 507 this.page_online_time = 0; 508 this.page_player_count = page[this.video_has_page_id][this.key_player_count]; 509 this.page_player_time = page[this.video_has_page_id][this.key_player_time]; 510 511 } else { // videoçåå§åç¶æ 512 if (this.is_popup_video_mode === 1) { 513 514 this.page_serial_id = this.generate_video_page_serial_id(); //å¤é¢å·²èµå¼ï¼åæ°é½ 515 this.page_popup_video_id = this.encode_popup_video_id(this.page_serial_id, this.page_class_id, this.page_category_id, this.page_article_id); 516 this.page_read_time = 0; 517 this.page_online_time = 0; 518 this.page_player_count = 0; 519 this.page_player_time = 0; 520 } 521 } 522 523 } 524 525 526 }, 527 generate_video_page_serial_id: function () { 528 this.page_serial_id = this.key_page_id_for_parent; // å¼¹çªçidè¦æ¿é¡µé¢çid 529 var page_popup_video_id = this.encode_popup_video_id(this.page_serial_id, this.page_class_id, this.page_category_id, this.page_article_id); 530 return page_popup_video_id.substring(0, 8); 531 }, 532 api_post_statistic: function () { 533 var has = this.has_data_page(); 534 if (has === 1) { 535 var data = this.get_data(); 536 this.api_post_function(data); 537 } 538 }, 539 api_post_function: function (data) { 540 //$.ajaxSetup({headers: {'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')}}); 541 var url = this.api_post_statistic_url; 542 var $this = this; 543 544 $.ajax({
545 type: 'post', 546 url: url, 547 async: false, 548 data: data, 549 dataType: 'json', 550 beforeSend: function () { 551 if ($this.is_frontend_remove_local_storage === 1) { 552 var page_id_array = []; 553 554 $.each(data, function (key, value) { //data=['345345345'=>[id,to=time],'456456456'=>[id,to=time]] 555 page_id_array.push(key); 556 }) 557 $this.remove_page_id(page_id_array, 'Frontend - '); 558 } 559 }, 560 success: function (result) { 561 if ($this.is_frontend_remove_local_storage === 0) { //å端å é¤ï¼é»è®¤ï¼ 562 if (result.Success == 1) { 563 global_consloe_log_open ? console.log(result.Message) : null; 564 $this.set_console_log(result.Message); 565 $this.remove_page_id(result.Data, 'Backend - '); //result.Data=['4564534534576','34645645645'] 566 } else { 567 global_consloe_log_open ? console.log(result.Message) : null; 568 $this.set_console_log(result.Message); 569 } 570 } 571 } 572 }); 573 }, 574 set_window_current: function (is_current) { 575 this.window_current = is_current; 576 }, 577 get_window_current: function () { 578 return this.window_current; 579 }, 580 run: function () { 581 582 //å¦æé¼ æ ä¸å¨å½å页é¢ï¼åæ¢è®¡æ¶ 583 if (this.get_window_current() === 0) { 584 585 //ä»LSè¯»åææ°çå¼ 586 this.init(); 587 588 this.page_online_time++; 589 590 this.save_all(); 591 592 //åªæå½æè®¡æ°è¿çææäº¤ï¼ä¸ç¶ä¸ç´ç¦»å¼ï¼å°±ä¸ä¼æäº¤ 593 if (this.window_current_out_first === 1) { 594 595 //this.set_console_log('离å¼é¡µé¢ï¼'); 596 //console.log('离å¼é¡µé¢ï¼') 597 598 this.api_post_statistic(); 599 600 this.window_current_out_first = 0; 601 this.window_current_in_first = 1 602 } 603 //é¼ æ å¨å½å页é¢ï¼å¼å§è®¡æ¶ï¼æ¾ç¤º 604 } else { 605 606 this.init(); 607 608 this.page_online_time++; 609 this.page_read_time++; 610 611 612 // å¦æè¯¥å°åºæ æ³ææ¾è§é¢ï¼è®¾ç½®read_time=0 613 if (set_read_time_to_zero_by_article_id === 1) { 614 this.set_read_time_to_zero = 1; 615 } 616 617 this.save_all(); 618 619 //åªæå½æè®¡æ°è¿çææäº¤ï¼ä¸ç¶ä¸ç´ç¦»å¼ï¼å°±ä¸ä¼æäº¤ 620 if (this.window_current_in_first === 1) { 621 622 //this.set_console_log('æ¿æ´»é¡µé¢ï¼'); 623 //console.log('æ¿æ´»é¡µé¢ï¼') 624 625 //this.api_post_statistic(); 626 627 this.window_current_in_first = 0; 628 this.window_current_out_first = 1; 629 } 630 } 631 632 if (this.display_html_info) { 633 this.display_all(); 634 } 635 636 // 任使¶åé½å¤ææ¯å¦æå¼¹çªå¼ææ¾ åªå¯¹é¡µé¢å®ä¾ææ 637 if (this.is_popup_video_mode === 0) { 638 anytime_popup_video(); 639 } 640 }, 641} 642 643var JwplayerStatistic = { // æ¿æ¢ææ¾å¨ // ææ¾å¨å®ä¾ 644 player: '', 645 stat: '', 646 647 status_playing: 0, 648 status_ending: 0, 649 status_pause: 0, 650 time_playing_exact: 0, 651 time_total: 0, 652 count_played: 0, 653 654 popup_video_id: 0, 655 656 interval_id: 0, 657 658 window_current: 1, 659 660 is_mobile: 0, 661 662 html_id_display_time: '.jwplayer_display_time', 663 html_id_display_play_pause: '.jwplayer_display_play_pause', 664 html_id_display_play_start: '.jwplayer_control_play_start', 665 html_id_display_play_end: '.jwplayer_control_play_end', 666 html_id_display_play_exact: '.jwplayer_display_play_exact', 667 html_id_display_time_total: '.jwplayer_display_time_total', 668 669 display_time: function () { 670 // var time = this.player.getPosition(); // æ¿æ¢ææ¾å¨ //ææ¾äºå¤å°ç§ 671 var time = this.player.currentTime(); // æ¿æ¢ææ¾å¨ //ææ¾äºå¤å°ç§ 672 $(this.html_id_display_time).html(Math.round(time)) 673 }, 674 display_play_pause: function () { 675 $(this.html_id_display_play_pause).html('å·²æå') 676 }, 677 display_play_exact: function () { 678 $(this.html_id_display_play_exact).html(this.time_playing_exact) 679 }, 680 display_time_total: function () { 681 $(this.html_id_display_time_total).html(this.time_total) 682 }, 683 set_is_mobile: function () { // æ¿æ¢ææ¾å¨ // 设置æ¯ç§»å¨ç«¯ 684 this.is_mobile = 1; 685 }, 686 set_play_time: function (play_time) { // æ¿æ¢ææ¾å¨ // ç§»å¨ç«¯è®¾ç½®ææ¾æ¶é´ 687 this.time_playing_exact = play_time; 688 }, 689 get_play_time: function () { 690 return this.time_playing_exact; 691 }, 692 get_play_time_total: function () { 693 return this.time_total; 694 }, 695 set_play_count: function () { 696 this.count_played = 1; 697 }, 698 get_play_count: function () { 699 return this.count_played; 700 }, 701 set_window_current: function (is_current) { 702 this.window_current = is_current; 703 }, 704 get_window_current: function () { 705 return this.window_current; 706 }, 707 set_stat_instance: function (stat) { 708 this.stat = stat; 709 }, 710 init: function () { 711 712 var $this = this; 713 714 // æ°ææ¾å¨ 715 this.player.on("play", function () { // æ¿æ¢ææ¾å¨ // å¼å§ææ¾ 716 global_consloe_log_open ? console.log('onPlay') : null; 717 $this.status_pause = 0; 718 $this.player_start(); 719 $this.player_continue(); 720 }); 721 /* 722 this.player.onPlay(function () { // æ¿æ¢ææ¾å¨ // å¼å§ææ¾ 723 global_consloe_log_open ? console.log('onPlay') : null; 724 $this.status_pause = 0; 725 $this.player_start(); 726 $this.player_continue(); 727 //thePlayerGlobal = 'ok'; 728 }); 729 */ 730 731 // æ°ææ¾å¨ 732 this.player.on("pause", function () { 733 global_consloe_log_open ? console.log('onPause') : null; 734 $this.player_pause(); 735 //$this.player_stop(); 736 $this.display_play_pause(); 737 }); 738 /* 739 this.player.onPause(function () { // æ¿æ¢ææ¾å¨ // æåææ¾ 740 global_consloe_log_open ? console.log('onPause') : null; 741 $this.player_pause(); 742 //$this.player_stop(); 743 $this.display_play_pause(); 744 }); 745 */ 746 747 // æ°ææ¾å¨ 748 this.player.on("ended", function () { 749 global_consloe_log_open ? console.log('onComplete') : null; 750 $this.player_stop(); 751 $this.player_continue(); 752 $(this.html_id_display_play_end).html('å·²ç»æ') 753 }); 754 /* 755 this.player.onComplete(function () { // æ¿æ¢ææ¾å¨ //ææ¾å·²ç»æ 756 global_consloe_log_open ? console.log('onComplete') : null; 757 $this.player_stop(); 758 $this.player_continue(); 759 $(this.html_id_display_play_end).html('å·²ç»æ') 760 }); 761 */ 762 }, 763 player_stop: function () { 764 this.status_playing = 0; 765 }, 766 player_start: function () { 767 this.status_playing = 1; 768 $(this.html_id_display_play_start).html('å·²å¼å§') 769 }, 770 player_continue: function () { 771 global_consloe_log_open ? console.log('åæ¶æå') : null; 772 this.status_pause = 0; 773 }, 774 player_pause: function () { 775 if (this.status_pause === 0) { 776 global_consloe_log_open ? console.log('迫使æåï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼') : null; 777 this.status_pause = 1; 778 } 779 }, 780 set_interval_id: function (interval_id) { 781 this.interval_id = interval_id; 782 }, 783 get_interval_id: function () { 784 return this.interval_id; 785 }, 786 play: function () { 787 788 if (this.is_mobile === 1) { 789 return; 790 } 791 792 /* 793 if (this.time_total === 0) { 794 if (typeof this.player.getDuration() === 'undefined') { // æ¿æ¢ææ¾å¨ // è·åæ»ææ¾æ¶é´ 795 return; 796 } 797 this.time_total = parseInt(this.player.getDuration()); // æ¿æ¢ææ¾å¨ // è·åæ»ææ¾æ¶é´ 798 } 799 */ 800 // æ°ç 801 if (this.time_total === 0) { 802 if (typeof this.player.duration() === 'undefined') { // æ¿æ¢ææ¾å¨ // è·åæ»ææ¾æ¶é´ 803 return; 804 } 805 this.time_total = parseInt(this.player.duration()); // æ¿æ¢ææ¾å¨ // è·åæ»ææ¾æ¶é´ 806 } 807 808 if (this.status_playing === 1 && this.time_playing_exact < this.time_total && this.status_pause === 0) { //ææ¾ä¸ 809 810 //å¦æé¼ æ ä¸å¨å½å页é¢ï¼åæ¢è®¡æ¶ 811 if (this.get_window_current() === 1) { // æ°å¢çï¼å¦æä¸å¨å½å页é¢ï¼å¤ä¸ªè§é¢ææ¾æ¶ä¸è®¡ç®å ¶ä»çï¼åªè®¡ç®å½åç 812 813 if (this.time_playing_exact <= this.stat.page_read_time) { // è¿ä¸æ¥é²æ¢è§é¢æ¶é¿åºé 814 815 this.time_playing_exact++; 816 this.set_play_count(); 817 global_consloe_log_open ? console.log('time_playing_exactï¼' + this.time_playing_exact + ' | popup_video_idï¼' + this.popup_video_id) : null; 818 } else { 819 global_consloe_log_open ? console.log('time_playing_exactï¼' + this.time_playing_exact + ' | larger than read_time') : null; 820 } 821 822 } 823 } else { 824 global_consloe_log_open ? console.log('time_playing_exactï¼' + this.time_playing_exact + ' status_playing==' + this.status_playing + ' | status_pause==' + this.status_pause + ' | popup_video_idï¼' + this.popup_video_id) : null; 825 } 826 if (this.time_playing_exact >= this.time_total) { 827 this.time_playing_exact = this.time_total; 828 } 829 this.display_time(); 830 this.display_play_exact(); 831 this.display_time_total(); 832 833 }, 834} 835 836var CleanStatistic = { 837 key_storage_clean: 'statistic_clean', 838 key_storage_statistic: 'statistic', 839 key_storage_lock: 'statistic_lock', 840
841 key_clean: 'clean', 842 key_page: 'page', 843 key_video: 'video', 844 key_online_time: 'online_time', 845 key_page_serial_id: 'current_page_id', 846 window_current: 1, 847 page_serial_id: 0, 848 lock_expire_time: 10, 849 page_expire_time: 10, 850 stat: {}, 851 player: {}, 852 data: {}, 853 854 storage_set: function (key, value) { 855 try { 856 var json = JSON.stringify(value); 857 window.localStorage.setItem(key, json); 858 } 859 catch (err) { 860 alert(err); 861 } 862 863 }, 864 storage_get: function (key) { 865 var json = window.localStorage.getItem(key); 866 return JSON.parse(json); 867 }, 868 get_data: function (key) { 869 var data = this.storage_get(key); 870 return data; 871 }, 872 get_data_page: function (key, key_page) { 873 var data = this.get_data(key); 874 if (data && data[key_page]) { 875 return data[key_page]; 876 } 877 return {}; 878 }, 879 generate_random_id: function () { 880 var max = 99999999; 881 var min = 10000000; 882 return Math.floor(Math.random() * (max - min + 1) + min); 883 }, 884 get_lock: function () { 885 return this.storage_get(this.key_storage_lock); 886 }, 887 set_lock: function () { 888 var lock = {}; 889 lock['page_serial_id'] = this.page_serial_id; 890 lock['time'] = Date.parse(new Date()) / 1000; 891 this.storage_set(this.key_storage_lock, lock); 892 }, 893 set_window_current: function (is_current) { 894 this.window_current = is_current; 895 }, 896 get_window_current: function () { 897 return this.window_current; 898 }, 899 900 loop_clean_collect: function () { 901 902 /* 903 if (!this.get_lock()) { 904 this.set_lock(); 905 } 906 907 var lock; 908 909 lock = this.get_lock(); 910 911 var is_lock_expire = Date.parse(new Date()) / 1000 - lock['time'] > this.lock_expire_time; // éè¿æäº 912 913 if (is_lock_expire) { 914 this.set_lock(); // 䏿¦lockè¿æï¼ç«å³è¢«å«é¡µé¢éå® 915 } 916 917 lock = this.get_lock(); 918 var is_this_lock = lock['page_serial_id'] === this.page_serial_id; 919 920 if (!is_this_lock) { // 䏿¯æéå®çï¼éåº 921 return; 922 } 923 924 this.set_lock(); // å½å页颿´æ°é 925 */ 926 927 var storage = {}; 928 var clean = {}; 929 930 var $this = this; 931 932 // 访é®è½¨è¿¹ç 933 var page = this.get_data_page(this.key_storage_statistic, this.key_page); 934 if (JSON.stringify(page) !== "{}") { 935 936 $.each(page, function (key, value) { 937 clean[key] = {}; 938 clean[key][$this.key_online_time] = Date.parse(new Date()) / 1000; 939 global_consloe_log_open ? console.log('ææºpageå°cleanï¼' + key) : null; 940 }); 941 942 } 943 944 storage[this.key_clean] = clean; 945 this.storage_set(this.key_storage_clean, storage); 946 947 }, 948 949 // åªæè¿å¨çº¿çé¡µé¢ææ´æ°cleanæ¶é´ 950 loop_clean_update: function () { 951 952 var $this = this; 953 954 // 访é®è½¨è¿¹ç 955 var clean = this.get_data_page(this.key_storage_clean, this.key_clean); 956 if (JSON.stringify(clean) !== "{}") { 957 958 $.each(clean, function (key, value) { 959 //console.log($this.page_serial_id); 960 //console.log(key); 961 //console.log(parseInt($this.page_serial_id) === parseInt(key)); 962 if (parseInt($this.page_serial_id) === parseInt(key)) { // åªæå½åé¡µé¢ææ´æ°æ¶é´ 963 clean[key][$this.key_online_time] = Date.parse(new Date()) / 1000; 964 global_consloe_log_open ? console.log('æ´æ°cleanæ¶é´ï¼' + key + ' æ¶é´ï¼' + clean[key][$this.key_online_time]) : null; 965 } 966 967 }); 968 969 } 970 var storage = {}; 971 storage[this.key_clean] = clean; 972 this.storage_set(this.key_storage_clean, storage); 973 974 }, 975 976 // è¿æç页é¢ï¼å é¤dataï¼æ¯ä¸ªé¡µé¢é½æææ§è¡ 977 loop_visit_remove: function () { 978 979 var $this = this; 980 981 // 访é®è½¨è¿¹ç 982 var page = this.get_data_page(this.key_storage_statistic, this.key_page); 983 var video = this.get_data_page(this.key_storage_statistic, this.key_video); 984 var clean = this.get_data_page(this.key_storage_clean, this.key_clean); 985 986 if (JSON.stringify(clean) !== "{}") { 987 988 var array_delete = new Array(); 989 990 $.each(clean, function (key, value) { 991 var key_online_time = value[$this.key_online_time]; 992 global_consloe_log_open ? console.log(key_online_time) : null; 993 var time_span = Date.parse(new Date()) / 1000 - key_online_time; 994 global_consloe_log_open ? console.log(time_span) : null; 995 if (time_span > $this.page_expire_time) { 996 console.log('åç°è¿æâ¦â¦ï¼' + key) 997 array_delete.push(key); 998 999 delete(clean[key]); 1000 } 1001 1002 }); 1003 1004 } 1005 1006 $.each(page, function (key, value) { 1007 for (var i in array_delete) { 1008 if (array_delete[i] === key) { 1009 delete (page[key]); 1010 global_consloe_log_open ? console.log('å é¤è¿æ Visitï¼' + key) : null; 1011 } 1012 } 1013 }); 1014 1015 1016 $.each(video, function (key, value) { 1017 for (var i in array_delete) { 1018 //console.log(video[key]); 1019 //console.log('video循ç¯ï¼', array_delete[i], video[key][$this.key_page_serial_id]); 1020 //console.log('video循ç¯ï¼', video[key]); 1021 if (video[key] && parseInt(array_delete[i]) === parseInt(video[key][$this.key_page_serial_id])) { 1022 delete (video[key]); 1023 global_consloe_log_open ? console.log('å é¤è¿æ Videoï¼' + key) : null; 1024 } 1025 } 1026 1027 }); 1028 1029 var storage = {}; 1030 var storage_clean = {}; 1031 1032 storage[this.key_page] = page; 1033 storage[this.key_video] = video; 1034 storage_clean[this.key_clean] = clean; 1035 1036 this.storage_set(this.key_storage_statistic, storage); 1037 this.storage_set(this.key_storage_clean, storage_clean); 1038 1039 }, 1040}; 1041 1042function storage_clear() { 1043 var key = jsStat.storage_key(); 1044 jsStat.storage_clear(key); 1045}
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.