Hello,
Mark and Jed helped me to build a widget, which shall directly import a
textfile with one click.
The construction is quite complex
The first function detects the click on an Iframe and the second imports
the URL by |XMLHttpRequest|.
On the backend a php writes the clicked address into a textfile which
ist read by the second function.
already worked with two flaws this workes with two flaws.
1. I works just once, so the widget shoud refresh.
2. Because the serverside appears to be slower I had to weave in a one
second timeout before executing the|||XMLHttpRequest|.
My attempt is below and on szenio.de/test you can see the working proof
which suffers from the delay of the server and thus points to the click
before.
It would be great if you could help me on this issue.
Ciao Jan
|/*\
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: "url"}
];
/*
Run the macro
*/
exports.run = function(url) {
var monitor = setInterval(function(){
var elem = document.activeElement;
if(elem && elem.tagName == 'IFRAME'){
setTimeout(TimeoutFunction, 1000);
clearInterval(monitor);
}
}, 100);
};
function TimeoutFunction(url) {
var client = new XMLHttpRequest();
client.open('GET', url, false);
client.setRequestHeader('Content-type', 'Content-Type: text/html;
charset=ISO-8859-1');
client.onreadystatechange = function() {
if (client.readyState == 4 && client.status == 200)
{
var urltext = unescape(client.responseText);
var fields = {title: '$:/Temp/URL', text: urltext}
$tw.wiki.addTiddler(new $tw.Tiddler(fields))
}
}
client.send();
}
})();|
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/5D347106.7040807%40googlemail.com.