<commit_before>//
//  avatarCounter.js
//
//  Created by <NAME> on 07/09/2018.
//  Copyright 2018 High Fidelity, Inc.
//
//  Distributed under the Apache License, Version 2.0.
//  See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//

(function() {
    var UPDATE_INTERVAL = 1000;
    var request = Script.require('./modules/request.js').request;
    var _this;

    var AvatarCounter = function() {
        _this = this;
    };

    AvatarCounter.prototype = {
        interval: null,

        preload: function(entityID) {
            _this.entityID = entityID;
            _this.interval = Script.setInterval(_this.update(), UPDATE_INTERVAL);
        },

        update: function() {
            request("https://highfidelity.com/api/v1/domains/d7dc9a4c-6d90-4515-9d51-770aa1004f54", function (error, data) {
                if (!error) {
                    Entities.editEntity(_this.entityID, { text: data.domain.online_users });
                }
            });
        },

        unload: function() {
            if (_this.interval) {
                Script.clearInterval(_this.interval);
            }
        }
        
    };
        
    return new AvatarCounter;
}); <commit_msg>Moved update function to inside of interval<commit_after>//
//  avatarCounter.js
//
//  Created by <NAME> on 07/09/2018.
//  Copyright 2018 High Fidelity, Inc.
//
//  Distributed under the Apache License, Version 2.0.
//  See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//

(function() {
    var UPDATE_INTERVAL = 1000;
    var request = Script.require('./modules/request.js').request;
    var _this;

    var AvatarCounter = function() {
        _this = this;
    };

    AvatarCounter.prototype = {
        interval: null,

        preload: function(entityID) {
            _this.entityID = entityID;
            _this.interval = Script.setInterval(function() {
                request("https://highfidelity.com/api/v1/domains/d7dc9a4c-6d90-4515-9d51-770aa1004f54", function (error, data) {
                    if (!error) {
                        Entities.editEntity(_this.entityID, { text: data.domain.online_users });
                    }
                });
            }, UPDATE_INTERVAL);
        },

        unload: function() {
            if (_this.interval) {
                Script.clearInterval(_this.interval);
            }
        }
        
    };
        
    return new AvatarCounter;
}); 
{'fraction_non_alphanumeric': 0.12646464646464647, 'fraction_numerical': 0.03474747474747475, 'mean_word_length': 1.8040770101925254, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5102784', 'n_tokens_mistral': 802, 'n_tokens_neox': 718, 'n_words': 142}