Hi Tiddlywikians,
I volunteered for a job in my food-coop which I thought would be easy to solve in TW.
I promised to create a sort of doodle where people can choose the time they do some necessary tasks which is the stored in a dictionary tiddler.
It turns out that I somehow miscalulated the task, because in TW if two people save in the same time, or download the wiki and save the result much later one result is lost ( I am on php single file setup).
My approach now is to update a single Tiddler by
- retrievieng it from a txt-file on the server with http-request,
- perform the action to create a new dictionary-tiddler and
- post an updated version of the dictionary-tiddler 1sec later with .js
- to save it on the server with the help of a php-file.
I can build a http request that you find down below.
But I do not know how to perform the upload which in this case cannot be done with a simple form like demonstrated here, but has to be triggered with .js to be performed after the other actions.
Who can teach me how to upload a tiddlers text to a php
/*\
title: $:/plugins/JJ/InterAction/macros/dataurl.js
type: application/javascript
module-type: macro
Macro to fetch an integrate a textfile from the server.
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name = "getdata";
/*
Run the macro
*/
exports.run = function() {
var dataurl = "data.txt";
var client = new XMLHttpRequest();client.open('GET', dataurl , false);
client.setRequestHeader('Content-type', 'Content-Type: text/html; charset=ISO-8859-1');
client.onreadystatechange = function() {
if (client.readyState == 4 && client.status == 200)
{
var data = client.responseText;
var fields = {title: '$:/temp/data', text: data}
$tw.wiki.addTiddler(new $tw.Tiddler(fields))
}
}
client.send();
})();