PageRenderTime 48ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/www/filemanager/editarea/exemples/exemple_full.html

http://github.com/thickpaddy/speck
HTML | 274 lines | 240 code | 34 blank | 0 comment | 0 complexity | ac07c189d9cfad7470efa5e261599965 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 xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  5. <title>EditArea - the code editor in a textarea</title>
  6. <script language="Javascript" type="text/javascript" src="../edit_area/edit_area_full.js"></script>
  7. <script language="Javascript" type="text/javascript">
  8. // initialisation
  9. editAreaLoader.init({
  10. id: "example_1" // id of the textarea to transform
  11. ,start_highlight: true // if start with highlight
  12. ,allow_resize: "both"
  13. ,allow_toggle: true
  14. ,language: "en"
  15. ,syntax: "php"
  16. });
  17. editAreaLoader.init({
  18. id: "example_2" // id of the textarea to transform
  19. ,start_highlight: true
  20. ,allow_toggle: false
  21. ,language: "en"
  22. ,syntax: "html"
  23. ,toolbar: "search, go_to_line, |, undo, redo, |, select_font, |, syntax_selection, |, change_smooth_selection, highlight, reset_highlight, |, help"
  24. ,syntax_selection_allow: "css,html,js,php,python,vb,xml,c,cpp,sql,basic,pas,brainfuck"
  25. ,is_multi_files: true
  26. ,EA_load_callback: "editAreaLoaded"
  27. ,show_line_colors: true
  28. });
  29. editAreaLoader.init({
  30. id: "example_3" // id of the textarea to transform
  31. ,start_highlight: true
  32. ,font_size: "8"
  33. ,font_family: "verdana, monospace"
  34. ,allow_resize: "y"
  35. ,allow_toggle: false
  36. ,language: "fr"
  37. ,syntax: "css"
  38. ,toolbar: "new_document, save, load, |, charmap, |, search, go_to_line, |, undo, redo, |, select_font, |, change_smooth_selection, highlight, reset_highlight, |, help"
  39. ,load_callback: "my_load"
  40. ,save_callback: "my_save"
  41. ,plugins: "charmap"
  42. ,charmap_default: "arrows"
  43. });
  44. editAreaLoader.init({
  45. id: "example_4" // id of the textarea to transform
  46. //,start_highlight: true // if start with highlight
  47. //,font_size: "10"
  48. ,allow_resize: "no"
  49. ,allow_toggle: true
  50. ,language: "de"
  51. ,syntax: "python"
  52. ,load_callback: "my_load"
  53. ,save_callback: "my_save"
  54. ,display: "later"
  55. ,replace_tab_by_spaces: 4
  56. ,min_height: 350
  57. });
  58. // callback functions
  59. function my_save(id, content){
  60. alert("Here is the content of the EditArea '"+ id +"' as received by the save callback function:\n"+content);
  61. }
  62. function my_load(id){
  63. editAreaLoader.setValue(id, "The content is loaded from the load_callback function into EditArea");
  64. }
  65. function test_setSelectionRange(id){
  66. editAreaLoader.setSelectionRange(id, 100, 150);
  67. }
  68. function test_getSelectionRange(id){
  69. var sel =editAreaLoader.getSelectionRange(id);
  70. alert("start: "+sel["start"]+"\nend: "+sel["end"]);
  71. }
  72. function test_setSelectedText(id){
  73. text= "[REPLACED SELECTION]";
  74. editAreaLoader.setSelectedText(id, text);
  75. }
  76. function test_getSelectedText(id){
  77. alert(editAreaLoader.getSelectedText(id));
  78. }
  79. function editAreaLoaded(id){
  80. if(id=="example_2")
  81. {
  82. open_file1();
  83. open_file2();
  84. }
  85. }
  86. function open_file1()
  87. {
  88. var new_file= {id: "to\\ é # € to", text: "$authors= array();\n$news= array();", syntax: 'php', title: 'beautiful title'};
  89. editAreaLoader.openFile('example_2', new_file);
  90. }
  91. function open_file2()
  92. {
  93. var new_file= {id: "Filename", text: "<a href=\"toto\">\n\tbouh\n</a>\n<!-- it's a comment -->", syntax: 'html'};
  94. editAreaLoader.openFile('example_2', new_file);
  95. }
  96. function close_file1()
  97. {
  98. editAreaLoader.closeFile('example_2', "to\\ é # € to");
  99. }
  100. function toogle_editable(id)
  101. {
  102. editAreaLoader.execCommand(id, 'set_editable', !editAreaLoader.execCommand(id, 'is_editable'));
  103. }
  104. </script>
  105. </head>
  106. <body>
  107. <h2>EditArea examples</h2>
  108. <p>Retrieve EditArea on <a href='http://sourceforge.net/projects/editarea'>sourceforge</a> or on
  109. my personal <a href='http://www.cdolivet.net/index.php?page=editArea'>website</a>.
  110. </p>
  111. <form action='' method='post'>
  112. <fieldset>
  113. <legend>Example 1</legend>
  114. <p>Test in English with php syntax, highlighted, toggle enabled, resize enabled and default toolbar. Also offer the possibility to switch on/off the readonly mode.</p>
  115. <textarea id="example_1" style="height: 350px; width: 100%;" name="test_1">
  116. <?php
  117. $authors= array();
  118. $news= array();
  119. $query="SELECT author, COUNT(id) as 'nb_news' FROM news_messages GROUP BY author";
  120. $result=mysql_query($query, $DBnews);
  121. while($line = mysql_fetch_assoc($result)){
  122. $authors[$line["author"]]= $line["author"];
  123. $news[$line["author"]]=$line['nb_news'];
  124. }
  125. $list= sprintf("('%s')", implode("', '", $authors));
  126. $query="SELECT p.people_id, p.name, p.fname, p.status, team_name, t.leader_id=p.people_id as 'team_leader', w.name as 'wp_name', w.type
  127. FROM people p, teams t, wppartis wp, wps w
  128. WHERE p.people_id IN $list AND p.org_id=t.team_id AND wp.team_id=t.team_id AND wp.wp_id=w.wp_id
  129. GROUP BY p.people_id";
  130. if(isset($_GET["order"]) && $_GET["order"]!="nb_news")
  131. $query.=" ORDER BY ".$_GET["order"];
  132. $result=mysql_query($query, $DBkal);
  133. while($line = mysql_fetch_assoc($result)){
  134. printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>", $line["name"], $line["fname"],
  135. $news[$line["people_id"]], $line["status"], $line["team_name"], ($line["team_leader"]=="1")?"yes":"no", $line["type"], $line["wp_name"]);
  136. }
  137. printf("</table>");
  138. ?>
  139. </textarea>
  140. <p>Custom controls:<br />
  141. <input type='button' onclick='alert(editAreaLoader.getValue("example_1"));' value='get value' />
  142. <input type='button' onclick='editAreaLoader.setValue("example_1", "new_value");' value='set value' />
  143. <input type='button' onclick='test_getSelectionRange("example_1");' value='getSelectionRange' />
  144. <input type='button' onclick='test_setSelectionRange("example_1");' value='setSelectionRange' />
  145. <input type='button' onclick='test_getSelectedText("example_1");' value='getSelectedText' />
  146. <input type='button' onclick='test_setSelectedText("example_1");' value='setSelectedText' />
  147. <input type='button' onclick='editAreaLoader.insertTags("example_1", "[OPEN]", "[CLOSE]");' value='insertTags' />
  148. <input type='button' onclick='toogle_editable("example_1");' value='Toggle readonly mode' />
  149. </p>
  150. </fieldset>
  151. <fieldset>
  152. <legend>Example 2</legend>
  153. <p>Multi file mode example with syntax selection option. The highlight colors of the selected line is also shown.</p>
  154. <textarea id="example_2" style="height: 250px; width: 100%;" name="test_2">
  155. </textarea>
  156. <p>Custom controls:<br />
  157. <input type='button' onclick='open_file1()' value='open file 1' />
  158. <input type='button' onclick='open_file2()' value='open file 2' />
  159. <input type='button' onclick='close_file1()' value='close file 1' />
  160. </p>
  161. </fieldset>
  162. <fieldset>
  163. <legend>Example 3</legend>
  164. <p>Test in French with css syntax, verdana font, smaller default font size, toggle disabled, vertical only resize, custom toolbar, visual keyboard plugin, save and load callback examples.</p>
  165. <textarea id="example_3" style="height: 350px; width: 100%;" name="test_3">
  166. /* toolbar buttons (inspired from tinyMCE ones)*/
  167. .editAreaButtonNormal, .editAreaButtonOver, .editAreaButtonDown, .editAreaSeparator, .editAreaSeparatorLine, .editAreaButtonDisabled, .editAreaButtonSelected {
  168. border: 0px; margin: 0px; padding: 0px; background: transparent;
  169. margin-top: 0px;
  170. margin-left: 1px;
  171. padding: 0px;
  172. }
  173. .editAreaButtonNormal {
  174. border: 1px solid #ECE9D8 !important;
  175. cursor: pointer;
  176. }
  177. .editAreaButtonOver {
  178. border: 1px solid #0A246A !important;
  179. cursor: pointer;
  180. background-color: #B6BDD2;
  181. }
  182. .editAreaButtonDown {
  183. cursor: pointer;
  184. border: 1px solid #0A246A !important;
  185. background-color: #8592B5;
  186. }
  187. .editAreaButtonSelected {
  188. border: 1px solid #C0C0BB !important;
  189. cursor: pointer;
  190. background-color: #F4F2E8;
  191. }
  192. .editAreaButtonDisabled {
  193. filter:progid:DXImageTransform.Microsoft.Alpha(opacity=30);
  194. -moz-opacity:0.3;
  195. opacity: 0.3;
  196. border: 1px solid #F0F0EE !important;
  197. cursor: pointer;
  198. }
  199. .editAreaSeparatorLine {
  200. margin: 1px 2px;
  201. background-color: #C0C0BB;
  202. width: 2px;
  203. height: 18px;
  204. }
  205. </textarea>
  206. </fieldset>
  207. <fieldset>
  208. <legend>example 4</legend>
  209. <p>Test in German with Python syntax, toggle enabled for a later display, with highlight not enabled by default, without resizing possibility (but with larger minimum height when editor is toggled), and with tabs replaced by 4 spaces.</p>
  210. <textarea id="example_4" style="height: 50px; width: 100%;" name="test_4">
  211. import Blender
  212. class Python:
  213. # Instancie un objet
  214. # cls = la classe Python et non pas l'object instancié
  215. def __new__(cls):
  216. pass
  217. # Constructeur de l'objet
  218. def __init__(self):
  219. self.items = [1, 2, 3]
  220. # Destructeur
  221. def __del__(self):
  222. print "Pourquoi tant de haine ?"
  223. # Utilisé pour : "len(p)"
  224. def __len__(self):
  225. return len(self.items)
  226. # Utilisé pour : "p[x]"
  227. def __getitem__(self, key):
  228. return self.items[key]
  229. # Utilisé pour : "x in p"
  230. def __contains__(self, value):
  231. return (value in self.items)
  232. # Utilisé pour : "for x in p"
  233. def __iter__(self):
  234. for x in self.items:
  235. yield x
  236. </textarea>
  237. </fieldset>
  238. </form>
  239. </body>
  240. </html>