Added RDBMS info

Canonical names to forced to lowercase
Made user model compatible to other DBs
CSS adjustments
Basic Firepad support (no presence info)
Cleaned up JS a bit
Added ability to remove draft from localstorage
Added support for drafts on multiple pages
Alert user if page changes, issue #1
This commit is contained in:
Matthew Scragg 2014-10-03 13:49:18 -05:00
parent d72ecf10f0
commit eb12c84e9a
21 changed files with 841 additions and 717 deletions

View file

@ -0,0 +1,52 @@
// Helper to get hash from end of URL or generate a random one.
function getExampleRef() {
var ref = new Firebase('https://' + Config['FIREBASE_HOSTNAME']);
var hash = window.location.hash.replace(/^#fp-/, '');
if (hash) {
ref = ref.child(hash);
} else {
ref = ref.push(); // generate unique location.
window.location = window.location + '#fp-' + ref.name(); // add it as a hash to the URL.
}
return ref;
}
function initFirepad() {
var new_ = true;
if (window.location.hash.lastIndexOf('#fp-', 0) === 0) {
new_ = false;
}
var firepadRef = getExampleRef();
var session = aced.editor.session;
var content;
if (new_) {
content = session.getValue();
}
// Firepad wants an empty editor
session.setValue('');
//// Create Firepad.
var firepad = Firepad.fromACE(firepadRef, aced.editor, {
defaultText: content
});
firepad.on('ready', function() {
startCollaboration();
});
$(document).on('end-collaboration', function() {
firepad.dispose();
});
}
$(document).on('loading-collaboration', function() {
initFirepad(true);
});
$(function(){
if (window.location.hash.lastIndexOf('#fp-', 0) === 0) {
loadingCollaboration();
}
});

View file

@ -0,0 +1,36 @@
var $startCollaborationBtn = $('#start-collaboration');
var $endCollaborationBtn = $('#end-collaboration');
var $loadingCollaborationBtn = $('#loading-collaboration');
function loadingCollaboration() {
$endCollaborationBtn.hide();
$startCollaborationBtn.hide();
$loadingCollaborationBtn.show();
$(document).trigger('loading-collaboration');
}
function startCollaboration() {
$loadingCollaborationBtn.hide();
$startCollaborationBtn.hide();
$endCollaborationBtn.show();
$(document).trigger('start-collaboration');
}
function endCollaboration() {
$loadingCollaborationBtn.hide();
$endCollaborationBtn.hide();
$startCollaborationBtn.show();
$(document).trigger('end-collaboration');
}
$(function() {
$startCollaborationBtn.click(function(e) {
loadingCollaboration();
e.preventDefault();
});
$endCollaborationBtn.click(function(e) {
endCollaboration();
e.preventDefault();
});
});

View file

@ -0,0 +1,28 @@
$(document).on('loading-collaboration', function() {
TogetherJS();
});
$(document).on('end-collaboration', function() {
TogetherJS();
});
TogetherJSConfig_toolName = "Collaboration";
TogetherJSConfig_suppressJoinConfirmation = true;
if (User.is_authenticated) {
TogetherJSConfig_getUserName = function () {
return User.username;
};
TogetherJSConfig_getUserAvatar = function () {
return User.avatar;
};
}
TogetherJSConfig_on_ready = function () {
startCollaboration();
};
TogetherJSConfig_on_close = function () {
//endCollaboration();
};