PageRenderTime 25ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/chrome/content/zk/codepress/index.html

https://gitlab.com/BGCX261/zkjet-git
HTML | 443 lines | 371 code | 65 blank | 7 comment | 0 complexity | 8c97ffc51d851f159a1c4d284bf78cf2 MD5 | raw file
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html>
  3. <head>
  4. <title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
  5. <style>
  6. body {color:#000;background-color:white;font:15px georgia, "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif; letter-spacing:0.01em;margin:15px;}
  7. p {margin:0 0 15px 0;}
  8. a,a:visited {color:#7f0055;}
  9. select {background:#ffffe1;}
  10. button {margin-top:5px;}
  11. button.actions {width:171px;font-family:arial;}
  12. h1 {color:#7f0055;margin:0;padding:0;font-size:42px;font-weight:normal;}
  13. h1 a {text-decoration:none;}
  14. h2 {margin:0;}
  15. h2 a {text-decoration:none;font-weight:normal;font-size:22px;color:black !important;}
  16. h3 {font-size:20px;font-weight:normal;padding:0;margin:25px 0 5px 0;color:#7f0055;font-weight:bold;border-bottom:2px dotted #d8d8d8;}
  17. h4 {font-size:18px;font-weight:normal;z-index:0;}
  18. code {color:#0080c0;font-size:13px;font-weight:bold;}
  19. ol, ul {padding:5px 0 5px 25px;margin:0;}
  20. ol li, ul li {margin:8px 0 8px 0;}
  21. #logo {text-align:center;background-color:#d6d6d6;padding:10px;-moz-border-radius:5px;border:1px solid silver;}
  22. #container {width:700px;margin:20px auto;padding:25px;border:3px solid #d9d9d9;-moz-border-radius:10px;background:#f8f8f8;}
  23. #languages {margin:5px 0;}
  24. #menu {width:100%;background:#7f0055;-moz-border-radius:4px;}
  25. #menu a {font:bold 17px georgia;color:white;padding:4px;display:block;border-left:1px solid white;text-align:center;text-decoration:none;}
  26. #menu a:hover {background:#b9669e;}
  27. .hidden-code {display:none;}
  28. .copycode {border:1px dotted gray;padding:10px;background:white;font-family:monospace;color:gray}
  29. </style>
  30. </head>
  31. <body>
  32. <div id="container">
  33. <div id="logo">
  34. <h1><a href="http://codepress.org/">CodePress</a></h1>
  35. <h2><a href="http://codepress.org/">Online Real Time Syntax Highlighting Editor</a></h2>
  36. </div>
  37. <br />
  38. <table cellpadding="0" cellspacing="0" id="menu">
  39. <tr>
  40. <td>
  41. <a href="http://www.codepress.org/index.php">Home/Download</a>
  42. </td>
  43. <td>
  44. <a href="http://www.codepress.org/install.php">&nbsp;&nbsp;Install&nbsp;&nbsp;</a>
  45. </td>
  46. <td>
  47. <a href="http://www.codepress.org/to-do.php">&nbsp;&nbsp;To-do&nbsp;&nbsp;</a>
  48. </td>
  49. <td>
  50. <a href="http://www.codepress.org/about.php" id="about">&nbsp;&nbsp;About&nbsp;&nbsp;</a>
  51. </td>
  52. </tr>
  53. </table>
  54. <h4>
  55. CodePress is web-based source code editor with syntax highlighting written in JavaScript that colors text in real time while it's being typed in the browser.
  56. </h4>
  57. <p>
  58. Go to <strong><a href="http://codepress.org/">http://codepress.org/</a></strong> for updates.
  59. </p>
  60. <h3>Demo</h3>
  61. <div id="languages">
  62. <em>choose example in:</em>
  63. <button onclick="cp1.edit('cp-php','php')">PHP</button>
  64. <button onclick="cp1.edit('cp-javascript','javascript')">JavaScript</button>
  65. <button onclick="cp1.edit('cp-java','java')">Java</button>
  66. <button onclick="cp1.edit('cp-perl','perl')">Perl</button>
  67. <button onclick="cp1.edit('cp-sql','sql')">SQL</button>
  68. <button onclick="cp1.edit('cp-html','html')">HTML</button>
  69. <button onclick="cp1.edit('cp-css','css')">CSS</button>
  70. </div>
  71. <textarea id="cp1" class="codepress php" style="width:700px;height:300px;" wrap="off">
  72. <?php
  73. // Very simple implementation of server side script
  74. if(isset($_GET['file'])) {
  75. $file = basename($_GET['file']);
  76. $full_file = $path['server'].'/'.$path['webdocs'].'/'.$path['files']."/".$file;
  77. if(file_exists($full_file)) {
  78. $code = file_get_contents($full_file);
  79. $code = preg_replace("/>/","&amp;gt;",$code);
  80. $code = preg_replace("/</","&amp;lt;",$code);
  81. $language = getLanguage($file);
  82. }
  83. }
  84. ?>
  85. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  86. <html>
  87. <head>
  88. <title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
  89. <link type="text/css" href="languages/codepress-<?=$language?>.css" rel="stylesheet" id="cp-lang-style" />
  90. <script type="text/javascript" src="codepress.js"></script>
  91. <script type="text/javascript">
  92. CodePress.language = '<?=$language?>';
  93. </script>
  94. </head>
  95. <body id="ffedt"><pre id="ieedt"><?=$code?></pre></body>
  96. </html>
  97. </textarea>
  98. <br /><br />
  99. <textarea id="codepress2" class="codepress javascript" style="width:700px;height:200px;" wrap="off">
  100. //set language
  101. this.setLanguage = function() {
  102. if(arguments[0]) {
  103. language = (typeof(Content.languages[arguments[0]])!='undefined') ? arguments[0] : this.setLanguage();
  104. cpLanguage.innerHTML = Content.languages[language].name;
  105. if(cpBody.document.designMode=='on') cpBody.document.designMode = 'off';
  106. CodePress.loadScript(cpBody.document, '../languages/'+language+'.js', function () { cpBody.CodePress.syntaxHighlight('init'); })
  107. cpBody.document.getElementById('cp-lang-style').href = '../languages/'+language+'.css';
  108. this.hideMenu();
  109. }
  110. else {
  111. var extension = filename.replace(/.*\.([^\.]+)$/,'$1');
  112. var aux = false;
  113. for(lang in Content.languages) {
  114. extensions = ','+Content.languages[lang].extensions+',';
  115. if(extensions.match(','+extension+',')) aux = lang;
  116. }
  117. language = (aux) ? aux : 'generic';
  118. }
  119. }
  120. </textarea>
  121. <p>
  122. <button class="actions" onclick="alert(codepress2.getCode())">get code from editor</button>
  123. <button class="actions" onclick="codepress2.toggleEditor()">turn on/off CodePress</button>
  124. <button class="actions" onclick="codepress2.toggleLineNumbers()">show/hide line numbers</button>
  125. <button class="actions" onclick="codepress2.toggleAutoComplete()">turn on/off auto-complete</button>
  126. <button class="actions" onclick="codepress2.toggleReadOnly()">turn on/off read only</button>
  127. </p>
  128. <h3>Installation</h3>
  129. <ol>
  130. <li>
  131. <p>
  132. <a href="http://codepress.org/">Download</a> and uncompress CodePress under a directory inside your webserver.<br>
  133. Example:<strong> http://yourserver/codepress/</strong><br />
  134. Since CodePress is pure JavaScript and HTML, you can also test it without a webserver.
  135. </p>
  136. </li>
  137. <li>
  138. <p>
  139. Insert CodePress script somewhere in your page inside the <code>&lt;head&gt;</code> or above the <code>&lt;/body&gt;</code> tag.
  140. </p>
  141. <p class="copycode">
  142. &lt;script src="/codepress/codepress.js" type="text/javascript"&gt;&lt;/script&gt;
  143. </p>
  144. </li>
  145. <li>
  146. <p>
  147. Add the <code>&lt;textarea&gt;</code> tag to the place on your page you want CodePress to appear. CodePress will inherit the width and height of your textarea.
  148. When the page loads, it will automatically replace your textarea with a CodePress window.
  149. </p>
  150. <p class="copycode">
  151. &lt;textarea id="myCpWindow" class="codepress javascript linenumbers-off"&gt;<br />
  152. &nbsp;&nbsp;&nbsp;// your code here<br />
  153. &lt;/textarea&gt;
  154. </p>
  155. <ul>
  156. <li>
  157. The <code>javascript</code> portion of the class="" means that the language being edited is JavaScript.
  158. </li>
  159. <li>
  160. The <code>codepress</code> portion of the class="" is mandatory and indicates a textarea to be replaced for a CodePress window.
  161. </li>
  162. <li>
  163. Other class options are <code>linenumbers-off</code>, <code>autocomplete-off</code> and <code>readonly-on</code>.
  164. </li>
  165. <li>
  166. Careful not to use the same id for two different CodePress windows (<code>&lt;textarea id="<strong>xx</strong>"...&gt;</code>)
  167. </li>
  168. </ul>
  169. </li>
  170. </ol>
  171. <h3>You also can...</h3>
  172. <ol>
  173. <li>
  174. Open/edit code from a different textarea.<br />
  175. Example: <code>textarea_id.edit('other_textarea_id','language')</code><br>
  176. </li>
  177. <li>
  178. Get code from CodePress window.<br />
  179. Example: <code>textarea_id.getCode()</code><br>
  180. </li>
  181. <li>
  182. Turn on/off CodePress editor and return to the regular textarea.<br />
  183. Example: <code>textarea_id.toggleEditor()</code><br>
  184. </li>
  185. <li>
  186. Turn on/off line numbers.<br />
  187. Example: <code>textarea_id.toggleLineNumbers()</code><br>
  188. </li>
  189. <li>
  190. Turn on/off read only.<br />
  191. Example: <code>textarea_id.toggleReadOnly()</code><br>
  192. </li>
  193. <li>
  194. Turn on/off auto-complete.<br />
  195. Example: <code>textarea_id.toggleAutoComplete()</code><br>
  196. </li>
  197. </ol>
  198. <!-- p>
  199. You may want to use [id].getCode() to get the content code from CodePress window and save it to your server since CodePress only edit files and do not save them.
  200. </p>
  201. <p>
  202. You may also want to open files from server. You'll have to write a server side script and replace the JavaScript call on codepress.js from codepress.html to codepress.php (if your server side language is PHP, of course).
  203. </p -->
  204. <h3>License</h3>
  205. <p>
  206. CodePress is distributed under the <a href="http://www.opensource.org/licenses/lgpl-license.php">LGPL</a>. If your software is <a href="http://www.gnu.org/philosophy/license-list.html#GPLCompatibleLicenses">compatible</a> with this licence or it is under <a href="http://creativecommons.org/">Creative Commons</a>, you can use it as you want. Just keep the credits somewhere around.
  207. </p>
  208. </div><!--/container-->
  209. <!-- hidden codes for loading -->
  210. <textarea id="cp-php" class="hidden-code">
  211. <?php
  212. // Very simple implementation of server side script
  213. if(isset($_GET['file'])) {
  214. $file = basename($_GET['file']);
  215. $full_file = $path['server'].'/'.$path['webdocs'].'/'.$path['files']."/".$file;
  216. if(file_exists($full_file)) {
  217. $code = file_get_contents($full_file);
  218. $code = preg_replace("/>/","&amp;gt;",$code);
  219. $code = preg_replace("/</","&amp;lt;",$code);
  220. $language = getLanguage($file);
  221. }
  222. }
  223. ?>
  224. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  225. <html>
  226. <head>
  227. <title>CodePress - Real Time Syntax Highlighting Editor written in JavaScript</title>
  228. <link type="text/css" href="languages/codepress-<?=$language?>.css" rel="stylesheet" id="cp-lang-style" />
  229. <script type="text/javascript" src="codepress.js"></script>
  230. <script type="text/javascript">
  231. CodePress.language = '<?=$language?>';
  232. </script>
  233. </head>
  234. <body id="ffedt"><pre id="ieedt"><?=$code?></pre></body>
  235. </html>
  236. </textarea>
  237. <textarea id="cp-javascript" class="hidden-code">
  238. CodePress = function(obj) {
  239. var self = document.createElement('iframe');
  240. self.textarea = obj;
  241. self.textarea.disabled = true;
  242. self.style.height = self.textarea.clientHeight +'px';
  243. self.style.width = self.textarea.clientWidth +'px';
  244. self.initialize = function() {
  245. self.editor = self.contentWindow.CodePress;
  246. self.editor.body = self.contentWindow.document.getElementsByTagName('body')[0];
  247. self.editor.setCode(self.textarea.value);
  248. self.editor.syntaxHighlight('init');
  249. }
  250. self.edit = function(id,language) {
  251. self.language = (language) ? language : self.textarea.className.replace(/ ?codepress ?/,'');
  252. self.src = cpPath+'modules/codepress.html?engine='+self.getEngine()+'&language='+self.language;
  253. if(self.attachEvent) self.attachEvent('onload',self.initialize);
  254. else self.addEventListener('load',self.initialize,false);
  255. }
  256. }
  257. </textarea>
  258. <textarea id="cp-autoit" class="hidden-code">
  259. #include
  260. IsNumber(15)
  261. @Macro
  262. ;comment
  263. $var = "string"
  264. </textarea>
  265. <textarea id="cp-java" class="hidden-code">
  266. import java.io.FileFilter;
  267. import java.io.IOException;
  268. import java.io.PrintWriter;
  269. /**
  270. * Project ECCO - File manager class
  271. * @author Fernando M.A.d.S.
  272. */
  273. public class FileManager extends HttpServlet {
  274. private static final long serialVersionUID = 1L;
  275. private static String login = "feanndor"; // session var should come here
  276. private static String usersPath = System.getProperty("user.dir")+File.separator+"htdocs"+File.separator+"ecco"+File.separator+"users"+File.separator;
  277. private static File dir = new File(usersPath+login+File.separator);
  278. static boolean existDirectories = false;
  279. static int isDirectory = 0;
  280. public FileFilter filterFiles(File dir) {
  281. return (new FileFilter() {
  282. public boolean accept(File pathname) {
  283. return !(pathname.isDirectory());
  284. }
  285. });
  286. }
  287. }
  288. </textarea>
  289. <textarea id="cp-perl" class="hidden-code">
  290. #!/usr/bin/perl
  291. # The first line of the script envokes Perl
  292. # Scalar variables
  293. $var1 = "Hello World";
  294. $var2 = 14.6;
  295. # Array variables
  296. @arr1 = ("zero","one","two","three","four");
  297. # Hash variable, or associative array
  298. %hash1 = ("one","Monday","two", "Tuesday","three", "Wednesday","four","Thursday");
  299. # Some simple printing
  300. print $var1;
  301. # Subroutine
  302. sub test() {
  303. print "ok";
  304. }
  305. </textarea>
  306. <textarea id="cp-sql" class="hidden-code">
  307. --
  308. -- simple select example
  309. --
  310. SELECT * FROM books
  311. WHERE price > 100.00 and price < 150.00
  312. ORDER BY title
  313. SELECT books.title, count(*) AS Authors
  314. FROM books
  315. JOIN book_authors
  316. ON books.book_number = book_authors.book_number
  317. GROUP BY books.title
  318. -- insert, update and delete examples
  319. INSERT INTO my_table (field1, field2, field3) VALUES ('test', 'N', NULL);
  320. BEGIN WORK;
  321. UPDATE inventory SET quantity = quantity - 3 WHERE item = 'pants';
  322. COMMIT;
  323. </textarea>
  324. <textarea id="cp-html" class="hidden-code">
  325. <html>
  326. <head>
  327. <title>CodePress - Online Real Time Syntax Highlighting Editor</title>
  328. <style type="text/css">
  329. @import url(styles.css);
  330. </style>
  331. <script type="text/javascript">
  332. function getCode() {
  333. alert(textWithoutHighlighting);
  334. }
  335. </script>
  336. </head>
  337. <body>
  338. <div id="logo">
  339. <h1><a href="http://codepress.org/">CodePress</a></h1>
  340. <h2>Online Real Time Syntax Highlighting Editor</h2>
  341. <img src="testimage.gif" />
  342. </div>
  343. <div id="languages">
  344. <em>choose language:</em>
  345. <button onclick="edit('codepress.php',this)" id="default">PHP</button>
  346. <button onclick="edit('FileManager.java',this)">Java</button>
  347. </div>
  348. </body>
  349. </html>
  350. </textarea>
  351. <textarea id="cp-css" class="hidden-code">
  352. /* CSS comment */
  353. body {
  354. color:#000;
  355. background-color:white;
  356. font:15px Georgia, "Lucida Grande", Arial, sans-serif;
  357. letter-spacing:0.01em;
  358. margin:15px;
  359. }
  360. p {
  361. margin:0 0 15px 0;
  362. }
  363. a,a:visited {
  364. color:#7f0055;
  365. }
  366. select {
  367. background:#ffffe1;
  368. }
  369. h1 {
  370. color:#7f0055;
  371. margin:0;
  372. padding:0;
  373. font-size:42px;
  374. }
  375. </textarea>
  376. <script src="codepress.js" type="text/javascript"></script>
  377. </body>
  378. </html>