api2.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. function startup(){
  2. }
  3. function NotImplementedYet(){
  4. alert("This method has not been implemented yet");
  5. }
  6. function tStopClicked(){
  7. var t_rc = window.external.Transport.Stop();
  8. }
  9. function tPlayClicked(){
  10. var t_rc = window.external.Transport.Play();
  11. }
  12. function tPauseClicked(){
  13. var t_rc = window.external.Transport.Pause();
  14. }
  15. function tPrevClicked(){
  16. var t_rc = window.external.Transport.Prev();
  17. }
  18. function tNextClicked(){
  19. var t_rc = window.external.Transport.Next();
  20. }
  21. function tGetMetadataClicked(){
  22. var metaTag = document.getElementById("t_t_mTag_in").value;
  23. var metadata = window.external.Transport.GetMetadata(metaTag);
  24. document.getElementById("t_t_mTag_Response").value = metadata;
  25. }
  26. function tGetShuffleClicked(){
  27. var t_shuffle = window.external.Transport.shuffle;
  28. document.getElementById("t_t_shuffle").value = t_shuffle;
  29. }
  30. function tSetShuffleClicked(){
  31. var t_shuffle = document.getElementById("t_t_shuffle_in").value;
  32. if (t_shuffle == "true") window.external.Transport.shuffle = true;
  33. else window.external.Transport.shuffle = false;
  34. tGetShuffleClicked();
  35. }
  36. function tGetRepeatClicked(){
  37. var t_repeat = window.external.Transport.repeat;
  38. document.getElementById("t_t_repeat").value = t_repeat;
  39. }
  40. function tSetRepeatClicked(){
  41. var t_repeat = document.getElementById("t_t_repeat_in").value;
  42. if (t_repeat == "true") window.external.Transport.repeat = true;
  43. else window.external.Transport.repeat = false;
  44. tGetRepeatClicked();
  45. }
  46. function tGetPositionClicked(){
  47. var t_position = window.external.Transport.position;
  48. document.getElementById("t_t_position").value = t_position;
  49. }
  50. function tSetPositionClicked(){
  51. var t_position = document.getElementById("t_t_position_in").value;
  52. window.external.Transport.position = parseInt(t_position);
  53. tGetPositionClicked();
  54. }
  55. function tLengthClicked(){
  56. var length = window.external.Transport.length;
  57. document.getElementById("t_t_Length").value = length;
  58. }
  59. function tURLClicked(){
  60. var url = window.external.Transport.url;
  61. document.getElementById("t_t_URL").value = url;
  62. }
  63. function tTitleClicked(){
  64. var title = window.external.Transport.title;
  65. document.getElementById("t_t_Title").value = title;
  66. }
  67. function tPlayingClicked(){
  68. var playing = window.external.Transport.playing;
  69. document.getElementById("t_t_Playing").value = playing;
  70. }
  71. function tPausedClicked(){
  72. var paused = window.external.Transport.paused;
  73. document.getElementById("t_t_Paused").value = paused;
  74. }
  75. function pqPlayClicked() {
  76. var myMusic = document.getElementById("pq_t_PlayURL_in").value;
  77. var title = document.getElementById("pq_t_PlayTitle_in").value
  78. var length = document.getElementById("pq_t_PlayLength_in").value;
  79. var ilength = parseInt(length);
  80. if (isNaN(ilength)) {ilength = 0;}
  81. var pq_play = window.external.PlayQueue.Play(myMusic, title, ilength);
  82. }
  83. function pqEnqueueClicked() {
  84. var myMusic = document.getElementById("pq_t_EnqueueURL_in").value;
  85. var title = document.getElementById("pq_t_EnqueueTitle_in").value
  86. var length = document.getElementById("pq_t_EnqueueLength_in").value;
  87. var ilength = parseInt(length);
  88. if (isNaN(ilength)) {ilength = 0};
  89. var pq_play = window.external.PlayQueue.Enqueue(myMusic, title, ilength);
  90. }
  91. function pqInsertClicked() {
  92. var position = document.getElementById("pq_t_InsertPosition_in").value;
  93. var iposition = parseInt(position);
  94. if (isNaN(iposition)) {iposition = 0;}
  95. var myMusic = document.getElementById("pq_t_InsertURL_in").value;
  96. var title = document.getElementById("pq_t_InsertTitle_in").value
  97. var length = document.getElementById("pq_t_InsertLength_in").value;
  98. var ilength = parseInt(length);
  99. if (isNaN(ilength)) {ilength = 0;}
  100. var pq_play = window.external.PlayQueue.Insert(iposition, myMusic, title, ilength);
  101. }
  102. function pqClearQClicked() {
  103. var pq_rc = window.external.PlayQueue.ClearQueue();
  104. }
  105. function pqGetMetadataClicked(){
  106. var metaPos = document.getElementById("pq_t_MetadataPosition_in").value;
  107. var imetaPos = parseInt(metaPos);
  108. var metaTag = document.getElementById("pq_t_MTag_in").value;
  109. var metadata = window.external.PlayQueue.GetMetadata(imetaPos, metaTag);
  110. document.getElementById("pq_t_MTag_Response").value = metadata;
  111. }
  112. function pqGetTitleClicked(){
  113. var position = document.getElementById("pq_t_TitlePosition_in").value;
  114. var iposition = parseInt(position);
  115. var title = window.external.PlayQueue.GetTitle(iposition);
  116. document.getElementById("pq_t_Title").value = title;
  117. }
  118. function pqGetURLClicked() {
  119. var position = document.getElementById("pq_t_URLPosition_in").value;
  120. var iposition = parseInt(position);
  121. var url = window.external.PlayQueue.GetURL(iposition);
  122. document.getElementById("pq_t_URL").value = url;
  123. }
  124. function pqGetLengthClicked(){
  125. var length = window.external.PlayQueue.length;
  126. document.getElementById("pq_t_Length").value = length;
  127. }
  128. function pqGetCursorClicked(){
  129. var cursor = window.external.PlayQueue.cursor;
  130. document.getElementById("pq_t_Cursor").value = cursor;
  131. }
  132. function pqSetCursorClicked(){
  133. var pq_cursor = document.getElementById("pq_t_Cursor_in").value;
  134. window.external.PlayQueue.cursor = parseInt(pq_cursor);
  135. pqGetCursorClicked();
  136. }
  137. var listPlaylists;
  138. function plsGetPlaylists(){
  139. listPlaylists = window.external.Playlists.GetPlaylists();
  140. var numPlaylists = listPlaylists.length;
  141. document.getElementById("pls_t_Count").value = numPlaylists;
  142. }
  143. function plsViewIndexClicked(){
  144. var view_index = document.getElementById("pls_t_Index_in").value;
  145. var iview_index = parseInt(view_index);
  146. document.getElementById("pls_t_Filename").value = listPlaylists[iview_index].filename;
  147. document.getElementById("pls_t_Title").value = listPlaylists[iview_index].title;
  148. document.getElementById("pls_t_PlaylistId").value = listPlaylists[iview_index].playlistId;
  149. document.getElementById("pls_t_Length").value = listPlaylists[iview_index].length;
  150. document.getElementById("pls_t_NumItems").value = listPlaylists[iview_index].numitems;
  151. document.getElementById("pls_t_OpenPlaylistId_in").value = listPlaylists[iview_index].playlistId;
  152. document.getElementById("pls_t_SavePlaylistId_in").value = listPlaylists[iview_index].playlistId;
  153. }
  154. var currentPlaylist;
  155. function plsOpenPlaylistClicked(){
  156. var id = document.getElementById("pls_t_OpenPlaylistId_in").value;
  157. currentPlaylist = window.external.Playlists.OpenPlaylist(id);
  158. document.getElementById("playlist_t_NumItems").value = currentPlaylist.numitems;
  159. plsDisableListMethods(false);
  160. showPlaylist();
  161. }
  162. var currentItemIndex = 0;
  163. function plsDisablePlaylistMethods(disable){
  164. var playlistSection = document.getElementById("playlistmethods");
  165. playlistSection.disabled = disable;
  166. for (var i=0; i < playlistSection.childNodes.length; i++){
  167. if (playlistSection.childNodes[i].nodeType == 1) {
  168. playlistSection.childNodes[i].disabled = disable;
  169. }
  170. }
  171. }
  172. function plsDisableListMethods(disable){
  173. var listSection = document.getElementById("listmethods");
  174. listSection.disabled = disable;
  175. for (var i=0; i < listSection.childNodes.length; i++){
  176. if (listSection.childNodes[i].nodeType == 1) {
  177. listSection.childNodes[i].disabled = disable;
  178. }
  179. }
  180. }
  181. function plsPlaylistViewIndexClicked(){
  182. var view_index = document.getElementById("playlist_t_ItemIndex_in").value;
  183. var iview_index = parseInt(view_index);
  184. currentItemIndex = iview_index;
  185. document.getElementById("playlist_t_Filename").value = currentPlaylist.GetItemFilename(currentItemIndex);
  186. document.getElementById("playlist_t_Title").value = currentPlaylist.GetItemTitle(currentItemIndex);
  187. document.getElementById("playlist_t_Length").value = currentPlaylist.GetItemLength(currentItemIndex);
  188. plsDisablePlaylistMethods(false);
  189. showPlaylist();
  190. }
  191. var playlistwin;
  192. var playlistWinShown = false;
  193. function showPlaylist(){
  194. var output = "";
  195. for (var i = 0; i < currentPlaylist.numitems; i++) {
  196. var title = currentPlaylist.GetItemTitle(i);
  197. output += i + ":" + title + "\n";
  198. }
  199. alert(output);
  200. }
  201. function plsPlaylistSetItemFilenameClicked(){
  202. var filename = document.getElementById("playlist_t_SetItemFilename_in").value;
  203. currentPlaylist.SetItemFilename(currentItemIndex, filename);
  204. document.getElementById("playlist_t_Filename").value = filename;
  205. }
  206. function plsPlaylistSetItemTitleClicked(){
  207. var title = document.getElementById("playlist_t_SetItemTitle_in").value;
  208. currentPlaylist.SetItemTitle(currentItemIndex, title);
  209. document.getElementById("playlist_t_Title").value = title;
  210. }
  211. function plsPlaylistSetItemLengthClicked(){
  212. var length = document.getElementById("playlist_t_SetItemLength_in").value;
  213. var iLength = parseInt(length);
  214. currentPlaylist.SetItemLengthMilliseconds(currentItemIndex, iLength);
  215. document.getElementById("playlist_t_Length").value = length;
  216. }
  217. function plsPlaylistReverseClicked(){
  218. currentPlaylist.Reverse();
  219. showPlaylist();
  220. }
  221. function plsPlaylistSwapItemsClicked(){
  222. var swap1 = document.getElementById("playlist_t_Swap1_in").value;
  223. var swap2 = document.getElementById("playlist_t_Swap2_in").value;
  224. var iswap1 = parseInt(swap1);
  225. var iswap2 = parseInt(swap2);
  226. var rc = currentPlaylist.SwapItems(iswap1, iswap2);
  227. showPlaylist();
  228. }
  229. function plsPlaylistRandomizeClicked(){
  230. currentPlaylist.Randomize();
  231. showPlaylist();
  232. }
  233. function plsPlaylistRemoveClicked(){
  234. alert("Inside Remove, currentItemIndex=" + currentItemIndex);
  235. currentPlaylist.RemoveItem(currentItemIndex);
  236. showPlaylist();
  237. }
  238. function plsPlaylistSortByTitleClicked(){
  239. currentPlaylist.SortByTitle();
  240. showPlaylist();
  241. }
  242. function plsPlaylistSortByFilenameClicked(){
  243. currentPlaylist.SortByFilename();
  244. showPlaylist();
  245. }
  246. function plsPlaylistInsertUrlClicked(){
  247. var url = document.getElementById("playlist_t_InsertUrl_in").value;
  248. var title = document.getElementById("playlist_t_InsertTitle_in").value;
  249. var length = document.getElementById("playlist_t_InsertLength_in").value;
  250. var iLength = parseInt(length);
  251. var rc = currentPlaylist.InsertURL(currentItemIndex, url, title, iLength);
  252. showPlaylist();
  253. }
  254. function plsPlaylistAppendUrlClicked(){
  255. var url = document.getElementById("playlist_t_AppendUrl_in").value;
  256. var title = document.getElementById("playlist_t_AppendTitle_in").value;
  257. var length = document.getElementById("playlist_t_AppendLength_in").value;
  258. var iLength = parseInt(length);
  259. var rc = currentPlaylist.AppendURL(url, title, iLength);
  260. showPlaylist();
  261. }
  262. function plsPlaylistClearClicked(){
  263. var rc = currentPlaylist.Clear();
  264. showPlaylist();
  265. }
  266. function plsSavePlaylistClicked() {
  267. var playlistId = document.getElementById("pls_t_SavePlaylistId_in").value;
  268. var rc = window.external.Playlists.SavePlaylist(playlistId, currentPlaylist);
  269. document.getElementById("playlistmethods").disabled = true;
  270. }
  271. function BMarkAddClicked(){
  272. var url = document.getElementById("bmark_t_AddURL_in").value;
  273. var title = document.getElementById("bmark_t_AddTitle_in").value;
  274. var rc = window.external.Bookmarks.Add(url, title);
  275. }
  276. function PodcastSubscribeClicked(){
  277. var podcUrl = document.getElementById("podc_t_SubscribeURL_in").value;
  278. var rc = window.external.Podcasts.Subscribe(podcUrl);
  279. }
  280. function ConfigSetPropertyClicked(){
  281. var inParam = document.getElementById("config_t_SetPropertyName_in").value;
  282. var inValue = document.getElementById("config_t_SetPropertyValue_in").value;
  283. if (pType[0].checked) {
  284. inValue = "'" + inValue + "'";
  285. } else if (pType[2].checked){
  286. if (inValue != "false"){
  287. inValue = "true";
  288. }
  289. }
  290. var funcBody = "var rc = window.external.Config." + inParam + "=" + inValue;
  291. var configPropSet = new Function(funcBody);
  292. configPropSet();
  293. }
  294. function ConfigGetPropertyClicked(){
  295. var inParam = document.getElementById("config_t_GetPropertyName_in").value;
  296. var funcBody = "return window.external.Config." + inParam;
  297. var configPropGet = new Function(funcBody);
  298. var propValue = configPropGet();
  299. document.getElementById("config_t_GetPropertyValue").value = propValue;
  300. }
  301. function ApplicationLaunchURLClicked(){
  302. var url = document.getElementById("application_t_URL_in").value;
  303. var forceExternal = document.getElementById("application_t_ForceExternal_in").checked;
  304. var rc = window.external.Application.LaunchURL(url, forceExternal);
  305. }
  306. function ApplicationNumVersionClicked(){
  307. var numVer = window.external.Application.version;
  308. document.getElementById("application_t_NumVersion").value = parseInt(numVer);
  309. }
  310. function ApplicationStringVersionClicked(){
  311. var stringVer = window.external.Application.versionstring;
  312. document.getElementById("application_t_StringVersion").value = stringVer;
  313. }
  314. function ApplicationLanguageClicked(){
  315. var lang = window.external.Application.language;
  316. document.getElementById("application_t_Language").value = lang;
  317. }
  318. function ApplicationLanguagePackClicked(){
  319. var langPack = window.external.Application.languagepack;
  320. document.getElementById("application_t_LanguagePack").value = langPack;
  321. }
  322. function SkinGetClassicColorClicked(){
  323. var colorNum = document.getElementById("skin_t_ClassicColorNumber_in").value;
  324. var iColorNum = parseInt(colorNum);
  325. var classicColor = window.external.Skin.GetClassicColor(iColorNum);
  326. document.getElementById("skin_t_ClassicColor").value = classicColor;
  327. }
  328. function SkinGetPlaylistColorClicked(){
  329. var colorNum = document.getElementById("skin_t_PlaylistColorNumber_in").value;
  330. var iColorNum = parseInt(colorNum);
  331. var playlistColor = window.external.Skin.GetPlaylistColor(iColorNum);
  332. document.getElementById("skin_t_PlaylistColor").value = playlistColor;
  333. }
  334. function SkinGetSkinColorClicked(){
  335. var colorName = document.getElementById("skin_t_SkinColorName_in").value;
  336. var skinColor = window.external.Skin.GetSkinColor(colorName);
  337. document.getElementById("skin_t_SkinColor").value = skinColor;
  338. }
  339. function SkinGetNameClicked(){
  340. var name = window.external.Skin.name;
  341. document.getElementById("skin_t_Name").value = name;
  342. }
  343. function SkinSetNameClicked() {
  344. var skinName = document.getElementById("skin_t_Name_in").value;
  345. window.external.Skin.name = skinName;
  346. }
  347. function SkinGetFontClicked(){
  348. var font = window.external.Skin.font;
  349. document.getElementById("skin_t_Font").value = font;
  350. }
  351. function SkinGetFontSizeClicked(){
  352. var fontsize = window.external.Skin.fontsize;
  353. document.getElementById("skin_t_FontSize").value = fontsize;
  354. }
  355. function mcGetMetadataClicked(){
  356. var metaFile = document.getElementById("mc_t_MediaCoreFilename_in").value;
  357. var metaTag = document.getElementById("mc_t_MediaCoreTag_in").value;
  358. var metadata = window.external.MediaCore.GetMetadata(metaFile, metaTag);
  359. document.getElementById("mc_t_MediaCoreMetadata_Response").value = metadata;
  360. }
  361. function mcIsRegisteredExtensionClicked(){
  362. var extension = document.getElementById("mc_t_MediaCoreExtension_in").value;
  363. var supported = window.external.MediaCore.IsRegisteredExtension(extension);
  364. document.getElementById("mc_t_MediaCoreRegisteredExtension_Response").value = supported;
  365. }
  366. function mcAddMetadataHookClicked(){
  367. var mUrl = document.getElementById("mc_t_AddMetadataHookUrl_in").value;
  368. var mTag = document.getElementById("mc_t_AddMetadataHookTag_in").value;
  369. var mValue = document.getElementById("mc_t_AddMetadataHookValue_in").value;
  370. window.external.MediaCore.AddMetadataHook(mUrl,mTag,mValue);
  371. }
  372. function mcRemoveMetadataHookClicked(){
  373. var mUrl = document.getElementById("mc_t_RemoveMetadataHookUrl_in").value;
  374. var mTag = document.getElementById("mc_t_RemoveMetadataHookTag_in").value;
  375. window.external.MediaCore.RemoveMetadataHook(mUrl,mTag);
  376. }
  377. function teRegisterClicked(){
  378. var rc = window.external.Transport.RegisterForEvents(onEvents);
  379. document.getElementById("teRegister").disabled = true;
  380. document.getElementById("teUnregister").disabled = false;
  381. }
  382. function teUnregisterClicked(){
  383. var rc = window.external.Transport.UnregisterFromEvents(onEvents);
  384. document.getElementById("teRegister").disabled = false;
  385. document.getElementById("teUnregister").disabled = true;
  386. }
  387. var eventsArray = new Array();
  388. var eventCount = 0;
  389. function onEvents(event){
  390. eventsArray[eventCount] = event;
  391. // populate the select box
  392. var eventSelect = document.getElementById("te_s_Select");
  393. var newOption = new Option((eventCount + 1) + ":" + event.event, event);
  394. eventSelect.options[eventCount] = newOption;
  395. eventCount++;
  396. }
  397. function teEventSelected(){
  398. var sel = document.getElementById("te_s_Select");
  399. var area = document.getElementById("te_ta_Area");
  400. var tarea = "";
  401. var obj = eventsArray[sel.selectedIndex];
  402. for (var prop in obj){
  403. tarea += "property:" + prop + " value:" + obj[prop] + "\n\n";
  404. }
  405. area.value = tarea;
  406. }
  407. function te_AreaCleared(){
  408. eventCount = 0;
  409. document.getElementById("te_ta_Area").value = "";
  410. document.getElementById("te_s_Select").options.length = 0;
  411. }
  412. function hisQueryClicked(){
  413. var query = document.getElementById("his_t_Query_in").value;
  414. var respArray = window.external.History.Query(query);
  415. alert(respArray[0].filename);
  416. var textOut = "";
  417. for (var obj in respArray){
  418. if (textOut != ""){
  419. textOut += "\n";
  420. }
  421. textOut += "==============";
  422. textOut += "\nTitle: " + respArray[obj].title;
  423. textOut += "\nLastPlay: " + respArray[obj].lastplay;
  424. textOut += "\nPlaycount: " + respArray[obj].playcount;
  425. textOut += "\nFilename: " + respArray[obj].filename;
  426. textOut += "\nLength: " + respArray[obj].length;
  427. }
  428. var textAreaOut = document.getElementById("his_t_Query");
  429. textAreaOut.value = textOut;
  430. }
  431. function AsyncDownloadMediaClicked(){
  432. var url = document.getElementById("asyncdownloader_t_URL_in").value;
  433. var destFile = document.getElementById("asyncdownloader_t_DestinationFile_in").value;
  434. document.getElementById("progressbar").firstChild.nodeValue = "";
  435. document.getElementById("slider").style.clip = "rect(0px 0px 16px 0px)";
  436. if (destFile)
  437. var rc = window.external.AsyncDownloader.DownloadMedia(url, destFile);
  438. else
  439. var rc = window.external.AsyncDownloader.DownloadMedia(url);
  440. }
  441. function AsyncDownloadMediaClicked1(){
  442. var url = document.getElementById("asyncdownloader_t_URL_in_1").value;
  443. var destFile = document.getElementById("asyncdownloader_t_DestinationFile_in_1").value;
  444. document.getElementById("progressbar1").firstChild.nodeValue = "";
  445. document.getElementById("slider1").style.clip = "rect(0px 0px 16px 0px)";
  446. if (destFile)
  447. var rc = window.external.AsyncDownloader.DownloadMedia(url, destFile);
  448. else
  449. var rc = window.external.AsyncDownloader.DownloadMedia(url);
  450. }
  451. function AsyncDownloadMultipleMediaClicked() {
  452. var multipleUrls = document.getElementById("multiple_urls").value;
  453. var urls = multipleUrls.split(";");
  454. for(index = 0; index < urls.length; index++){
  455. if (urls[index].length > 0) {
  456. if (urls[index].indexOf("http://") != -1) urls[index] = urls[index].substr(7);
  457. var rc = window.external.AsyncDownloader.DownloadMedia("http://"+escape(urls[index]));
  458. }
  459. }
  460. }
  461. function downloaderRegisterClicked(){
  462. var rc = window.external.AsyncDownloader.RegisterForEvents(onDownloaderEvents);
  463. document.getElementById("downloaderRegister").disabled = true;
  464. document.getElementById("downloaderUnregister").disabled = false;
  465. }
  466. function downloaderUnregisterClicked(){
  467. var rc = window.external.AsyncDownloader.UnregisterFromEvents(onDownloaderEvents);
  468. document.getElementById("downloaderRegister").disabled = false;
  469. document.getElementById("downloaderUnregister").disabled = true;
  470. }
  471. var downloaderEventsArray = new Array();
  472. var downloaderEventCount = 0;
  473. function downloader_AreaCleared(){
  474. downloaderEventCount = 0;
  475. document.getElementById("downloader_ta_Area").value = "";
  476. document.getElementById("downloader_s_Select").options.length = 0;
  477. }
  478. function onDownloaderEvents(event){
  479. downloaderEventsArray[downloaderEventCount] = event;
  480. // populate the select box
  481. var eventSelect = document.getElementById("downloader_s_Select");
  482. var newOption = new Option((downloaderEventCount + 1) + ":" + event.event, event);
  483. eventSelect.options[downloaderEventCount] = newOption;
  484. downloaderEventCount++;
  485. var progress, slider;
  486. if (event.url == document.getElementById("asyncdownloader_t_URL_in").value)
  487. {
  488. progress = document.getElementById("progressbar");
  489. slider = document.getElementById("slider");
  490. }
  491. if (event.url == document.getElementById("asyncdownloader_t_URL_in_1").value)
  492. {
  493. progress = document.getElementById("progressbar1");
  494. slider = document.getElementById("slider1");
  495. }
  496. if (progress && slider)
  497. {
  498. if (event.event == 'OnInit')
  499. {
  500. progress.firstChild.nodeValue = 'Progress: Start downloading ...';
  501. }
  502. if (event.event == 'OnData')
  503. {
  504. progress.firstChild.nodeValue = 'Progress: Downloading ...';
  505. var factor = event.downloadedlen/event.totallen;
  506. slider.firstChild.nodeValue = Math.ceil(factor * 100) + '%';
  507. slider.style.clip = "rect(0px " + parseInt(factor * 417) + "px 16px 0px)";
  508. }
  509. if (event.event == 'OnFinish')
  510. {
  511. progress.firstChild.nodeValue = 'Progress: Downloading Succeed';
  512. slider.firstChild.nodeValue = '100%';
  513. }
  514. if (event.event == 'OnError' || event.event == 'OnCancel')
  515. {
  516. progress.firstChild.nodeValue = 'Progress: Downloading Failed';
  517. }
  518. }
  519. }
  520. function downloaderEventSelected(){
  521. var sel = document.getElementById("downloader_s_Select");
  522. var area = document.getElementById("downloader_ta_Area");
  523. var tarea = "";
  524. var obj = downloaderEventsArray[sel.selectedIndex];
  525. if (obj.url)
  526. tarea += "property:url value:" + obj.url + "\n\n";
  527. if (obj.event == 'OnData')
  528. {
  529. tarea += "property:downloadedlen value:" + obj.downloadedlen + "\n\n";
  530. tarea += "property:totallen value:" + obj.totallen + "\n\n";
  531. }
  532. if (obj.event == 'OnFinish')
  533. tarea += "property:destfilename value:" + obj.destfilename + "\n\n";
  534. if (obj.event == 'OnError')
  535. tarea += "property:error value:" + obj.error + "\n\n";
  536. area.value = tarea;
  537. }