Advertisement
Guest User

Untitled

a guest
Aug 14th, 2018
598
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.04 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//HbbTV//1.1.1//EN" "http://www.hbbtv.org/dtd/HbbTV-1.1.1.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>Launcher</title>
  6. <meta http-equiv="content-type" content="Content-Type: application/vnd.hbbtv.xhtml+xml; charset=UTF-8" />
  7.  
  8. <link href='launcher.css?version=1528967768' rel='stylesheet' type='text/css'/>
  9. <link href='../dialog.css?version=1528974926' rel='stylesheet' type='text/css'/>
  10. <link href='../common/common.css?version=1528463613' rel='stylesheet' type='text/css'/>
  11. <script src='../jquery-1.11.3.min.js?version=1521445459' type='text/javascript'></script>
  12. <script src='../common.js?version=1528874135' type='text/javascript'></script>
  13. <script src='../TDTplayer/nowrunning.js?version=1528353789' type='text/javascript'></script>
  14. <script src='../dialog.js?version=1528968529' type='text/javascript'></script>
  15. <script src='../tracking.js?version=1527689344' type='text/javascript'></script>
  16. <script src='../debug-screen.js?version=1528968836' type='text/javascript'></script>
  17. <link href='../debugscreen.css?version=1528888739' rel='stylesheet' type='text/css'/>
  18. <script src='clientError.js?version=1521445459' type='text/javascript'></script>
  19.  
  20. <script type="text/javascript" language="javascript">
  21. <![CDATA[
  22.  
  23. var diffTime, curTime, prevm, t_time;
  24. var refTime = 1534236393106;
  25. var ntpTime = 1534236393106;
  26. var localDate = new Date(1534229193106);
  27. var tz = 120;
  28. var loading = true;
  29.  
  30. setInterval( function(){
  31. ntpTime += 1000;
  32. }, 1000 );
  33.  
  34. function getNTPtime(){
  35. return new Date( ntpTime );
  36. }
  37.  
  38. function getGMTTime( timestring ){
  39. var t = new Date(timestring + "Z"); // make it as UTC time
  40. console.log( "time from start transferred to utc time ", t );
  41. var utc = t.getTime() - (tz*1000 *60 ); // shift utc time depending on timesone of local time (millis)
  42. console.log( "difference shifted to timezone " + tz, t.getTime() - utc);
  43. var localTime = new Date( utc ); // new time wth correct utc time
  44. console.log( "new date object ", localTime );
  45. return localTime;
  46. }
  47.  
  48.  
  49. var certified = true;
  50. var development = false;
  51. var analytics = "";
  52. var broadcastChannel = "";
  53. var SOpromptDelay = 130;
  54. var idCookie = 'b4783e0bcee5765833581806b04c4570';
  55. var idSession = '1534236393105';
  56. var fsatPrivacyPolicy = '';
  57. var cdn = 'level3';
  58.  
  59. var palyerRoot = "../TDTplayer/";
  60.  
  61. var app = null;
  62. var uivisible = false;
  63. var blueActive, startOverAllowed, yellowActive;
  64. var chlistdvb = null;
  65. var item = null;
  66. var animating = false;
  67. var startOverAllowed = false;
  68. var channelNumber = null;
  69.  
  70.  
  71.  
  72.  
  73. var menu = [{ button : VK_GREEN, title : "WC", action : function(){
  74. if( analytics == "mediaset" ){
  75. location.href = "http://cdnwc.cellnextelecom.net/mundial18/mundial/app/v1.0.0/index.html";
  76. }
  77. console.log("green action"); }},
  78. { button : VK_YELLOW, title : "Restart Current Programme", action : function(){
  79. console.log("yellow action");
  80. if( startOverAllowed ){
  81. launchStartOver();
  82. }
  83. }},
  84. { button: VK_BLUE, title : "TDT Play (es)", action : function(){
  85. console.log("blue action");
  86. launchTDTplay( {lang : "es"} );
  87. }},
  88. { title : "TDT Play (en help)", action : function(){
  89. console.log("menu action");
  90. //launchTDTplay( {lang : "es", section : "help"} );
  91. }},
  92. {
  93. button : VK_RED, action : function(){
  94. console.log("red action");
  95. if( debugScreenOn ){
  96. activateDebug(false);
  97. }
  98. else{
  99. activateDebug(true);
  100. }
  101. // currently not in use
  102. //launchMenu();
  103. }
  104. }];
  105.  
  106. function buttonAction( button ){
  107. var entry = null;
  108. $.each( menu , function(i, item){
  109. if( item.button == button ){
  110. entry = item;
  111. return false;
  112. }
  113. });
  114. return entry;
  115. }
  116.  
  117.  
  118.  
  119. function launchMenu(){
  120. location.href = "menu.php?ch=" + broadcastChannel;
  121. }
  122.  
  123. jQuery(document).ready(function(){
  124.  
  125.  
  126. try {
  127. if( typeof( initHbbTv ) == "function" ){
  128. initHbbTv();
  129. console.log("initHbbTv() succeed");
  130. }
  131. } catch (e) {
  132. console.error(e.message);
  133. }
  134.  
  135. initApp();
  136. registerKeyListener();
  137.  
  138. registerKeys( (development? 1 : 0) ); // if development register also numbers
  139.  
  140. // for non certified devives, no actions
  141. if( certified ){
  142. if( launcherActive){
  143. showHook();
  144. }
  145. // for certified devices on mediaset channels enable WC app
  146. if( !launcherActive && analytics == "mediaset" ){
  147. setTimeout( function(){
  148. $("#mundial").css("display", "block");
  149. showWChook();
  150. }, 500);
  151. }
  152. }
  153.  
  154. showApplication();
  155.  
  156. });
  157.  
  158.  
  159. function showWChook(){
  160. $("#mundial").css("display", "block");
  161. $("#mundial").addClass("fadein").removeClass("fadeout");
  162. setTimeout( function(){
  163. $("#mundial").removeClass("fadein").addClass("fadeout");
  164. }, 5000);
  165.  
  166. }
  167.  
  168. function showHook(){
  169. $(".ui_wrapper").css("display", "block");
  170. showButton("blue");
  171.  
  172. // WC app for mediaset channels
  173. if( analytics == "mediaset" ){
  174. showButton("green");
  175. }
  176.  
  177. getNowrunning( broadcastChannel, function(){
  178. item = getNowrunningAsset( broadcastChannel );
  179. channelNumber = item.number;
  180. console.log( item, item.startOver );
  181. if( item.startOver && fsatPrivacyPolicy ){
  182. showButton("yellow");
  183. startOverAllowed = true;
  184. console.log("Press Yellow to restart programme " + item.title);
  185. }
  186. else{
  187. startOverAllowed = false;
  188. //showInfo("Now running: " + item.title + ". (no start over available)");
  189. }
  190. } );
  191. }
  192.  
  193.  
  194. function initApp() {
  195. try {
  196. app = document.getElementById('appmgr').getOwnerApplication(document);
  197. } catch (e) {
  198. // ignore
  199. }
  200. }
  201.  
  202. function showApplication() {
  203. try {
  204. app.show();
  205. app.activate();
  206. } catch (e) {
  207. // ignore
  208. }
  209. }
  210.  
  211. var buttonSequence = [];
  212. var buttonSequenceCode = [ VK_BLUE, VK_YELLOW, VK_BLUE, VK_YELLOW ];
  213. var launcherActive = true;
  214.  
  215. function onKey(keyCode) {
  216. console.log("onkey", uivisible);
  217.  
  218. if( dialog.open ){
  219. navigateDialog( keyCode );
  220. return;
  221. }
  222.  
  223. if( (analytics == "mediaset" && keyCode == VK_GREEN) ){
  224. var entry = buttonAction( keyCode );
  225. console.log( typeof( entry.action ) );
  226. if( entry && typeof( entry.action ) == "function" ){
  227. entry.action();
  228. }
  229. return;
  230. }
  231.  
  232. // TODO: remove when application is allowed for all
  233. if( !launcherActive ){
  234.  
  235. buttonSequence.push( keyCode );
  236.  
  237. if( buttonSequence.length > 4 ){
  238. buttonSequence.shift();
  239. }
  240.  
  241. if( buttonSequenceCode.toString() == buttonSequence.toString() ){
  242. launcherActive = true;
  243. showHook();
  244. }
  245.  
  246. return;
  247. }
  248.  
  249. switch (keyCode) {
  250. case VK_BACK:
  251. showButtons( false );
  252. break;
  253. case VK_RED:
  254. case VK_BLUE:
  255. case VK_GREEN:
  256. case VK_YELLOW:
  257. console.log("a color button pressed ", keyCode);
  258.  
  259. // only blue button is active without fsatPrivacyPolicy;
  260. if( !fsatPrivacyPolicy && keyCode != VK_BLUE){
  261. console.log( "No privacy policy agreed");
  262. break;
  263. }
  264.  
  265. var entry = buttonAction( keyCode );
  266. console.log( typeof( entry.action ) );
  267. if( entry && typeof( entry.action ) == "function" ){
  268. entry.action();
  269. }
  270. break;
  271. case VK_ENTER:
  272. break;
  273. case VK_DOWN:
  274. break;
  275. case VK_UP:
  276. break;
  277. case VK_RIGHT:
  278. if( development ){
  279. activateDebug(1);
  280. }
  281. break;
  282. case VK_LEFT:
  283. if( development ){
  284. activateDebug(0);
  285. }
  286. break;
  287. case VK_1:
  288. showButtons( true, 99999999 );
  289. break;
  290. case VK_2:
  291. showButtons( false );
  292. break;
  293. case VK_3:
  294. showButtons( true, 5000 );
  295. break;
  296. case VK_4:
  297. showButton( "blue", true, 5000 );
  298. break;
  299. case VK_5:
  300. showButton( "yellow", true, 5000 );
  301. break;
  302. case VK_6:
  303. showButton( "red", true, 5000 );
  304. break;
  305. }
  306. }
  307.  
  308. function showButtons( show, timeout ) {
  309. $.each( $(".row"), function(i, button){
  310. clearTimeout( timeouts[ button.id ] );
  311. showButton( button.id, show, timeout );
  312. } )
  313. }
  314.  
  315. var timeouts = {};
  316. function showButton( color, show, timeout ) {
  317. if( typeof( show ) == "undefined" || show == true ){
  318. $("#" + color).addClass("fadein").removeClass("fadeout");;
  319. if( typeof( timeout ) == "undefined" ){
  320. timeout = 5000;
  321. }
  322. timeouts[ color ] = setTimeout( function(){ showButton( color, false); }, timeout);
  323. // TODO: show menu bar also when button is displayed
  324. }
  325. else{
  326. $("#" + color).removeClass("fadein").addClass("fadeout");;
  327. clearTimeout( timeouts[ color ] );
  328. delete timeouts[color];
  329. }
  330.  
  331. var hidden = ( Object.keys( timeouts ).length == 0);
  332.  
  333. if( hidden ){
  334. // not visible buttons
  335. // NOTE: no need to remove fadein
  336. //$("#colorbuttons").removeClass("fadein").addClass("fadeout");
  337. $("#colorbuttons").addClass("fadeout");
  338. $(".logo_container").addClass("fadeout");
  339. }
  340. else{
  341. // one or more visible buttons
  342. $("#colorbuttons").addClass("fadein").removeClass("fadeout");
  343. //$(".logo_container").addClass("simplefadein").removeClass("fadeout");
  344. $(".logo_container").addClass("fadein").removeClass("fadeout");
  345. }
  346.  
  347. if( hidden && analytics == "atresmedia" ){
  348. if( Object.keys( timeouts ).length == 0){
  349. SMARTNS.showSC( console.log );
  350. }
  351. else{
  352. SMARTNS.hideSC( console.log );
  353. }
  354. }
  355. }
  356.  
  357. function hideButtons() {
  358. document.getElementById("master").style.opacity = "0";
  359. uivisible = false;
  360. $("#blue, #green, #red, #yellow").hide();
  361. }
  362.  
  363. function launchStartOver() {
  364. if( startOverAllowed ){
  365. window.location = "../TDTplayer/index.php?ch="+channelID;
  366. }
  367. else{
  368. //showInfo("Current programme "+ item.title +" is not available for Start Over");
  369. }
  370. }
  371.  
  372. function launchTDTplay( overrides ) {
  373.  
  374. params = {
  375. channelID : channelID,
  376. section : "1lg",
  377. ch : channelID,
  378. timestamp : ntpTime, // mandatory
  379. boxID : idCookie, // mandatory
  380. sessionID : idSession, // mandatory
  381. };
  382. if( overrides ){
  383. $.each( overrides, function(key, value){
  384. params[ key ] = value; // override defaults
  385. } );
  386. }
  387.  
  388. //var url = "http://static.cnx.metaphor-platform.com/app/A/main.html" + Object.keys(params).reduce( function(a,b){ return a + b +"="+ params[b] + "&";}, "?" );
  389. var url = "http://gcpstatic.lovestv.es/app/A/main.html" + Object.keys(params).reduce( function(a,b){ return a + b +"="+ params[b] + "&";}, "?" );
  390.  
  391. //showInfo("Launch TDTplay: " + url);
  392.  
  393. //TODO: Send analytics to endpoint
  394. // mandatory for analytcis: ‘idChannel’, ‘idCookie’, ‘idSession’ and ‘page’
  395.  
  396.  
  397. sendTDTanalytics( {"tvID":idCookie,"sID":idSession,"ssID":null,"ts":ntpTime,"env":"dtt","srvID": serviceID ,"age":10,"pos":1} );
  398.  
  399.  
  400.  
  401. window.location.href = url;
  402. }
  403.  
  404.  
  405.  
  406. function sendTDTanalytics( params ){
  407. var user = "cellnex";
  408. var pass = "Xsw21q@Z";
  409. var auth = "Basic " + btoa(user + ":" + pass);
  410. console.log( auth, JSON.stringify( params ) );
  411. $.ajax({
  412. type: "POST",
  413. data : JSON.stringify( params ),
  414. crossDomain : true,
  415. contentType: "json",
  416. beforeSend: function (xhr) {
  417. xhr.withCredentials = true;
  418. xhr.setRequestHeader( "authorization", auth );
  419. },
  420. //url : "http://hbbtvandraw-pro.eu-west-1.elasticbeanstalk.com/events",
  421. url : "http://api-events.lovestv.es/events",
  422. success : function(response){
  423. console.log(response);
  424. showDialog("Succes: Sent data: " + query, "Response: " + response, ["OK"]);
  425. },
  426. fail : function(response){
  427. console.log(response);
  428. showDialog("Error: Sent data: " + query, "Response: " + response, ["OK"]);
  429. },
  430. alwasy : function(response){
  431. console.log("sending analytics");
  432. console.log(response);
  433. }
  434. });
  435. }
  436.  
  437.  
  438.  
  439. ]]>
  440. </script>
  441.  
  442.  
  443. </head>
  444. <body>
  445. <div style="visibility:hidden;position: absolute; left: 0px; top: 0px; width: 0px; height: 0px;">
  446. <object id="appmgr" type="application/oipfApplicationManager"></object>
  447. <object id="oipfcfg" type="application/oipfConfiguration"></object>
  448. </div>
  449. <div id="info" class="hide"></div>
  450.  
  451. <object id="video" type="video/broadcast"></object>
  452.  
  453. <div id="ui_wrapper" class="ui_wrapper ch_" style="display:none;">
  454. <div id="colorbuttons" class="blue fadein fadeout">
  455. <div class="row" id="blue"><div class="label">Pulsa</div><div class="button"></div></div>
  456. <div class="row" id="yellow"><div class="label"><small>Inicio</small> Pulsa</div><div class="button"></div></div>
  457. <div class="row" id="green"><div class="label">Ver MUNDIAL</div><div class="button"></div></div>
  458. <div class="row" id="red"><div class="label">Broadcaster App</div><div class="button"></div></div>
  459. </div>
  460. <div class="logo_container fadein fadeout">
  461. <div class="logo"></div>
  462. </div>
  463. </div>
  464. <div class="hide" id="loading"></div>
  465.  
  466. <div id="mundial" class="fadeout" style="display:none;">
  467. <img src="images/icon_mundial.png" />
  468. </div>
  469.  
  470. </body>
  471. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement