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

OA系统

开发平台:

Java

  1. var devkit = parent.tinyMCE.plugins['devkit'], logEnabled = true, flip = false, book = null;
  2. function init() {
  3. var log, i, f = document.forms[0];
  4. devkit._winLoaded = true;
  5. log = tinyMCE.log;
  6. for (i=0; i<log.length; i++)
  7. debug(log[i]);
  8. f.logfilter.value = devkit._logFilter;
  9. }
  10. function changeFilter(f) {
  11. devkit._logFilter = f;
  12. }
  13. function toggleLog(s) {
  14. logEnabled = s;
  15. }
  16. function toggleFlip() {
  17. document.getElementById('flipbtn').src = flip ? 'images/flip_down.gif' : 'images/flip_up.gif';
  18. if (flip)
  19. parent.document.getElementById('devkit').className = 'devkitup';
  20. else
  21. parent.document.getElementById('devkit').className = 'devkitdown';
  22. flip = !flip;
  23. }
  24. function debug(s) {
  25. var d, l, n;
  26. if (!logEnabled || !new RegExp(devkit._logFilter, 'gi').test(s))
  27. return;
  28. d = document;
  29. l = d.getElementById('log');
  30. n = d.createElement('span');
  31. n.innerHTML = tinyMCE.xmlEncode(s);
  32. l.appendChild(n);
  33. l.scrollTop = l.scrollHeight;
  34. }
  35. function renderInfo() {
  36. var se = document.getElementById('info'), n, sn, inst, h = '', sel, rng, instCount = 0, rc;
  37. h += '<h2>Browser info:</h2>';
  38. h += '<table border="0" cellpadding="0" cellspacing="0" class="data">';
  39. h += addRenderInfo('navigator.userAgent', navigator.userAgent);
  40. h += addRenderInfo('navigator.appName', navigator.appName);
  41. h += addRenderInfo('navigator.platform', navigator.platform);
  42. h += addRenderInfo('navigator.language', navigator.language, 'bspec');
  43. h += addRenderInfo('navigator.browserLanguage', navigator.browserLanguage, 'bspec');
  44. h += addRenderInfo('navigator.systemLanguage', navigator.systemLanguage, 'bspec');
  45. h += addRenderInfo('navigator.userLanguage', navigator.userLanguage, 'bspec');
  46. h += addRenderInfo('opera.buildNumber("inconspicuous")', typeof(opera) != 'undefined' && opera.buildNumber ? opera.buildNumber('inconspicuous') : null, 'bspec');
  47. h += addRenderInfo('window.innerWidth', parent.window.innerWidth, 'bspec');
  48. h += addRenderInfo('window.innerHeight', parent.window.innerHeight, 'bspec');
  49. h += addRenderInfo('document.body.offsetWidth', parent.document.body.offsetWidth);
  50. h += addRenderInfo('document.body.offsetHeight', parent.document.body.offsetHeight);
  51. h += addRenderInfo('screen.width', screen.width);
  52. h += addRenderInfo('screen.height', screen.height);
  53. h += addRenderInfo('screen.availWidth', screen.availWidth);
  54. h += addRenderInfo('screen.availHeight', screen.availHeight);
  55. h += addRenderInfo('screen.colorDepth', screen.colorDepth);
  56. h += addRenderInfo('screen.pixelDepth', screen.pixelDepth, 'bspec');
  57. h += addRenderInfo('document.contentType', document.contentType, 'bspec');
  58. h += '</table>';
  59. h += '<h2>TinyMCE_Engine info:</h2>';
  60. h += '<table border="0" cellpadding="0" cellspacing="0" class="data">';
  61. h += addRenderInfo('baseURL', tinyMCE.baseURL);
  62. h += addRenderInfo('selectedInstance.editorId', tinyMCE.selectedInstance ? tinyMCE.selectedInstance.editorId : null);
  63. h += addRenderInfo('selectedElement.nodeName', tinyMCE.selectedElement ? tinyMCE.selectedElement.nodeName : null, 'dep');
  64. h += addRenderInfo('loadedFiles',tinyMCE.loadedFiles.join(','));
  65. h += addRenderInfo('isMSIE', tinyMCE.isMSIE);
  66. h += addRenderInfo('isMSIE5', tinyMCE.isMSIE5);
  67. h += addRenderInfo('isMSIE5_0', tinyMCE.isMSIE5_0);
  68. h += addRenderInfo('isMSIE7', tinyMCE.isMSIE7);
  69. h += addRenderInfo('isGecko', tinyMCE.isGecko);
  70. h += addRenderInfo('isSafari', tinyMCE.isSafari);
  71. h += addRenderInfo('isOpera', tinyMCE.isOpera);
  72. h += addRenderInfo('isMac', tinyMCE.isMac);
  73. h += addRenderInfo('isNS7', tinyMCE.isNS7);
  74. h += addRenderInfo('isNS71', tinyMCE.isNS71);
  75. h += addRenderInfo('idCounter', tinyMCE.idCounter);
  76. h += addRenderInfo('currentConfig', tinyMCE.currentConfig);
  77. h += addRenderInfo('majorVersion', tinyMCE.majorVersion);
  78. h += addRenderInfo('minorVersion', tinyMCE.minorVersion);
  79. h += addRenderInfo('releaseDate', tinyMCE.releaseDate);
  80. h += addRenderInfo('documentBasePath', tinyMCE.documentBasePath);
  81. h += addRenderInfo('documentURL', tinyMCE.documentURL);
  82. h += '</table>';
  83. for (n in tinyMCE.instances) {
  84. inst = tinyMCE.instances[n];
  85. if (!tinyMCE.isInstance(inst))
  86. continue;
  87. sel = inst.selection.getSel();
  88. rng = inst.selection.getRng();
  89. h += '<h2>TinyMCE_Control(' + (instCount++) + ') id: ' + inst.editorId + '</h2>';
  90. h += '<table border="0" cellpadding="0" cellspacing="0" class="data">';
  91. h += addRenderInfo('editorId', inst.editorId);
  92. h += addRenderInfo('visualAid', inst.visualAid);
  93. h += addRenderInfo('foreColor', inst.foreColor);
  94. h += addRenderInfo('backColor', inst.backColor);
  95. h += addRenderInfo('formTargetElementId', inst.formTargetElementId);
  96. h += addRenderInfo('formElement', inst.formElement ? inst.formElement.nodeName : null);
  97. h += addRenderInfo('oldTargetElement', inst.oldTargetElement ? inst.oldTargetElement.nodeName : null);
  98. h += addRenderInfo('linkElement', inst.linkElement ? inst.linkElement.nodeName : null, 'dep');
  99. h += addRenderInfo('imgElement', inst.imgElement ? inst.imgElement.nodeName : null, 'dep');
  100. h += addRenderInfo('selectedNode', inst.selectedNode ? inst.selectedNode.nodeName : null, 'dep');
  101. h += addRenderInfo('targetElement', inst.targetElement ? inst.targetElement.nodeName : null);
  102. h += addRenderInfo('getBody().nodeName', inst.getBody() ? inst.getBody().nodeName : null);
  103. h += addRenderInfo('getBody().getAttribute("id")', inst.getBody() ? inst.getBody().getAttribute("id") : null);
  104. h += addRenderInfo('getDoc().location', inst.getDoc() ? inst.getDoc().location : null);
  105. h += addRenderInfo('startContent', inst.startContent);
  106. h += addRenderInfo('isHidden()', inst.isHidden());
  107. h += addRenderInfo('isDirty()', inst.isDirty());
  108. h += addRenderInfo('undoRedo.undoLevels.length', inst.undoRedo.undoLevels.length);
  109. h += addRenderInfo('undoRedo.undoIndex', inst.undoRedo.undoIndex);
  110. h += addRenderInfo('selection.getSelectedHTML()', inst.selection.getSelectedHTML());
  111. h += addRenderInfo('selection.isCollapsed()', inst.selection.isCollapsed() || 'false');
  112. h += addRenderInfo('selection.getSelectedText()', inst.selection.getSelectedText());
  113. h += addRenderInfo('selection.getFocusElement().nodeName', inst.selection.getFocusElement().nodeName);
  114. h += addRenderInfo('selection.getFocusElement().outerHTML', tinyMCE.getOuterHTML(inst.selection.getFocusElement()));
  115. if ((tinyMCE.isGecko || tinyMCE.isOpera) && sel && rng) {
  116. h += addRenderInfo('selection.getSel().anchorNode.nodeName', sel.anchorNode ? sel.anchorNode.nodeName : null, 'bspec');
  117. h += addRenderInfo('selection.getSel().anchorOffset', sel.anchorOffset, 'bspec');
  118. h += addRenderInfo('selection.getSel().focusNode.nodeName', sel.focusNode ? sel.focusNode.nodeName : null, 'bspec');
  119. h += addRenderInfo('selection.getSel().focusOffset', sel.focusOffset, 'bspec');
  120. h += addRenderInfo('selection.getRng().startContainer.nodeName', rng.startContainer ? rng.startContainer.nodeName : null, 'bspec');
  121. h += addRenderInfo('selection.getRng().startOffset', rng.startOffset, 'bspec');
  122. h += addRenderInfo('selection.getRng().endContainer.nodeName', rng.endContainer ? rng.endContainer.nodeName : null, 'bspec');
  123. h += addRenderInfo('selection.getRng().endOffset', rng.endOffset, 'bspec');
  124. }
  125. if (typeof(rng.item) != 'undefined' || typeof(rng.htmlText) != 'undefined') {
  126. if (!rng.item) {
  127. h += addRenderInfo('selection.getSel().type', sel.type, 'bspec');
  128. h += addRenderInfo('selection.getRng().htmlText', rng.htmlText, 'bspec');
  129. h += addRenderInfo('selection.getRng().text', rng.text, 'bspec');
  130. } else
  131. h += addRenderInfo('selection.getRng().item(0).nodeName', rng.item(0).nodeName, 'bspec');
  132. }
  133. h += '</table>';
  134. }
  135. h += '<p>Fields marked in <strong class="bspec">gray</strong> is not cross browser and should be used with care.</p>';
  136. h += '<p>Fields marked <strong class="dep">red</strong> are marked deprecated and will be removed in the future.</p><br />';
  137. se.innerHTML = h;
  138. }
  139. function addRenderInfo(n, v, c) {
  140. return '<tr><td' + (c ? ' class="' + c + '"' : '')+ '>' + n + '</td><td><input type="text" value="' + tinyMCE.xmlEncode(v != null ? ('' + v).replace(/[rn]/g, '') : 'null') + '" /></td></tr>';
  141. }
  142. function renderSettings() {
  143. var se = document.getElementById('settings'), n, sn, inst, h = '', v;
  144. for (n in tinyMCE.instances) {
  145. inst = tinyMCE.instances[n];
  146. if (!tinyMCE.isInstance(inst))
  147. continue;
  148. h += '<h2>Instance id: ' + inst.editorId + '</h2>';
  149. h += '<table border="0" cellpadding="0" cellspacing="0" class="data">';
  150. for (sn in inst.settings) {
  151. v = inst.settings[sn];
  152. h += '<tr><td class="col1">' + tinyMCE.xmlEncode(sn) + '</td><td><input type="text" value="' + tinyMCE.xmlEncode(v) + '" /></td></tr>';
  153. }
  154. h += '</table>';
  155. }
  156. se.innerHTML = h;
  157. }
  158. function renderContent() {
  159. var se = document.getElementById('content'), n, inst, h = '';
  160. for (n in tinyMCE.instances) {
  161. inst = tinyMCE.instances[n];
  162. if (!tinyMCE.isInstance(inst))
  163. continue;
  164. h += '<h2>Instance id: ' + inst.editorId + '</h2>';
  165. h += '<h3>Start content - inst.startContent:</h3>';
  166. h += '<div>' + tinyMCE.xmlEncode(inst.startContent) + '</div>';
  167. h += '<h3>Raw content - inst.getBody().innerHTML or inst.getHTML(true):</h3>';
  168. h += '<div>' + tinyMCE.xmlEncode(inst.getHTML(true)) + '</div>';
  169. h += '<h3>Cleaned content - inst.getHTML():</h3>';
  170. h += '<div>' + tinyMCE.xmlEncode(inst.getHTML()) + '</div>';
  171. if (inst.serializedHTML) {
  172. h += '<h3>Serialized HTML content - inst.serializedHTML:</h3>';
  173. h += '<div>' + tinyMCE.xmlEncode(inst.serializedHTML) + '</div>';
  174. }
  175. }
  176. se.innerHTML = h;
  177. }
  178. function renderCommandStates() {
  179. var se = document.getElementById('command_states'), n, inst, h = '', v, ex;
  180. var cmds = new Array('2D-Position','AbsolutePosition','BackColor','BlockDirLTR','BlockDirRTL','Bold','BrowseMode','Copy','CreateBookmark','CreateLink','Cut','Delete','DirLTR','DirRTL','EditMode','enableInlineTableEditing','enableObjectResizing','FontName','FontSize','ForeColor','FormatBlock','Indent','InsertButton','InsertFieldset','InsertHorizontalRule','InsertIFrame','InsertImage','InsertInputButton','InsertInputCheckbox','InsertInputFileUpload','InsertInputHidden','InsertInputImage','InsertInputPassword','InsertInputRadio','InsertInputReset','InsertInputSubmit','InsertInputText','InsertMarquee','InsertOrderedList','InsertParagraph','InsertSelectDropdown','InsertSelectListbox','InsertTextArea','InsertUnorderedList','Italic','JustifyCenter','JustifyFull','JustifyLeft','JustifyNone','JustifyRight','LiveResize','MultipleSelection','Open','Outdent','OverWrite','Paste','PlayImage','Redo','Refresh','RemoveFormat','SaveAs','SelectAll','SizeToControl','SizeToControlHeight','SizeToControlWidth','Stop','StopImage','StrikeThrough','styleWithCSS','Subscript','Superscript','UnBookmark','Underline','Undo','Unlink','Unselect'), i;
  181. for (n in tinyMCE.instances) {
  182. inst = tinyMCE.instances[n];
  183. if (!tinyMCE.isInstance(inst))
  184. continue;
  185. h += '<h2>Instance id: ' + inst.editorId + '</h2>';
  186. h += '<table border="0" cellpadding="0" cellspacing="0" class="data">';
  187. for (i=0; i<cmds.length; i++) {
  188. v = null;
  189. try {
  190. v = tinyMCE.isGecko || inst.getDoc().queryCommandSupported(cmds[i]);
  191. v = v ? inst.queryCommandState(cmds[i]) : 'Not supported';
  192. } catch (ex) {
  193. v = 'Not supported';
  194. }
  195. h += '<tr><td><input type="text" value="' + tinyMCE.xmlEncode(cmds[i]) + '" /></td><td><input type="text" value="' + tinyMCE.xmlEncode(v) + '" /></td></tr>';
  196. }
  197. h += '</table>';
  198. }
  199. se.innerHTML = h;
  200. }
  201. function renderUndoRedo() {
  202. var se = document.getElementById('undo_redo'), inst, n, h = '', i, le, id, d, ur;
  203. var f = document.forms[0];
  204. if (tinyMCE.undoLevels) {
  205. le = tinyMCE.undoLevels;
  206. h += '<h2>Global undo/redo</h2>';
  207. h += '<table border="0" cellpadding="0" cellspacing="0" width="50%" class="data">';
  208. h += '<tr><td>undoLevels.length</td><td>' + le.length + '</td></tr>';
  209. h += '<tr><td>undoIndex</td><td>' + tinyMCE.undoIndex + '</td></tr>';
  210. h += '</table>';
  211. for (i=0; i<le.length; i++)
  212. h += '<h3>Level: ' + i + ', Instance: ' + (le[i] ? le[i].editorId : 'null') + '</h3>';
  213. }
  214. for (n in tinyMCE.instances) {
  215. inst = tinyMCE.instances[n];
  216. if (!tinyMCE.isInstance(inst))
  217. continue;
  218. ur = inst.undoRedo;
  219. le = ur.undoLevels;
  220. h += '<hr /><h2>Instance id: ' + inst.editorId + '</h2>';
  221. h += '<table border="0" cellpadding="0" cellspacing="0" width="50%" class="data">';
  222. h += '<tr><td>undoLevels.length</td><td>' + le.length + '</td></tr>';
  223. h += '<tr><td>undoIndex</td><td>' + ur.undoIndex + '</td></tr>';
  224. h += '<tr><td>typingUndoIndex</td><td>' + ur.typingUndoIndex + '</td></tr>';
  225. h += '<tr><td>undoRedo</td><td>' + ur.undoRedo + '</td></tr>';
  226. h += '</table>';
  227. for (i=0; i<le.length; i++) {
  228. h += '<h3>Level: ' + i + (!le[i].bookmark ? "" : " [bookmark]") + '</h3>';
  229. h += '<div class="undodata">' + tinyMCE.xmlEncode(le[i].content) + '</div>';
  230. if (i > 0 && f.undo_diff.checked) {
  231. d = diff_main(i > 0 ? le[i-1].content.replace(/[rn]+/g, '') : null, le[i].content.replace(/[rn]+/g, ''), false);
  232. diff_cleanup_semantic(d);
  233. h += '<h3>Diff ' + (i-1) + ',' + i + '</h3><div class="undodata">' + diff_prettyhtml(d) + '</div>';
  234. }
  235. }
  236. }
  237. se.innerHTML = h;
  238. }
  239. function clearLog() {
  240. document.getElementById('log').innerHTML = '';
  241. devkit._startTime = null;
  242. }
  243. function cancelAction() {
  244. parent.document.getElementById('devkit').style.display = 'none';
  245. }
  246. function toggleDebugEvents(s) {
  247. devkit._debugEvents(s);
  248. }
  249. function storeSelection() {
  250. book = tinyMCE.selectedInstance.selection.getBookmark();
  251. return false;
  252. }
  253. function restoreSelection() {
  254. tinyMCE.selectedInstance.selection.moveToBookmark(book);
  255. return false;
  256. }