cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <!-- Bootstrap core CSS -->
<link href="https://v4-alpha.getbootstrap.com/dist/css/bootstrap.min.css" rel="stylesheet">

<div class="container">
  <div>
    To run sketchpad server:
    <pre class="terminal"><code>
git clone https://github.com/cojapacze/sketchpad.git
cd sketchpad
npm install
node server/server.js
              </code></pre>
  </div>
</div>
<div class="container">
      <div class="row">
        <div class="col-sm-6">
          <!-- SketchpadJS container here: -->
          <div id="sketchpadA" class="sketchpad"></div>
        </div>
        <div class="col-sm-6">
          <!-- SketchpadJS container here: -->
          <div id="sketchpadB" class="sketchpad"></div>
        </div>
      </div>
    </div>

<!-- http://sketchpad.pro - free online drawing board tool -->
<script src="http://cdn.sketchpad.pro/dist/current/sketchpad.min.js"></script>

            
          
!
            
              pre.terminal {
	background-color: #000;
	color: #eee;
	padding-left: 1em;
  padding-right: 1em;
}

.sketchpad {
    width: 100%;
    height: 640px;
    border:1px solid rgba(128, 128, 128, 1);;
}

            
          
!
            
              /*global window, Sketchpad, WebSocket, Colorpalette, alert*/
var primaryServer = "ws://" + (window.location.hostname || "localhost") + ":8067/",
    secondaryServer = "ws://public.server.sketchpad.pro:8067/";

function splitScreen(wsA, wsB) {
    "use strict";
    console.log("Inintializing splitScreen", wsA, wsB);


    var sketchpadA = new Sketchpad({
        containerEl: document.getElementById("sketchpadA"),
        token: window.location.hash || "#multiplayer",
        ws: wsA,
        createPageConfig: {sid: "#1page_token"}
    });
    sketchpadA.setTool("pen");

    var sketchpadB = new Sketchpad({
        containerEl: document.getElementById("sketchpadB"),
        token: window.location.hash || "#multiplayer",
        ws: wsB,
        createPageConfig: {sid: "#1page_token"}
    });
    sketchpadB.setTool("highlighter");

    //objects visible in developer console
    window.sketchpadA = sketchpadA;
    window.sketchpadB = sketchpadB;

}
function connectToServer(wsServerAddress, onSuccessCallback, onErrorCallback) {
    "use strict";
    var wsA = new WebSocket(wsServerAddress);
    var wsB = new WebSocket(wsServerAddress);
    function onError(e) {
        wsA.removeEventListener("error", onError);
        wsB.removeEventListener("error", onError);
        onErrorCallback(e);
    }

    function onOpen() {
        if (wsA.readyState === 1 && wsB.readyState === 1) {
            wsA.removeEventListener("error", onError);
            wsB.removeEventListener("error", onError);
            onSuccessCallback(wsA, wsB);
        }
    }
    wsA.addEventListener("open", onOpen);
    wsB.addEventListener("open", onOpen);
    wsA.addEventListener("error", onError);
    wsB.addEventListener("error", onError);
}

function initSketchpad() {
    "use strict";

    connectToServer(primaryServer, splitScreen, function () {
        console.log("Primary server fail, trying secondary server...", secondaryServer);
        connectToServer(secondaryServer, splitScreen, function () {
            alert("Connection fail.\n\nFollow instructions from: \nhttp://developers.sketchpad.pro\n \nto setup own sketchpad server.");
        });
    });

    window.addEventListener("hashchange", function () {
        window.location.reload();//reconnect on room name in hash change
    });

}
initSketchpad();



            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console