Advertisement
Ninjaxd666

as

Aug 17th, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.58 KB | None | 0 0
  1. function QS2Hash() {
  2. var q = {};
  3.  
  4. var qs = window.location.search.substring(1)
  5. qs && qs.split('&').forEach(function(i) {
  6. q[i.split('=')[0]] = i.split('=')[1];
  7. });
  8.  
  9. return q
  10. }
  11. //Query string params
  12. var params = QS2Hash()
  13.  
  14.  
  15. function includeJs(filename, cb) {
  16. var head = document.getElementsByTagName('head')[0]
  17. var script = document.createElement('script')
  18. script.src = filename
  19. script.type = 'text/javascript'
  20. script.onload = cb
  21. head.appendChild(script)
  22. }
  23.  
  24. function O_assign(dest, tpl, custom) {
  25.  
  26. Object.keys(tpl).forEach(function(k) {
  27. dest[k] = tpl[k]
  28. })
  29.  
  30. Object.keys(custom).forEach(function(k) {
  31. dest[k] = custom[k]
  32. })
  33.  
  34. return dest
  35. }
  36.  
  37. function isFlashPlayerSupported(){
  38. var isFlashInstalled = (function(){
  39. var b=new function(){var n=this;n.c=!1;var a="ShockwaveFlash.ShockwaveFlash",r=[{name:a+".7",version:function(n){return e(n)}},{name:a+".6",version:function(n){var a="6,0,21";try{n.AllowScriptAccess="always",a=e(n)}catch(r){}return a}},{name:a,version:function(n){return e(n)}}],e=function(n){var a=-1;try{a=n.GetVariable("$version")}catch(r){}return a},i=function(n){var a=-1;try{a=new ActiveXObject(n)}catch(r){a={activeXError:!0}}return a};n.b=function(){if(navigator.plugins&&navigator.plugins.length>0){var a="application/x-shockwave-flash",e=navigator.mimeTypes;e&&e[a]&&e[a].enabledPlugin&&e[a].enabledPlugin.description&&(n.c=!0)}else if(-1==navigator.appVersion.indexOf("Mac")&&window.execScript)for(var t=-1,c=0;c<r.length&&-1==t;c++){var o=i(r[c].name);o.activeXError||(n.c=!0)}}()};
  40. return b.c;
  41. })();
  42.  
  43. if(isFlashInstalled){
  44. return true
  45. }else{
  46. return false
  47. }
  48. }
  49.  
  50. function i18nText(identifier){
  51. var texts = {
  52. es: {
  53. ads: {
  54. skipmessage: 'Saltar en xx',
  55. skiptext: 'Saltar',
  56. admessage: 'El anuncio se cerrará en xx segundos...',
  57. cuetext: 'Publicidad'
  58. },
  59. sharing: {
  60. heading: 'Compartir Video',
  61. },
  62. player: {
  63. title: 'Reproducir video',
  64. live: 'En vivo'
  65. },
  66. related: {
  67. heading: 'Videos Relacionados',
  68. autoplaymessage: '__title__ se reproducirá en xx segundos'
  69. },
  70. flash:{
  71. message: 'Debes tener instalado Flash Player para reproducir el contenido.',
  72. linkText: 'Haz click aquí para ir a la página de descarga'
  73. }
  74. },
  75. en: {
  76. ads: {
  77. skipmessage: 'Skip in xx',
  78. skiptext: 'Skip',
  79. admessage: 'Skip ad in xx seconds...',
  80. cuetext: 'Advertising'
  81. },
  82. sharing: {
  83. heading: 'Share Video',
  84. },
  85. player: {
  86. title: 'Play Video',
  87. live: 'Live Broadcast'
  88. },
  89. related: {
  90. heading: 'Related Videos',
  91. autoplaymessage: '__title__ will reproduce in xx seconds'
  92. },
  93. flash: {
  94. message: 'You must have Flash Player installed ir order to play this content',
  95. linkText: 'Go to download page...'
  96. }
  97. }
  98. }
  99.  
  100. return texts[identifier.toLowerCase()] || texts['es'];
  101. }
  102.  
  103.  
  104. function buildAdvertising(opts) {
  105.  
  106. var tag = opts.adsTag
  107. var adsTagRaw = opts.adsTagRaw
  108. var adsClient = opts.adsClient || 'vast' //Por defecto que sea vast por el momento. Con richard vamos a ver si lo cambiamos a ima.
  109. var adBreaks = opts.adBreaks || [{offset: 'pre'}, {offset: 3 * 60}, {offset: 'post'}]
  110.  
  111. var description_url = opts.canonical_url
  112. ? encodeURIComponent(opts.canonical_url)
  113. : encodeURIComponent(location.protocol + '//' + location.hostname + location.pathname);
  114.  
  115. var duration = 3 * 60;
  116. var ord = Number(ord) || Math.floor(Math.random()*10e12);
  117. var lang = opts.lang || 'es'
  118. var adTag = adsTagRaw ? adsTagRaw : 'https://pubads.g.doubleclick.net/gampad/ads?sz=640x480|300x250|320x50|300x600|960x90&iu=' + tag + '&ciu_szs=300x250,320x50,728x90,970x90&impl=s&gdfp_req=1&env=vp&output=xml_vast2&unviewed_position_start=1&url=[referrer_url]&description_url=' + description_url + '&correlator=' + ord;
  119.  
  120. var breaks = adBreaks.map(function(i) {
  121. return O_assign({}, {type: 'linear', tag: adTag}, i)
  122. })
  123.  
  124. // //Echate el postroll para los live streams
  125. // //Esto se hizo, para el patchUefa, cosa que el postroll del bumper no vaya y por lo tanto no se repita 3 veces la publicidad...
  126. // if (opts.file && opts.file.indexOf('m3u8') > -1)
  127. // breaks = breaks.filter(function(i) {return i.offset !== 'post'})
  128.  
  129. var schedule = breaks.reduce(function(prev, curr, idx){
  130. prev['adbreak' + (idx+1)] = curr
  131. return prev
  132. }, {})
  133.  
  134. return {
  135. autoplayadsmuted: true, //autoplay for ads
  136. client: adsClient,
  137. skipmessage: i18nText(lang).ads.skipmessage,
  138. skiptext: i18nText(lang).ads.skiptext,
  139. admessage: i18nText(lang).ads.admessage,
  140. cuetext: i18nText(lang).ads.cuetext,
  141. schedule: schedule
  142. }
  143.  
  144. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement