This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This should be easier, but due to an oversight in the checkpoint id's, it's a tad tricky (you need this revision/id stuff). | |
// I'll rework things to be cleaner in the near future. | |
function pruneHistory(firepadRef) { | |
var characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; | |
function revisionToId(revision) { | |
if (revision === 0) { | |
return 'A0'; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
console.log = (function() { | |
var console_log = console.log; | |
var timeStart = new Date().getTime(); | |
return function() { | |
var delta = new Date().getTime() - timeStart; | |
var args = []; | |
args.push((delta / 1000).toFixed(2) + ':'); | |
for(var i = 0; i < arguments.length; i++) { | |
args.push(arguments[i]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set autoindent ignorecase noerrorbells ruler hlsearch sw=4 sts=4 expandtab | |
set textwidth=79 nowrapscan formatoptions-=t incsearch tabstop=4 | |
set scrolloff=2 norestorescreen history=100 shortmess=ao nobackup | |
set matchtime=1 showmatch smartcase wildmenu wildmode=longest:full | |
syntax on | |
map Q gq | |
map Y y$ | |
behave xterm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
codeMirror.setOption('onDragEvent', function(cm, e) { | |
// Move the cursor as they drag. | |
var pos = codeMirror.coordsChar({left: e.x, top: e.y }); | |
codeMirror.setCursor(pos); | |
codeMirror.focus(); | |
var isImageDrop = e.type == 'drop' && e.dataTransfer.files && e.dataTransfer.files.length > 0 && e.dataTransfer.files[0].type && e.dataTransfer.files[0].type.indexOf('image/') > -1; | |
if (!isImageDrop) return; | |
event.preventDefault(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firepad.registerEntity('img', { | |
render: function(info, handle) { | |
var attrs = ['src', 'alt', 'width', 'height', 'style', 'class']; | |
var html = '<img '; | |
for(var i = 0; i < attrs.length; i++) { | |
var attr = attrs[i]; | |
if (attr in info) { | |
html += ' ' + attr + '="' + info[attr] + '"'; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.firepad { | |
height: auto; | |
} | |
.firepad-toolbar { | |
position: relative; | |
margin-top: 20px; | |
margin-left: 10px; | |
top: auto; | |
left: auto; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
firepad.insertEntity('img', { | |
'src' : 'http://cdn.dashburst.com/wp-content/uploads/2013/01/Grumpy-Cat.jpg', | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jsdom = require('jsdom'); | |
var fs = require('fs'); | |
var Firepad = {}; | |
Firepad.load = function(ref, callback) { | |
jsdom.env('<head></head><body><div id="firepad"></div></body>', function (errors, window) { | |
var document = document || window.document; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var presenceRef = new Firebase('https://mike.firebaseio.com/users/michael/presence'); | |
presenceRef.root().child('.info/connected').on('value', function(s) { | |
if (s.val() === true) { | |
// we're connected. Set up presence with a per-session presence bit. | |
var ref = presenceRef.push(); | |
ref.onDisconnect().remove(); | |
ref.set(true); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
codeMirror.setOption('onDragEvent', function(cm, e) { | |
// Move the cursor as they drag. | |
var pos = codeMirror.coordsChar({left: e.x, top: e.y }); | |
codeMirror.setCursor(pos); | |
codeMirror.focus(); | |
var isImageDrop = e.type == 'drop' && e.dataTransfer.files && e.dataTransfer.files.length > 0 && e.dataTransfer.files[0].type && e.dataTransfer.files[0].type.indexOf('image/') > -1; | |
if (!isImageDrop) return; | |
event.preventDefault(); |
OlderNewer