mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-10-06 08:01:42 +00:00
Remove function wrapper from development documentation. (#9027)
This commit is contained in:
@@ -34,13 +34,11 @@ Suppose we want to make a filter operator that returns every other tiddler from
|
|||||||
We make a new tiddler, set its `type` and `module-type` appropriately, and begin writing the code:
|
We make a new tiddler, set its `type` and `module-type` appropriately, and begin writing the code:
|
||||||
|
|
||||||
```
|
```
|
||||||
(function(){
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
exports.everyother = function(source, operator, options) {
|
exports.everyother = function(source, operator, options) {
|
||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
For the example filter syntax, our function will be called with
|
For the example filter syntax, our function will be called with
|
||||||
@@ -54,7 +52,6 @@ As is usually the case, we don't care about `operator.operator` here (since that
|
|||||||
We could implement the operator by iterating over the input tiddlers and explicitly building a result array of titles:
|
We could implement the operator by iterating over the input tiddlers and explicitly building a result array of titles:
|
||||||
|
|
||||||
```
|
```
|
||||||
(function(){
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
exports.everyother = function(source, operator, options) {
|
exports.everyother = function(source, operator, options) {
|
||||||
@@ -66,7 +63,6 @@ exports.everyother = function(source, operator, options) {
|
|||||||
});
|
});
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
That is, we supply a callback to `source` that negates `include` each time through (in order to grab every other result) and pushes the `title` of every other tiddler onto the result.
|
That is, we supply a callback to `source` that negates `include` each time through (in order to grab every other result) and pushes the `title` of every other tiddler onto the result.
|
||||||
@@ -74,7 +70,6 @@ That is, we supply a callback to `source` that negates `include` each time throu
|
|||||||
Alternatively, we can return our own iterator, by returning a function that accepts a similar callback and only calls it on every other tiddler:
|
Alternatively, we can return our own iterator, by returning a function that accepts a similar callback and only calls it on every other tiddler:
|
||||||
|
|
||||||
```
|
```
|
||||||
(function(){
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
exports.everyother = function(source, operator, options) {
|
exports.everyother = function(source, operator, options) {
|
||||||
@@ -86,7 +81,6 @@ exports.everyother = function(source, operator, options) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Either way, we could interpret the `!` flag on the filter, if present, to mean that we want the //other// half of the tiddlers, by using it to set the initial value of `include`: `var include = operator.prefix !== "!";`
|
Either way, we could interpret the `!` flag on the filter, if present, to mean that we want the //other// half of the tiddlers, by using it to set the initial value of `include`: `var include = operator.prefix !== "!";`
|
||||||
|
|||||||
@@ -40,10 +40,7 @@ module-type: startup
|
|||||||
YOUR DISCRCRIPTION COMES HERE!
|
YOUR DISCRCRIPTION COMES HERE!
|
||||||
|
|
||||||
\*/
|
\*/
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global $tw: false, exports: true */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
// Export name and synchronous status
|
// Export name and synchronous status
|
||||||
@@ -63,6 +60,4 @@ exports.startup = function() {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -11,10 +11,7 @@ The wikitext parser subclassing mechanism makes it possible for custom parsers t
|
|||||||
Here is an example of a subclass of the checkbox widget that adds logging to the event handler:
|
Here is an example of a subclass of the checkbox widget that adds logging to the event handler:
|
||||||
|
|
||||||
```js
|
```js
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global $tw: false */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
var WikiParser = require("$:/core/modules/parsers/wikiparser/wikiparser.js")["text/vnd.tiddlywiki"],
|
var WikiParser = require("$:/core/modules/parsers/wikiparser/wikiparser.js")["text/vnd.tiddlywiki"],
|
||||||
@@ -38,5 +35,4 @@ var MyCustomWikiParser = function(type,text,options) {
|
|||||||
|
|
||||||
exports["text/vnd.my-custom-type"] = MyCustomWikiParser;
|
exports["text/vnd.my-custom-type"] = MyCustomWikiParser;
|
||||||
|
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -26,10 +26,7 @@ module-type: widget-subclass
|
|||||||
Widget base class
|
Widget base class
|
||||||
|
|
||||||
\*/
|
\*/
|
||||||
(function(){
|
|
||||||
|
|
||||||
/*jslint node: true, browser: true */
|
|
||||||
/*global $tw: false */
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
exports.baseClass = "checkbox"; // Extend the <$checkbox> widget
|
exports.baseClass = "checkbox"; // Extend the <$checkbox> widget
|
||||||
@@ -50,5 +47,4 @@ exports.prototype.handleChangeEvent = function(event) {
|
|||||||
console.log("Checkbox status:",this.inputDomNode.checked);
|
console.log("Checkbox status:",this.inputDomNode.checked);
|
||||||
};
|
};
|
||||||
|
|
||||||
})();
|
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user