Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.id = 'search2';
- exports.title = 'Searcher East';
- exports.group = 'Common';
- exports.color = '#2ec9e2';
- exports.input = 1;
- exports.output = 1;
- exports.author = 'DPain';
- exports.icon = 'tasks';
- exports.version = '0.0.1';
- exports.options = {
- name: '',
- age: '',
- height: '',
- hobby: ''
- };
- exports.html = `<div data-scope="?__init:scopeinit">
- <div class="padding">
- <div class="row">
- <div class="col-md-6 m">
- <div data---="input__?.name__required:1;placeholder:Search or Create a Name;dirsource:name_list;dircustom:true;$setter:request_preset">@(Name)</div>
- </div>
- <div class="col-md-6 m">
- <div data---="textbox__?.age__type:string">@(Age)</b></div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-12 m">
- <div data---="textbox__?.height__type:string">@(Height)</div>
- </div>
- </div>
- <div class="row">
- <div class="col-md-12 m">
- <div data---="textbox__?.hobby__type:string">@(Hobby)</div>
- </div>
- </div>
- </div>
- </div>
- <script>
- name_list = ['Ai', 'Bao', 'Chan'];
- presets = [
- {
- name: 'Ai',
- age: '99',
- height: '80cm',
- hobby: 'Bowling'
- }, {
- name: 'Bao',
- age: '88',
- height: '85cm',
- hobby: 'Movies'
- }, {
- name: 'Chan',
- age: '77',
- height: '60cm',
- hobby: 'Video Games'
- }
- ];
- /*
- Scope for this component.
- */
- scope = null;
- function scopeinit(path, el) {
- scope = el.scope();
- console.log(scope.id);
- console.log(scope.path);
- }
- // ----- //
- old_value = null;
- function request_preset(value) {
- // Value is not empty.
- if (value != null) {
- // Value is different.
- if (value != old_value) {
- old_value = value;
- if (name_list.includes(value)) {
- console.log('Selected value is not a custom value!');
- let obj = null;
- presets.forEach(function(element) {
- if(element.name == value) {
- obj = element;
- }
- });
- if(obj != null) {
- Object.keys(obj).forEach(function(key) {
- console.log(key);
- scope.set(key, obj[key]);
- });
- }
- }
- }
- }
- }
- ON('save.search2', function(component, options) {
- // Reassigning values to options.
- Object.keys(options).forEach(function(key) {
- let val = scope.get(key);
- if (val != null) {
- options[key] = val;
- }
- });
- });
- </script>`
- exports.readme = `# Test`
- exports.install = function (instance) {
- instance.on('data', function (response) {
- console.log(response);
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement