media.js
上传用户:dlqqsh
上传日期:2021-11-13
资源大小:7840k
文件大小:17k
源码类别:

OA系统

开发平台:

Java

  1. var oldWidth, oldHeight;
  2. var url = tinyMCE.getParam("media_external_list_url");
  3. if (url != null) {
  4. // Fix relative
  5. if (url.charAt(0) != '/' && url.indexOf('://') == -1)
  6. url = tinyMCE.documentBasePath + "/" + url;
  7. document.write('<sc'+'ript language="javascript" type="text/javascript" src="' + url + '"></sc'+'ript>');
  8. }
  9. function init() {
  10. var pl = "", f, val;
  11. var type = "flash", fe, i;
  12. tinyMCEPopup.resizeToInnerSize();
  13. f = document.forms[0]
  14. fe = tinyMCE.selectedInstance.getFocusElement();
  15. if (/mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(tinyMCE.getAttrib(fe, 'class'))) {
  16. pl = "x={" + fe.title + "};";
  17. switch (tinyMCE.getAttrib(fe, 'class')) {
  18. case 'mceItemFlash':
  19. type = 'flash';
  20. break;
  21. case 'mceItemShockWave':
  22. type = 'shockwave';
  23. break;
  24. case 'mceItemWindowsMedia':
  25. type = 'wmp';
  26. break;
  27. case 'mceItemQuickTime':
  28. type = 'qt';
  29. break;
  30. case 'mceItemRealMedia':
  31. type = 'rmp';
  32. break;
  33. }
  34. document.forms[0].insert.value = tinyMCE.getLang('lang_update', 'Insert', true); 
  35. }
  36. document.getElementById('filebrowsercontainer').innerHTML = getBrowserHTML('filebrowser','src','media','media');
  37. document.getElementById('qtsrcfilebrowsercontainer').innerHTML = getBrowserHTML('qtsrcfilebrowser','qt_qtsrc','media','media');
  38. document.getElementById('bgcolor_pickcontainer').innerHTML = getColorPickerHTML('bgcolor_pick','bgcolor');
  39. var html = getMediaListHTML('filebrowser','src','media','media');
  40. if (html == "")
  41. document.getElementById("linklistrow").style.display = 'none';
  42. else
  43. document.getElementById("linklistcontainer").innerHTML = html;
  44. // Resize some elements
  45. if (isVisible('filebrowsercontainer'))
  46. document.getElementById('src').style.width = '230px';
  47. // Setup form
  48. if (pl != "") {
  49. pl = eval(pl);
  50. switch (type) {
  51. case "flash":
  52. setBool(pl, 'flash', 'play');
  53. setBool(pl, 'flash', 'loop');
  54. setBool(pl, 'flash', 'menu');
  55. setBool(pl, 'flash', 'swliveconnect');
  56. setStr(pl, 'flash', 'quality');
  57. setStr(pl, 'flash', 'scale');
  58. setStr(pl, 'flash', 'salign');
  59. setStr(pl, 'flash', 'wmode');
  60. setStr(pl, 'flash', 'base');
  61. setStr(pl, 'flash', 'flashvars');
  62. break;
  63. case "qt":
  64. setBool(pl, 'qt', 'loop');
  65. setBool(pl, 'qt', 'autoplay');
  66. setBool(pl, 'qt', 'cache');
  67. setBool(pl, 'qt', 'controller');
  68. setBool(pl, 'qt', 'correction');
  69. setBool(pl, 'qt', 'enablejavascript');
  70. setBool(pl, 'qt', 'kioskmode');
  71. setBool(pl, 'qt', 'autohref');
  72. setBool(pl, 'qt', 'playeveryframe');
  73. setBool(pl, 'qt', 'tarsetcache');
  74. setStr(pl, 'qt', 'scale');
  75. setStr(pl, 'qt', 'starttime');
  76. setStr(pl, 'qt', 'endtime');
  77. setStr(pl, 'qt', 'tarset');
  78. setStr(pl, 'qt', 'qtsrcchokespeed');
  79. setStr(pl, 'qt', 'volume');
  80. setStr(pl, 'qt', 'qtsrc');
  81. break;
  82. case "shockwave":
  83. setBool(pl, 'shockwave', 'sound');
  84. setBool(pl, 'shockwave', 'progress');
  85. setBool(pl, 'shockwave', 'autostart');
  86. setBool(pl, 'shockwave', 'swliveconnect');
  87. setStr(pl, 'shockwave', 'swvolume');
  88. setStr(pl, 'shockwave', 'swstretchstyle');
  89. setStr(pl, 'shockwave', 'swstretchhalign');
  90. setStr(pl, 'shockwave', 'swstretchvalign');
  91. break;
  92. case "wmp":
  93. setBool(pl, 'wmp', 'autostart');
  94. setBool(pl, 'wmp', 'enabled');
  95. setBool(pl, 'wmp', 'enablecontextmenu');
  96. setBool(pl, 'wmp', 'fullscreen');
  97. setBool(pl, 'wmp', 'invokeurls');
  98. setBool(pl, 'wmp', 'mute');
  99. setBool(pl, 'wmp', 'stretchtofit');
  100. setBool(pl, 'wmp', 'windowlessvideo');
  101. setStr(pl, 'wmp', 'balance');
  102. setStr(pl, 'wmp', 'baseurl');
  103. setStr(pl, 'wmp', 'captioningid');
  104. setStr(pl, 'wmp', 'currentmarker');
  105. setStr(pl, 'wmp', 'currentposition');
  106. setStr(pl, 'wmp', 'defaultframe');
  107. setStr(pl, 'wmp', 'playcount');
  108. setStr(pl, 'wmp', 'rate');
  109. setStr(pl, 'wmp', 'uimode');
  110. setStr(pl, 'wmp', 'volume');
  111. break;
  112. case "rmp":
  113. setBool(pl, 'rmp', 'autostart');
  114. setBool(pl, 'rmp', 'loop');
  115. setBool(pl, 'rmp', 'autogotourl');
  116. setBool(pl, 'rmp', 'center');
  117. setBool(pl, 'rmp', 'imagestatus');
  118. setBool(pl, 'rmp', 'maintainaspect');
  119. setBool(pl, 'rmp', 'nojava');
  120. setBool(pl, 'rmp', 'prefetch');
  121. setBool(pl, 'rmp', 'shuffle');
  122. setStr(pl, 'rmp', 'console');
  123. setStr(pl, 'rmp', 'controls');
  124. setStr(pl, 'rmp', 'numloop');
  125. setStr(pl, 'rmp', 'scriptcallbacks');
  126. break;
  127. }
  128. setStr(pl, null, 'src');
  129. setStr(pl, null, 'id');
  130. setStr(pl, null, 'name');
  131. setStr(pl, null, 'vspace');
  132. setStr(pl, null, 'hspace');
  133. setStr(pl, null, 'bgcolor');
  134. setStr(pl, null, 'align');
  135. setStr(pl, null, 'width');
  136. setStr(pl, null, 'height');
  137. if ((val = tinyMCE.getAttrib(fe, "width")) != "")
  138. pl.width = f.width.value = val;
  139. if ((val = tinyMCE.getAttrib(fe, "height")) != "")
  140. pl.height = f.height.value = val;
  141. oldWidth = pl.width ? parseInt(pl.width) : 0;
  142. oldHeight = pl.height ? parseInt(pl.height) : 0;
  143. } else
  144. oldWidth = oldHeight = 0;
  145. selectByValue(f, 'media_type', type);
  146. changedType(type);
  147. updateColor('bgcolor_pick', 'bgcolor');
  148. TinyMCE_EditableSelects.init();
  149. generatePreview();
  150. }
  151. function insertMedia() {
  152. var fe, f = document.forms[0], h;
  153. if (!AutoValidator.validate(f)) {
  154. alert(tinyMCE.getLang('lang_invalid_data'));
  155. return false;
  156. }
  157. f.width.value = f.width.value == "" ? 100 : f.width.value;
  158. f.height.value = f.height.value == "" ? 100 : f.height.value;
  159. fe = tinyMCE.selectedInstance.getFocusElement();
  160. if (fe != null && /mceItem(Flash|ShockWave|WindowsMedia|QuickTime|RealMedia)/.test(tinyMCE.getAttrib(fe, 'class'))) {
  161. switch (f.media_type.options[f.media_type.selectedIndex].value) {
  162. case "flash":
  163. fe.className = "mceItemFlash";
  164. break;
  165. case "shockwave":
  166. fe.className = "mceItemShockWave";
  167. break;
  168. case "qt":
  169. fe.className = "mceItemQuickTime";
  170. break;
  171. case "wmp":
  172. fe.className = "mceItemWindowsMedia";
  173. break;
  174. case "rmp":
  175. fe.className = "mceItemRealMedia";
  176. break;
  177. }
  178. if (fe.width != f.width.value || fe.height != f.width.height)
  179. tinyMCE.selectedInstance.repaint();
  180. fe.title = serializeParameters();
  181. fe.width = f.width.value;
  182. fe.height = f.height.value;
  183. fe.style.width = f.width.value + (f.width.value.indexOf('%') == -1 ? 'px' : '');
  184. fe.style.height = f.height.value + (f.height.value.indexOf('%') == -1 ? 'px' : '');
  185. fe.align = f.align.options[f.align.selectedIndex].value;
  186. } else {
  187. h = '<img src="' + tinyMCE.getParam("theme_href") + '/images/spacer.gif"' ;
  188. switch (f.media_type.options[f.media_type.selectedIndex].value) {
  189. case "flash":
  190. h += ' class="mceItemFlash"';
  191. break;
  192. case "shockwave":
  193. h += ' class="mceItemShockWave"';
  194. break;
  195. case "qt":
  196. h += ' class="mceItemQuickTime"';
  197. break;
  198. case "wmp":
  199. h += ' class="mceItemWindowsMedia"';
  200. break;
  201. case "rmp":
  202. h += ' class="mceItemRealMedia"';
  203. break;
  204. }
  205. h += ' title="' + serializeParameters() + '"';
  206. h += ' width="' + f.width.value + '"';
  207. h += ' height="' + f.height.value + '"';
  208. h += ' align="' + f.align.options[f.align.selectedIndex].value + '"';
  209. h += ' />';
  210. tinyMCE.selectedInstance.execCommand('mceInsertContent', false, h);
  211. }
  212. tinyMCEPopup.close();
  213. }
  214. function getMediaListHTML() {
  215. if (typeof(tinyMCEMediaList) != "undefined" && tinyMCEMediaList.length > 0) {
  216. var html = "";
  217. html += '<select id="linklist" name="linklist" style="width: 250px" onfocus="tinyMCE.addSelectAccessibility(event, this, window);" onchange="this.form.src.value=this.options[this.selectedIndex].value;">';
  218. html += '<option value="">---</option>';
  219. for (var i=0; i<tinyMCEMediaList.length; i++)
  220. html += '<option value="' + tinyMCEMediaList[i][1] + '">' + tinyMCEMediaList[i][0] + '</option>';
  221. html += '</select>';
  222. return html;
  223. }
  224. return "";
  225. }
  226. function getType(v) {
  227. var fo = tinyMCE.getParam("media_types", "flash=swf;shockwave=dcr;qt=mov,qt,mpg,mp3,mp4,mpeg;shockwave=dcr;wmp=avi,wmv,wm,asf,asx,wmx,wvx;rmp=rm,ra,ram").split(';'), i, c, el, x;
  228. for (i=0; i<fo.length; i++) {
  229. c = fo[i].split('=');
  230. el = c[1].split(',');
  231. for (x=0; x<el.length; x++)
  232. if (v.indexOf('.' + el[x]) != -1)
  233. return c[0];
  234. }
  235. return null;
  236. }
  237. function switchType(v) {
  238. var t = getType(v), d = document, f = d.forms[0];
  239. if (!t)
  240. return;
  241. selectByValue(d.forms[0], 'media_type', t);
  242. changedType(t);
  243. // Update qtsrc also
  244. if (t == 'qt' && f.src.value.toLowerCase().indexOf('rtsp://') != -1) {
  245. alert(tinyMCE.getLang("lang_media_qt_stream_warn"));
  246. if (f.qt_qtsrc.value == '')
  247. f.qt_qtsrc.value = f.src.value;
  248. }
  249. }
  250. function changedType(t) {
  251. var d = document;
  252. d.getElementById('flash_options').style.display = 'none';
  253. d.getElementById('qt_options').style.display = 'none';
  254. d.getElementById('shockwave_options').style.display = 'none';
  255. d.getElementById('wmp_options').style.display = 'none';
  256. d.getElementById('rmp_options').style.display = 'none';
  257. d.getElementById(t + '_options').style.display = 'block';
  258. }
  259. function serializeParameters() {
  260. var d = document, f = d.forms[0], s = '';
  261. switch (f.media_type.options[f.media_type.selectedIndex].value) {
  262. case "flash":
  263. s += getBool('flash', 'play', true);
  264. s += getBool('flash', 'loop', true);
  265. s += getBool('flash', 'menu', true);
  266. s += getBool('flash', 'swliveconnect', false);
  267. s += getStr('flash', 'quality');
  268. s += getStr('flash', 'scale');
  269. s += getStr('flash', 'salign');
  270. s += getStr('flash', 'wmode');
  271. s += getStr('flash', 'base');
  272. s += getStr('flash', 'flashvars');
  273. break;
  274. case "qt":
  275. s += getBool('qt', 'loop', false);
  276. s += getBool('qt', 'autoplay', false);
  277. s += getBool('qt', 'cache', false);
  278. s += getBool('qt', 'controller', true);
  279. s += getBool('qt', 'correction', false, 'none', 'full');
  280. s += getBool('qt', 'enablejavascript', false);
  281. s += getBool('qt', 'kioskmode', false);
  282. s += getBool('qt', 'autohref', false);
  283. s += getBool('qt', 'playeveryframe', false);
  284. s += getBool('qt', 'targetcache', false);
  285. s += getStr('qt', 'scale');
  286. s += getStr('qt', 'starttime');
  287. s += getStr('qt', 'endtime');
  288. s += getStr('qt', 'target');
  289. s += getStr('qt', 'qtsrcchokespeed');
  290. s += getStr('qt', 'volume');
  291. s += getStr('qt', 'qtsrc');
  292. break;
  293. case "shockwave":
  294. s += getBool('shockwave', 'sound');
  295. s += getBool('shockwave', 'progress');
  296. s += getBool('shockwave', 'autostart');
  297. s += getBool('shockwave', 'swliveconnect');
  298. s += getStr('shockwave', 'swvolume');
  299. s += getStr('shockwave', 'swstretchstyle');
  300. s += getStr('shockwave', 'swstretchhalign');
  301. s += getStr('shockwave', 'swstretchvalign');
  302. break;
  303. case "wmp":
  304. s += getBool('wmp', 'autostart', true);
  305. s += getBool('wmp', 'enabled', false);
  306. s += getBool('wmp', 'enablecontextmenu', true);
  307. s += getBool('wmp', 'fullscreen', false);
  308. s += getBool('wmp', 'invokeurls', true);
  309. s += getBool('wmp', 'mute', false);
  310. s += getBool('wmp', 'stretchtofit', false);
  311. s += getBool('wmp', 'windowlessvideo', false);
  312. s += getStr('wmp', 'balance');
  313. s += getStr('wmp', 'baseurl');
  314. s += getStr('wmp', 'captioningid');
  315. s += getStr('wmp', 'currentmarker');
  316. s += getStr('wmp', 'currentposition');
  317. s += getStr('wmp', 'defaultframe');
  318. s += getStr('wmp', 'playcount');
  319. s += getStr('wmp', 'rate');
  320. s += getStr('wmp', 'uimode');
  321. s += getStr('wmp', 'volume');
  322. break;
  323. case "rmp":
  324. s += getBool('rmp', 'autostart', false);
  325. s += getBool('rmp', 'loop', false);
  326. s += getBool('rmp', 'autogotourl', true);
  327. s += getBool('rmp', 'center', false);
  328. s += getBool('rmp', 'imagestatus', true);
  329. s += getBool('rmp', 'maintainaspect', false);
  330. s += getBool('rmp', 'nojava', false);
  331. s += getBool('rmp', 'prefetch', false);
  332. s += getBool('rmp', 'shuffle', false);
  333. s += getStr('rmp', 'console');
  334. s += getStr('rmp', 'controls');
  335. s += getStr('rmp', 'numloop');
  336. s += getStr('rmp', 'scriptcallbacks');
  337. break;
  338. }
  339. s += getStr(null, 'id');
  340. s += getStr(null, 'name');
  341. s += getStr(null, 'src');
  342. s += getStr(null, 'align');
  343. s += getStr(null, 'bgcolor');
  344. s += getInt(null, 'vspace');
  345. s += getInt(null, 'hspace');
  346. s += getStr(null, 'width');
  347. s += getStr(null, 'height');
  348. s = s.length > 0 ? s.substring(0, s.length - 1) : s;
  349. return s;
  350. }
  351. function setBool(pl, p, n) {
  352. if (typeof(pl[n]) == "undefined")
  353. return;
  354. document.forms[0].elements[p + "_" + n].checked = pl[n];
  355. }
  356. function setStr(pl, p, n) {
  357. var f = document.forms[0], e = f.elements[(p != null ? p + "_" : '') + n];
  358. if (typeof(pl[n]) == "undefined")
  359. return;
  360. if (e.type == "text")
  361. e.value = pl[n];
  362. else
  363. selectByValue(f, (p != null ? p + "_" : '') + n, pl[n]);
  364. }
  365. function getBool(p, n, d, tv, fv) {
  366. var v = document.forms[0].elements[p + "_" + n].checked;
  367. tv = typeof(tv) == 'undefined' ? 'true' : "'" + jsEncode(tv) + "'";
  368. fv = typeof(fv) == 'undefined' ? 'false' : "'" + jsEncode(fv) + "'";
  369. return (v == d) ? '' : n + (v ? ':' + tv + ',' : ':' + fv + ',');
  370. }
  371. function getStr(p, n, d) {
  372. var e = document.forms[0].elements[(p != null ? p + "_" : "") + n];
  373. var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value;
  374. return ((n == d || v == '') ? '' : n + ":'" + jsEncode(v) + "',");
  375. }
  376. function getInt(p, n, d) {
  377. var e = document.forms[0].elements[(p != null ? p + "_" : "") + n];
  378. var v = e.type == "text" ? e.value : e.options[e.selectedIndex].value;
  379. return ((n == d || v == '') ? '' : n + ":" + v.replace(/[^0-9]+/g, '') + ",");
  380. }
  381. function jsEncode(s) {
  382. s = s.replace(new RegExp('\\', 'g'), '\\');
  383. s = s.replace(new RegExp('"', 'g'), '\"');
  384. s = s.replace(new RegExp("'", 'g'), "\'");
  385. return s;
  386. }
  387. function generatePreview(c) {
  388. var f = document.forms[0], p = document.getElementById('prev'), h = '', cls, pl, n, type, codebase, wp, hp, nw, nh;
  389. p.innerHTML = '<!-- x --->';
  390. nw = parseInt(f.width.value);
  391. nh = parseInt(f.height.value);
  392. if (f.width.value != "" && f.height.value != "") {
  393. if (f.constrain.checked) {
  394. if (c == 'width' && oldWidth != 0) {
  395. wp = nw / oldWidth;
  396. nh = Math.round(wp * nh);
  397. f.height.value = nh;
  398. } else if (c == 'height' && oldHeight != 0) {
  399. hp = nh / oldHeight;
  400. nw = Math.round(hp * nw);
  401. f.width.value = nw;
  402. }
  403. }
  404. }
  405. if (f.width.value != "")
  406. oldWidth = nw;
  407. if (f.height.value != "")
  408. oldHeight = nh;
  409. // After constrain
  410. pl = serializeParameters();
  411. switch (f.media_type.options[f.media_type.selectedIndex].value) {
  412. case "flash":
  413. cls = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';
  414. codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0';
  415. type = 'application/x-shockwave-flash';
  416. break;
  417. case "shockwave":
  418. cls = 'clsid:166B1BCA-3F9C-11CF-8075-444553540000';
  419. codebase = 'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0';
  420. type = 'application/x-director';
  421. break;
  422. case "qt":
  423. cls = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';
  424. codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0';
  425. type = 'video/quicktime';
  426. break;
  427. case "wmp":
  428. cls = tinyMCE.getParam('media_wmp6_compatible') ? 'clsid:05589FA1-C356-11CE-BF01-00AA0055595A' : 'clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6';
  429. codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';
  430. type = 'application/x-mplayer2';
  431. break;
  432. case "rmp":
  433. cls = 'clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA';
  434. codebase = 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701';
  435. type = 'audio/x-pn-realaudio-plugin';
  436. break;
  437. }
  438. if (pl == '') {
  439. p.innerHTML = '';
  440. return;
  441. }
  442. pl = eval('x={' + pl + '};');
  443. if (!pl.src) {
  444. p.innerHTML = '';
  445. return;
  446. }
  447. pl.src = tinyMCE.convertRelativeToAbsoluteURL(tinyMCE.settings['base_href'], pl.src);
  448. pl.width = !pl.width ? 100 : pl.width;
  449. pl.height = !pl.height ? 100 : pl.height;
  450. pl.id = !pl.id ? 'obj' : pl.id;
  451. pl.name = !pl.name ? 'eobj' : pl.name;
  452. pl.align = !pl.align ? '' : pl.align;
  453. h += '<object classid="clsid:' + cls + '" codebase="' + codebase + '" width="' + pl.width + '" height="' + pl.height + '" id="' + pl.id + '" name="' + pl.name + '" align="' + pl.align + '">';
  454. for (n in pl) {
  455. h += '<param name="' + n + '" value="' + pl[n] + '">';
  456. // Add extra url parameter if it's an absolute URL
  457. if (n == 'src' && pl[n].indexOf('://') != -1)
  458. h += '<param name="url" value="' + pl[n] + '" />';
  459. }
  460. h += '<embed type="' + type + '" ';
  461. for (n in pl)
  462. h += n + '="' + pl[n] + '" ';
  463. h += '></embed></object>';
  464. p.innerHTML = "<!-- x --->" + h;
  465. }