Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
71 lines (61 sloc) 2.38 KB
<!doctype html>
<!-- See http://www.wildpad.io/docs/ for detailed embedding docs. -->
<html>
<head>
<meta charset="utf-8" />
<!-- Wilddog -->
<script src="https://cdn.wilddog.com/js/client/current/wilddog.js"></script>
<!-- CodeMirror and its JavaScript mode file -->
<script src="https://dl.wdstatic.cn/cloudflare/ajax/libs/codemirror/5.2.0/codemirror.js"></script>
<script src="https://dl.wdstatic.cn/cloudflare/ajax/libs/codemirror/5.2.0/mode/javascript/javascript.js"></script>
<link rel="stylesheet" href="https://dl.wdstatic.cn/cloudflare/ajax/libs/codemirror/5.2.0/codemirror.css" />
<!-- Wildpad -->
<link rel="stylesheet" href="https://cdn.wilddog.com/app/wildpad/0.1/wildpad.css" />
<script src="https://cdn.wilddog.com/app/wildpad/0.1/wildpad.js"></script>
<style>
html { height: 100%; }
body { margin: 0; height: 100%; position: relative; }
/* Height / width / positioning can be customized for your use case.
For demo purposes, we make wildpad fill the entire browser. */
#wildpad-container {
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="wildpad-container"></div>
<script>
function init() {
//// Initialize Wilddog.
var wildpadRef = getExampleRef();
// TODO: Replace above line with:
// var wildpadRef = new Wilddog('<YOUR WILDDOG URL>');
//// Create CodeMirror (with line numbers and the JavaScript mode).
var codeMirror = CodeMirror(document.getElementById('wildpad-container'), {
lineNumbers: true,
mode: 'javascript'
});
//// Create Wildpad.
var wildpad = Wildpad.fromCodeMirror(wildpadRef, codeMirror, {
defaultText: '// JavaScript Editing with Wildpad!\nfunction go() {\n var message = "Hello, world.";\n console.log(message);\n}'
});
}
// Helper to get hash from end of URL or generate a random one.
function getExampleRef() {
var ref = new Wilddog('https://wildpad.wilddogio.com');
var hash = window.location.hash.replace(/#/g, '');
if (hash) {
ref = ref.child(hash);
} else {
ref = ref.push(); // generate unique location.
window.location = window.location + '#' + ref.key(); // add it as a hash to the URL.
}
if (typeof console !== 'undefined')
console.log('Wilddog data: ', ref.toString());
return ref;
}
init();
</script>
</body>
</html>