On Thursday, December 5, 2013 2:42:56 PM UTC+1, infernoape wrote:Imo it also depends on your usecase. eg:Well, I found setTimeout(), setInterval(), clearTimeout(), and clearInterval() which are supported by node.js but I'm trying to access the computer's internal clock using what? It's just javascript? I'm confused as to what language to use to program a widget in TW5? Does it matter if I'm using TW5 stand alone edition or if it is shared via an actual node.js install?
If you just want to show the actual time somewhere, the iframe solution jeremy suggested, imo would be the best solution.
If you want to click the watch and record some start / stop timestamps to eg: track working hours, imo it would be the best idea to just get the actual time / date if you click a "start" or "stop" button .....
So if you can describe your usecase a bit closer, we may be able to point you in the right direction, that fits your usecase, instead of guessing your usecase.
-mario
I am still trying to make my first widget, which is still a clock button for my top menu. So here is what I have so far. I put the following in a tiddler with title: $:/core/modules/widgets/clock.js, Type: application/javascript and added a filed module-type: widget. In another tiddler I put <$clock> but all still get Undefined widget 'clock'. What am I missing?
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/groups/opt_out.
/*\
title: $:/core/modules/widgets/clock.js
type: application/javascript
module-type: widget
A widget to display a clock
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Widget = require("$:/core/modules/widgets/widget.js").widget;
var ClockWidget = function(parseTreeNode,options) {
this.initialise(parseTreeNode,options);
};
/*
Inherit from the base widget class
*/
ClockWidget.prototype = new Widget();
/*
Render this widget into the DOM
*/
ClockWidget.prototype.render = function(parent,nextSibling) {
this.parentDomNode = parent;
this.computeAttributes();
this.execute();
var domNode = this.document.createElement('p');
domNode.setAttribute("id","tw-clockbutton");
parent.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null);
this.domNodes.push(domNode);
};
/*
Compute the internal state of the widget
*/
ClockWidget.prototype.execute = function() {
var myVar=setInterval(function(){
var d=new Date();
var t=d.toLocaleTimeString();
document.getElementById("tw-clockbutton").innerHTML=t;
},1000);
};
/*
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/
ClockWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes(),
hasChangedAttributes = $tw.utils.count(changedAttributes) > 0;
if(hasChangedAttributes) {
// Update our attributes
this.assignAttributes(this.domNodes[0]);
}
return this.refreshChildren(changedTiddlers) || hasChangedAttributes;
};
exports.clock = ClockWidget;
})();I think it could be quite helpful, would you put yor stuff on tiddlyspot or somewhere else where we can view it.
--
I know it has been over a year but after alot of learning and reading all messages again, I discovered one of jeremy's responses about my clock and I thought I would try to tackle it again. When I put startup module-type in and save and reload, well, obviouly I don't know how to program. Anyone interested in helping? http://t5a.tiddlyspot.com/#%24%3A%2FModules%2FStartup%2FClock.js Just trying to follow jeremy's suggestion of a system tiddler that automatically updates with the time.
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.
Thank you for looking at this. Well, I tried it and now I have a setText error message. I'm wondering if I'm trying to do something before a function is defined? I can't run developer tools from my phone. Do I have to pass "text" and "null" as params? I thought that setText didn't need them.
--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To post to this group, send email to tiddly...@googlegroups.com.
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.
exports.startup = function() {
var timer=setInterval(function(){
var d=new Date();
var t=d.toLocaleTimeString();
$tw.wiki.addTiddler(new $tw.Tiddler({title: "$:/temp/clock", text: t}));
},250);
};--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywikidev/qwyXraJ6bkI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to tiddlywikide...@googlegroups.com.