Hi!
I need to get the content of the field text as a variable for a
macro. This macro is triggered when an Iframe is clicked. Therefore
it does not need a macrocall.
It generates three tiddler for textfiles on the server via
http.requests. The aim ist to receive postings from students which
are clicked in a PHP in an Iframe and then generate kartouche.txt.
This worked some time with the names of the files ("kartouche.txt")
but then it ceased to wor because the request got caught by the
Proxy. So I need to combine it to a changing number generated in the
text of
$:/Temp/anti
+ "kartouche.txt" to get a changing name.
This is my approach but it does not work yet. Handicap: The solution
should also work calling just "kartouche.txt" if "anti" is not set
yet.
Thanks for your help
title: $:/core/modules/macros/urltext.js
type: application/javascript
module-type: macro
Makro, das eine Textdatei darstellt
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
/*
Information about this macro
*/
exports.name = "geturl";
exports.params = [
{name: "anti"}
];
/*
Run the macro
*/
exports.run = function() {
var monitor = setInterval(function(){
var elem = document.activeElement;
if(elem && elem.tagName == 'IFRAME'){
setTimeout(TimeoutFunction, 350);
clearInterval(monitor);
}
}, 100);
};
function TimeoutFunction(anti) {
var kartouche = anti + "kartouche.txt";
var client = new XMLHttpRequest();client.open('GET', kartouche , false);
client.setRequestHeader('Content-type', 'Content-Type: text/html; charset=ISO-8859-1');
client.onreadystatechange = function() {
if (client.readyState == 4 && client.status == 200)
{
var titel = client.responseText.replace("+", "%20");
var fields = {title: '$:/Temp/URL', text: titel}
$tw.wiki.addTiddler(new $tw.Tiddler(fields))
}
}
client.send();
var kassiber = anti + "kassiber.txt";
var inhalt = new XMLHttpRequest();inhalt.open('GET', kassiber, false);
inhalt.setRequestHeader('Content-type', 'Content-Type: text/html; charset=ISO-8859-1');
inhalt.onreadystatechange = function() {
if (inhalt.readyState == 4 && inhalt.status == 200)
{
var nachricht = inhalt.responseText.replace("+", "%20");
var fields = {title: '$:/Temp/URL-Text', text: nachricht}
$tw.wiki.addTiddler(new $tw.Tiddler(fields))
}
}
inhalt.send();
var geo = anti + "position.txt";
var position = new XMLHttpRequest();position.open('GET', geo, false);
position.setRequestHeader('Content-type', 'Content-Type: text/html; charset=ISO-8859-1');
position.onreadystatechange = function() {
if (position.readyState == 4 && position.status == 200)
{
var koordinaten = position.responseText.replace("+", "%20");
var fields = {title: '$:/Temp/URL-Position', text: koordinaten}
$tw.wiki.addTiddler(new $tw.Tiddler(fields))
}
}
position.send();
}
})();