Permalink
Browse files

Add original JS Bin source

  • Loading branch information...
0 parents commit e895c32089ac1bd310b5d91aecabda219f2eccea @aron aron committed Aug 3, 2012
@@ -0,0 +1,27 @@
+<IfModule mod_rewrite.c>
+
+# $Id: .htaccess,v 1.3 2006/11/09 09:08:14 remy Exp $
+Options +FollowSymLinks +ExecCGI
+RewriteEngine On
+RewriteBase /
+
+# strip www. from the domain
+RewriteCond %{HTTP_HOST} ^www\.jsbin\.com$ [NC]
+RewriteRule ^(.*)$ http://jsbin.com/$1 [R=301,L]
+
+# used when site is down or making significant upgrades
+# RewriteCond %{REQUEST_FILENAME} images
+# RewriteRule .* - [L]
+# RewriteRule .* down.html
+
+# if the file or directory don't exist
+RewriteCond %{REQUEST_FILENAME} -d [OR]
+RewriteCond %{REQUEST_FILENAME} -f
+RewriteRule .* - [L]
+
+RewriteRule ^about$ about.php [L]
+
+# using 'index.php' because it forces a '/' request to the handler
+RewriteRule ^(.*)$ index.php [QSA,L]
+</IfModule>
+
@@ -0,0 +1,106 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+<title>JS Bin - About</title>
+<link rel="stylesheet" href="/sandbox.css" type="text/css" media="screen" charset="utf-8" />
+</head>
+<body id="aboutpage">
+<div id="header">
+ <ul>
+ <li class="right"><a id="back" href="/">Back to code editing</a></li>
+ </ul>
+</div>
+<ul id="navigation">
+ <li><a class="tab selected" href="#about">About</a></li>
+ <li><a class="tab" href="#video">Video Introduction</a></li>
+ <li><a class="tab" href="#ajax">Ajax Debugging</a></li>
+ <li><a class="tab" href="#faq">FAQ</a></li>
+</ul>
+<div id="wrapper">
+ <div id="body">
+ <div id="about" class="panel">
+ <h1>About</h1>
+ <p><a href="/">JS Bin</a> is a webapp specifically designed to help JavaScript and CSS folk test snippets of code, within some context, and debug the code collaboratively.</p>
+ <p>JS Bin allows you to edit and test JavaScript and HTML (reloading the URL also maintains the state of your code - new tabs doesn't). Once you're happy you can save, and send the URL to a peer for review or help. They can then make further changes saving anew if required.</p>
+ <p>The original idea spawned from a conversation with another developer in trying to help him debug an Ajax issue. The original aim was to build it using Google's app engine, but in the end, it was <a href="http://ejohn.org">John Resig</a>'s <a href="http://ejohn.org/apps/learn">Learning app</a> that inspired me to build the whole solution in JavaScript with liberal dashes of jQuery and a tiny bit of LAMP for the saving process.</p>
+ <p>It took me the best part of 4 hours to develop - so if it's shaky around the edges, let me know!</p>
+ <p>This webapp was built by <a href="http://remysharp.com">Remy Sharp</a> of <a href="http://leftlogic.com">Left Logic</a>. <a href="http://leftlogic.com/contact?message=Found%20through%20jsbin.com">Please get in touch</a> if you're interested in contracting Left Logic.</p>
+ </div>
+ <div id="video" class="panel">
+ <h1>Video Introduction</h1>
+ <div class="videoBlock">
+ <div id="introVideo"></div>
+ </div>
+ </div>
+ <div id="ajax" class="panel">
+ <h1>Ajax Debugging</h1>
+ <div class="videoBlock">
+ <div id="ajaxVideo"></div>
+ </div>
+ </div>
+ <div id="faq" class="panel">
+ <h1>FAQ</h1>
+ <h2>My JavaScript isn't inserting</h2>
+ <p>The <em>special %code%</em> symbol will be replaced with your JavaScript. If it is omitted from the HTML content it won't be inserted.</p>
+
+ <h2>How do I re-run the code</h2>
+ <p>Just <em>click the 'Output'</em> tab, and the entire frame will re-execute.</p>
+
+ <h2>Can I see the output outside of this window?</h2>
+ <p>Yes. First you must save the code, then <em>use the 'Live' link</em>. This is now stored privately and can be shared amongst your peers.</p>
+
+ <h2>When I click the live link it doesn't reflect my changes</h2>
+ <p>The live link <em>only shows the saved</em> code, any changes must be saved first.</p>
+
+ <h2>How long does saved code last?</h2>
+ <p>Code that hasn't be viewed in <em>3 months</em> is automatically deleted.</p>
+
+ <h2>Can JS Bin respond to Ajax requests?</h2>
+ <p>Yes. See the <a class="tab" href="#video">video introduction</a> for a demo. Or, it's as simple as removing the HTML output, saving the code, then requesting the URL via a new snippet. JS Bin will respond to Ajax requests appropriately.</p>
+
+ <h2>Is there a bookmarklet?</h2>
+ <p>Funny you ask! Yes, just drag the following <a href="javascript:(function(){window.location='http://jsbin.com/?js='+encodeURIComponent((window.getSelection?window.getSelection():document.selection.createRange().text)+'')})()">jsbin</a> bookmarklet to your bookmark bar. The bookmarklet will inject any selected JavaScript in to JS Bin.</p>
+
+ <h2>IE6?</h2>
+ <p>Sorry: <em>no</em>.</p>
+
+ <h2>My question isn't answered</h2>
+ <p>Feel free to <a href="http://leftlogic.com/contact?message=Question%20regarding%20JS Bin:%20">get in touch</a> and if appropriate I'll add it to the FAQ.</p>
+
+ </div>
+ </div>
+</div>
+<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
+<script type="text/javascript" src="/swfobject.js"></script>
+<script type="text/javascript" charset="utf-8">
+$(function () {
+ var so = new SWFObject('/player.swf','mpl','1038','666','9');
+ so.addParam('allowfullscreen','true');
+ so.addParam('flashvars','autoplay=false&file=http://jqueryfordesigners.com/media/ajax.flv&image=/ajax.jpg');
+ so.write('ajaxVideo');
+
+ so = new SWFObject('/player.swf','mpl','1038','666','9');
+ so.addParam('allowfullscreen','true');
+ so. addParam('flashvars','autoplay=false&file=http://jqueryfordesigners.com/media/jsbin.flv&image=/jsbin.jpg');
+ so.write('introVideo');
+
+
+ $('#back').click(function () {
+ window.history.back();
+ return false;
+ });
+
+ var $tabLinks = $('#navigation a');
+ $('a.tab').click(function () {
+ $tabLinks.removeClass('selected');
+ $tabLinks.filter('[hash=' + this.hash + ']').addClass('selected');
+ var a = $('#body .panel').hide().filter(this.hash).show();
+ return false;
+ });
+ $tabLinks.filter(window.location.hash ? '[hash=' + window.location.hash + ']' : ':first').click();
+});
+</script>
+</body>
+</html>
@@ -0,0 +1,126 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
+<title>JS Bin - About</title>
+<link rel="stylesheet" href="/sandbox.css" type="text/css" media="screen" charset="utf-8" />
+</head>
+<?php
+if (@$_COOKIE['light']) {
+ echo "<body id=\"\aboutpage\" class=\"light\">\n";
+} else {
+ echo "<body id=\"\aboutpage\">\n";
+}
+?>
+
+<div id="header">
+ <ul>
+ <li class="right"><a id="back" href="/">Back to code editing</a></li>
+ </ul>
+</div>
+<ul id="navigation">
+ <li><a class="tab selected" href="#about">About</a></li>
+ <li><a class="tab" href="#video">Video Introduction</a></li>
+ <li><a class="tab" href="#ajax">Ajax Debugging</a></li>
+ <li><a class="tab" href="#faq">FAQ</a></li>
+</ul>
+<div id="wrapper">
+ <div id="body">
+ <div id="about" class="panel">
+ <h1>About</h1>
+ <p><a href="/">JS Bin</a> is a webapp specifically designed to help JavaScript and CSS folk test snippets of code, within some context, and debug the code collaboratively.</p>
+ <p>JS Bin allows you to edit and test JavaScript and HTML (reloading the URL also maintains the state of your code - new tabs doesn't). Once you're happy you can save, and send the URL to a peer for review or help. They can then make further changes saving anew if required.</p>
+ <p>The original idea spawned from a conversation with another developer in trying to help him debug an Ajax issue. The original aim was to build it using Google's app engine, but in the end, it was <a href="http://ejohn.org">John Resig</a>'s <a href="http://ejohn.org/apps/learn">Learning app</a> that inspired me to build the whole solution in JavaScript with liberal dashes of jQuery and a tiny bit of LAMP for the saving process.</p>
+ <p>It took me the best part of 4 hours to develop - so if it's shaky around the edges, let me know!</p>
+ <p><em>This webapp was built by <a href="http://remysharp.com">Remy Sharp</a> (<a href="http://twitter.com/rem">@rem</a>) of <a href="http://leftlogic.com">Left Logic</a>. <a href="http://leftlogic.com/contact?message=Found%20through%20jsbin.com">Please get in touch</a> if you're interested in working with me.</em></p>
+ </div>
+ <div id="video" class="panel">
+ <h1>Video Introduction</h1>
+ <div class="videoBlock">
+ <div id="introVideo"></div>
+ </div>
+ </div>
+ <div id="ajax" class="panel">
+ <h1>Ajax Debugging</h1>
+ <div class="videoBlock">
+ <div id="ajaxVideo"></div>
+ </div>
+ </div>
+ <div id="faq" class="panel">
+ <h1>FAQ</h1>
+
+ <h2>I didn't insert the JavaScript and it still runs</h2>
+ <p>When you tab to the <em>output</em> panel, JS Bin <em>automatically</em> inserts your JavaScript on the fly, so you don't need to worry about it.</p>
+
+ <h2>I need my JavaScript inserted in a specific position</h2>
+ <p>The <em>special %code%</em> symbol will be replaced with your JavaScript. If it's not included, it will be included just before the body closes. Otherwise you can add <em>&lt;script&gt;%code%&lt;/script&gt;</em> anywhere you like.</p>
+
+ <h2>How do I re-run the code</h2>
+ <p>Just <em>click the 'Output'</em> tab, and the entire frame will re-execute.</p>
+
+ <h2>Can I see the output outside of this window?</h2>
+ <p>Yes. First you must save the code, then <em>use the 'Live' link</em>. This is now stored privately and can be shared amongst your peers.</p>
+
+ <h2>When I click the live link it doesn't reflect my changes</h2>
+ <p>The live link <em>only shows the saved</em> code, any changes must be saved first.</p>
+<?php /*
+ <h2>How long does saved code last?</h2>
+ <p>Code that hasn't be viewed in <em>3 months</em> is automatically deleted.</p>
+*/ ?>
+
+ <h2>Can JS Bin respond to Ajax requests?</h2>
+ <p>Yes. See the <a class="tab" href="#video">video introduction</a> for a demo. Or, it's as simple as removing the HTML output, saving the code, then requesting the URL via a new snippet. JS Bin will respond to Ajax requests appropriately.</p>
+
+ <h2>Is there a bookmarklet?</h2>
+ <p>Funny you ask! Yes, just drag the following <a href="javascript:(function(){window.location='http://jsbin.com/?js='+encodeURIComponent((window.getSelection?window.getSelection():document.selection.createRange().text)+'')})()">jsbin</a> bookmarklet to your bookmark bar. The bookmarklet will inject any selected JavaScript in to JS Bin.</p>
+
+ <h2>IE6?</h2>
+ <p>Sorry: <em>no</em>.</p>
+
+ <h2>My question isn't answered</h2>
+ <p>Feel free to <a href="http://leftlogic.com/contact?message=Question%20regarding%20JS Bin:%20">get in touch</a> and if appropriate I'll add it to the FAQ.</p>
+
+ </div>
+ </div>
+</div>
+<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
+<script type="text/javascript" src="/swfobject.js"></script>
+<script type="text/javascript" charset="utf-8">
+$(function () {
+ var so = new SWFObject('/player.swf','mpl','1038','666','9');
+ so.addParam('allowfullscreen','true');
+ so.addParam('flashvars','autoplay=false&file=http://jqueryfordesigners.com/media/ajax.flv&image=/ajax.jpg');
+ so.write('ajaxVideo');
+
+ so = new SWFObject('/player.swf','mpl','1038','666','9');
+ so.addParam('allowfullscreen','true');
+ so. addParam('flashvars','autoplay=false&file=http://jqueryfordesigners.com/media/jsbin.flv&image=/jsbin.jpg');
+ so.write('introVideo');
+
+
+ $('#back').click(function () {
+ window.history.back();
+ return false;
+ });
+
+ var $tabLinks = $('#navigation a');
+ $('a.tab').click(function () {
+ $tabLinks.removeClass('selected');
+ $tabLinks.filter('[hash=' + this.hash + ']').addClass('selected');
+ var a = $('#body .panel').hide().filter(this.hash).show();
+ return false;
+ });
+ $tabLinks.filter(window.location.hash ? '[hash=' + window.location.hash + ']' : ':first').click();
+});
+</script>
+<script type="text/javascript">
+var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+</script>
+<script type="text/javascript">
+var pageTracker = _gat._getTracker("UA-1656750-13");
+pageTracker._trackPageview();
+</script>
+</body>
+</html>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,131 @@
+<?
+/*
+ *
+ * Phomet: a php comet client
+ *
+ * Copyright (C) 2008 Morgan 'ARR!' Allen <morganrallen@gmail.com> http://morglog.alleycatracing.com
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+
+*/
+ class Bayeux
+ {
+ private $oCurl = '';
+ private $nNextId = 0;
+
+ public $sUrl = '';
+
+ function __construct($sUrl)
+ {
+ $this->sUrl = $sUrl;
+
+ $this->oCurl = curl_init();
+
+ $aHeaders = array();
+ $aHeaders[] = 'Connection: keep-alive';
+
+ curl_setopt($this->oCurl, CURLOPT_URL, $sUrl);
+ curl_setopt($this->oCurl, CURLOPT_HTTPHEADER, $aHeaders);
+ curl_setopt($this->oCurl, CURLOPT_HEADER, 0);
+ curl_setopt($this->oCurl, CURLOPT_POST, 1);
+ curl_setopt($this->oCurl, CURLOPT_RETURNTRANSFER,1);
+
+ $this->handShake();
+ }
+
+ function __destruct()
+ {
+ $this->disconnect();
+ }
+
+ function handShake()
+ {
+ $msgHandshake = array();
+ $msgHandshake['channel'] = '/meta/handshake';
+ $msgHandshake['version'] = "1.0";
+ $msgHandshake['minimumVersion'] = "0.9";
+ $msgHandshake['id'] = $this->nNextId++ . "";
+
+ curl_setopt($this->oCurl, CURLOPT_POSTFIELDS, "message=".urlencode(str_replace('\\', '', json_encode(array($msgHandshake)))));
+
+ $data = curl_exec($this->oCurl);
+
+ if(curl_errno($this->oCurl))
+ die("Error: " . curl_error($this->oCurl));
+
+ $oReturn = json_decode($data);
+ $oReturn = $oReturn[0];
+
+ $bSuccessful = ($oReturn->successful) ? true : false;
+
+ if($bSuccessful)
+ {
+ $this->clientId = $oReturn->clientId;
+
+ $this->connect();
+ }
+ }
+
+ public function connect()
+ {
+ $aMsg['channel'] = '/meta/connect';
+ $aMsg['id'] = $this->nNextId++ . "";
+ $aMsg['clientId'] = $this->clientId;
+ $aMsg['connectionType'] = 'long-polling';
+
+ curl_setopt($this->oCurl, CURLOPT_POSTFIELDS, "message=".urlencode(str_replace('\\', '', json_encode(array($aMsg)))));
+
+ $data = curl_exec($this->oCurl);
+ }
+
+ function disconnect()
+ {
+ $msgHandshake = array();
+ $msgHandshake['channel'] = '/meta/disconnect';
+ $msgHandshake['id'] = $this->nNextId++ . "";
+ $msgHandshake['clientId'] = $this->clientId;
+
+ curl_setopt($this->oCurl, CURLOPT_POSTFIELDS, "message=".urlencode(str_replace('\\', '', json_encode(array($msgHandshake)))));
+
+ curl_exec($this->oCurl);
+ }
+
+ public function publish($sChannel, $oData)
+ {
+ if(!$sChannel || !$oData)
+ return;
+
+ $aMsg = array();
+
+ $aMsg['channel'] = $sChannel;
+ $aMsg['id'] = $this->nNextId++ . "";
+ $aMsg['data'] = $oData;
+ $aMsg['clientId'] = $this->clientId;
+
+ curl_setopt($this->oCurl, CURLOPT_POSTFIELDS, "message=".urlencode(json_encode(array($aMsg))));
+
+ $data = curl_exec($this->oCurl);
+ // var_dump($data);
+ return $data;
+ }
+ }
+
+
+ // $oPhomet = new Bayeux("http://127.0.0.1:8080/cometd");
+ // $oPhomet->publish('/jsbin/3faa8442fc917e92dd863b5f953671ef', array('javascript' => "Just trying out with\nnew lines and some \\b escaped characters!\n\nRemy.", "html" => ''));
+
+
+?>
@@ -0,0 +1 @@
+<html><head><style>body{background:#000;}</style></head><body></body></html>
Oops, something went wrong. Retry.

0 comments on commit e895c32

Please sign in to comment.