var second_to_check = 10; var minute_to_stats = 1; // questo tempo corrisponde alla granularità delle statistiche del canale var minute_to_guida = 5; var n=0; site_root = "http://embed.glomera.it/";//var site_root = "http://embed-dev.glomera.it/"; //var site_root = "http://embed.glomera.it/"; // <<<<<<<<<<<<< MESSA IN PRODUZIONE var last_id_pal; var last_type; var idCanale; var struct; // var settate dal parametro s var label_infocont; var label_player; var label_bottom; var label_infocontvert; var label_ib; var label_commento; var label_h_player; var label_h_infocont; var label_h_guidacan; // var settate dal tipo di contratto var label_banner; var label_vista; var is_vod; var is_pal; var now_is_pal = false; var num_top_file_to_show = 10; var id_cont_vod = ''; var vod_da_esterno = false; var primo = 0; var except = "DEFAULT"; var viral = ""; // ========================================================== // Chiamata principale, da iframe, crea la struttura principale // da generate_code.php e poi richiama mostra_vista() // ========================================================== function embed(s, c, w) { // if(c==746){ return;} // canale hot... bloccato idCanale = c; struct = s; // ELEMENTI visualizzabili label_infocont = false; label_player = false; label_bottom = false; label_banner = false; label_vista = false; label_infocontvert = false; label_ib = false; label_commento = false; label_h_player = false; label_h_infocont = false; label_h_guidacan = false; switch(s) { // LAY OUT verticali case 0: label_infocont = true; label_player = true; break; case 1: label_infocont = true; label_player = true; label_bottom = true; break; case 2: label_player = true; label_infocontvert = true; label_ib = true; break; case 3: label_player = true; label_bottom = true; label_infocontvert = true; label_ib = true; break; case 4: label_player = true; label_bottom = true; label_infocontvert = true; label_ib = true; label_commento = true; break; case 8: label_h_player = true; label_h_infocont = true; label_h_guidacan = true; force_vod = true; break; case 9: label_h_player = true; label_h_infocont = true; label_h_guidacan = true; break; // case 9: // label_player = true; // label_infocont = true; // label_bottom = true; // label_guidacan = true; // break; // singoli elementi case 10: label_ib = true; break; case 11: label_bottom = true; break; case 12: label_infocont = true; break; case 13: label_infocontvert = true; break; case 14: label_commento = true; break; case 15: label_player = true; break; default: label_player = true; label_bottom = true; label_infocontvert = true; label_ib = true; label_commento = true; break; } // ATTIVAZIONE ECCEZIONI switch (idCanale) { case 290: // VIA DEL GUSTO if (s == 9) { except = "290_HORIZONTAL_PAL"; } if (s == 8) { except = "290_HORIZONTAL_VOD"; } if (s == 15) { except = "290_LITTLE_PLAYER"; } break; case 565: // GOLF ITALIANO if (s == 9) { except = "565_HORIZONTAL"; } if (s == 8) { except = "565_HORIZONTAL_VOD"; } break; case 894: // RTS WebTV if (s == 8) { except = "894_HORIZONTAL_VOD"; now_is_pal = false; label_banner = true; label_infocont = true; } break; default: except = "DEFAULT"; break; } // attivazione elementi da contratto: getURL = site_root + "srv/get_bitmask_contratto.php?c=" + idCanale; new Ajax.Request(getURL, { method: 'GET', onSuccess: function(transport) { // Leggo tipo di contratto var arr_contratto = transport.responseText.split("-"); if(arr_contratto[0]==1){ is_pal = true; } if(arr_contratto[1]==1){ is_vod = true; } if(arr_contratto[2]==1 && label_player){ label_banner = true; } /* Aggiunta per vod chiamato da esterno se w contiene .flv forzo il fatto di fare vedere l'ondemand */ if(w>1) { vod_da_esterno = true; is_pal = false; id_cont_vod = w; if (except <= 0) { s = 15; } } // creo struttura principale: getURL = site_root + "generate_code.php?c_struct=" + idCanale + "&s=" + s + "&n=" + n++ + "&exc=" + except; new Ajax.Request(getURL, { method: 'GET', onSuccess: function(transport) { $('embedGlomVideo').update(transport.responseText); // chiamo MOSTRA_VISTA mostra_vista(); } }); // end inner Ajax.Request } // end OnSuccess }); // end Ajax.Request } // end functiont Embed(); // ========================================================== // chiama i vari pezzi da generate_code e li mette nei DIV giusti // ========================================================== function mostra_vista() { last_type = "flv"; last_id_pal = -1; primo = 1; // controllo palinsesto/ondemand if(now_is_pal && is_vod){ now_is_pal = false; }else{ if(is_pal){ now_is_pal = true; }else{ now_is_pal = false; } } // VISTA if(is_pal && is_vod && (struct==4 || struct==3 || struct==1 || struct==8 || struct==9)){ set_vista(); } // ----------------------------- // Se ora siamo in palinsesto if(now_is_pal) { // PLAYER if(label_player) { set_player(); // update_stats(); update_pal_iframe(); } if (label_h_player) { set_hplayer(); } if(label_bottom) { update_bottom("bottom_pal"); } auto_check_idpal(); } // Se ora siamo in VOD else { // VOD CLASSICO: if(!vod_da_esterno) { if (except=="894_HORIZONTAL_VOD") { if (!id_cont_vod) { start_first_id_video_to_play(); } else { runPlayer(id_cont_vod); } update_bottom_2("bottom_vod_horiz", "hguidac"); } else { if(label_player) { start_first_id_video_to_play(); } update_bottom("bottom_vod"); } } // QUA E' UNA CHIAMATA VOD DA ESTERNO else { if (except=="565_HORIZONTAL_VOD") { if (!id_cont_vod) { start_first_id_video_to_play(); } else { runPlayer(id_cont_vod); } update_bottom_2("bottom_vod_horiz", "hguidac"); } else { var getUrl = site_root + "srv/verify_cont.php?c="+idCanale+"&nf="+id_cont_vod; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { // Controllo se id_canale OK if(transport.responseText==1) { runPlayer(id_cont_vod); } else { alert("Spiacente, non puoi visualizzare questo video!"); } } }); } } // end if !vod_da_esterno update_vod_iframe(); } // ALTRI PEZZI if(label_h_infocont && except != "565_HORIZONTAL_VOD") { set_hcontent(); } if (label_h_guidacan) { if (except == "565_HORIZONTAL_VOD") { set_hguida_vod(); } else { set_hguida(); } } if(label_commento){ update_pezzo("commento"); } if(label_infocont){ update_pezzo("infocont"); } if(label_infocontvert){ update_pezzo("infocontvert"); } if(label_ib){ update_pezzo("ib"); } // BANNER if(label_banner) { set_banner(); } } function update_pal_iframe(){ getUrl = site_root + "generate_code.php?c_pal_iframe=" + idCanale + "&m=" + minute_to_stats + "&uri=" + log_referer +"&n=" + n++ + "&exc=" + except; new Ajax.Updater('pal_stats', getUrl); if(primo==1){ primo = 0; setTimeout('update_pal_iframe()', 5000); }else{ setTimeout('update_pal_iframe()', minute_to_stats*60*1000); } } function update_vod_iframe(){ getUrl = site_root + "generate_code.php?c_vod_iframe=" + idCanale + "&id_cont=" + id_cont_vod + "&m=" + minute_to_stats + "&uri=" + log_referer +"&n=" + n++ + "&exc=" + except; new Ajax.Updater('vod_stats', getUrl); if(primo==1){ primo = 0; setTimeout('update_vod_iframe()', 5000); }else{ setTimeout('update_vod_iframe()', minute_to_stats*60*1000); } } function set_player(){ getUrl = site_root + "generate_code.php?c_cont=" + idCanale + "&p=player&n=" + n++ + "&exc=" + except; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('player').update(transport.responseText); } }); } function set_hplayer(){ getUrl = site_root + "generate_code.php?c_cont=" + idCanale + "&p=player_horiz&n=" + n++ + "&exc=" + except; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('hplayer').update(transport.responseText); } }); } function set_hcontent(){ getURL = site_root + "generate_code.php?c_cont=" + idCanale + "&p=infocont_horiz&n=" + n++ + "&exc=" + except + "&id_cont=" + id_cont_vod; if (viral != "") { getURL = getURL + "&viral=" + viral; } new Ajax.Request(getURL, { method: 'GET', onSuccess: function(transport) { $('hinfoc').update(transport.responseText); } }); } function set_hguida(){ getUrl = site_root + "generate_code.php?c_cont=" + idCanale + "&p=bottom_pal_horiz&n=" + n++ + "&exc=" + except; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('hguidac').update(transport.responseText); } }); } function set_hguida_vod(){ getUrl = site_root + "generate_code.php?c_cont=" + idCanale + "&p=bottom_vod_horiz&n=" + n++ + "&exc=" + except; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('hguidac').update(transport.responseText); } }); } // questo è semplice, non faccio generare nulla a generate_code, tanto è codice statico. function set_banner() { if(idCanale==891 || idCanale==935){ $('banner').update('
'); }else{ $('banner').update(''); } } // ========================================================== // Imposta la visualizzazione del tab pali/vod su uno dei due // ========================================================== function set_vista () { // Imposta su VOD if(!now_is_pal) { getUrl = site_root + "generate_code.php?c_cont=" + idCanale + "&p=vista_vod&n=" + n++ + "&exc=" + except; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('vista').update(transport.responseText); } } ); } // Imposta su PALINSESTO else { getUrl = site_root + "generate_code.php?c_cont=" + idCanale + "&p=vista_pali&n=" + n++ + "&exc=" + except; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('vista').update(transport.responseText); } } ); } } // end set_vista function auto_check_idpal() { if(now_is_pal) { url = site_root + "generate_code.php?c_idpal=" + idCanale + "&n=" + n++ + "&exc=" + except; new Ajax.Request(url, { method: 'GET', onSuccess: function(transport) { var dati = transport.responseText.split("-"); var current_id_pal = dati[0]; if(dati[1]){ var current_type = dati[1].substr(0, 3); } if(current_id_pal != last_id_pal){ if(last_id_pal == -1 || last_type != current_type) { if(label_player){ set_player(); } if (label_h_player){ set_hplayer(); } } if(label_infocont){ update_pezzo("infocont"); } if(label_infocontvert){ update_pezzo("infocontvert"); } if(label_bottom){ update_bottom("bottom_pal"); } if(label_ib){ update_pezzo("ib"); } if (label_h_infocont){ update_pezzo_2("infocont_horiz", "hinfoc"); } if (label_h_guidacan){ update_pezzo_2("bottom_pal_horiz", "hguidac" ); } last_id_pal = current_id_pal; last_type = current_type; } setTimeout('auto_check_idpal()', second_to_check*1000); } }); } } function update_pezzo(pezzo){ geturl = site_root + "generate_code.php?c_cont=" + idCanale + "&p=" + pezzo + "&n=" + n++ + "&exc=" + except; new Ajax.Request(geturl, { method: 'GET', onSuccess: function(transport) { $(pezzo).update(transport.responseText); } }); } function update_pezzo_2 (pezzo, div) { geturl = site_root + "generate_code.php?c_cont=" + idCanale + "&p=" + pezzo + "&n=" + n++ + "&exc=" + except; new Ajax.Request(geturl, { method: 'GET', onSuccess: function(transport) { $(div).update(transport.responseText); } }); } function update_bottom(pezzo){ url = site_root + "generate_code.php?c_cont=" + idCanale + "&p=" + pezzo + "&n=" + n++ + "&exc=" + except; new Ajax.Request(url, { method: 'GET', onSuccess: function(transport) { if(now_is_pal && pezzo == "bottom_pal"){ $("bottom").update(transport.responseText); setTimeout('update_bottom("bottom_pal")', minute_to_guida*60*1000); }else if(!now_is_pal && pezzo == "bottom_vod"){ $("bottom").update(transport.responseText); fillCategorie(idCanale); } } }); } function update_bottom_2(pezzo, div){ url = site_root + "generate_code.php?c_cont=" + idCanale + "&p=" + pezzo + "&n=" + n++ + "&exc=" + except; new Ajax.Request(url, { method: 'GET', onSuccess: function(transport) { if(now_is_pal){ $(div).update(transport.responseText); setTimeout('update_bottom_2("bottom_pal_horiz", "hguidac")', minute_to_guida*60*1000); }else{ $(div).update(transport.responseText); fillCategorie(idCanale); } } }); } function update_guida(){ update_pezzo("guida"); setTimeout('update_guida("' + idCanale + '")', minute_to_guida*60*1000); } function asyncEmbVote(tipo, addr, userID, c_id, voto){ if(userID=='') userID='0'; if(tipo=="channel") tipoID="id_canale"; else if(tipo=="content") tipoID="id_contenuto"; var getUrl = site_root+"srv/forIFrameVote.php?id_account="+userID+"&"+tipoID+"="+c_id+"&voto="+voto+"&n="+n++; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { var arr = transport.responseText.split('-'); if(arr[0]=='x'){ alert(arr[1]); }else{ $('media_voto_contenuto').setStyle({width: arr[0]+'%'}); $('tot_voti_contenuto').update(' ' + arr[1] + ' voti'); } } }); } function send_comment(idCan, addr) { var comm = escape(document.getElementById("comm").value); var autor = escape(document.getElementById("autore").value); if (comm=='') { alert("Impossibile inviare un commento vuoto!"); return false; } var getUrl = site_root+"srv/sendIFrameCommento.php?id_canale="+idCan+"&commento="+comm+"&autore="+autor; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('risposta').update(transport.responseText); } }); } /******************************************************* * FUNZIONI PER L'EMBED DELL'ONDEMAND * ********************************************************/ function fillCategorie(idCan){ var getUrl = site_root+"ondemand/srv/get_categories.php?id_canale="+idCan; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('ricerca_cat').update(transport.responseText); getTopContenuti(idCan, "top_rated", num_top_file_to_show); } }); } function getTopContenuti(idCan, param, num){ document.getElementById("category_list_0").selected = true; var getUrl = site_root + "ondemand/srv/get_contenuti.php?id_canale="+idCan+"&by="+param+"&num="+num; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('contenuti').update(transport.responseText); } }); } function getContenuti(idCat, idCan){ if(idCat == -1){ document.getElementById("category_list_0").selected = true; var getUrl = site_root + "ondemand/srv/get_contenuti.php?id_canale="+idCan+"&by=tag&chiave="+document.getElementById("tag_input").value; }else{ document.getElementById("category_list_"+idCat).selected = true; var getUrl = site_root + "ondemand/srv/get_contenuti.php?id_canale="+idCan+"&by=cat&idCat="+idCat; } new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('contenuti').update(transport.responseText); } }); } function getTag(tag, idCan){ var getUrl = site_root + "ondemand/srv/get_contenuti.php?id_canale="+idCan+"&by=tag&chiave="+tag; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('contenuti').update(transport.responseText); } }); } function start_first_id_video_to_play(){ var getUrl = site_root + "srv/get_first_id_video_to_play.php?c="+idCanale; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { // id_cont_vod = transport.responseText; runPlayer(transport.responseText); } }); } function runPlayer(idCont) { if(label_infocont){ get_info_cont(idCont); } if(label_infocontvert){ get_info_cont_vert(idCont); } if(label_ib){ get_cont_ib(idCont); } /* CODICE PER CHIAMATA DIRETTA AL FILE */ var getUrl = site_root + "ondemand/srv/get_file_name_by_id.php?id_cont="+idCont; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { filePath = transport.responseText; if(idCanale==176) { var codice = ''; } else { // LEGGO DIMENSIONI PERSONALIZZATE DEL PLAYER player_dims = new Array(); player_dims["DEFAULT-width"] = 480; player_dims["DEFAULT-height"] = 360; player_dims["290_LITTLE_PLAYER-width"] = 193; player_dims["290_LITTLE_PLAYER-height"] = 143; player_dims["290_HORIZONTAL-width"] = 480; player_dims["290_HORIZONTAL-height"] = 360; player_dims["290_HORIZONTAL_VOD-width"] = 480; player_dims["290_HORIZONTAL_VOD-height"] = 360; player_dims["565_HORIZONTAL_VOD-width"] = 480; player_dims["565_HORIZONTAL_VOD-height"] = 360; player_dims["565_HORIZONTAL-width"] = 480; player_dims["565_HORIZONTAL-height"] = 360; player_dims["894_HORIZONTAL_VOD-width"] = 480; player_dims["894_HORIZONTAL_VOD-height"] = 360; var xw = except+"-width"; var xh = except+"-height"; var codice = ''; codice = codice + ''; } id_cont_vod = idCont; if(label_player){ $("player").update(codice); getUrl = site_root + "generate_code.php?c_vod_iframe=" + idCanale + "&id_cont=" + id_cont_vod + "&m=" + minute_to_stats + "&uri=" + log_referer + "&exc=" + except; new Ajax.Updater('vod_stats', getUrl); } if(label_h_player){ $("hplayer").update(codice); getUrl = site_root + "generate_code.php?c_vod_iframe=" + idCanale + "&id_cont=" + id_cont_vod + "&m=" + minute_to_stats + "&uri=" + log_referer + "&exc=" + except; new Ajax.Updater('vod_stats', getUrl); } } }); /* CODICE PER FILE PASSATO VIA PHP */ //var codice = ''; //$("player").update(codice); } function get_info_cont(idCont){ getUrl = site_root + "generate_code.php?c_cont="+idCanale+"&p=infocont&id_cont=" + idCont; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('infocont').update(transport.responseText); } }); } function get_info_cont_vert(idCont){ getUrl = site_root + "generate_code.php?c_cont="+idCanale+"&p=infocontvert&id_cont=" + idCont; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('infocontvert').update(transport.responseText); } }); } function get_cont_ib(idCont){ getUrl = site_root + "generate_code.php?c_cont="+idCanale+"&p=ib&id_cont=" + idCont; new Ajax.Request(getUrl, { method: 'GET', onSuccess: function(transport) { $('ib').update(transport.responseText); } }); } function update_ib_stats(statsUrl, num_link, idIB, idChan){ $('ib_stats').update(''); } function set_viral(targ){ viral = targ; }