video_app.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. /**
  2. * Zend Framework
  3. *
  4. * LICENSE
  5. *
  6. * This source file is subject to the new BSD license that is bundled
  7. * with this package in the file LICENSE.txt.
  8. * It is also available through the world-wide-web at this URL:
  9. * http://framework.zend.com/license/new-bsd
  10. * If you did not receive a copy of the license and are unable to
  11. * obtain it through the world-wide-web, please send an email
  12. * to license@zend.com so we can send you a copy immediately.
  13. *
  14. * @category Zend
  15. * @package Zend_Gdata
  16. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  17. * @license http://framework.zend.com/license/new-bsd New BSD License
  18. */
  19. /**
  20. * @fileoverview Provides functions for browsing and searching YouTube
  21. * data API feeds, as well as performing authentication, syndicated uploads
  22. * and playlist management using a PHP backend powered by the Zend_Gdata component
  23. * of Zend Framework.
  24. */
  25. /**
  26. * provides namespacing for the YouTube Video Application PHP version (ytVideoApp)
  27. */
  28. var ytVideoApp = {};
  29. /**
  30. * maximum number of results to return for list of videos
  31. * @type Number
  32. */
  33. ytVideoApp.MAX_RESULTS_LIST = 5;
  34. /**
  35. * navigation button id used to page to the previous page of
  36. * results in the list of videos
  37. * @type String
  38. */
  39. ytVideoApp.PREVIOUS_PAGE_BUTTON = 'previousPageButton';
  40. /**
  41. * navigation button id used to page to the next page of
  42. * results in the list of videos
  43. * @type String
  44. */
  45. ytVideoApp.NEXT_PAGE_BUTTON = 'nextPageButton';
  46. /**
  47. * container div for navigation elements
  48. * @type String
  49. */
  50. ytVideoApp.NAVIGATION_DIV = 'navigationForm';
  51. /**
  52. * container div id used to hold list of videos
  53. * @type String
  54. */
  55. ytVideoApp.VIDEO_LIST_CONTAINER_DIV = 'searchResultsVideoList';
  56. /**
  57. * container div id used to hold video search results
  58. * @type String
  59. */
  60. ytVideoApp.VIDEO_SEARCH_RESULTS_DIV = 'searchResultsVideoColumn';
  61. /**
  62. * container div id used to hold the video player
  63. * @type String
  64. */
  65. ytVideoApp.VIDEO_PLAYER_DIV = 'videoPlayer';
  66. /**
  67. * container div id used to hold the search box displayed at the top of
  68. * the browser after one search has already been performed
  69. * @type String
  70. */
  71. ytVideoApp.TOP_SEARCH_CONTAINER_DIV = 'searchBox';
  72. /** container div to show detailed upload status
  73. * @type String
  74. */
  75. ytVideoApp.VIDEO_UPLOAD_STATUS = 'detailedUploadStatus';
  76. /**
  77. * container div to hold the form for syndicated upload
  78. * @type String
  79. */
  80. ytVideoApp.SYNDICATED_UPLOAD_DIV = 'syndicatedUploadDiv';
  81. /**
  82. * container div to hold the form to edit video meta-data
  83. * @type String
  84. */
  85. ytVideoApp.VIDEO_DATA_EDIT_DIV = 'editForm';
  86. /**
  87. * containder div to hold authentication link in special cases where auth gets
  88. * set prior to developer key
  89. * @type String
  90. */
  91. ytVideoApp.AUTHSUB_REQUEST_DIV = 'generateAuthSubLink';
  92. /**
  93. * container div to hold the form for editing video meta-data
  94. * @type String
  95. */
  96. ytVideoApp.VIDEO_META_DATA_EDIT_DIV = 'editVideoMetaDataDiv';
  97. /**
  98. * container div to hold the form for adding a new playlist
  99. * @type String
  100. */
  101. ytVideoApp.PLAYLIST_ADD_DIV = 'addNewPlaylist';
  102. /**
  103. * the page number to use for the next page navigation button
  104. * @type Number
  105. */
  106. ytVideoApp.nextPage = 2;
  107. /**
  108. * the page number to use for the previous page navigation button
  109. * @type Number
  110. */
  111. ytVideoApp.previousPage = 0;
  112. /**
  113. * the last search term used to query - allows for the navigation
  114. * buttons to know what string query to perform when clicked
  115. * @type String
  116. */
  117. ytVideoApp.previousSearchTerm = '';
  118. /**
  119. * the last query type used for querying - allows for the navigation
  120. * buttons to know what type of query to perform when clicked
  121. * @type String
  122. */
  123. ytVideoApp.previousQueryType = 'all';
  124. /**
  125. * Retrieves a list of videos matching the provided criteria. The list of
  126. * videos can be restricted to a particular standard feed or search criteria.
  127. * @param {String} op The type of action to be done.
  128. * for querying all videos, or the name of a standard feed.
  129. * @param {String} searchTerm The search term(s) to use for querying as the
  130. * 'vq' query parameter value
  131. * @param {Number} page The 1-based page of results to return.
  132. */
  133. ytVideoApp.listVideos = function(op, searchTerm, page) {
  134. ytVideoApp.previousSearchTerm = searchTerm;
  135. ytVideoApp.previousQueryType = op;
  136. var maxResults = ytVideoApp.MAX_RESULTS_LIST;
  137. var startIndex = (((page - 1) * ytVideoApp.MAX_RESULTS_LIST) + 1);
  138. ytVideoApp.presentFeed(op, maxResults, startIndex, searchTerm);
  139. ytVideoApp.updateNavigation(page);
  140. };
  141. /**
  142. * Sends an AJAX request to the server to retrieve a list of videos or
  143. * the video player/metadata. Sends the request to the specified filePath
  144. * on the same host, passing the specified params, and filling the specified
  145. * resultDivName with the resutls upon success.
  146. * @param {String} filePath The path to which the request should be sent
  147. * @param {String} params The URL encoded POST params
  148. * @param {String} resultDivName The name of the DIV used to hold the results
  149. */
  150. ytVideoApp.sendRequest = function(filePath, params, resultDivName) {
  151. if (window.XMLHttpRequest) {
  152. var xmlhr = new XMLHttpRequest();
  153. } else {
  154. var xmlhr = new ActiveXObject('MSXML2.XMLHTTP.3.0');
  155. }
  156. xmlhr.open('POST', filePath);
  157. xmlhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  158. xmlhr.onreadystatechange = function() {
  159. var resultDiv = document.getElementById(resultDivName);
  160. if (xmlhr.readyState == 1) {
  161. resultDiv.innerHTML = '<b>Loading...</b>';
  162. } else if (xmlhr.readyState == 4 && xmlhr.status == 200) {
  163. if (xmlhr.responseText) {
  164. resultDiv.innerHTML = xmlhr.responseText;
  165. }
  166. } else if (xmlhr.readyState == 4) {
  167. alert('Invalid response received - Status: ' + xmlhr.status);
  168. }
  169. }
  170. xmlhr.send(params);
  171. }
  172. /**
  173. * Uses ytVideoApp.sendRequest to display a YT video player and metadata for the
  174. * specified video ID.
  175. * @param {String} videoId The ID of the YouTube video to show
  176. */
  177. ytVideoApp.presentVideo = function(videoId, updateThumbnail) {
  178. var params = 'operation=show_video&videoId=' + videoId;
  179. var filePath = 'operations.php';
  180. ytVideoApp.sendRequest(filePath, params, ytVideoApp.VIDEO_PLAYER_DIV);
  181. }
  182. /**
  183. * Creates a form to enter video meta-data in preparation for syndicated upload.
  184. */
  185. ytVideoApp.prepareUploadForm = function() {
  186. var metaDataForm = ['<br clear="all"><form id="uploadForm" ',
  187. 'onsubmit="ytVideoApp.prepareSyndicatedUpload(',
  188. 'this.videoTitle.value, ',
  189. 'this.videoDescription.value, ',
  190. 'this.videoCategory.value, ',
  191. 'this.videoTags.value); ',
  192. 'return false;">',
  193. 'Enter video title:<br /><input size="50" name="videoTitle" ',
  194. 'type="text" /><br />',
  195. 'Enter video description:<br /><textarea cols="50" ',
  196. 'name="videoDescription"></textarea><br />',
  197. 'Select a category: <select name="videoCategory">',
  198. '<option value="Autos">Autos &amp; Vehicles</option>',
  199. '<option value="Music">Music</option>',
  200. '<option value="Animals">Pets &amp; Animals</option>',
  201. '<option value="Sports">Sports</option>',
  202. '<option value="Travel">Travel &amp; Events</option>',
  203. '<option value="Games">Gadgets &amp; Games</option>',
  204. '<option value="Comedy">Comedy</option>',
  205. '<option value="People">People &amp; Blogs</option>',
  206. '<option value="News">News &amp; Politics</option>',
  207. '<option value="Entertainment">Entertainment</option>',
  208. '<option value="Education">Education</option>',
  209. '<option value="Howto">Howto &amp; Style</option>',
  210. '<option value="Nonprofit">Nonprofit &amp; Activism</option>',
  211. '<option value="Tech">Science &amp; Technology</option>',
  212. '</select><br />',
  213. 'Enter some tags to describe your video ',
  214. '<em>(separated by spaces)</em>:<br />',
  215. '<input name="videoTags" type="text" size="50" value="video" /><br />',
  216. '<input type="submit" value="go">',
  217. '</form>'].join('');
  218. document.getElementById(ytVideoApp.SYNDICATED_UPLOAD_DIV).innerHTML = metaDataForm;
  219. }
  220. /**
  221. * Uses ytVideoApp.sendRequest to prepare a syndicated upload.
  222. *
  223. * @param {String} videoTitle The title for new video
  224. * @param {String} videoDescription The video's description
  225. * @param {String} videoCategory The category for the video
  226. * @param {String} videoTags A white-space separated string of Tags
  227. */
  228. ytVideoApp.prepareSyndicatedUpload = function(videoTitle, videoDescription, videoCategory, videoTags) {
  229. var filePath = 'operations.php';
  230. var params = 'operation=create_upload_form' +
  231. '&videoTitle=' + videoTitle +
  232. '&videoDescription=' + videoDescription +
  233. '&videoCategory=' + videoCategory +
  234. '&videoTags=' + videoTags;
  235. ytVideoApp.sendRequest(filePath, params, ytVideoApp.SYNDICATED_UPLOAD_DIV);
  236. }
  237. /**
  238. * Uses ytVideoApp.sendRequest to create the authSub link.
  239. */
  240. ytVideoApp.presentAuthLink = function() {
  241. var filePath = 'operations.php';
  242. var params = 'operation=auth_sub_request';
  243. ytVideoApp.sendRequest(filePath, params, ytVideoApp.AUTHSUB_REQUEST_DIV);
  244. }
  245. /**
  246. * Uses ytVideoApp.sendRequest to check a videos upload status.
  247. *
  248. * @param {String} videoId The id of the video to check
  249. */
  250. ytVideoApp.checkUploadDetails = function(videoId) {
  251. var filePath = 'operations.php';
  252. var params = 'operation=check_upload_status' +
  253. '&videoId=' + videoId;
  254. ytVideoApp.sendRequest(filePath, params, ytVideoApp.VIDEO_UPLOAD_STATUS);
  255. }
  256. /**
  257. * Creates an HTML form to edit a video's meta-data, populated with the
  258. * videos current meta-data.
  259. *
  260. * @param {String} oldVideoTitle The old title of the video
  261. * @param {String} oldVideoDescription The old description of the video
  262. * @param {String} oldVideoCategory The old category of the video
  263. * @param {String} oldVideoTags The old tags for the video (separated by white-space)
  264. * @param {String} videoId The id of the video to be edited
  265. */
  266. ytVideoApp.presentMetaDataEditForm = function(oldVideoTitle, oldVideoDescription, oldVideoCategory, oldVideoTags, videoId) {
  267. // split oldVideoTags by comma and present as whitespace separated
  268. var oldVideoTagsArray = oldVideoTags.split(',');
  269. oldVideoTags = oldVideoTagsArray.join(' ');
  270. var editMetaDataForm = ['<form id="editForm" ',
  271. 'onsubmit="ytVideoApp.editMetaData(',
  272. 'this.newVideoTitle.value, ',
  273. 'this.newVideoDescription.value, ',
  274. 'this.newVideoCategory.value, ',
  275. 'this.newVideoTags.value, ',
  276. 'this.videoId.value);',
  277. 'return false;">',
  278. 'Enter a new video title:<br />',
  279. '<input size="50" name="newVideoTitle" ',
  280. 'type="text" value="',
  281. oldVideoTitle,
  282. '"/><br />',
  283. 'Enter a new video description:<br />',
  284. '<textarea cols="50" name="newVideoDescription">',
  285. oldVideoDescription,
  286. '</textarea><br />',
  287. 'Select a new category: <select ',
  288. 'name="newVideoCategory">',
  289. '<option value="Autos">Autos &amp; Vehicles</option>',
  290. '<option value="Music">Music</option>',
  291. '<option value="Animals">Pets &amp; Animals</option>',
  292. '<option value="Sports">Sports</option>',
  293. '<option value="Travel">Travel &amp; Events</option>',
  294. '<option value="Games">Gadgets &amp; Games</option>',
  295. '<option value="Comedy">Comedy</option>',
  296. '<option value="People">People &amp; Blogs</option>',
  297. '<option value="News">News &amp; Politics</option>',
  298. '<option value="Entertainment">Entertainment</option>',
  299. '<option value="Education">Education</option>',
  300. '<option value="Howto">Howto &amp; Style</option>',
  301. '<option value="Nonprofit">Nonprofit &amp; Activism</option>',
  302. '<option value="Tech">Science &amp; Technology</option>',
  303. '</select><br />',
  304. 'Enter some new tags to describe your video ',
  305. '<em>(separated by spaces)</em>:<br />',
  306. '<input name="newVideoTags" type="text" size="50" ',
  307. 'value="',
  308. oldVideoTags,
  309. '"/><br />',
  310. '<input name="videoId" type="hidden" value="',
  311. videoId,
  312. '" /><br />',
  313. '<input type="submit" value="go">',
  314. '</form>'].join('');
  315. document.getElementById(ytVideoApp.VIDEO_SEARCH_RESULTS_DIV).innerHTML = editMetaDataForm;
  316. }
  317. /**
  318. * Uses ytVideoApp.sendRequest to submit updated video meta-data.
  319. *
  320. * @param {String} newVideoTitle The new title of the video
  321. * @param {String} newVideoDescription The new description of the video
  322. * @param {String} newVideoCategory The new category of the video
  323. * @param {String} newVideoTags The new tags for the video (separated by white-space)
  324. * @param {String} videoId The id of the video to be edited
  325. */
  326. ytVideoApp.editMetaData = function(newVideoTitle, newVideoDescription, newVideoCategory, newVideoTags, videoId) {
  327. var filePath = 'operations.php';
  328. var params = 'operation=edit_meta_data' +
  329. '&newVideoTitle=' + newVideoTitle +
  330. '&newVideoDescription=' + newVideoDescription +
  331. '&newVideoCategory=' + newVideoCategory +
  332. '&newVideoTags=' + newVideoTags +
  333. '&videoId=' + videoId;
  334. ytVideoApp.sendRequest(filePath, params, ytVideoApp.VIDEO_SEARCH_RESULTS_DIV);
  335. };
  336. /**
  337. * Confirms whether user wants to delete a video.
  338. * @param {String} videoId The video Id to be deleted
  339. */
  340. ytVideoApp.confirmDeletion = function(videoId) {
  341. var answer = confirm('Do you really want to delete the video with id: ' + videoId + ' ?');
  342. if (answer) {
  343. ytVideoApp.prepareDeletion(videoId);
  344. }
  345. }
  346. /**
  347. * Uses ytVideoApp.sendRequest to request a video to be deleted.
  348. * @param {String} videoId The video Id to be deleted
  349. */
  350. ytVideoApp.prepareDeletion = function(videoId) {
  351. var filePath = 'operations.php';
  352. var params = 'operation=delete_video' +
  353. '&videoId=' + videoId;
  354. var table = document.getElementById('videoResultList');
  355. var indexOfRowToBeDeleted = -1;
  356. var tableRows = document.getElementsByTagName('TR');
  357. for (var i = 0, tableRow; tableRow = tableRows[i]; i++) {
  358. if (tableRow.id == videoId) {
  359. indexOfRowToBeDeleted = i;
  360. }
  361. }
  362. if (indexOfRowToBeDeleted > -1) {
  363. table.deleteRow(indexOfRowToBeDeleted);
  364. }
  365. ytVideoApp.sendRequest(filePath, params, ytVideoApp.VIDEO_SEARCH_RESULTS_DIV);
  366. }
  367. /**
  368. * Uses ytVideoApp.sendRequest to display a list of of YT videos.
  369. * @param {String} op The operation to perform to retrieve a feed
  370. * @param {Number} maxResults The maximum number of videos to list
  371. * @param {Number} startIndex The first video to include in the list
  372. * @param {String} searchTerm The search terms to pass to the specified feed
  373. */
  374. ytVideoApp.presentFeed = function(op, maxResults, startIndex, searchTerm){
  375. var params = 'operation=' + op +
  376. '&maxResults=' + maxResults +
  377. '&startIndex=' + startIndex +
  378. '&searchTerm=' + searchTerm;
  379. var filePath = 'operations.php';
  380. ytVideoApp.sendRequest(filePath, params, ytVideoApp.VIDEO_LIST_CONTAINER_DIV);
  381. };
  382. /**
  383. * Updates the variables used by the navigation buttons and the 'enabled'
  384. * status of the buttons based upon the current page number passed in.
  385. * @param {Number} page The current page number
  386. */
  387. ytVideoApp.updateNavigation = function(page) {
  388. ytVideoApp.nextPage = page + 1;
  389. ytVideoApp.previousPage = page - 1;
  390. document.getElementById(ytVideoApp.NEXT_PAGE_BUTTON).style.display = 'inline';
  391. document.getElementById(ytVideoApp.PREVIOUS_PAGE_BUTTON).style.display = 'inline';
  392. if (ytVideoApp.previousPage < 1) {
  393. document.getElementById(ytVideoApp.PREVIOUS_PAGE_BUTTON).disabled = true;
  394. } else {
  395. document.getElementById(ytVideoApp.PREVIOUS_PAGE_BUTTON).disabled = false;
  396. }
  397. document.getElementById(ytVideoApp.NEXT_PAGE_BUTTON).disabled = false;
  398. };
  399. /**
  400. * Hides the navigation.
  401. */
  402. ytVideoApp.hideNavigation = function() {
  403. document.getElementById(ytVideoApp.NAVIGATION_DIV).style.display = 'none';
  404. };
  405. /**
  406. * Update video results div
  407. */
  408. ytVideoApp.refreshSearchResults = function() {
  409. document.getElementById(ytVideoApp.VIDEO_SEARCH_RESULTS_DIV).innerHTML = '';
  410. }
  411. /**
  412. * Method called when the query type has been changed. Clears out the
  413. * value of the search term input box by default if one of the standard
  414. * feeds is selected. This is to improve usability, as many of the standard
  415. * feeds may not include results for even fairly popular search terms.
  416. * @param {String} op The operation to perform.
  417. * for querying all videos, or the name of one of the standard feeds.
  418. * @param {Node} searchTermInputElement The HTML input element for the input
  419. * element.
  420. */
  421. ytVideoApp.queryTypeChanged = function(op, searchTermInputElement) {
  422. if (op == 'search_username') {
  423. searchTermInputElement.value = '-- enter username --';
  424. } else if (op != 'search_all') {
  425. searchTermInputElement.value = '';
  426. }
  427. };
  428. /**
  429. * Create a basic HTML form to use for creating a new playlist.
  430. */
  431. ytVideoApp.prepareCreatePlaylistForm = function() {
  432. var newPlaylistForm = ['<br /><form id="addPlaylist" ',
  433. 'onsubmit="ytVideoApp.createNewPlaylist(this.newPlaylistTitle.value, ',
  434. 'this.newPlaylistDescription.value); ">',
  435. 'Enter a title for the new playlist:<br />',
  436. '<input size="50" name="newPlaylistTitle" type="text" /><br />',
  437. 'Enter a description:<br />',
  438. '<textarea cols="25" name="newPlaylistDescription" >',
  439. '</textarea><br />',
  440. '<input type="submit" value="go">',
  441. '</form>'].join('');
  442. document.getElementById(ytVideoApp.PLAYLIST_ADD_DIV).innerHTML = newPlaylistForm;
  443. }
  444. /**
  445. * Uses ytVideoApp.sendRequest to create a new playlist.
  446. *
  447. * @param {String} playlistTitle The title of the new playlist
  448. * @param {String} playlistDescription A description of the new playlist
  449. */
  450. ytVideoApp.createNewPlaylist = function(playlistTitle, playlistDescription) {
  451. var filePath = 'operations.php';
  452. var params = 'operation=create_playlist' +
  453. '&playlistTitle=' + playlistTitle +
  454. '&playlistDescription=' + playlistDescription;
  455. ytVideoApp.hideNavigation();
  456. ytVideoApp.sendRequest(filePath, params, ytVideoApp.VIDEO_SEARCH_RESULTS_DIV);
  457. }
  458. /**
  459. * Confirm user wants to delete a playlist
  460. *
  461. * @param {String} playlistTitle The title of the playlist to be deleted
  462. */
  463. ytVideoApp.confirmPlaylistDeletion = function(playlistTitle) {
  464. var answer = confirm('Do you really want to delete the playlist titled : ' +
  465. playlistTitle + ' ?');
  466. if (answer) {
  467. ytVideoApp.deletePlaylist(playlistTitle);
  468. }
  469. }
  470. /**
  471. * Uses ytVideoApp.sendRequest to delete a playlist.
  472. *
  473. * @param {String} playlistTitle The title of the new playlist
  474. */
  475. ytVideoApp.deletePlaylist = function(playlistTitle) {
  476. var filePath = 'operations.php';
  477. var params = 'operation=delete_playlist' +
  478. '&playlistTitle=' + playlistTitle;
  479. ytVideoApp.sendRequest(filePath, params, ytVideoApp.VIDEO_SEARCH_RESULTS_DIV);
  480. }
  481. /**
  482. * Create a basic HTML form to use for modifying a playlist.
  483. *
  484. * @param {String} oldPlaylistTitle The old title of the playlist
  485. * @param {String} oldPlaylistDescription The old description of the playlist
  486. */
  487. ytVideoApp.prepareUpdatePlaylistForm = function(oldPlaylistTitle, oldPlaylistDescription) {
  488. var playlistUpdateForm = ['<br /><form id="updatePlaylist" ',
  489. 'onsubmit="ytVideoApp.updatePlaylist(this.newPlaylistTitle.value, ',
  490. 'this.newPlaylistDescription.value, this.oldPlaylistTitle.value);">',
  491. 'Enter a title for the new playlist:<br />',
  492. '<input size="50" name="newPlaylistTitle" type="text" value="',
  493. oldPlaylistTitle,
  494. '"/><br />',
  495. 'Enter a description:<br />',
  496. '<textarea cols="25" name="newPlaylistDescription" >',
  497. oldPlaylistDescription,
  498. '</textarea><br />',
  499. '<input type="submit" value="go" />',
  500. '<input type="hidden" value="',
  501. oldPlaylistTitle,
  502. '" name="oldPlaylistTitle" />',
  503. '</form>'].join('');
  504. document.getElementById(ytVideoApp.VIDEO_SEARCH_RESULTS_DIV).innerHTML = playlistUpdateForm;
  505. }
  506. /**
  507. * Uses ytVideoApp.sendRequest to update a playlist.
  508. *
  509. * @param {String} newPlaylistTitle The new title of the playlist
  510. * @param {String} newPlaylistDescription A new description of the playlist
  511. */
  512. ytVideoApp.updatePlaylist = function(newPlaylistTitle, newPlaylistDescription, oldPlaylistTitle) {
  513. var filePath = 'operations.php';
  514. var params = 'operation=update_playlist' +
  515. '&newPlaylistTitle=' + newPlaylistTitle +
  516. '&newPlaylistDescription=' + newPlaylistDescription +
  517. '&oldPlaylistTitle=' + oldPlaylistTitle;
  518. ytVideoApp.sendRequest(filePath, params, ytVideoApp.VIDEO_LIST_CONTAINER_DIV);
  519. }
  520. /**
  521. * Uses ytVideoApp.sendRequest to retrieve a users playlist.
  522. *
  523. */
  524. ytVideoApp.retrievePlaylists = function() {
  525. var filePath = 'operations.php';
  526. var params = 'operation=retrieve_playlists';
  527. ytVideoApp.hideNavigation();
  528. ytVideoApp.sendRequest(filePath, params, ytVideoApp.VIDEO_LIST_CONTAINER_DIV);
  529. }