<commit_before>slikcalc.adapter = {

	eventTopicCounter : 0,
	
	get : function(id) {
		var element = $(id);
        return element;
	},
	
	addListener : function(id, type, method, scope) {
        this.addOnLoad(function() {
        	console.log(id + ' : listener added');
            $(id).observe(type, function() {
               method.call(scope); 
            });
        });
	},
	
	addOnLoad : function(method, scope) {
		Event.observe(window, 'load', function() {
            method.call(scope);
        });
	},
	
	createCustomEvent : function(eventType) {
		this.eventTopicCounter = this.eventTopicCounter + 1;
		return {
			topic: "slikcalc:" + eventType + this.eventTopicCounter
		}
	},
	
	bindEvent : function(event, method, scope) {
        document.observe(event.topic, function() {
            method.call(scope);    
        });
	},
	
	fireEvent : function(event) {
		document.fire(event.topic);
	}
    
}<commit_msg>fixed loading of event listeners from when called before the dom is ready or present<commit_after>slikcalc.adapter = {

	eventTopicCounter : 0,
	
	get : function(id) {
		return $(id);
	},
	
	addListener : function(id, type, method, scope) {
		if(this.get(id) === null) {
			this.addOnLoad(function() {
	            $(id).observe(type, function() {
	               method.call(scope); 
	            });
	        });
		}else {
			$(id).observe(type, function() {
               method.call(scope); 
            });
		}
	},
	
	addOnLoad : function(method, scope, element) {
		Event.observe(window, 'load', function() {
            method.call(scope);
        });
	},
	
	createCustomEvent : function(eventType) {
		this.eventTopicCounter = this.eventTopicCounter + 1;
		return {
			topic: "slikcalc:" + eventType + this.eventTopicCounter
		}
	},
	
	bindEvent : function(event, method, scope) {
        document.observe(event.topic, function() {
            method.call(scope);    
        });
	},
	
	fireEvent : function(event) {
		document.fire(event.topic);
	}
    
}
{'fraction_non_alphanumeric': 0.14664664664664664, 'fraction_numerical': 0.002002002002002002, 'mean_word_length': 2.405451448040886, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7200740', 'n_tokens_mistral': 676, 'n_tokens_neox': 614, 'n_words': 113}