After much fiddling, I have a working update macro.
/*\
title: $:/macros/ek/imageupdate.js
type: application/javascript
module-type: macro
embed images with class='u5m'
put <<imageupdate>> at the bottom
all images with that class will be updated every 5 minutes
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
exports.name = "imageupdate";
exports.params = [];
/*
Run the macro
*/
exports.run = function() {
setInterval(function() {
var imgElements = document.getElementsByClassName('u5m');
/* var srclist = ''; */
for (var i = 0; i < imgElements.length; i++) {
var img = imgElements[i];
img.src = ( (img.src.indexOf('?') == -1) ? img.src :
img.src.substr(0,img.src.indexOf('?')) ) + '?c=' + Math.random();
/* srclist = srclist + " " + img.src; */
}
document.getElementById('iuon').innerHTML = 'Refreshed ' + Date(); /*+
"<br>" + srclist; */
}, 300000); /* 300000 for 5 minutes */
/* for debugging, print the source list once */
var imgElements = document.getElementsByClassName('u5m');
var output = 'Img Urls:';
for (var i = 0; i < imgElements.length; i++) {
var img = imgElements[i];
output = output + " " + img.src;
}
return '<span id="iuon">Refreshed ' + Date() /* + output */ + '</span>';
};
})();
--
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 post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/b7004d02-e992-43c5-a0fc-189486781df8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.