Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-163-generic #173-Ubuntu SMP Tue Oct 14 17:51:00 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/.nvm/versions/node/v18.17.1/lib/node_modules/pm2/node_modules/blessed/lib/widgets/ drwxr-xr-x | |
| Viewing file: Select action/file-type: /**
* checkbox.js - checkbox element for blessed
* Copyright (c) 2013-2015, Christopher Jeffrey and contributors (MIT License).
* https://github.com/chjj/blessed
*/
/**
* Modules
*/
var Node = require('./node');
var Input = require('./input');
/**
* Checkbox
*/
function Checkbox(options) {
var self = this;
if (!(this instanceof Node)) {
return new Checkbox(options);
}
options = options || {};
Input.call(this, options);
this.text = options.content || options.text || '';
this.checked = this.value = options.checked || false;
this.on('keypress', function(ch, key) {
if (key.name === 'enter' || key.name === 'space') {
self.toggle();
self.screen.render();
}
});
if (options.mouse) {
this.on('click', function() {
self.toggle();
self.screen.render();
});
}
this.on('focus', function() {
var lpos = self.lpos;
if (!lpos) return;
self.screen.program.lsaveCursor('checkbox');
self.screen.program.cup(lpos.yi, lpos.xi + 1);
self.screen.program.showCursor();
});
this.on('blur', function() {
self.screen.program.lrestoreCursor('checkbox', true);
});
}
Checkbox.prototype.__proto__ = Input.prototype;
Checkbox.prototype.type = 'checkbox';
Checkbox.prototype.render = function() {
this.clearPos(true);
this.setContent('[' + (this.checked ? 'x' : ' ') + '] ' + this.text, true);
return this._render();
};
Checkbox.prototype.check = function() {
if (this.checked) return;
this.checked = this.value = true;
this.emit('check');
};
Checkbox.prototype.uncheck = function() {
if (!this.checked) return;
this.checked = this.value = false;
this.emit('uncheck');
};
Checkbox.prototype.toggle = function() {
return this.checked
? this.uncheck()
: this.check();
};
/**
* Expose
*/
module.exports = Checkbox;
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0033 ]-- |