// -------------------------------------------------------------------------------------- // TOOLS.JS - Collezione di funzioni JavaScript di utilita' // Lucio Travagnin (lucio.travagnin@guest.matrix.it) // -------------------------------------------------------------------------------------- // Patch per IE - Crea la funzione vuota console.log() se non esiste if (window.console == undefined) { window.console = {log:function(){}}; } // Alcune variabili globali var videoBaseUrl = '/show.php'; var imageServer = 'http://images.alice.it'; // ---------------------------------------------------------------------------- // encodeArtistItem () // ---------------------------------------------------------------------------- function encodeArtistItem (item) { var encodedItem; encodedItem = item.toLowerCase(); return encodedItem; } // ---------------------------------------------------------------------------- // getParameter () // Recupera un parametro dalla Query String // ---------------------------------------------------------------------------- function getParameter (url,parameterName) { var url,pos,parameterValue,i,index; pos = url.indexOf('#'); if (pos!=-1) { url = url.substring(0,pos); } pos = url.indexOf('?'); if (pos==-1) { return null; } queryString = url.substring(pos+1); parameters = queryString.split(/&(?!amp;)/); for (i=0; ip.nomeartista:first>a').html(ArtistsHP.allArtists[theRandomArray[0]].d); $('div.boxgenere:eq('+index+')>p.nomeartista:first>a').attr('href',url); $('div.boxgenere:eq('+index+')>p.foto>a').attr('href',url); $('div.boxgenere:eq('+index+')>p.foto>a>img').attr('src', imageServer + '/n_canali/musica/artisti/' + ArtistsHP.allArtists[theRandomArray[0]].p); var altText = ArtistsHP.allArtists[theRandomArray[0]].d; altText = altText.replace(/"/g,''); $('div.boxgenere:eq('+index+')>p.foto>a>img').attr('alt',altText); $('div.boxgenere:eq('+index+')>p.foto>a>img').attr('title',altText); } function writeArtists(boxIndex, artistIndex, theRandomArray){ $('div.boxgenere:eq('+boxIndex+')>ul>li:eq('+(artistIndex-1)+')>a').html(ArtistsHP.allArtists[theRandomArray[artistIndex]].d); $('div.boxgenere:eq('+boxIndex+')>ul>li:eq('+(artistIndex-1)+')>a').attr('href', '/'+ArtistsHP.allArtists[theRandomArray[artistIndex]].c+'/'+ArtistsHP.allArtists[theRandomArray[artistIndex]].p.replace(/\.jpg/, '/index.html')); } if (theList) {ArtistsHP.allArtists = theList;} var output = ''; var randomRock = fillRandomArray('rock'); var randomPop = fillRandomArray('pop'); var randomSoul = fillRandomArray('soul-rhythm-and-blues'); var randomHiphop = fillRandomArray('hip-hop'); var randomWorld = fillRandomArray('world'); writeFirstArtist( 0, randomRock ); writeFirstArtist( 1, randomPop ); writeFirstArtist( 2, randomSoul ); writeFirstArtist( 3, randomHiphop ); writeFirstArtist( 4, randomWorld ); for (var i=1; i<=5; i++){ writeArtists(0, i, randomRock); writeArtists(1, i, randomPop); writeArtists(2, i, randomSoul); writeArtists(3, i, randomHiphop); writeArtists(4, i, randomWorld); } }, suggest: function (theEvent){ function getArtistUrl( index ){ return '/'+ArtistsHP.allArtists[index].c+'/'+ArtistsHP.allArtists[index].p.replace(/\.jpg/, '/index.html'); } $('#thesuggested').html(' '); $('#thesuggested').show(); console.log('0)' + $('#searchsuggest').get(0).value); console.log('0)' + $('#thesuggested').html()); console.log('0)' + theEvent.keyCode); if(theEvent && theEvent.keyCode && theEvent.keyCode==13 && ArtistsHP.suggestedUrls.length>0){ window.location.href = ArtistsHP.suggestedUrls[ArtistsHP.currentSuggested]; }else if(theEvent && theEvent.keyCode && theEvent.keyCode==38 && ArtistsHP.suggestedUrls.length>0){ ArtistsHP.currentSuggested--; if(ArtistsHP.currentSuggested<0){ ArtistsHP.currentSuggested=ArtistsHP.suggestedUrls.length-1 } }else if(theEvent && theEvent.keyCode && theEvent.keyCode==40 && ArtistsHP.suggestedUrls.length>0){ ArtistsHP.currentSuggested++; if(ArtistsHP.currentSuggested>=ArtistsHP.suggestedUrls.length){ ArtistsHP.currentSuggested=0 } }else{ ArtistsHP.currentSuggested=0; } var what = $('#searchsuggest').get(0).value; if(what.length>=2){ var toSuggest = ''; var count = 0; ArtistsHP.suggestedUrls = []; for (var i=0; i=5){ break; } if (c=='') { continue; } if ( s.substring(0,what.length) == what ){ toSuggest += '

' + s + '

'; ArtistsHP.suggestedUrls[ArtistsHP.suggestedUrls.length] = getArtistUrl(i); count++; continue; } if ( d.substring(0,what.length) == what ){ toSuggest += '

' + d + '

'; ArtistsHP.suggestedUrls[ArtistsHP.suggestedUrls.length] = getArtistUrl(i); count++; continue; } }catch(exc){ continue; } } if (count==0) { toSuggest += '

Nessun artista trovato

'; } $('#thesuggested').append(toSuggest + '

Chiudi

'); }else{ $('#thesuggested').append('

Inserisci almeno due caratteri

Chiudi

'); } $('#thesuggested').show(); if(ArtistsHP.suggestedUrls.length>0){ $('p.stampanome:eq('+ArtistsHP.currentSuggested+')').css( { backgroundColor: '#ccc', backgroundImage: 'url(../images/freccia_suggest.gif)', backgroundRepeat: 'no-repeat', backgroundPosition: '230px 5px'} ); console.log('3) ' + ArtistsHP.currentSuggested); } console.log('999)' + $('#searchsuggest').get(0).value); console.log('999)' + $('#thesuggested').html()); }, close: function(){ $('#thesuggested').hide(); } } var MyStrands = { carga: function (artistId, artistName, trackTitle, trackTime){ artistName = encodeURIComponent(artistName); trackTitle = encodeURIComponent(trackTitle); if (trackTime==undefined) { trackTime = '-1'; } var URL = 'http://tv.mymusic.virgilio.it/popup/artist/'+artistName+'#'+artistId+'|0|0|'+trackTime+'|'+trackTitle; window.open(URL, /*artistName*/'_blank', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=344,height=750'); }, cargaArtistVideo: function (videoId, artistName, trackTitle, trackTime){ artistName = encodeURIComponent(artistName); trackTitle = encodeURIComponent(trackTitle); if (trackTime==undefined) { trackTime = '-1'; } var URL = 'http://tv.mymusic.virgilio.it/popup/artist/'+artistName+'#0|'+videoId+'|3|'+trackTime+'|'+trackTitle; window.open(URL, /*artistName*/'_blank', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=344,height=750'); }, cargaQSVideo: function (videoId,queryString, trackTitle, trackTime){ queryString = encodeURIComponent(queryString); trackTitle = encodeURIComponent(trackTitle); if (trackTime==undefined) { trackTime = '-1'; } var URL = 'http://tv.mymusic.virgilio.it/popup/video/'+queryString+'#0|'+videoId+'|3|'+trackTime+'|'+trackTitle; window.open(URL, /*trackTitle*/'_blank', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=344,height=750'); }, cargaArtistChannel: function (artistName){ artistName = encodeURIComponent(artistName); var URL = 'http://tv.mymusic.virgilio.it/popup/artist/'+artistName; window.open(URL, /*artistName*/'_blank', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=344,height=750'); }, cargaUserChannel: function (alias){ alias = encodeURIComponent(alias); var URL = 'http://tv.mymusic.virgilio.it/popup/user/'+alias; window.open(URL, /*alias*/'_blank', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=344,height=750'); }, cargaGenreChannel: function (genre){ genre = encodeURIComponent(genre); var URL = 'http://tv.mymusic.virgilio.it/popup/genre/'+genre; window.open(URL, /*genre*/'_blank', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=344,height=750'); } } //alert(MyStrands) // -------------------------------------------------------------------------------------- // boxFiltriAggiungi (filtro,valore) // -------------------------------------------------------------------------------------- function boxFiltriAggiungi(filtro,valore) { var url; if (filtro=='genere') { if (location.href.match(/\/news\//)) { url = '/news/'+valore+'/index.html?'+getQueryString(location.href); } else { url = '/'+valore+'/index.html?'+getQueryString(location.href); } url = removeParameter(url,'offset'); console.log (url); location.href = url; } if (filtro=='tipo' || filtro=='fonte') { url = location.href; url = addParameter(url,filtro,valore); url = removeParameter(url,'offset'); console.log (url); location.href = url; } } // -------------------------------------------------------------------------------------- // boxFiltriRimuovi (filtro) // -------------------------------------------------------------------------------------- function boxFiltriRimuovi(filtro) { var url; if (filtro=='genere') { if (location.href.match(/\/news\//)) { url = '/news/index.html?'+getQueryString(location.href); } else { //url = '/ricerca/index.html?'+getQueryString(location.href); url = '/artisti/index.html'; } url = removeParameter(url,'offset'); console.log (url); location.href = url; } if (filtro=='tipo' || filtro=='fonte') { url = location.href; url = removeParameter(url,filtro); url = removeParameter(url,'offset'); console.log (url); location.href = url; } } // -------------------------------------------------------------------------------------- // pagingHide () // -------------------------------------------------------------------------------------- function pagingHide() { $(".paginazione").html(""); }