1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-17 23:34:50 +00:00
TiddlyWiki5/plugins/tiddlywiki/tahoelafs/saver.js
2013-04-26 22:18:46 +01:00

58 lines
1.1 KiB
JavaScript

/*\
title: $:/plugins/tiddlywiki/tahoelafs/saver.js
type: application/javascript
module-type: saver
A bare bones saver for Tahoe-LAFS. It just PUTs the new HTML file back to the server at the same URL.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Select the appropriate saver module and set it up
*/
var TahoeSaver = function(wiki) {
this.wiki = wiki;
};
TahoeSaver.prototype.save = function(text) {
// Do the HTTP post
var http = new XMLHttpRequest();
http.open("PUT",document.location.toString(),true);
http.onreadystatechange = function() {
if(http.readyState == 4 && http.status == 200) {
window.alert("Saved to Tahoe-LAFS: " + http.responseText);
}
};
http.send(text);
return true;
};
/*
Information about this saver
*/
TahoeSaver.prototype.info = {
name: "tahoelafs",
priority: 1000
};
/*
Static method that returns true if this saver is capable of working
*/
exports.canSave = function(wiki) {
return true;
};
/*
Create an instance of this saver
*/
exports.create = function(wiki) {
return new TahoeSaver(wiki);
};
})();