Giter Club home page Giter Club logo

servicemanager-classier's Introduction

Currently unmaintained since I have moved from Microfocus Service Manager to ServiceNow - Sorry guys!

servicemanager-classier

This class extending engine is a fork from https://github.com/ironboy/classier.

It includes only the required changes to make it work inside the service manager.

A detailed description how this engine works is available here: https://classier.cloudeducation.se/

Limitations

  • You have to define the _class variable, because the service manager has no DOM or something else which is required to use the existing functionality from the classier engine

  • The definition of private and protected variables has no effect. It's always possible to access private & protected variables - The reason for this is the old javascript version.

Real Life Example

Simple Example

ScriptLibrary: Animal

var classier = system.library.classier.getClass();

var Animal = classier.$extend({

    _class : "Animal",

    __init__ : function(name, age) {
        this.name = name;
        this.age = age;
    },

    health: 100,
    _secret: "I'm always hungry.",
    __extraSecret: "I'm scared of humans.",

      // as well as methods
    die : function() {
        this.health = 0;
    },

    eat : function(what) {
        this.health += 5;
    },

    tellSecret : function() {
        return this._secret;
    },

    tellExtraSecret : function() {
        return this.__extraSecret;
    }

});

var Tiger = Animal.$extend({

    _class : "Tiger",

    eat : function(animal) {
        this.$super(animal);
        animal.die();
    }
});

var Sheep = Animal.$extend({

    _class : "Sheep",

    __init__ : function(name, age, shorn) {
        this.$super(name, age);
        this.shorn = shorn;
    }

});

function getClass() {
	return {
		'animal' : Animal,
		'tiger' : Tiger,
		'sheep' : Sheep
	};
}

ScriptLibrary: AnimalTest

var Animals = system.library.Animal.getClass();
var Animal = Animals['animal'];
var Tiger = Animals['tiger'];
var Sheep = Animals['sheep'];

var Anni = new Animal('Anni', 5);
var Leo = new Tiger('Leo',3);
var Molly = new Sheep('Molly', 1);

/*
print(Anni.name+" age: "+Anni.age) // => Anni age: 5;
print(Leo.name+" age: "+Leo.age); // => Leo age: 3
print(Molly.name+" age: "+Molly.age); // => Molly age: 1
*/

/*
print(Anni instanceof Animal); // => true
print(Anni instanceof Tiger); // => false
print(Anni instanceof Sheep); // => false
*/

/*
print(Leo instanceof Animal); // => true
print(Leo instanceof Tiger); // => true
print(Leo instanceof Sheep); // => false
*/

/*
print(Molly instanceof Animal); // => true
print(Molly instanceof Tiger); // => false
print(Molly instanceof Sheep); // => true
*/

/*
Leo.eat(Molly);
print("Leo health: "+Leo.health); // => 105
print("Molly health: "+Molly.health); // => 0
*/

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.