|
|
@ -150,7 +150,10 @@ define([
|
|
|
|
var obj = {content: textValue};
|
|
|
|
var obj = {content: textValue};
|
|
|
|
|
|
|
|
|
|
|
|
// append the userlist to the hyperjson structure
|
|
|
|
// append the userlist to the hyperjson structure
|
|
|
|
obj.metadata = userList;
|
|
|
|
obj.metadata = {
|
|
|
|
|
|
|
|
users: userList,
|
|
|
|
|
|
|
|
title: document.title
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// set mode too...
|
|
|
|
// set mode too...
|
|
|
|
obj.highlightMode = module.highlightMode;
|
|
|
|
obj.highlightMode = module.highlightMode;
|
|
|
@ -355,6 +358,7 @@ define([
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
document.title = title;
|
|
|
|
document.title = title;
|
|
|
|
|
|
|
|
onLocal();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
@ -461,13 +465,33 @@ define([
|
|
|
|
});
|
|
|
|
});
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var updateUserList = function(shjson) {
|
|
|
|
var updateTitle = function (newTitle) {
|
|
|
|
|
|
|
|
if (newTitle === document.title) { return; }
|
|
|
|
|
|
|
|
// Change the title now, and set it back to the old value if there is an error
|
|
|
|
|
|
|
|
var oldTitle = document.title;
|
|
|
|
|
|
|
|
document.title = newTitle;
|
|
|
|
|
|
|
|
Cryptpad.setPadTitle(newTitle, function (err, data) {
|
|
|
|
|
|
|
|
if (err) {
|
|
|
|
|
|
|
|
console.log("Couldn't set pad title");
|
|
|
|
|
|
|
|
console.error(err);
|
|
|
|
|
|
|
|
document.title = oldTitle;
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var updateMetadata = function(shjson) {
|
|
|
|
// Extract the user list (metadata) from the hyperjson
|
|
|
|
// Extract the user list (metadata) from the hyperjson
|
|
|
|
var hjson = (shjson === "") ? "" : JSON.parse(shjson);
|
|
|
|
var json = (shjson === "") ? "" : JSON.parse(shjson);
|
|
|
|
if(hjson && hjson.metadata) {
|
|
|
|
if (json && json.metadata) {
|
|
|
|
var userData = hjson.metadata;
|
|
|
|
if (json.metadata.users) {
|
|
|
|
// Update the local user data
|
|
|
|
var userData = json.metadata.users;
|
|
|
|
addToUserList(userData);
|
|
|
|
// Update the local user data
|
|
|
|
|
|
|
|
addToUserList(userData);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (json.metadata.title) {
|
|
|
|
|
|
|
|
updateTitle(json.metadata.title);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
@ -572,7 +596,7 @@ define([
|
|
|
|
var shjson = module.realtime.getUserDoc();
|
|
|
|
var shjson = module.realtime.getUserDoc();
|
|
|
|
|
|
|
|
|
|
|
|
// Update the user list (metadata) from the hyperjson
|
|
|
|
// Update the user list (metadata) from the hyperjson
|
|
|
|
updateUserList(shjson);
|
|
|
|
updateMetadata(shjson);
|
|
|
|
|
|
|
|
|
|
|
|
var hjson = JSON.parse(shjson);
|
|
|
|
var hjson = JSON.parse(shjson);
|
|
|
|
var remoteDoc = hjson.content;
|
|
|
|
var remoteDoc = hjson.content;
|
|
|
@ -607,7 +631,10 @@ define([
|
|
|
|
var localDoc = canonicalize($textarea.val());
|
|
|
|
var localDoc = canonicalize($textarea.val());
|
|
|
|
var hjson2 = {
|
|
|
|
var hjson2 = {
|
|
|
|
content: localDoc,
|
|
|
|
content: localDoc,
|
|
|
|
metadata: userList,
|
|
|
|
metadata: {
|
|
|
|
|
|
|
|
users: userList,
|
|
|
|
|
|
|
|
title: document.title
|
|
|
|
|
|
|
|
},
|
|
|
|
highlightMode: highlightMode,
|
|
|
|
highlightMode: highlightMode,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
var shjson2 = stringify(hjson2);
|
|
|
|
var shjson2 = stringify(hjson2);
|
|
|
|