|
|
@ -39,11 +39,12 @@ define([
|
|
|
|
return Hyperjson.toDOM(H); //callOn(H, Hyperscript);
|
|
|
|
return Hyperjson.toDOM(H); //callOn(H, Hyperscript);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var module = window.REALTIME_MODULE = {
|
|
|
|
var module = window.REALTIME_MODULE = window.APP = {
|
|
|
|
Hyperjson: Hyperjson,
|
|
|
|
Hyperjson: Hyperjson,
|
|
|
|
TextPatcher: TextPatcher,
|
|
|
|
TextPatcher: TextPatcher,
|
|
|
|
logFights: true,
|
|
|
|
logFights: true,
|
|
|
|
fights: []
|
|
|
|
fights: [],
|
|
|
|
|
|
|
|
Cryptpad: Cryptpad
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var toolbar;
|
|
|
|
var toolbar;
|
|
|
@ -236,10 +237,10 @@ define([
|
|
|
|
var createChangeName = function(id, $container) {
|
|
|
|
var createChangeName = function(id, $container) {
|
|
|
|
var buttonElmt = $container.find('#'+id)[0];
|
|
|
|
var buttonElmt = $container.find('#'+id)[0];
|
|
|
|
buttonElmt.addEventListener("click", function() {
|
|
|
|
buttonElmt.addEventListener("click", function() {
|
|
|
|
var newName = window.prompt("Change your name :", myUserName);
|
|
|
|
Cryptpad.prompt("Change your name:", '', function (newName) {
|
|
|
|
if (newName && newName.trim()) {
|
|
|
|
if (!(typeof(newName) === 'string' && newName.trim())) { return; }
|
|
|
|
var myUserNameTemp = newName.trim();
|
|
|
|
var myUserNameTemp = newName.trim();
|
|
|
|
if(newName.trim().length > 32) {
|
|
|
|
if(myUserNameTemp.length > 32) {
|
|
|
|
myUserNameTemp = myUserNameTemp.substr(0, 32);
|
|
|
|
myUserNameTemp = myUserNameTemp.substr(0, 32);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
myUserName = myUserNameTemp;
|
|
|
|
myUserName = myUserNameTemp;
|
|
|
@ -247,8 +248,8 @@ define([
|
|
|
|
name: myUserName
|
|
|
|
name: myUserName
|
|
|
|
};
|
|
|
|
};
|
|
|
|
addToUserList(myData);
|
|
|
|
addToUserList(myData);
|
|
|
|
editor.fire( 'change' );
|
|
|
|
editor.fire('change');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -389,16 +390,35 @@ define([
|
|
|
|
return new DOMParser().parseFromString(html, 'text/html');
|
|
|
|
return new DOMParser().parseFromString(html, 'text/html');
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getHeadingText = function () {
|
|
|
|
|
|
|
|
if (['h1', 'h2', 'h3'].some(function (t) {
|
|
|
|
|
|
|
|
var $header = $(inner).find(t + ':first-of-type');
|
|
|
|
|
|
|
|
if ($header.length && $header.text()) {
|
|
|
|
|
|
|
|
text = $header.text();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})) { return text; }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var suggestName = module.suggestName = function () {
|
|
|
|
|
|
|
|
var hash = window.location.hash.slice(1, 9);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (document.title === hash) {
|
|
|
|
|
|
|
|
return getHeadingText() || hash;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return document.title || getHeadingText() || hash;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var exportFile = function () {
|
|
|
|
var exportFile = function () {
|
|
|
|
var html = getHTML();
|
|
|
|
var html = getHTML();
|
|
|
|
console.log(html === getHTML(domFromHTML(html)));
|
|
|
|
var suggestion = suggestName();
|
|
|
|
|
|
|
|
Cryptpad.prompt("What would you like to name your file?",
|
|
|
|
console.log(html);
|
|
|
|
suggestion.replace(/ /g, '-') + '.html', function (filename) {
|
|
|
|
var filename = window.prompt('What would you like to name your file?', "MyPad.html");
|
|
|
|
if (!(typeof(filename) === 'string' && filename)) { return; }
|
|
|
|
if (filename) {
|
|
|
|
|
|
|
|
var blob = new Blob([html], {type: "text/html;charset=utf-8"});
|
|
|
|
var blob = new Blob([html], {type: "text/html;charset=utf-8"});
|
|
|
|
saveAs(blob, filename);
|
|
|
|
saveAs(blob, filename);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var onInit = realtimeOptions.onInit = function (info) {
|
|
|
|
var onInit = realtimeOptions.onInit = function (info) {
|
|
|
@ -437,19 +457,19 @@ define([
|
|
|
|
.addClass('cryptpad-rename rightside-button')
|
|
|
|
.addClass('cryptpad-rename rightside-button')
|
|
|
|
.text('RENAME')
|
|
|
|
.text('RENAME')
|
|
|
|
.click(function () {
|
|
|
|
.click(function () {
|
|
|
|
var suggestion = $(inner).find('h1:first-of-type').text();
|
|
|
|
var suggestion = suggestName();
|
|
|
|
|
|
|
|
|
|
|
|
var title = window.prompt("How would you like to title this pad?", suggestion);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.prompt("How would you like to title this pad?", suggestion, function (title) {
|
|
|
|
if (title === null) { return; }
|
|
|
|
if (title === null) { return; }
|
|
|
|
if (Cryptpad.causesNamingConflict(title)) {
|
|
|
|
if (Cryptpad.causesNamingConflict(title)) {
|
|
|
|
window.alert("Another pad already has that title");
|
|
|
|
Cryptpad.alert("Another pad already has that title");
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Cryptpad.setPadTitle(title);
|
|
|
|
Cryptpad.setPadTitle(title);
|
|
|
|
document.title = title;
|
|
|
|
document.title = title;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
$rightside.append($rename);
|
|
|
|
$rightside.append($rename);
|
|
|
|
|
|
|
|
|
|
|
|
/* add a forget button */
|
|
|
|
/* add a forget button */
|
|
|
@ -461,11 +481,11 @@ define([
|
|
|
|
.click(function () {
|
|
|
|
.click(function () {
|
|
|
|
var href = window.location.href;
|
|
|
|
var href = window.location.href;
|
|
|
|
var question = "Clicking OK will remove the URL for this pad from localStorage, are you sure?";
|
|
|
|
var question = "Clicking OK will remove the URL for this pad from localStorage, are you sure?";
|
|
|
|
|
|
|
|
Cryptpad.confirm(question, function (yes) {
|
|
|
|
if (window.confirm(question)) {
|
|
|
|
if (!yes) { return; }
|
|
|
|
Cryptpad.forgetPad(href);
|
|
|
|
Cryptpad.forgetPad(href);
|
|
|
|
document.title = window.location.hash.slice(1,9);
|
|
|
|
document.title = window.location.hash.slice(1,9);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
$rightside.append($forgetPad);
|
|
|
|
$rightside.append($forgetPad);
|
|
|
|
|
|
|
|
|
|
|
@ -474,6 +494,7 @@ define([
|
|
|
|
|
|
|
|
|
|
|
|
var title = document.title = Cryptpad.getPadTitle();
|
|
|
|
var title = document.title = Cryptpad.getPadTitle();
|
|
|
|
Cryptpad.rememberPad(title);
|
|
|
|
Cryptpad.rememberPad(title);
|
|
|
|
|
|
|
|
Cryptpad.styleAlerts();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// this should only ever get called once, when the chain syncs
|
|
|
|
// this should only ever get called once, when the chain syncs
|
|
|
|