corrade-nucleus-nucleons – Blame information for rev 20

Subversion Repositories:
Rev:
Rev Author Line No. Line
20 office 1 <!DOCTYPE html>
2 <html lang="en">
3 <head>
4 <meta charset="UTF-8">
5 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
6 <link href="style.css" rel="stylesheet" type="text/css">
7 <title>Ace Bookmarklet Builder</title>
8 </head>
9 <body>
10  
11 <div id="wrapper">
12  
13 <div class="content" style="width: 950px">
14 <div class="column1" style="margin-top: 47px">
15 <textarea id="textarea" style="width:300px; height:300px">
16 /**
17 * This is Ace injected using a bookmarklet.
18 */
19 function foo() {
20 var bar = true;
21 }</textarea><br>
22 SourceUrl: <br>
23 <input id="srcURL" style="width:300px" value="http://ajaxorg.github.com/ace-builds/src-noconflict"></input><br>
24 <button id="buBuild">Build Link</button> <br> <a href="#"></a>
25 <a href="https://github.com/ajaxorg/ace/">
26 <div class="fork_on_github" ></div>
27 </a>
28 </div>
29 <div class="column2">
30 <h1>Ace Bookmarklet Builder</h1>
31  
32 <p id="first">
33 <strong>WARNING:</strong> Currently, this is only supported in non IE browsers.
34 </p>
35  
36 <h2>How to use it:</h2>
37 <ul>
38 <li>Select the options as you want them to be by default.</li>
39 <li>Enter the "SourceUrl". This has to be the URL pointing to build/textarea/src/ (you can leave the default to server the scripts from GitHub).</li>
40 <li>Click the "Build Link" button to generate your custom Ace Bookmarklet.</li>
41 <li>Drag the generated link to your toolbar or store it somewhere else.</li>
42 <li>Go to a page with a textarea element and click the bookmarklet - wait a little bit till the files are loaded.</li>
43 <li>Click three times on the textarea you want to replace - Ace will replace it.</li>
44 <li>To change settings, just click the red icon in the bottom right corner.</li>
45 </ul>
46 </div>
47 </div>
48 </div>
49  
50 <script>
51  
52 function inject(options, callback) {
53 var baseUrl = options.baseUrl || "../../src-noconflict";
54  
55 var load = function(path, callback) {
56 var head = document.getElementsByTagName('head')[0];
57 var s = document.createElement('script');
58  
59 s.src = baseUrl + "/" + path;
60 head.appendChild(s);
61  
62 s.onload = s.onreadystatechange = function(_, isAbort) {
63 if (isAbort || !s.readyState || s.readyState == "loaded" || s.readyState == "complete") {
64 s = s.onload = s.onreadystatechange = null;
65 if (!isAbort)
66 callback();
67 }
68 };
69 };
70  
71 load("ace.js", function() {
72 ace.config.loadModule("ace/ext/textarea", function() {
73 var event = ace.require("ace/lib/event");
74 var areas = document.getElementsByTagName("textarea");
75 for (var i = 0; i < areas.length; i++) {
76 event.addListener(areas[i], "click", function(e) {
77 if (e.detail == 3) {
78 ace.transformTextarea(e.target, options.ace);
79 }
80 });
81 }
82 callback && callback();
83 });
84 });
85 }
86  
87 // Call the inject function to load the ace files.
88 var textAce;
89 inject({}, function () {
90 // Transform the textarea on the page into an ace editor.
91 var t = document.querySelector("textarea");
92 textAce = ace.require("ace/ext/textarea").transformTextarea(t);
93 setTimeout(function(){textAce.setDisplaySettings(true)});
94 });
95  
96  
97 document.getElementById("buBuild").onclick = function() {
98 var injectSrc = inject.toString().split("\n").join("");
99 injectSrc = injectSrc.replace(/\s+/g, " ");
100  
101 var options = textAce.getOptions();
102 options.baseUrl = document.getElementById("srcURL").value;
103  
104 var a = document.querySelector("a");
105 a.href = "javascript:(" + injectSrc + ")(" + JSON.stringify(options) + ")";
106 a.innerHTML = "Ace Bookmarklet Link";
107 }
108  
109 </script>
110  
111 </body>
112 </html>