-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsaveScripts.js
37 lines (32 loc) · 994 Bytes
/
saveScripts.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const getSaveScript = () => `
<script type="text/javascript">
var saveFile = function(fileUrl,content) {
jQuery.ajax({
type: 'POST',
url: '/receive?loc=' + btoa(document.location.pathname.substring(1)) + '&lastSaved=' + window.wikiModified.toISOString(),
data: content,
success: function(msg) {
window.wikiModified = new Date();
console.log("Wiki saved.");
},
error: function(xhr, textStatus, errorThrown) {
var saveFailedMessage = "Save failed";
clearMessage();
displayMessage(saveFailedMessage);
alert(saveFailedMessage + ": " + xhr.responseText);
}
});
return true;
};
if(typeof config.options.chkHttpReadOnly === "boolean"){
config.options.chkHttpReadOnly = false;
}
if(!window.wikiModified){
window.wikiModified = new Date();
}
</script>`;
const getPostScript = () => "\n\n<!--POST-SCRIPT-END-->\n\n</body>\n</html>";
module.exports = {
getSaveScript: getSaveScript,
getPostScript: getPostScript
};