<commit_before>tetra.controller.register('autocomplete', {
	scope: 'comp_autocomplete',
	use: ['suggestions'],
	
	constr: function(me, app, page, orm) {
		
		return {
			events: {

				model: {
					'suggestions': {
						'append': function(col) {
							app.notify('display suggestions', col[0].getAll());
						}
					}
				},
				
				view: {
					
					'do query': function(data) {

						orm('suggestions').select({
                                                        param: data.param,
                                                        uriParams: {
                                                                url: data.url
                                                        },
                                                        id: data.id
                                                });
						
					},
					
					'select suggestion': function(data) {

						var
							packRef = data.ref.split(':')[0],
							objRef = data.ref.split(':')[1]
						;

						orm('suggestions').findByRef(packRef, function(pack){
							page.notify('autocomplete: item selected', {
								obj : pack.get('suggestions').data[objRef],
								origin : data.id
							});
						});

						app.notify('display value', data);
					}
					
				}
			}
			
		};
	}
});<commit_msg>added timer to orm requests<commit_after>tetra.controller.register('autocomplete', {
	scope: 'comp_autocomplete',
	use: ['suggestions'],
	
	constr: function(me, app, page, orm) {
		
		return {
			events: {

				model: {
					'suggestions': {
						'append': function(col) {
							app.notify('display suggestions', col[0].getAll());
						}
					}
				},
				
				view: {
					
					'do query': function(data) {
						me.methods.startCountDown(function(data){
							orm('suggestions').select({
                                                	        param: data.param,
                                                	        uriParams: {
                                                	                url: data.url
                                                	        },
                                                	        id: data.id
                                                	});
						}, data);
					},
					
					'select suggestion': function(data) {

						var
							packRef = data.ref.split(':')[0],
							objRef = data.ref.split(':')[1]
						;

						orm('suggestions').findByRef(packRef, function(pack){
							page.notify('autocomplete: item selected', {
								obj : pack.get('suggestions').data[objRef],
								origin : data.id
							});
						});

						app.notify('display value', data);
					}
					
				}
			},
			methods : {
				init : function(){
					me.delay = 150; // default delay before sending server-side request
					me.countDown = null;
				},
				startCountDown : function(callback, data){
					// cancel previous counter if it exists
					if(me.countDown) { window.clearTimeout(me.countDown) }
					// set a new counter
					me.countDown = window.setTimeout(callback, me.delay, data);
				}
			}
			
		};
	}
});
{'fraction_non_alphanumeric': 0.12868369351669942, 'fraction_numerical': 0.0029469548133595285, 'mean_word_length': 1.1651311126860382, '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': 24, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '532804', 'n_tokens_mistral': 1168, 'n_tokens_neox': 772, 'n_words': 140}