|
|
@ -17,12 +17,10 @@ define([
|
|
|
|
return secret;
|
|
|
|
return secret;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var rememberPad = common.rememberPad = window.rememberPad = function () {
|
|
|
|
var storageKey = common.storageKey = 'CryptPad_RECENTPADS';
|
|
|
|
// bail out early
|
|
|
|
var timeframe = common.timeframe = 1000 * 60 * 60 * 24 * 30;
|
|
|
|
if (!/#/.test(window.location.hash)) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var storageKey = 'CryptPad_RECENTPADS';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getRecentPads = function () {
|
|
|
|
var recentPadsStr = localStorage[storageKey];
|
|
|
|
var recentPadsStr = localStorage[storageKey];
|
|
|
|
|
|
|
|
|
|
|
|
var recentPads = [];
|
|
|
|
var recentPads = [];
|
|
|
@ -34,17 +32,61 @@ define([
|
|
|
|
// just overwrite it.
|
|
|
|
// just overwrite it.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return recentPads;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var setRecentPads = function (pads) {
|
|
|
|
|
|
|
|
localStorage[storageKey] = JSON.stringify(pads);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var rememberPad = common.rememberPad = window.rememberPad = function (title) {
|
|
|
|
|
|
|
|
// bail out early
|
|
|
|
|
|
|
|
if (!/#/.test(window.location.hash)) { return; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var recentPads = getRecentPads();
|
|
|
|
|
|
|
|
|
|
|
|
var now = new Date();
|
|
|
|
var now = new Date();
|
|
|
|
var timeframe = 1000 * 60 * 60 * 24 * 30;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var out = recentPads.filter(function (pad) {
|
|
|
|
var out = recentPads.filter(function (pad) {
|
|
|
|
return (pad && pad[0] !== window.location.href &&
|
|
|
|
return (pad && pad[0] !== window.location.href &&
|
|
|
|
(now.getTime() - new Date(pad[1]).getTime()) < timeframe);
|
|
|
|
(now.getTime() - new Date(pad[1]).getTime()) < timeframe);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
out.push([window.location.href, now]);
|
|
|
|
// href, atime, name
|
|
|
|
localStorage[storageKey] = JSON.stringify(out);
|
|
|
|
out.push([window.location.href, now, title || '']);
|
|
|
|
|
|
|
|
setRecentPads(out);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var setPadTitle = common.setPadTitle = function (name) {
|
|
|
|
|
|
|
|
var href = window.location.href;
|
|
|
|
|
|
|
|
var recent = getRecentPads();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var renamed = recent.map(function (pad) {
|
|
|
|
|
|
|
|
if (pad[0] === href) {
|
|
|
|
|
|
|
|
// update the atime
|
|
|
|
|
|
|
|
pad[1] = new Date().toISOString();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// set the name
|
|
|
|
|
|
|
|
pad[2] = name;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//console.log(pad);
|
|
|
|
|
|
|
|
return pad;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setRecentPads(renamed);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var getPadTitle = common.getPadTitle = function () {
|
|
|
|
|
|
|
|
var href = window.location.href;
|
|
|
|
|
|
|
|
var hashSlice = window.location.hash.slice(1,9);
|
|
|
|
|
|
|
|
var title = '';
|
|
|
|
|
|
|
|
getRecentPads().some(function (pad) {
|
|
|
|
|
|
|
|
if (pad[0] === href) {
|
|
|
|
|
|
|
|
title = pad[2] || hashSlice;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
return title;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var importContent = common.importContent = function (type, f) {
|
|
|
|
var importContent = common.importContent = function (type, f) {
|
|
|
|