2015-09-01 16:25:45 +00:00
|
|
|
/*\
|
|
|
|
title: $:/plugins/tiddlywiki/text-slicer/modules/commands/slice.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: command
|
|
|
|
|
|
|
|
Command to slice a specified tiddler
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
2016-12-22 17:46:42 +00:00
|
|
|
var widget = require("$:/core/modules/widgets/widget.js"),
|
|
|
|
textSlicer = require("$:/plugins/tiddlywiki/text-slicer/modules/slicer.js");
|
2015-09-01 16:25:45 +00:00
|
|
|
|
|
|
|
exports.info = {
|
|
|
|
name: "slice",
|
2016-02-27 12:25:48 +00:00
|
|
|
synchronous: false
|
2015-09-01 16:25:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
var Command = function(params,commander,callback) {
|
|
|
|
this.params = params;
|
|
|
|
this.commander = commander;
|
|
|
|
this.callback = callback;
|
|
|
|
};
|
|
|
|
|
|
|
|
Command.prototype.execute = function() {
|
|
|
|
if(this.params.length < 1) {
|
|
|
|
return "Missing parameters";
|
|
|
|
}
|
|
|
|
var self = this,
|
|
|
|
wiki = this.commander.wiki,
|
2016-02-27 12:25:48 +00:00
|
|
|
sourceTitle = this.params[0],
|
|
|
|
destTitle = this.params[1],
|
2016-12-22 17:46:42 +00:00
|
|
|
slicer = new textSlicer.Slicer({
|
|
|
|
sourceTiddlerTitle: sourceTitle,
|
|
|
|
baseTiddlerTitle: destTitle,
|
|
|
|
wiki: wiki
|
2016-02-27 12:25:48 +00:00
|
|
|
});
|
2016-12-22 17:46:42 +00:00
|
|
|
wiki.addTiddlers(slicer.getTiddlers());
|
2016-02-27 12:25:48 +00:00
|
|
|
$tw.utils.nextTick(this.callback);
|
2015-09-01 16:25:45 +00:00
|
|
|
return null;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.Command = Command;
|
|
|
|
|
|
|
|
})();
|