moevideo.php 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * @var $this \yii\web\View
  4. */
  5. $this->registerJsFile("//s.clickiocdn.com/t/202435/360.js",['position'=>\yii\web\View::POS_HEAD, 'async'=>true]);
  6. $this->registerJsFile("//s.luxupadva.com/t/common_403.js",['position'=>\yii\web\View::POS_HEAD, 'async'=>true]);
  7. $controller = Yii::$app->controller->id;
  8. $action = Yii::$app->controller->action->id;
  9. if(($controller!="site" && $action!="index") && Yii::$app->deviceDetect->isMobile()):?>
  10. <div id="vi_105778" class="moevideo_inject"></div>
  11. <script type="text/javascript">
  12. function moevideo() {
  13. console.log("Подключение моёвидео")
  14. (
  15. () => {
  16. const script = document.createElement("script");
  17. script.defer = true,
  18. script.src = "https://cdn1.moe.video/player/mvplayer.min.js";
  19. script.onload = () => {
  20. addContentRoll({
  21. width: '100%',
  22. placement: 10167,
  23. promo: true,
  24. advertCount: 10,
  25. slot: 'page',
  26. sound: 'onclick',
  27. fly:{
  28. mode: 'stick',
  29. animation: 'fly',
  30. width: 450,
  31. closeSecOffset: 3,
  32. position: 'bottom-right',
  33. },
  34. adEmpty: () => {
  35. var i = document.createElement("script");
  36. i.src = "https://player.codes/tag/load.js?sid=105778&tag_id=vi_105778";
  37. document.head.append(i); },
  38. });
  39. }
  40. document.body.append(script);
  41. }
  42. )()
  43. }
  44. function adfinityVideoAdv(){
  45. console.log("Подключение adfinity")
  46. adfinity.event().publish('externalLaunch', 8427);
  47. }
  48. function videoAdvRotate(){
  49. const date = new Date();
  50. date.getSeconds()
  51. let flag = false;
  52. const scrollDelay = 200;
  53. console.log("Загрузка видеорекламы, ожидание прокрутки "+scrollDelay+"px")
  54. if(window.scrollY>scrollDelay && !flag) {
  55. console.log("Подключение видеорекламы, скролл достигнул " + scrollDelay + "px")
  56. flag = true;
  57. window.removeEventListener("scroll", moevideo);
  58. if(date.getSeconds()%2){
  59. moevideo();
  60. } else {
  61. adfinityVideoAdv();
  62. }
  63. }
  64. }
  65. setTimeout((function (){
  66. // let flag = false;
  67. window.addEventListener('scroll',videoAdvRotate);
  68. }), 7000);
  69. </script>
  70. <?php endif;?>