1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-18 07:44:51 +00:00
TiddlyWiki5/editions/dev/tiddlers/javascript-widget-tutorial/tiddlerfield-norefresh.js
btheado 6af3eb539b
Adds a javascript widget tutorial to the dev tiddlywiki edition (#7016)
* Initial widget tutorials extracted from https://btheado.github.io/tw-widget-tutorial/

* Fixes for refresh behavior change
2022-10-30 16:10:12 +00:00

37 lines
717 B
JavaScript

/*\
Hello, World widget
\*/
(function() {
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Widget = require("$:/core/modules/widgets/widget.js").widget;
var MyWidget = function(parseTreeNode, options) {
this.initialise(parseTreeNode, options);
};
/*
Inherit from the base widget class
*/
MyWidget.prototype = new Widget();
/*
Render this widget into the DOM
*/
MyWidget.prototype.render = function(parent, nextSibling) {
this.parentDomNode = parent;
var text = this.wiki.getTiddlerText("test", "<empty>")
var textNode = this.document.createTextNode(text);
parent.insertBefore(textNode, nextSibling);
this.domNodes.push(textNode);
};
exports.tiddlerfield = MyWidget;
})();