Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 217 lines (205 sloc) 8.096 kb
5dc412a @remy Some Menlo love and moved the version number in to index.php
remy authored
1 <?php
2
3 include('app.php');
1527da4 @remy Nearly there with IE7 - just need to fix keeping the right splitter p…
remy authored
4
09d4a41 @remy removed secondary post reading
remy authored
5 if (false && (@$_POST['html'] || @$_POST['javascript'])) {
1527da4 @remy Nearly there with IE7 - just need to fix keeping the right splitter p…
remy authored
6 $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'), array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
5e1c90f @remy add support for preview JS as well as HTML
remy authored
7 if (@$_POST['html']) {
cd8a67a @remy removed random quoting
remy authored
8 $html = str_replace($jsonReplaces[0], $jsonReplaces[1], $_POST['html']);
5e1c90f @remy add support for preview JS as well as HTML
remy authored
9 } else {
10 $html = '';
11 }
12 if (@$_POST['javascript']) {
cd8a67a @remy removed random quoting
remy authored
13 $javascript = str_replace($jsonReplaces[0], $jsonReplaces[1], $_POST['javascript']);
5e1c90f @remy add support for preview JS as well as HTML
remy authored
14 } else {
15 $javascript = '';
16 }
17
18 if ($html == '') {
19 // if there's no HTML, let's pop some simple HTML in place to give the JavaScript
20 // some context to run inside of
21 list($latest_revision, $defhtml, $defjavascript) = getCode($code_id, $revision, true);
22 $html = $defhtml;
23 }
1527da4 @remy Nearly there with IE7 - just need to fix keeping the right splitter p…
remy authored
24 } else {
25 list($code_id, $revision) = getCodeIdParams($request);
26
27 $edit_mode = false;
28
29 if ($code_id) {
601caf4 @remy Support running jsbin from a subdirectory - change the ROOT config va…
remy authored
30 list($latest_revision, $html, $javascript) = getCode($code_id, $revision, true);
1527da4 @remy Nearly there with IE7 - just need to fix keeping the right splitter p…
remy authored
31 } else {
b13873e @remy Accidentally broke default code - now fixed.
remy authored
32 list($latest_revision, $html, $javascript) = defaultCode();
1527da4 @remy Nearly there with IE7 - just need to fix keeping the right splitter p…
remy authored
33 }
34 }
601caf4 @remy Support running jsbin from a subdirectory - change the ROOT config va…
remy authored
35
36 if ($revision != 1 && $revision) {
37 $code_id .= '/' . $revision;
38 }
d03b966 @remy Changes to make local install of jsbin much easier - in particular fo…
remy authored
39 $code_id_path = ROOT;
601caf4 @remy Support running jsbin from a subdirectory - change the ROOT config va…
remy authored
40 if ($code_id) {
d03b966 @remy Changes to make local install of jsbin much easier - in particular fo…
remy authored
41 $code_id_path = ROOT . $code_id . '/';
601caf4 @remy Support running jsbin from a subdirectory - change the ROOT config va…
remy authored
42 }
d03b966 @remy Changes to make local install of jsbin much easier - in particular fo…
remy authored
43
203669c @remy Supporting revisions on js bins
remy authored
44 ?>
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
45 <!DOCTYPE html>
46 <html lang="en">
47 <head>
48 <meta charset=utf-8 />
49 <title>JS Bin - Collaborative JavaScript Debugging</title>
7509efe @remy <?= -> <?php echo ::sigh:: stupid php!
remy authored
50 <link rel="stylesheet" href="<?php echo ROOT?>css/style.css?<?php echo VERSION?>" type="text/css" />
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
51 </head>
2edf8c4 @remy Mostly IE8 fixes - getting IE7 to work...
remy authored
52 <!--[if lt IE 7 ]><body class="source ie ie6"><![endif]-->
1527da4 @remy Nearly there with IE7 - just need to fix keeping the right splitter p…
remy authored
53 <!--[if lt IE 8 ]><body class="source ie ie7"><![endif]-->
54 <!--[if gte IE 8 ]><body class="source ie"><![endif]-->
b803885 @remy Updated library support (removed some legacy crap), now supports jsbi…
remy authored
55 <!--[if !IE]><!--><body class="source"><!--<![endif]-->
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
56 <div id="control">
57 <div class="control">
6c29138 @remy Adding buttons - currently just styling
remy authored
58 <div class="buttons">
5db19ee @remy New navigation style and logic around the revert showing or not to he…
remy authored
59 <a class="tab button source group left" accesskey="1" href="#source">Code</a>
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
60 <a class="tab button preview group right gap" accesskey="2" href="#preview" title="Run with alerts, prompts, etc">Render</a>
7509efe @remy <?= -> <?php echo ::sigh:: stupid php!
remy authored
61 <a title="Revert" class="button light group left" id="revert" href="#"><img class="enabled" src="<?php echo ROOT?>images/revert.png" /><img class="disabled" src="<?php echo ROOT?>images/revert-disabled.png" /></a>
fdab286 @remy Testing initial code creation
remy authored
62 <?php if ($code_id) : ?>
c9de02c @remy General tidying of code - need to add better support for back and his…
remy authored
63 <a id="jsbinurl" class="button group light left" href="http://<?php echo $_SERVER['HTTP_HOST'] . ROOT . $code_id?>"><?php echo $_SERVER['HTTP_HOST'] . ROOT . $code_id?></a>
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
64
ad4864e @remy Closes #66 - changed the menu towards version 3 - i.e. save dropdown,…
remy authored
65 <div class="button group gap right tall">
7509efe @remy <?= -> <?php echo ::sigh:: stupid php!
remy authored
66 <a href="<?php echo ROOT?>save" class="save title">Save</a>
67 <a id="clone" title="Create a new copy" class="button clone group light" href="<?php echo ROOT?>clone">Clone</a>
68 <a id="save" title="Save new a new revision" class="button light save group" href="<?php echo $code_id_path?>save">Save</a>
ad4864e @remy Closes #66 - changed the menu towards version 3 - i.e. save dropdown,…
remy authored
69 <?php else : ?>
cabfcc6 @remy rounded edge on save button when alone
remy authored
70 <div class="button group gap left right">
7509efe @remy <?= -> <?php echo ::sigh:: stupid php!
remy authored
71 <a href="<?php echo ROOT?>save" class="save title">Save</a>
72 <a id="save" title="Save new bin" class="button save group" href="<?php echo ROOT?>save">Save</a>
ad4864e @remy Closes #66 - changed the menu towards version 3 - i.e. save dropdown,…
remy authored
73 <?php endif ?>
7509efe @remy <?= -> <?php echo ::sigh:: stupid php!
remy authored
74 <a id="download" title="Save to drive" class="button download group light" href="<?php echo ROOT?>download">Download</a>
73d8229 @remy Restored "save as template" feature. Makes sense again in new context.
remy authored
75 <a id="startingpoint" title="Set as starting code" class="button group" href="<?php echo ROOT?>save">As template</a>
ad4864e @remy Closes #66 - changed the menu towards version 3 - i.e. save dropdown,…
remy authored
76 </div>
77
78 <span id="panelsvisible" class="gap">View:
79 <input type="checkbox" data-panel="javascript" id="showjavascript"><label for="showjavascript">JavaScript</label>
80 <input type="checkbox" data-panel="html" id="showhtml"><label for="showhtml">HTML</label>
81 <input type="checkbox" data-panel="live" id="showlive"><label for="showlive">Real-time preview</label>
82 </span>
5db19ee @remy New navigation style and logic around the revert showing or not to he…
remy authored
83 </div>
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
84 </div>
85 <div class="help">
86 <ul class="flat">
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
87 <li><a target="_blank" href="http://jsbin.tumblr.com">Help &amp; tutorials</a></li>
c9de02c @remy General tidying of code - need to add better support for back and his…
remy authored
88 <li class="prefsButton"><a href="#"><img src="/images/gear.png"></a></li>
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
89 </ul>
90 </div>
91 </div>
1527da4 @remy Nearly there with IE7 - just need to fix keeping the right splitter p…
remy authored
92 <div id="bin" class="stretch" style="opacity: 0; filter:alpha(opacity=0);">
6c29138 @remy Adding buttons - currently just styling
remy authored
93 <div id="source" class="binview stretch">
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
94 <div class="code stretch javascript">
73d8229 @remy Restored "save as template" feature. Makes sense again in new context.
remy authored
95 <div class="label"><p><strong id="jslabel">JavaScript</strong></p></div>
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
96 <div class="editbox">
8c9038d @remy Disable spellcheck, autocomplete and all that rubbish for iOS view. F…
remy authored
97 <textarea spellcheck="false" autocapitalize="off" autocorrect="off" id="javascript"></textarea>
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
98 </div>
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
99 </div>
100 <div class="code stretch html">
c8005f0 @remy Added include libraries and rendered preview mode (along with js raw …
remy authored
101 <div class="label">
73d8229 @remy Restored "save as template" feature. Makes sense again in new context.
remy authored
102 <p>HTML</p>
c8005f0 @remy Added include libraries and rendered preview mode (along with js raw …
remy authored
103 <label for="library">Include</label>
104 <select id="library">
e862ba3 @remy Added console log inline to rendered preview, includes debug.js and m…
remy authored
105 <option value="none">None</option>
c8005f0 @remy Added include libraries and rendered preview mode (along with js raw …
remy authored
106 <option value="jquery">jQuery</option>
107 <option value="jquery+jqueryui">jQuery UI</option>
108 <option value="yui">YUI</option>
e862ba3 @remy Added console log inline to rendered preview, includes debug.js and m…
remy authored
109 <option value="prototype">Prototype</option>
0678c16 @remy Changed Prototype + Scriptaculous to just Scriptaculous for better re…
remy authored
110 <option value="prototype+scriptaculous">Scriptaculous</option>
c8005f0 @remy Added include libraries and rendered preview mode (along with js raw …
remy authored
111 <option value="mootools">Mootools</option>
e862ba3 @remy Added console log inline to rendered preview, includes debug.js and m…
remy authored
112 <option value="dojo">Dojo</option>
113 <option value="ext">Ext js</option>
c8005f0 @remy Added include libraries and rendered preview mode (along with js raw …
remy authored
114 </select>
115 </div>
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
116 <div class="editbox">
8c9038d @remy Disable spellcheck, autocomplete and all that rubbish for iOS view. F…
remy authored
117 <textarea spellcheck="false" autocapitalize="off" autocorrect="off" id="html"></textarea>
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
118 </div>
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
119 </div>
8b7f861 @remy Fixed width splitters
remy authored
120
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
121 </div>
6326028 @remy Putting live panel back on far right
remy authored
122 <div id="live" class="stretch livepreview"><a href="<?php echo ROOT ?>live" target="_new" id="popout" class="popout button light left right">Pop out</a></div>
b9003be @remy Create the preview iframe whenever the preview button is clicked, thu…
remy authored
123 <div id="preview" class="binview stretch"></div>
7509efe @remy <?= -> <?php echo ::sigh:: stupid php!
remy authored
124 <form method="post" action="<?php echo $code_id_path?>save">
a5d4c1b @remy Working on beta features:
remy authored
125 <input type="hidden" name="method" />
126 </form>
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
127 </div>
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
128 <div id="tip"><p>You can jump to the latest bin by adding <code>/latest</code> to your URL</p><a class="dismiss" href="#">Dismiss x</a></div>
c530375 @remy tips and help in place
remy authored
129 <div id="keyboardHelp">
c9de02c @remy General tidying of code - need to add better support for back and his…
remy authored
130 <div>
131 <h2>Keyboard Shortcuts</h2>
132 <table>
133 <thead>
134 <tr>
135 <th>Shortcut</th>
136 <th>Action</th>
137 </tr>
138 </thead>
139 <tbody>
140 <tr>
141 <td>ctrl + &rarr;</td>
142 <td>Focus HTML panel</td>
143 </tr>
144 <tr>
145 <td>ctrl + &larr;</td>
146 <td>Focus JavaScript panel</td>
147 </tr>
148 <tr>
149 <td>ctrl + 1</td>
150 <td>Source tab</td>
151 </tr>
152 <tr>
153 <td>ctrl + 2</td>
154 <td>Rendered preview tab</td>
155 </tr>
156 <tr>
157 <td>ctrl + /</td>
158 <td>Toggle comment on single line</td>
159 </tr>
160 <tr>
161 <td>ctrl + alt + .</td>
162 <td>Close current HTML element</td>
163 </tr>
164 <tr>
165 <td>esc</td>
166 <td>Code complete (JavaScript only)</td>
167 </tr>
168 <tr>
169 <td>ctrl + s</td>
170 <td>Save current Bin</td>
171 </tr>
172 <tr>
173 <td>ctrl + shift + s</td>
174 <td>Clone current Bin</td>
175 </tr>
176 <tr>
177 <td>tab</td>
178 <td>Indents selected lines</td>
179 </tr>
180 <tr>
181 <td>shift + tab</td>
182 <td>Unindents selected lines</td>
183 </tr>
184 </tbody>
185 </table>
186 </div>
c530375 @remy tips and help in place
remy authored
187 </div>
c9de02c @remy General tidying of code - need to add better support for back and his…
remy authored
188 <div class="prefsOverlay"></div>
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
189 <script>
190 <?php
ad4864e @remy Closes #66 - changed the menu towards version 3 - i.e. save dropdown,…
remy authored
191 // assumes http - if that's not okay, this need to be changed
192 $url = 'http://' . $_SERVER['HTTP_HOST'] . '/' . $code_id . ($revision == 1 ? '' : '/' . $revision);
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
193 if (!$ajax) {
194 echo 'var template = ';
195 }
196 // doubles as JSON
197 echo '{"url":"' . $url . '","html" : ' . encode($html) . ',"javascript":' . encode($javascript) . '}';
1527da4 @remy Nearly there with IE7 - just need to fix keeping the right splitter p…
remy authored
198 ?>
1ddb2a0 @remy Mass check in of JS Bin 2.8 - lots of UI changes - in complete though…
remy authored
199 </script>
87b491e @remy adding root to jsbin object to help with API
remy authored
200 <script>jsbin = { root: "<?php echo HOST ?>", version: "<?php echo VERSION?>" }; tips = <?php echo file_get_contents('tips.json')?>;</script>
7509efe @remy <?= -> <?php echo ::sigh:: stupid php!
remy authored
201 <script src="<?php echo ROOT?>js/<?php echo VERSION?>/jsbin.js"></script>
ea67980 @remy Don't use GA if offline
remy authored
202 <?php if (!OFFLINE) : ?>
e8f0258 @remy Fixing HTML & JS injection on the URL, and adding support for *any* b…
remy authored
203 <script>
a1eb8f6 @remy Creating the ability to inject entire web pages into JS Bin via a boo…
remy authored
204 var _gaq = _gaq || [];
205 _gaq.push(['_setAccount', 'UA-1656750-13']);
206 _gaq.push(['_trackPageview']);
207
208 (function() {
209 var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
210 ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
211 (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(ga);
212 })();
e8f0258 @remy Fixing HTML & JS injection on the URL, and adding support for *any* b…
remy authored
213 </script>
ea67980 @remy Don't use GA if offline
remy authored
214 <?php endif ?>
cf2e320 @remy Early version of JS Bin 1.5 - redesign
remy authored
215 </body>
a5d4c1b @remy Working on beta features:
remy authored
216 </html>
Something went wrong with that request. Please try again.