AnonSec Team
Server IP : 127.0.0.1  /  Your IP : 127.0.0.1
Web Server : Apache/2.4.10 (Win32) OpenSSL/1.0.1i PHP/5.6.3
System : Windows NT WIN-R7LTCC7BPLI 6.3 build 9200 (Windows Server 2012 R2 Datacenter Edition) i586
User : GerbangSIPAD ( 0)
PHP Version : 5.6.3
Disable Function : NONE
MySQL : ON  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF
Directory (0777) :  C:/xampp5/htdocs/bhumie/../bphtb/js/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : C:/xampp5/htdocs/bhumie/../bphtb/js/readonly.js
/**
 * Readonly v2.0.1
 * by Arthur Corenzan <arthur@corenzan.com>
 * more on https://github.com/haggen/readonly
 */
;(function(undefined) {

  var readonly = function(target) {
    target.setAttribute('disabled', true);
    target.setAttribute('readonly', true);
    target.classList.add('readonly');

    if (!hasSham(target)) {
      var sham = document.createElement('input');

      sham.name = target.name;
      sham.type = 'hidden';
      sham.value = target.value;
      sham.setAttribute('data-sham', target.name);

      target.parentNode.insertBefore(sham, target.nextSibling);
    }
  };

  var editable = function(target) {
    target.removeAttribute('disabled');
    target.removeAttribute('readonly');
    target.classList.remove('readonly');

    if(hasSham(target)) {
      target.parentNode.removeChild(target.nextElementSibling);
    }
  };

  var toggle = function(target, value) {
    console.log(target, value)

    if(typeof target === 'string') {
      target = document.querySelectorAll(target);
    }

    if(target instanceof HTMLElement) {
      target = [target];
    }

    [].forEach.call(target, function(el) {
      if(value === undefined ? !el.getAttribute('data-readonly') : value) {
        readonly(el);
      } else {
        editable(el);
      }
    });
  }

  var hasSham = function (target) {
    return target.nextElementSibling && target.nextElementSibling.getAttribute('data-sham') === target.name;
  }

  if(this.jQuery !== undefined) {
    this.jQuery.fn.readonly = function(value) {
      return this.each(function() {
        toggle(this, value);
      });
    };
  }

  this.readonly = toggle;

})(this);

AnonSec - 2021