VaKeR CYBER ARMY
Logo of a company Server : Apache/2.4.41 (Ubuntu)
System : Linux absol.cf 5.4.0-198-generic #218-Ubuntu SMP Fri Sep 27 20:18:53 UTC 2024 x86_64
User : www-data ( 33)
PHP Version : 7.4.33
Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Directory :  /var/www/html/libs/absol-full/dist/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /var/www/html/libs/absol-full/dist/js/mdls__absol-acomp__js__adapter__SearchObjectArrayAdapter.js
/*** module: node_modules/absol-acomp/js/adapter/SearchObjectArrayAdapter.js ***/
"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

/**
 * @typedef {Object} SearchObjectArrayAdapter
 * @property {function} getItemText
 * 
 * 
 * 
 * @param {Array<Object>} arr 
 * @param {SearchArrayAdapterOption} options
 */
function SearchObjectArrayAdapter(objects, options) {
  if (!this.queryItems) return new SearchObjectArrayAdapter(texts, options);
  this.objects = objects;
  this.options = options;
}

SearchObjectArrayAdapter.prototype.queryItems = function (query, mInput) {
  var query = query.toLocaleLowerCase();
  return this.objects.map(function (object) {
    var text = this.getItemText(object);
    var start = text.toLocaleLowerCase().indexOf(query);

    if (start >= 0) {
      var hightlightedText = text.substr(0, start) + '<strong style="color:red">' + text.substr(start, query.length) + '</strong>' + text.substr(start + query.length);
      return Object.assign(object, {
        __hightlightedText__: hightlightedText
      });
    } else return null;
  }.bind(this)).filter(function (it) {
    return it !== null;
  });
};

SearchObjectArrayAdapter.prototype.onAttached = function (parent) {
  this.parent = parent;

  parent.getSelectedObject = function () {
    if (this._selectedIndex >= 0) {
      return this.$poolItems[this._selectedIndex]._holderItem;
    } else {
      return null;
    }
  };
};

SearchObjectArrayAdapter.prototype.getItemText = function (item, mInput) {
  if (this.options && this.options.getItemText) return this.options.getItemText.call(this, item, mInput);else if (typeof item.text == 'string') {
    return item.text;
  } else return item.toString();
};

SearchObjectArrayAdapter.prototype.getItemView = function (item, index, _, $, query, reuseItem, refParent, mInput) {
  if (reuseItem) {
    reuseItem.childNodes[0].innerHTML = item.__hightlightedText__;
    return reuseItem;
  } else return _({
    tag: 'div',
    child: {
      tag: 'span',
      props: {
        innerHTML: item.__hightlightedText__
      }
    }
  });
};

var _default = SearchObjectArrayAdapter;
exports.default = _default;

VaKeR 2022