Software zum Installieren eines Smart-Mirror Frameworks , zum Nutzen von hochschulrelevanten Informationen, auf einem Raspberry-Pi.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

class.js 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /* global Class, xyz */
  2. /* Simple JavaScript Inheritance
  3. * By John Resig https://johnresig.com/
  4. *
  5. * Inspired by base2 and Prototype
  6. *
  7. * MIT Licensed.
  8. */
  9. (function () {
  10. let initializing = false;
  11. const fnTest = /xyz/.test(function () {
  12. xyz;
  13. })
  14. ? /\b_super\b/
  15. : /.*/;
  16. // The base Class implementation (does nothing)
  17. this.Class = function () {};
  18. // Create a new Class that inherits from this class
  19. Class.extend = function (prop) {
  20. let _super = this.prototype;
  21. // Instantiate a base class (but only create the instance,
  22. // don't run the init constructor)
  23. initializing = true;
  24. const prototype = new this();
  25. initializing = false;
  26. // Make a copy of all prototype properties, to prevent reference issues.
  27. for (const p in prototype) {
  28. prototype[p] = cloneObject(prototype[p]);
  29. }
  30. // Copy the properties over onto the new prototype
  31. for (const name in prop) {
  32. // Check if we're overwriting an existing function
  33. prototype[name] =
  34. typeof prop[name] === "function" && typeof _super[name] === "function" && fnTest.test(prop[name])
  35. ? (function (name, fn) {
  36. return function () {
  37. const tmp = this._super;
  38. // Add a new ._super() method that is the same method
  39. // but on the super-class
  40. this._super = _super[name];
  41. // The method only need to be bound temporarily, so we
  42. // remove it when we're done executing
  43. const ret = fn.apply(this, arguments);
  44. this._super = tmp;
  45. return ret;
  46. };
  47. })(name, prop[name])
  48. : prop[name];
  49. }
  50. /**
  51. * The dummy class constructor
  52. */
  53. function Class() {
  54. // All construction is actually done in the init method
  55. if (!initializing && this.init) {
  56. this.init.apply(this, arguments);
  57. }
  58. }
  59. // Populate our constructed prototype object
  60. Class.prototype = prototype;
  61. // Enforce the constructor to be what we expect
  62. Class.prototype.constructor = Class;
  63. // And make this class extendable
  64. Class.extend = arguments.callee;
  65. return Class;
  66. };
  67. })();
  68. /**
  69. * Define the clone method for later use. Helper Method.
  70. *
  71. * @param {object} obj Object to be cloned
  72. * @returns {object} the cloned object
  73. */
  74. function cloneObject(obj) {
  75. if (obj === null || typeof obj !== "object") {
  76. return obj;
  77. }
  78. const temp = obj.constructor(); // give temp the original obj's constructor
  79. for (const key in obj) {
  80. temp[key] = cloneObject(obj[key]);
  81. if (key === "lockStrings") {
  82. Log.log(key);
  83. }
  84. }
  85. return temp;
  86. }
  87. /*************** DO NOT EDIT THE LINE BELOW ***************/
  88. if (typeof module !== "undefined") {
  89. module.exports = Class;
  90. }