tuiHoneyPot

front and back end of my TUI honeypot
Log | Files | Refs | README

command.js (1428B)


      1 /**
      2  * The base command object, commands should extend this object
      3  * @return {Object}
      4  */
      5 window.FakeTerminal.command = function (instance) {
      6 
      7     /**
      8      * Avoid scope issues by using `base` instead of `this`
      9      * @type {Object}
     10      */
     11     var base = this;
     12 
     13     // --------------------------------------------------------------------------
     14 
     15     /**
     16      * The commands main deferred object; this is resolved or rejected when the
     17      * command completes
     18      * @type {$.Deferred}
     19      */
     20     base.deferred = new $.Deferred();
     21 
     22     // --------------------------------------------------------------------------
     23 
     24     /**
     25      * Describes the command
     26      * @return {Object}
     27      */
     28     base.info = function () {
     29         return {
     30             'private': true
     31         };
     32     };
     33 
     34     // --------------------------------------------------------------------------
     35 
     36     /**
     37      * This method is called when fake terminal encounters the command which this class represents
     38      * @return {Object} A promise which will be resolved when the command completes
     39      */
     40     base.execute = function () {
     41         base.deferred.resolve();
     42         return base.deferred.promise();
     43     };
     44 
     45     // --------------------------------------------------------------------------
     46 
     47     /**
     48      * Called if the command is terminated with CTL+C; useful for cleaning up
     49      */
     50     base.terminate = function() {
     51         base.deferred.reject();
     52     };
     53 };