Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
HTML / CSS - problemino con API youtube
Forum - HTML / CSS - problemino con API youtube

Avatar
giocala88 (Normal User)
Expert


Messaggi: 248
Iscritto: 23/04/2008

Segnala al moderatore
Postato alle 17:16
Giovedì, 05/08/2010
Salve ragazzi vorrei cercare di capire delle cose su un frammento di codice trovato su internet. Allora ho scaricato ed assemblato un frammento di codice html che include dei video di youtube sul mio sito e fin qui tutto ok.
Ora, però, vorrei capire:
1. da dove li prende i risultati dei video che mi restituisce?
2. come posso importare il form di ricerca di youtube?
3. è possibile linkare i risultati verso una nuova pagina che non sia la visualizzazione del video restituito?
Grazie a tutti. :)

Codice sorgente - presumibilmente Delphi

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="it" dir="ltr" lang="it-IT">
  3. <head>
  4.                 <title>Esempio Youtube API</title>
  5.                 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6.                 <meta name="keywords" content="Youtube API, Google API, video, api" />
  7.                 <meta name="description" content="Esempio di integrazione delle Youtube API con PrettyPhoto" />
  8.                 <link rel="stylesheet" type="text/css" href="css/common.css"/>
  9.                 <link rel="stylesheet" type="text/css" href="css/prettyPhoto.css"/>
  10.  
  11.                 <script type="text/javascript">
  12.                 function getVideos(data) {
  13.                   var feed = data.feed;
  14.                   var entries = feed.entry || [];
  15.                   var html = [''];
  16.                   for (var i = 0; i < entries.length; i++) {
  17.                         var entry = entries[i];
  18.                         var title = entry.title.$t.substr(0, 35);
  19.                         var thumbnailUrl = entries[i].media$group.media$thumbnail[0].url;
  20.                         var videoUrl = entries[i].media$group.media$player[0].url;
  21.                         html.push('<div class="singleVideo"><a rel="prettyPhoto[flash]" href="',videoUrl,'" title="',title,'">',
  22.                                           '<img src="', thumbnailUrl, '"/>', '</a>','<a rel="prettyPhoto[flash]" href="',videoUrl,'" title="',title,'"><span>',title,'...</span></a></div>');
  23.                   }
  24.                   document.getElementById('videoContainer').innerHTML = html.join('');
  25.                 }
  26.                 </script>
  27.         </head>
  28.         <body>
  29.                 <div id="contenitore">
  30.                         <h1>Esempio di integrazione delle Youtube API con PrettyPhoto</h1>
  31.                         <div id="videoContainer">
  32.                         </div>
  33.                 </div>
  34.  
  35.         </body>
  36.         <script type="text/javascript" src="javascript/jquery.js"></script>
  37.         <script type="text/javascript" src="javascript/prettyPhoto.js"></script>
  38.         <script type="text/javascript">
  39.                 $(function() {
  40.                         $("a[rel^='prettyPhoto']").prettyPhoto({
  41.                         animationSpeed: 'normal',
  42.                         padding: 40,
  43.                         opacity: 0.35,
  44.                         showTitle: true,
  45.                         allowresize: true,
  46.                         counter_separator_label: ' di ',
  47.                         theme: 'light_square',
  48.                         callback: function(){}
  49.                         });
  50.                 });
  51.         </script>
  52.         <script type="text/javascript" src="http://gdata.youtube.com/feeds/users/GoogleDevelopers/uploads?alt=json-in-script&callback=getVideos"></script>
  53. </html>


PM Quote
Avatar
Mte90 (Member)
Guru


Messaggi: 1144
Iscritto: 25/03/2008

Segnala al moderatore
Postato alle 21:19
Giovedì, 05/08/2010
io lavorai con le vecchie api di youube per prendere i dati dei video via xml.
mi ricordo che sul sito di youtube è strapieno di esempi.
i dati dei video userà qualche api che comunicherà via json o ajax.

PM Quote
Avatar
giocala88 (Normal User)
Expert


Messaggi: 248
Iscritto: 23/04/2008

Segnala al moderatore
Postato alle 12:22
Venerdì, 06/08/2010
Allora, innanzitutto ringrazio per la risposta. guardando questo codice HTML

Codice sorgente - presumibilmente HTML / CSS

  1. <html>
  2. <head>
  3.   <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  4.   <title></title>
  5.  
  6.   <script src="http://www.google.com/uds/api?file=uds.js&v=1.0&key=internal-solution"
  7.     type="text/javascript"></script>
  8.  
  9.   <script src="gsvideosearch.js" type="text/javascript"></script>
  10.        
  11.   <link href="gsvideosearch.css" rel="stylesheet" type="text/css"/>
  12.   <style type="text/css">
  13.     body, table, p{
  14.       background-color: white;
  15.       font-family: Arial, sans-serif;
  16.       font-size: 13px;
  17.     }
  18.  
  19.     #videosc {
  20.       width : 600px;
  21.       margin-left: 10px;
  22.       padding: 4px;
  23.       border : 1px solid #f9f9f9;
  24.     }
  25.   </style>
  26.   <script type="text/javascript">
  27.     function OnLoad() {
  28.       // establish default tags
  29.       var defaultTags = [
  30.         { query : "" },
  31.         { query : "" },
  32.         { query : "" },
  33.         { query : "" }
  34.       ];
  35.  
  36.       new GSvideoSearchControl(
  37.         document.getElementById("videosc"),         // container
  38.         defaultTags,                                // default tag array
  39.         null,
  40.         null,
  41.         null
  42.         );
  43.     }
  44.     GSearch.setOnLoadCallback(OnLoad);
  45.   </script>
  46. </head>
  47. <body bgcolor='yellow'>
  48.   <div id="videosc">Loading...</div>
  49. </body>
  50. </html>



e tenendo conto di quest'altro codice .js

Codice sorgente - presumibilmente HTML / CSS

  1. /**
  2.  * Copyright (c) 2008 Google Inc.
  3.  *
  4.  * You are free to copy and use this sample.
  5.  * License can be found here: http://code.google.com/apis/ajaxsearch/faq/#license
  6. */
  7.  
  8. function GSvideoSearchControl(root, defaultTags,
  9.                    opt_loadTagsFunction, opt_saveTagsFunction, opt_options) {
  10.  
  11.   this.processArguments(root, defaultTags, opt_loadTagsFunction,
  12.                         opt_saveTagsFunction, opt_options);
  13.  
  14.   this.setGlobals();
  15.   this.bindToPage();
  16.   this.loadTags();
  17.   this.startSearchControl();
  18. }
  19.  
  20. GSvideoSearchControl.prototype.processArguments = function(root, defaultTags,
  21.                                                 opt_loadTagsFunction,
  22.                                                 opt_saveTagsFunction,
  23.                                                 opt_options) {
  24.   this.root = root;
  25.   this.defaultTags = defaultTags;
  26.   this.enableEditTags = false;
  27.  
  28.   if (opt_loadTagsFunction) {
  29.     this.loadCallback = opt_loadTagsFunction;
  30.   } else {
  31.     this.loadCallback = null;
  32.   }
  33.  
  34.   if (opt_saveTagsFunction) {
  35.     this.saveCallback = opt_saveTagsFunction;
  36.     this.enableEditTags = true;
  37.   } else {
  38.     this.saveCallback = null;
  39.   }
  40.  
  41.   // set defaults that are changable via options
  42.   this.resultSetSize = GSearch.SMALL_RESULTSET;
  43.   this.ssDelay = 350;
  44.   this.twoRowMode = false;
  45.   this.ST_ALL_DONE = GSearch.strings["im-done"];
  46.  
  47.   // process options if specified
  48.   if (opt_options) {
  49.  
  50.     // option.largetResultSet
  51.     if (opt_options.largeResultSet && opt_options.largeResultSet == true ) {
  52.       this.resultSetSize = GSearch.LARGE_RESULTSET;
  53.     } else {
  54.       this.resultSetSize = GSearch.SMALL_RESULTSET;
  55.     }
  56.  
  57.     // option.startupDelay
  58.     if (opt_options.startupDelay &&
  59.         (opt_options.startupDelay > 0 && opt_options.startupDelay <= 2000) ) {
  60.       this.ssDelay = opt_options.startupDelay;
  61.     }
  62.  
  63.     // option.twoRowMode
  64.     if (opt_options.twoRowMode && opt_options.twoRowMode == true ) {
  65.       this.twoRowMode = true;
  66.     }
  67.  
  68.     if (opt_options.string_allDone) {
  69.       this.ST_ALL_DONE = opt_options.string_allDone;
  70.     }
  71.   }
  72. }
  73.  
  74. GSvideoSearchControl.prototype.setGlobals = function() {
  75.   this.br_AgentContains_cache_ = {};
  76.  
  77.   // superstructure class
  78.   this.CLSS_MORE = "more_gsvsc";
  79.   this.CLSS_READBOX = "readBox_gsvsc";
  80.   this.CLSS_EDITBOX = "editBox_gsvsc";
  81.   this.CLSS_FOOTERBOX = "footerBox_gsvsc";
  82.   this.CLSS_CONTROLBOX = "controlBox_gsvsc";
  83.   this.CLSS_PLAYERBOX = "playerBox_gsvsc";
  84.   this.CLSS_TAGSTACKBOX = "tagStackBox_gsvsc";
  85.   this.CLSS_SEARCHFORM = "searchForm_gsvsc";
  86.   this.CLSS_RESULTSBOX = "results_gsvsc";
  87.   this.CLSS_TINYRESULTSBOX = "tiny-results_gsvsc";
  88.  
  89.   // global classes
  90.   // major app states
  91.   this.CL_READING = "app_gsvsc reading_gsvsc";
  92.   this.CL_SEARCHING = "app_gsvsc searching_gsvsc";
  93.   this.CL_EDITING = "app_gsvsc editing_gsvsc";
  94.   this.CL_PLAYING = "app_gsvsc playing_gsvsc";
  95.   this.CL_TAGCONTROL = "tag-control_gsvsc";
  96.   this.CL_ODD = "odd_gsvsc";
  97.   this.CL_EVEN = "even_gsvsc";
  98.  
  99.   // tag classes
  100.   this.CL_TAG = "tag_gsvsc";
  101.   this.CL_TAGSELECTED = " tag-selected_gsvsc";
  102.   this.CL_RTAG_PREFIX = "tag_gsvsc-";
  103.   this.CL_EDITTAG = "edit-tag_gsvsc";
  104.  
  105.   // search form components
  106.   this.CL_SFINPUT = "search-form-input_gsvsc";
  107.   this.CL_SFINPUTCELL = "search-form-input-cell_gsvsc";
  108.   this.CL_SFSEARCH = "search-form-search_gsvsc";
  109.   this.CL_SFSEARCHCELL = "search-form-search-cell_gsvsc";
  110.   this.CL_SFSAVE = "search-form-save_gsvsc";
  111.   this.CL_SFCOMPLETE = "searchForm_gsvsc search-form-complete_gsvsc";
  112.  
  113.   // edit form components
  114.   this.CL_EFINPUTBOX = "edit-form-input-box_gsvsc";
  115.   this.CL_EFINPUT = "edit-form-input_gsvsc";
  116.   this.CL_EFDELETE = "edit-form-delete_gsvsc";
  117.   this.CL_EFDELETE_OPERA = "edit-form-delete-opera_gsvsc";
  118.   this.CL_EFSUBMITBOX = "edit-form-submit-box_gsvsc";
  119.  
  120.   // results
  121.   this.CL_VIDEORESULT = "video-result_gsvsc";
  122.   this.CL_TINYVIDEORESULT = "tiny-video-result_gsvsc";
  123.   this.CL_VIDEORESULTTABLE = "video-result-table_gsvsc";
  124.   this.CL_VIDEORESULTCELL = "video-result-cell_gsvsc-";
  125.  
  126.   // player
  127.   this.CL_PLAYER = "player_gsvsc";
  128.   this.CL_TITLE = "title_gsvsc";
  129.  
  130.   // footer
  131.   this.CL_FOOTERLINK = "footer-link_gsvsc";
  132.   this.CL_FOOTEREDIT = "footer-edit_gsvsc";
  133.  
  134.   // non-settable strings, strings that
  135.   // are not modifiable via options
  136.   this.ST_SEARCH = GSearch.strings["search"];
  137.   this.ST_EDIT = GSearch.strings["edit-tags"];
  138.   this.ST_SAVESEARCH = GSearch.strings["tag-search"];
  139.   this.ST_QUERY = GSearch.strings["search"];
  140.   this.ST_LABEL = GSearch.strings["optional-label"];
  141.   this.ST_DELETE = GSearch.strings["delete"];
  142.   this.ST_DELETED = GSearch.strings["deleted"];
  143.   this.ST_SAVEBTN = GSearch.strings["save"];
  144.   this.ST_CANCELBTN = GSearch.strings["cancel"];
  145.   this.ST_MOREVIDEOS = GSearch.strings["upload-video"];
  146.  
  147.   this.tinyResultBoxHeight = 39;
  148.   this.resultBoxHeight = 77;
  149.   this.maxRandom = 2;
  150.   this.footerUrl = "http://www.youtube.com/my_videos_upload";
  151. }
  152.  
  153. GSvideoSearchControl.prototype.buildSuperStructure = function() {
  154.   this.app = this.createDiv(null, this.CL_READING);
  155.  
  156.   // first level children
  157.   this.more = this.createDiv(null, this.CLSS_MORE);
  158.   this.readBox = this.createDiv(null, this.CLSS_READBOX);
  159.   this.editBox = this.createDiv(null, this.CLSS_EDITBOX);
  160.   this.footerBox = this.createDiv(null, this.CLSS_FOOTERBOX);
  161.   this.app.appendChild(this.more);
  162.   this.app.appendChild(this.readBox);
  163.   this.app.appendChild(this.editBox);
  164.   this.app.appendChild(this.footerBox);
  165.  
  166.   // readBox children
  167.   this.controlBox = this.createDiv(null, this.CLSS_CONTROLBOX);
  168.   this.searchForm = this.createDiv(null, this.CLSS_SEARCHFORM);
  169.   this.results = this.createDiv(null, this.CLSS_RESULTSBOX);
  170.   this.tinyResults = this.createDiv(null, this.CLSS_TINYRESULTSBOX);
  171.   this.playerBox = this.createDiv(null, this.CLSS_PLAYERBOX);
  172.   this.tagStack = this.createDiv(null, this.CLSS_TAGSTACKBOX);
  173.   this.controlBox.appendChild(this.playerBox);
  174.   this.controlBox.appendChild(this.searchForm);
  175.   this.controlBox.appendChild(this.results);
  176.   this.controlBox.appendChild(this.tinyResults);
  177.   this.controlBox.appendChild(this.tagStack);
  178.   this.readBox.appendChild(this.controlBox);
  179.  
  180.   // footerBox children
  181.   this.footerLink = this.createLink(this.footerUrl, this.ST_MOREVIDEOS);
  182.  
  183.   if (this.enableEditTags) {
  184.     var table = this.createTable();
  185.     var row = this.createTableRow(table);
  186.     var editCell = this.createTableCell(row, this.CL_FOOTEREDIT);
  187.     var linkCell = this.createTableCell(row, this.CL_FOOTERLINK);
  188.  
  189.     var edit = this.createDiv(this.ST_EDIT, this.CL_EDITTAG);
  190.     edit.onclick = this.methodClosure(this, GSvideoSearchControl.prototype.startEditing, [true]);
  191.     editCell.appendChild(edit);
  192.  
  193.     // footer link
  194.     linkCell.appendChild(this.footerLink);
  195.     this.footerBox.appendChild(table);
  196.   } else {
  197.     this.footerBox.appendChild(this.footerLink);
  198.   }
  199. }
  200. GSvideoSearchControl.prototype.bindToPage = function() {
  201.   this.buildSuperStructure();
  202.   this.removeChildren(this.root);
  203.   this.root.appendChild(this.app);
  204.  
  205.   // bind up the search and edit controls
  206.   this.more.innerHTML = this.ST_SEARCH;
  207.   this.more.onclick = this.methodClosure(this, GSvideoSearchControl.prototype.twiddleMore, []);
  208.  
  209.   // build the search form
  210.   this.vsf = new GSearchForm(false, this.searchForm,
  211.                              {
  212.                                clickableBrandingUrl : "http://video.google.com"
  213.                              });
  214.   this.vsf.setOnSubmitCallback(this,GSvideoSearchControl.prototype.searchByString);
  215.  
  216.   if ( this.enableEditTags ) {
  217.     this.vsfSaveQuery = this.createDiv(this.ST_SAVESEARCH, this.CL_SFSAVE);
  218.     this.vsf.userDefinedCell.appendChild(this.vsfSaveQuery);
  219.     this.vsfSaveQuery.onclick = this.methodClosure(this, GSvideoSearchControl.prototype.addTag, []);
  220.   }
  221. }
  222.  
  223. GSvideoSearchControl.prototype.startSearchControl = function() {
  224.   this.vs = new GvideoSearch();
  225.   this.vs.setResultSetSize(this.resultSetSize);
  226.   this.vs.setSearchCompleteCallback(this, GSvideoSearchControl.prototype.searchComplete, [null]);
  227.   this.searchCounter = 0;
  228.   this.startupTimer = setTimeout(this.methodClosure(this, GSvideoSearchControl.prototype.firstSearch, [null]), this.ssDelay);
  229. }
  230.  
  231. GSvideoSearchControl.prototype.firstSearch = function() {
  232.   if (this.searchCounter == 0) {
  233.     this.doRandomSearch();
  234.   }
  235. }
  236.  
  237. GSvideoSearchControl.prototype.searchComplete = function() {
  238.   if ( this.vs.results && this.vs.results.length > 0) {
  239.     this.removeChildren(this.results);
  240.     this.removeChildren(this.tinyResults);
  241.     if (this.vsf.input.value != "") {
  242.       if ( this.enableEditTags ) {
  243.         this.cssSetClass(this.searchForm, this.CL_SFCOMPLETE);
  244.       }
  245.       if (this.currentItem) {
  246.         this.cssSetClass(this.currentItem.domNode, this.currentItem.savedClassName);
  247.         this.currentItem = null;
  248.       }
  249.     }
  250.  
  251.     var maxColumns = 2;
  252.     var tinyMaxColumns = 4;
  253.     if (this.getNodeWidth(this.results) > 350 || this.getNodeWidth(this.tinyResults) > 350 ) {
  254.       maxColumns = 3;
  255.       tinyMaxColumns = 6;
  256.     }
  257.     var table = this.createTable(this.CL_VIDEORESULTTABLE + " " + this.CL_VIDEORESULTTABLE + "-" + maxColumns);
  258.     table.setAttribute("align", "center");
  259.     var tinyTable = this.createTable(this.CL_VIDEORESULTTABLE + " " + this.CL_VIDEORESULTTABLE + "-" + tinyMaxColumns);
  260.     tinyTable.setAttribute("align", "center");
  261.  
  262.     var row = null;
  263.     var tinyRow = null;
  264.     var cellCounter = 0;
  265.     var tinyCellCounter = 0;
  266.     var rowCounter = 0;
  267.  
  268.     for (var i = 0; i < this.vs.results.length; i++) {
  269.       var res = this.vs.results[i];
  270.  
  271.       // full size image
  272.       var imageScaler = {width:100,height:75};
  273.       var scaled = GSearch.scaleImage(res.tbWidth, res.tbHeight, imageScaler);
  274.       var img = this.createImage(res.tbUrl, scaled.width, scaled.height, null);
  275.       img.onclick = this.methodClosure(this, GSvideoSearchControl.prototype.playVideo, [res]);
  276.  
  277.       // half sized image
  278.       var tinyImageScaler = {width:500,height:370};
  279.       var tinyScaled = GSearch.scaleImage(res.tbWidth, res.tbHeight, tinyImageScaler);
  280.  
  281.       var tinyImg = this.createImage(res.tbUrl, tinyScaled.width, tinyScaled.height, null);
  282.       tinyImg.onclick = this.methodClosure(this, GSvideoSearchControl.prototype.playVideo, [res]);
  283.  
  284.       // manually set the top padding
  285.       if ((this.resultBoxHeight - scaled.height) > 0) {
  286.         var padTop = Math.round((this.resultBoxHeight - scaled.height)/2);
  287.  
  288.         if  ( this.br_IsNav() ) {
  289.           //img.setAttribute("style", "{padding-top:" + padTop +";}");
  290.           img.setAttribute("vspace", padTop);
  291.         } else {
  292.           img.setAttribute("vspace", padTop);
  293.         }
  294.       }
  295.       if ((this.tinyResultBoxHeight - tinyScaled.height) > 0) {
  296.         var tinyPadTop = Math.round((this.tinyResultBoxHeight - tinyScaled.height)/2);
  297.  
  298.         if  ( this.br_IsNav() ) {
  299.           //tinyImg.setAttribute("style", "{padding-top:" + tinyPadTop +";}");
  300.           tinyImg.setAttribute("vspace", tinyPadTop);
  301.         } else {
  302.           tinyImg.setAttribute("vspace", tinyPadTop);
  303.         }
  304.       }
  305.  
  306.       // compute duration
  307.       var seconds = res.duration;
  308.       var minutes = parseInt(seconds/60);
  309.       var durationString;
  310.       if (minutes > 0) {
  311.         durationString = minutes + "m";
  312.         var remainder = seconds%60;
  313.         if (remainder > 20) {
  314.           durationString += " " + remainder + "s";
  315.         }
  316.       } else {
  317.         durationString = seconds + "s";
  318.       }
  319.  
  320.       var toolTip = res.titleNoFormatting + " ( " + durationString + " )";
  321.       var div = this.createDiv(null, this.CL_VIDEORESULT);
  322.       div.title = toolTip;
  323.       div.appendChild(img);
  324.  
  325.       var tinyDiv = this.createDiv(null, this.CL_TINYVIDEORESULT);
  326.       tinyDiv.title = toolTip;
  327.       tinyDiv.appendChild(tinyImg);
  328.  
  329.       // create rows as needed
  330.       if (row == null || cellCounter >= maxColumns) {
  331.         row = this.createTableRow(table);
  332.         cellCounter = 0;
  333.         rowCounter++;
  334.         if (this.twoRowMode && rowCounter > 2) {
  335.           break;
  336.         }
  337.       }
  338.  
  339.       // create rows as needed
  340.       if (tinyRow == null || tinyCellCounter >= tinyMaxColumns) {
  341.         tinyRow = this.createTableRow(tinyTable);
  342.         tinyCellCounter = 0;
  343.       }
  344.  
  345.       var cell = this.createTableCell(row, this.CL_VIDEORESULTCELL + cellCounter);
  346.       cell.appendChild(div);
  347.       cellCounter++;
  348.  
  349.       var tinyCell = this.createTableCell(tinyRow, this.CL_VIDEORESULTCELL + cellCounter);
  350.       tinyCell.appendChild(tinyDiv);
  351.       tinyCellCounter++;
  352.     }
  353.     this.results.appendChild(table);
  354.     this.tinyResults.appendChild(tinyTable);
  355.   }
  356. }
  357.  
  358. GSvideoSearchControl.prototype.playVideo = function(result) {
  359.   this.stopVideo();
  360.   if (result.playUrl && result.playUrl != "") {
  361.  
  362.     // switch to the player
  363.     this.more.innerHTML = this.ST_ALL_DONE;
  364.     this.cssSetClass(this.app, this.CL_PLAYING);
  365.     if (GvideoSearch.createPlayer) {
  366.       this.player = GvideoSearch.createPlayer(result, this.CL_PLAYER);
  367.     } else {
  368.       var playUrl = result.playUrl;
  369.  
  370.       if (this.br_IsOpera()) {
  371.         this.player = document.createElement("object");
  372.         this.player.className = this.CL_PLAYER;
  373.         this.player.setAttribute("type", "application/x-shockwave-flash");
  374.         this.player.setAttribute("data", playUrl);
  375.       } else {
  376.         this.player = document.createElement("embed");
  377.         this.player.className = this.CL_PLAYER;
  378.         this.player.setAttribute("type", "application/x-shockwave-flash");
  379.         this.player.setAttribute("src", playUrl);
  380.         if (result.videoType) {
  381.           if (result.videoType == "Google") {
  382.             this.player.setAttribute("bgcolor", "#000000");
  383.           } else {
  384.             this.player.setAttribute("wmode", "transparent");
  385.           }
  386.         } else {
  387.           this.player.setAttribute("bgcolor", "#000000");
  388.         }
  389.       }
  390.     }
  391.     this.playerBox.appendChild(this.player);
  392.  
  393.     // the title
  394.     var title = this.createDivLink(result.url, result.title, null, this.CL_TITLE);
  395.     this.playerBox.appendChild(title);
  396.   }
  397. }
  398.  
  399. GSvideoSearchControl.prototype.stopVideo = function(result) {
  400.   this.removeChildren(this.playerBox);
  401.   if (this.player) {
  402.     delete(this.player);
  403.     this.player = null;
  404.   }
  405. }
  406.  
  407. GSvideoSearchControl.prototype.doRandomSearch = function() {
  408.   // pick a random video
  409.   var max = this.tags.length - 1;
  410.   var index = Math.round(max * Math.random());
  411.   this.searchByIndex(index);
  412. }
  413.  
  414. GSvideoSearchControl.prototype.loadTags = function() {
  415.  
  416.   if (this.loadCallback) {
  417.     var tags = this.loadCallback();
  418.     if (tags == null || tags == "") {
  419.       this.tags = this.defaultTags;
  420.     } else {
  421.       this.tags = GSvideoSearchControl_JSON.parse(tags);
  422.     }
  423.   } else {
  424.     this.tags = this.defaultTags;
  425.   }
  426.  
  427.   this.removeChildren(this.tagStack);
  428.   for (var i=0; i < this.tags.length; i++ ) {
  429.     this.loadTagItem(i);
  430.   }
  431. }
  432.  
  433. GSvideoSearchControl.prototype.loadTagItem = function(itemIndex) {
  434.  
  435.   var item = this.tags[itemIndex]
  436.   var baseClassName = this.CL_TAG + " " + this.CL_RTAG_PREFIX;
  437.   var label = item.query;
  438.   if (item.label) {
  439.     label = item.label;
  440.   }
  441.  
  442.   // random class between 0 and this.maxRandom
  443.   var r = Math.round(this.maxRandom * Math.random());
  444.   className = baseClassName + r;
  445.  
  446.   label = " " + label.replace(/\s/g,"") + " ";
  447.   var div = this.createDiv(label, className);
  448.   div.onclick = this.methodClosure(this, GSvideoSearchControl.prototype.searchByIndex, [itemIndex]);
  449.   this.tagStack.appendChild(div);
  450.  
  451.   item.savedClassName = className;
  452.   item.domNode = div;
  453. }
  454.  
  455. GSvideoSearchControl.prototype.addTag = function() {
  456.   if ( this.enableEditTags ) {
  457.     if (this.vsf.input.value && this.vsf.input.value != "") {
  458.       var item = new Object();
  459.       item.query = this.vsf.input.value;
  460.  
  461.       // ensure this one is not already in our stack
  462.       var matchFound = false;
  463.       for (var i=0; i < this.tags.length; i++) {
  464.         var ci = this.tags[i];
  465.         if (ci.query.toLowerCase() == item.query.toLowerCase()) {
  466.           matchFound = true;
  467.           break;
  468.         }
  469.       }
  470.       this.vsf.input.value = "";
  471.       if (!matchFound) {
  472.         this.tags.push(item);
  473.         this.loadTagItem(this.tags.length-1);
  474.         this.setSelectedIndex(this.tags.length-1);
  475.         this.twiddleMore();
  476.         this.saveTags();
  477.       } else {
  478.         this.twiddleMore();
  479.       }
  480.     }
  481.   }
  482. }
  483.  
  484. GSvideoSearchControl.prototype.saveTags = function() {
  485.  
  486.   var cleanTags = new Array();
  487.   for (var i=0; i < this.tags.length; i++) {
  488.     var ci = this.tags[i];
  489.     var ni = new Object();
  490.     ni.query = ci.query;
  491.     if (ci.label) {
  492.       ni.label = ci.label;
  493.     }
  494.     cleanTags.push(ni);
  495.   }
  496.   var tagStrings = GSvideoSearchControl_JSON.stringify(cleanTags);
  497.   if (tagStrings) {
  498.     if (this.saveCallback) {
  499.       this.saveCallback(tagStrings);
  500.     }
  501.   }
  502. }
  503.  
  504. GSvideoSearchControl.prototype.deleteTag = function(formRow, itemIndex) {
  505.  
  506.   this.tags[itemIndex].softDeleted = true;
  507.   if (this.br_IsOpera()) {
  508.     // opera will not let me touch the table
  509.     // so I just redraw the thing instead
  510.  
  511.     // create a value table array so I can promote the current form
  512.     // values...
  513.  
  514.     valueTable = new Array();
  515.     for (var i=0; i < this.formInputs.length; i++) {
  516.       var inputObject = new Object();
  517.  
  518.       // promote query value
  519.       if (this.tags[i].softDeleted) {
  520.         inputObject.query = "";
  521.         inputObject.label = "";
  522.       } else {
  523.         if (this.formInputs[i].queryInput.value) {
  524.           inputObject.query = this.cleanse(this.formInputs[i].queryInput.value);
  525.         } else {
  526.           inputObject.query = "";
  527.         }
  528.         if (this.formInputs[i].labelInput.value) {
  529.           inputObject.label = this.cleanse(this.formInputs[i].labelInput.value);
  530.         } else {
  531.           inputObject.label = "";
  532.         }
  533.       }
  534.       valueTable.push(inputObject);
  535.     }
  536.     this.createEditForm(valueTable);
  537.   } else {
  538.     this.cssSetClass(formRow, this.CL_EFDELETE);
  539.   }
  540. }
  541.  
  542. GSvideoSearchControl.prototype.startEditing = function() {
  543.   if (this.tags.length <= 0) {
  544.     return;
  545.   }
  546.   this.cssSetClass(this.app, this.CL_EDITING);
  547.   this.createEditForm(null);
  548. }
  549.  
  550. GSvideoSearchControl.prototype.stopEditing = function(formDisposition) {
  551.   this.cssSetClass(this.app, this.CL_READING);
  552.   this.submitEditForm(formDisposition);
  553.   return false;
  554. }
  555.  
  556. GSvideoSearchControl.prototype.createEditForm = function(opt_valueTable) {
  557.  
  558.   // build the search form
  559.   this.removeChildren(this.editBox);
  560.   this.ef = this.createForm(null);
  561.   this.formInputs = new Array();
  562.  
  563.   var table = this.createTable();
  564.   for (var i=0; i < this.tags.length; i++) {
  565.     var rowClass = this.CL_ODD;
  566.     if (i % 2 == 0) {
  567.       var rowClass = this.CL_EVEN;
  568.     }
  569.     var item = this.tags[i];
  570.     var inputObject = new Object();
  571.  
  572.     // for each item, create a row, input cell, delete cell, etc
  573.     var row = this.createTableRow(table, rowClass);
  574.     var inputCell = this.createTableCell(row, this.CL_EFINPUT);
  575.     var deleteCell = this.createTableCell(row, this.CL_EFDELETE);
  576.  
  577.     // query
  578.     var div = this.createDiv(null, this.CL_EFINPUTBOX);
  579.     var input = this.createTextInput(this.CL_EFINPUT, "query");
  580.     var label = this.createDiv(this.ST_QUERY, this.CL_TAGCONTROL);
  581.     div.appendChild(input);
  582.     div.appendChild(label);
  583.     inputCell.appendChild(div);
  584.     if (item.softDeleted) {
  585.       input.value = this.ST_DELETED;
  586.       input.disabled = true;
  587.     } else {
  588.       if (opt_valueTable) {
  589.         input.value = opt_valueTable[i].query;
  590.       } else {
  591.         if (item.query) {
  592.           input.value = item.query;
  593.         }
  594.       }
  595.     }
  596.     inputObject.queryInput = input;
  597.  
  598.     // label
  599.     div = this.createDiv(null, this.CL_EFINPUTBOX);
  600.     input = this.createTextInput(this.CL_EFINPUT, "label");
  601.     label = this.createDiv(this.ST_LABEL, this.CL_TAGCONTROL);
  602.     div.appendChild(input);
  603.     div.appendChild(label);
  604.     inputCell.appendChild(div);
  605.     if (item.softDeleted) {
  606.       input.value = this.ST_DELETED;
  607.       input.disabled = true;
  608.     } else {
  609.       if (opt_valueTable) {
  610.         input.value = opt_valueTable[i].label;
  611.       } else {
  612.         if (item.label) {
  613.           input.value = item.label;
  614.         }
  615.       }
  616.     }
  617.     inputObject.labelInput = input;
  618.     this.formInputs.push(inputObject);
  619.  
  620.     // delete
  621.     if (item.softDeleted) {
  622.       div = this.createDiv(" ", this.CL_TAGCONTROL);
  623.     } else {
  624.       div = this.createDiv(this.ST_DELETE, this.CL_TAGCONTROL);
  625.       div.onclick = this.methodClosure(this, GSvideoSearchControl.prototype.deleteTag, [row, i]);
  626.     }
  627.  
  628.     deleteCell.appendChild(div);
  629.   }
  630.   this.ef.appendChild(table);
  631.  
  632.   // save/cancel buttons
  633.   div = this.createDiv(null, this.CL_EFSUBMITBOX);
  634.   var button = this.createButton(this.ST_CANCELBTN, this.CL_TAGCONTROL);
  635.   button.onclick = this.methodClosure(this, GSvideoSearchControl.prototype.stopEditing, [false]);
  636.   div.appendChild(button);
  637.  
  638.   button = this.createButton(this.ST_SAVEBTN, this.CL_TAGCONTROL);
  639.   button.onclick = this.methodClosure(this, GSvideoSearchControl.prototype.stopEditing, [true]);
  640.   this.ef.onsubmit = this.methodClosure(this, GSvideoSearchControl.prototype.stopEditing, [true]);
  641.   div.appendChild(button);
  642.   this.ef.appendChild(div);
  643.  
  644.   this.editBox.appendChild(this.ef)
  645. }
  646.  
  647. GSvideoSearchControl.prototype.submitEditForm = function(ok) {
  648.   if (ok) {
  649.  
  650.     // whip through the form creating a new set of items
  651.     var cleanTags = new Array();
  652.     for (var i=0; i < this.tags.length; i++) {
  653.       ci = this.tags[i];
  654.  
  655.       // skip soft deletes
  656.       if (ci.softDeleted) {
  657.         continue;
  658.       }
  659.  
  660.       var item = new Object();
  661.       // safari forces me to use
  662.       // a parallel array... if (this.ef["query"][i].value) {
  663.       if (this.formInputs[i].queryInput.value) {
  664.         item.query = this.cleanse(this.formInputs[i].queryInput.value);
  665.       } else {
  666.         item.query = ci.query;
  667.       }
  668.  
  669.       if (this.formInputs[i].labelInput.value) {
  670.         item.label = this.cleanse(this.formInputs[i].labelInput.value);
  671.       }
  672.       cleanTags.push(item);
  673.     }
  674.  
  675.     // resort to default if you have nuked everything?
  676.     if (cleanTags.length) {
  677.       this.tags = cleanTags;
  678.     } else {
  679.       this.tags = this.defaultTags;
  680.     }
  681.     this.saveTags();
  682.  
  683.     // todo(markl): this should be a this.loadTags()
  684.     this.removeChildren(this.tagStack);
  685.     for (var i=0; i < this.tags.length; i++ ) {
  686.       this.loadTagItem(i);
  687.     }
  688.     this.doRandomSearch();
  689.   } else {
  690.     for (var i=0; i < this.tags.length; i++) {
  691.       ci = this.tags[i];
  692.       ci.softDeleted = false;
  693.     }
  694.   }
  695. }
  696.  
  697. GSvideoSearchControl.prototype.setSelectedIndex = function(itemIndex) {
  698.   if (this.currentItem) {
  699.     this.cssSetClass(this.currentItem.domNode, this.currentItem.savedClassName);
  700.   }
  701.   var item = this.tags[itemIndex];
  702.   this.currentItem = item;
  703.   this.cssSetClass(this.currentItem.domNode, this.currentItem.savedClassName + this.CL_TAGSELECTED);
  704. }
  705.  
  706. GSvideoSearchControl.prototype.searchByIndex = function(itemIndex) {
  707.   var item = this.tags[itemIndex];
  708.   this.setSelectedIndex(itemIndex);
  709.   this.searchByString(this.vsf, item.query);
  710. }
  711.  
  712. /**
  713.  * Standard .execute function to perform a search
  714.  */
  715. GSvideoSearchControl.prototype.execute = function(query) {
  716.   this.vsf.input.value = query;
  717.   this.searchByString(this.vsf);
  718. }
  719.  
  720. GSvideoSearchControl.prototype.searchByString = function(form, opt_query) {
  721.  
  722.   this.searchCounter++;
  723.   clearTimeout(this.startupTimer);
  724.  
  725.   var query = "";
  726.   if (opt_query) {
  727.     query = opt_query;
  728.     this.vsf.input.value = "";
  729.     this.cssSetClass(this.searchForm, this.CLSS_SEARCHFORM);
  730.   } else if (this.vsf.input.value) {
  731.     query = this.vsf.input.value;
  732.   } else {
  733.     return false;
  734.   }
  735.   if (this.twoRowMode) {
  736.     if (this.getNodeWidth(this.results) > 350 || this.getNodeWidth(this.tinyResults) > 350 ) {
  737.       this.resultSetSize = GSearch.LARGE_RESULTSET;
  738.     } else {
  739.       this.resultSetSize = GSearch.SMALL_RESULTSET;
  740.     }
  741.     this.vs.setResultSetSize(this.resultSetSize);
  742.   }
  743.   this.vs.execute(query);
  744.  
  745.   return false;
  746. }
  747.  
  748. GSvideoSearchControl.prototype.twiddleMore = function() {
  749.   if (this.app.className == this.CL_READING) {
  750.     this.more.innerHTML = this.ST_ALL_DONE;
  751.     this.cssSetClass(this.app, this.CL_SEARCHING);
  752.     this.cssSetClass(this.searchForm, this.CLSS_SEARCHFORM);
  753.   } else if (this.app.className == this.CL_PLAYING) {
  754.     this.more.innerHTML = this.ST_SEARCH;
  755.     this.cssSetClass(this.app, this.CL_READING);
  756.     this.stopVideo();
  757.   } else {
  758.     this.more.innerHTML = this.ST_SEARCH;
  759.     this.cssSetClass(this.app, this.CL_READING);
  760.   }
  761. }
  762.  
  763. /**
  764.  * Static Helper Method
  765. */
  766. GSvideoSearchControl.methodCallback = function(object, method) {
  767.   return function() {
  768.     return method.apply(object, arguments);
  769.   }
  770. }
  771.  
  772. /**
  773.  * Class methods
  774. */
  775. GSvideoSearchControl.prototype.cleanse = function(str) {
  776.   return str.replace(/</g, '<').replace(/>/g, '>');
  777. }
  778.  
  779. GSvideoSearchControl.prototype.methodClosure = function(object, method, opt_argArray) {
  780.   return function() {
  781.     return method.apply(object, opt_argArray);
  782.   }
  783. }
  784.  
  785. GSvideoSearchControl.prototype.createDiv = function(opt_text, opt_className) {
  786.   var el = document.createElement("div");
  787.   if (opt_text) {
  788.     el.innerHTML = opt_text;
  789.   }
  790.   if (opt_className) { el.className = opt_className; }
  791.   return el;
  792. }
  793.  
  794. GSvideoSearchControl.prototype.removeChildren = function(parent) {
  795.   while (parent.firstChild) {
  796.     parent.removeChild(parent.firstChild);
  797.   }
  798. }
  799.  
  800. GSvideoSearchControl.prototype.removeChild = function(parent, child) {
  801.   parent.removeChild(child);
  802. }
  803.  
  804. GSvideoSearchControl.prototype.cssSetClass = function(el, className) {
  805.   el.className = className;
  806. }
  807.  
  808.  
  809. GSvideoSearchControl.prototype.createForm = function(opt_className) {
  810.   var el = document.createElement("form");
  811.   if (opt_className) { el.className = opt_className; }
  812.   return el;
  813. }
  814.  
  815. GSvideoSearchControl.prototype.createTable = function(opt_className) {
  816.   var el = document.createElement("table");
  817.   if (opt_className) { el.className = opt_className; }
  818.   return el;
  819. }
  820.  
  821. GSvideoSearchControl.prototype.createTableRow = function(table, opt_className) {
  822.   var tr = table.insertRow(-1);
  823.   if (opt_className) { tr.className = opt_className; }
  824.   return tr;
  825. }
  826.  
  827. GSvideoSearchControl.prototype.createTableCell = function(tr, opt_className) {
  828.   var td = tr.insertCell(-1);
  829.   if (opt_className) { td.className = opt_className; }
  830.   return td;
  831. }
  832.  
  833. GSvideoSearchControl.prototype.createTextInput = function(opt_className, opt_name) {
  834.   var el = document.createElement("input");
  835.   el.type = "text";
  836.   if (opt_className) { el.className = opt_className; }
  837.   if (opt_name) { el.name = opt_name; }
  838.   return el;
  839. }
  840.  
  841. GSvideoSearchControl.prototype.createLink = function(href, text, opt_target, opt_className) {
  842.   var el = document.createElement("a");
  843.   el.href = href;
  844.   el.appendChild(document.createTextNode(text));
  845.   if (opt_className) {
  846.     el.className = opt_className;
  847.   }
  848.   if (opt_target) {
  849.     el.target = opt_target;
  850.   }
  851.   return el;
  852. }
  853.  
  854. GSvideoSearchControl.prototype.createDivLink = function(href, text, opt_target, opt_className) {
  855.   var div = this.createDiv(null, opt_className);
  856.   var el = document.createElement("a");
  857.   el.href = href;
  858.   el.appendChild(document.createTextNode(text));
  859.   if (opt_className) {
  860.     el.className = opt_className;
  861.   }
  862.   if (opt_target) {
  863.     el.target = opt_target;
  864.   }
  865.   div.appendChild(el);
  866.   return div;
  867. }
  868.  
  869. GSvideoSearchControl.prototype.createButton = function(value, opt_className) {
  870.   var el = document.createElement("input");
  871.   el.type = "button";
  872.   el.value = value;
  873.   if (opt_className) { el.className = opt_className; }
  874.   return el;
  875. }
  876.  
  877. GSvideoSearchControl.prototype.createImage = function(src, opt_w, opt_h, opt_className) {
  878.   var el = document.createElement("img");
  879.   el.src = src;
  880.   if (opt_w) { el.width = opt_w; }
  881.   if (opt_h) { el.height = opt_h; }
  882.   if (opt_className) { el.className = opt_className; }
  883.   return el;
  884. }
  885.  
  886.  
  887. GSvideoSearchControl.prototype.getNodeWidth = function(node) {
  888.   return node.offsetWidth;
  889. }
  890.  
  891. GSvideoSearchControl.prototype.br_AgentContains_ = function(str) {
  892.   if (str in this.br_AgentContains_cache_) {
  893.     return this.br_AgentContains_cache_[str];
  894.   }
  895.  
  896.   return this.br_AgentContains_cache_[str] =
  897.     (navigator.userAgent.toLowerCase().indexOf(str) != -1);
  898. }
  899.  
  900. GSvideoSearchControl.prototype.br_IsIE = function() {
  901.   return this.br_AgentContains_('msie');
  902. }
  903.  
  904. GSvideoSearchControl.prototype.br_IsKonqueror = function() {
  905.   return this.br_AgentContains_('konqueror');
  906. }
  907.  
  908. GSvideoSearchControl.prototype.br_IsOpera = function() {
  909.   return this.br_AgentContains_('opera');
  910. }
  911.  
  912. GSvideoSearchControl.prototype.br_IsSafari = function() {
  913.   return this.br_AgentContains_('safari') || this.br_IsKonqueror();
  914. }
  915.  
  916. GSvideoSearchControl.prototype.br_IsNav = function() {
  917.   return !this.br_IsIE() &&
  918.          !this.br_IsSafari() &&
  919.          this.br_AgentContains_('mozilla');
  920. }
  921.  
  922. GSvideoSearchControl.prototype.br_IsWin = function() {
  923.   return this.br_AgentContains_('win');
  924. }
  925.  
  926. /*
  927. Copyright (c) 2005 JSON.org
  928.  
  929. Permission is hereby granted, free of charge, to any person obtaining a copy
  930. of this software and associated documentation files (the "Software"), to deal
  931. in the Software without restriction, including without limitation the rights
  932. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  933. copies of the Software, and to permit persons to whom the Software is
  934. furnished to do so, subject to the following conditions:
  935.  
  936. The Software shall be used for Good, not Evil.
  937.  
  938. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  939. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  940. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  941. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  942. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  943. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  944. SOFTWARE.
  945. */
  946.  
  947. /*
  948.     The global object GSvideoSearchControl_JSON contains two methods.
  949.  
  950.     GSvideoSearchControl_JSON.stringify(value) takes a JavaScript value and produces a JSON text.
  951.     The value must not be cyclical.
  952.  
  953.     GSvideoSearchControl_JSON.parse(text) takes a JSON text and produces a JavaScript value. It will
  954.     return false if there is an error.
  955. */
  956. var GSvideoSearchControl_JSON = function () {
  957.     var m = {
  958.             '\b': '\\b',
  959.             '\t': '\\t',
  960.             '\n': '\\n',
  961.             '\f': '\\f',
  962.             '\r': '\\r',
  963.             '"' : '\\"',
  964.             '\\': '\\\\'
  965.         },
  966.         s = {
  967.             'boolean': function (x) {
  968.                 return String(x);
  969.             },
  970.             number: function (x) {
  971.                 return isFinite(x) ? String(x) : 'null';
  972.             },
  973.             string: function (x) {
  974.                 if (/[\"\\\x00-\x1f]/.test(x)) {
  975.                     x = x.replace(/([\x00-\x1f\\\"])/g, function(a, b) {
  976.                         var c = m[b];
  977.                         if (c) {
  978.                             return c;
  979.                         }
  980.                         c = b.charCodeAt();
  981.                         return '\\u00' +
  982.                             Math.floor(c / 16).toString(16) +
  983.                             (c % 16).toString(16);
  984.                     });
  985.                 }
  986.                 return '"' + x + '"';
  987.             },
  988.             object: function (x) {
  989.                 if (x) {
  990.                     var a = [], b, f, i, l, v;
  991.                     if (x instanceof Array) {
  992.                         a[0] = '[';
  993.                         l = x.length;
  994.                         for (i = 0; i < l; i += 1) {
  995.                             v = x[i];
  996.                             f = s[typeof v];
  997.                             if (f) {
  998.                                 v = f(v);
  999.                                 if (typeof v == 'string') {
  1000.                                     if (b) {
  1001.                                         a[a.length] = ',';
  1002.                                     }
  1003.                                     a[a.length] = v;
  1004.                                     b = true;
  1005.                                 }
  1006.                             }
  1007.                         }
  1008.                         a[a.length] = ']';
  1009.                     } else if (x instanceof Object) {
  1010.                         a[0] = '{';
  1011.                         for (i in x) {
  1012.                             v = x[i];
  1013.                             f = s[typeof v];
  1014.                             if (f) {
  1015.                                 v = f(v);
  1016.                                 if (typeof v == 'string') {
  1017.                                     if (b) {
  1018.                                         a[a.length] = ',';
  1019.                                     }
  1020.                                     a.push(s.string(i), ':', v);
  1021.                                     b = true;
  1022.                                 }
  1023.                             }
  1024.                         }
  1025.                         a[a.length] = '}';
  1026.                     } else {
  1027.                         return;
  1028.                     }
  1029.                     return a.join('');
  1030.                 }
  1031.                 return 'null';
  1032.             }
  1033.         };
  1034.     return {
  1035.         copyright: '(c)2005 JSON.org',
  1036.         license: 'http://www.crockford.com/JSON/license.html',
  1037. /*
  1038.     Stringify a JavaScript value, producing a JSON text.
  1039. */
  1040.         stringify: function (v) {
  1041.             var f = s[typeof v];
  1042.             if (f) {
  1043.                 v = f(v);
  1044.                 if (typeof v == 'string') {
  1045.                     return v;
  1046.                 }
  1047.             }
  1048.             return null;
  1049.         },
  1050. /*
  1051.     Parse a JSON text, producing a JavaScript value.
  1052.     It returns false if there is a syntax error.
  1053. */
  1054.         parse: function (text) {
  1055.             try {
  1056.                 return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test(
  1057.                         text.replace(/"(\\.|[^"\\])*"/g, ''))) &&
  1058.                     eval('(' + text + ')');
  1059.             } catch (e) {
  1060.                 return false;
  1061.             }
  1062.         }
  1063.     };
  1064. }();



mi domando se fosse possibile risalire al link del video di youtube.
Mi spiego meglio: durante la ricerca dal mio sito su youtube, attrvaerso le api di youtube, mi compaiono i video come anteprime. E' possibile far comparire, oltre alle anteprime i rispettivi link di appartenenza? (un esempio di link potrebbe essere http://www.youtube.com/watch?v=UKIjzaSrJ4E&feature=fvst)
Come si fa??? ... sto impazzendo. 8-|

PM Quote
Avatar
Mte90 (Member)
Guru


Messaggi: 1144
Iscritto: 25/03/2008

Segnala al moderatore
Postato alle 16:02
Venerdì, 06/08/2010
adesso a laggermi tutto il codice javscript proprio non ne ho voglia.
ma non c'è una guida sul sito di google con gli esempi e i tutorial?
io mi ricordo che ne trovai a bizzeffe.

PM Quote