Hi!
The question is just about refreshing now, the timeout-issue is solved
by the code below.
-A new question arises: How can I call a modal in a widget?
-How do I refresh this widget?
You can see the mechanism working go to Szenio.de/Test
Cheers 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() {
var monitor = setInterval(function(){
var elem = document.activeElement;
if(elem && elem.tagName == 'IFRAME'){
setTimeout(TimeoutFunction, 300);
clearInterval(monitor);
}
}, 100);
};
function TimeoutFunction(url) {
var client = new XMLHttpRequest();client.open('GET', "handover.txt",
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: client.responseText}
$tw.wiki.addTiddler(new $tw.Tiddler(fields))
}
}
client.send();
}
})();|
Am 21.07.2019 um 16:04 schrieb Jan:
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
--
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/5D34B09E.5060409%40googlemail.com.