EJI

by sandipchitale

HTML

<script src="http:////ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<br/>
<br/>
<div class="container">
    <div class="row">
        <div class="col12">
            <div ng-app ng-controller="JIController">
                <pre>
function Person(name) {
    this.name = name;
}

Person.prototype.getName = function () {
    return this.name;
};

function Employee(name, salary) {
    var _ = arguments.callee.prototype;
    if (_.__proto__ === Object.prototype) {
        _.__proto__ = Person.prototype;
        _.getSalary = function () {
            return this.salary;
        };
    }
    _.__proto__.constructor.call(this, name);
    this.salary = salary;
};

function Executive(name, salary, bonus) {
    var _ = arguments.callee.prototype;
    if (_.__proto__ === Object.prototype) {
        _.__proto__ = Employee.prototype;
        _.getBonus = function () {
            return this.bonus;
        };
    }
    _.__proto__.constructor.call(this, name, salary);
    this.bonus = bonus;
};

var hotshot = new Executive("Hotshot", 400000, 100000);
var workerbee = new Employee("Workerbee", 100000);
var person = new Person("John Doe");
    </pre>
                <br/>
                <div class="input-group">
                    <input class="form-control" size="60" ng-model="expression" />
                    <div class="input-group-btn">
                        <button class="btn btn-default btn-success" ng-click="evaluate()">Evaluate</button>
                        <button class="btn btn-default btn-danger" ng-click="clear()">X</button>
                    </div>
                </div>
                <br/>
                <div class="input-group">
                    <textarea class="form-control" id="result" rows="8" cols="120"></textarea>
                </div>
                <div class="text-center">
                <img...

CSS

@import url('http://getbootstrap.com/dist/css/bootstrap.css');
 textarea, input {
    font-family: Monospace !important;
}
textarea {
    width: 100% !important;
}

JavaScript

function JIController($scope) {
    function Person(name) {
        this.name = name;
    }

    Person.prototype.getName = function () {
        return this.name;
    };

    function Employee(name, salary) {
        var _ = arguments.callee.prototype;
        if (_.__proto__ === Object.prototype) {
            _.__proto__ = Person.prototype;
            _.getSalary = function () {
                return this.salary;
            };
        }
        _.__proto__.constructor.call(this, name);
        this.salary = salary;
    };

    function Executive(name, salary, bonus) {
        var _ = arguments.callee.prototype;
        if (_.__proto__ === Object.prototype) {
            _.__proto__ = Employee.prototype;
            _.getBonus = function () {
                return this.bonus;
            };
        }
        _.__proto__.constructor.call(this, name, salary);
        this.bonus = bonus;
    };

    var hotshot = new Executive("Hotshot", 400000, 100000);
    var workerbee = new Employee("Workerbee", 100000);
    var person = new Person("John Doe");
    
    $scope.expression = 'hotshot instanceof Executive;';

    var textarea = document.getElementById('result');
    $scope.evaluate = function () {
        try {
            textarea.value = $scope.expression + ' => ' + eval($scope.expression) + '\n' + textarea.value;
        } catch (e) {
            textarea.value = $scope.expression + ' => ' + e + '\n' + textarea.value;
        }
    }

    $scope.clear = function () {
        $scope.expression = '';
        textarea.value = '';
    }

}