2017-06-12 04:04:07 +08:00
|
|
|
function message(str) {
|
2017-08-22 09:31:23 +08:00
|
|
|
const top = $("#top-message");
|
|
|
|
|
2017-09-24 23:34:16 +08:00
|
|
|
top.fadeIn(1500).css("display","inline-block");
|
2017-08-22 09:31:23 +08:00
|
|
|
top.html(str);
|
|
|
|
top.fadeOut(1500);
|
2017-08-14 09:42:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function error(str) {
|
2017-08-22 09:31:23 +08:00
|
|
|
const error = $("#error-message");
|
|
|
|
|
2017-09-24 23:34:16 +08:00
|
|
|
error.show().css("display","inline-block");
|
2017-08-22 09:31:23 +08:00
|
|
|
error.html(str);
|
|
|
|
error.fadeOut(10000);
|
2017-09-07 10:06:43 +08:00
|
|
|
}
|
|
|
|
|
2017-09-19 08:48:02 +08:00
|
|
|
function getAutocompleteItems(noteIds) {
|
2017-09-10 00:06:15 +08:00
|
|
|
const autocompleteItems = [];
|
|
|
|
|
2017-09-19 08:48:02 +08:00
|
|
|
for (const noteId of noteIds) {
|
2017-09-10 00:06:15 +08:00
|
|
|
const fullName = getFullName(noteId);
|
|
|
|
|
2017-09-19 08:48:02 +08:00
|
|
|
if (fullName !== null) {
|
|
|
|
autocompleteItems.push({
|
|
|
|
value: fullName + " (" + noteId + ")",
|
|
|
|
label: fullName
|
|
|
|
});
|
|
|
|
}
|
2017-09-10 00:06:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return autocompleteItems;
|
|
|
|
}
|
|
|
|
|
2017-09-07 10:06:43 +08:00
|
|
|
function uint8ToBase64(u8Arr) {
|
|
|
|
const CHUNK_SIZE = 0x8000; //arbitrary number
|
|
|
|
const length = u8Arr.length;
|
|
|
|
let index = 0;
|
|
|
|
let result = '';
|
|
|
|
let slice;
|
|
|
|
while (index < length) {
|
|
|
|
slice = u8Arr.subarray(index, Math.min(index + CHUNK_SIZE, length));
|
|
|
|
result += String.fromCharCode.apply(null, slice);
|
|
|
|
index += CHUNK_SIZE;
|
|
|
|
}
|
|
|
|
return btoa(result);
|
|
|
|
}
|
|
|
|
|
|
|
|
function base64ToUint8Array(base64encoded) {
|
|
|
|
return new Uint8Array(atob(base64encoded).split("").map(function(c) { return c.charCodeAt(0); }));
|
2017-06-12 04:04:07 +08:00
|
|
|
}
|