{:uriI"file:///Users/leandro/src/job_notifier/app/assets/javascripts/job_notifier/notifier.js?type=application/javascript&pipeline=self&id=13f690d2455e89f4391ffc50984bd44f85798b99a0d91f368553f5cebe77cf1b:ET:load_pathI";/Users/leandro/src/job_notifier/app/assets/javascripts;T: filenameI"T/Users/leandro/src/job_notifier/app/assets/javascripts/job_notifier/notifier.js;T: nameI"job_notifier/notifier;T:logical_pathI""job_notifier/notifier.self.js;T:content_typeI"application/javascript;T: sourceI"(function(window){ 'use strict'; function defineLibrary(){ var MILLISECONDS_TO_GET_JOBS = 5000; var JobNotifier = {}; JobNotifier.init = function() { var body = document.querySelector('body'); JobNotifier.jobIdentifier = body.dataset.identifier; if(!JobNotifier.jobIdentifier) { return; } JobNotifier.rootUrl = body.dataset.rootUrl; JobNotifier.findJobs(); }; JobNotifier.performRequest = function(method, action, onLoadCallback) { var oReq = new XMLHttpRequest(); oReq.onload = onLoadCallback; oReq.onerror = JobNotifier.onError; var url = JobNotifier.rootUrl + 'job_notifier/' + JobNotifier.jobIdentifier + '/jobs/' + action + '.json'; oReq.open(method, url, true); oReq.send(); }; JobNotifier.findJobs = function() { setTimeout(JobNotifier.findPendingJobs, MILLISECONDS_TO_GET_JOBS); }; JobNotifier.findPendingJobs = function() { JobNotifier.performRequest('get', 'pending', JobNotifier.onPendingJobsLoad); }; JobNotifier.notifyJobs = function() { JobNotifier.performRequest('put', 'notify', JobNotifier.onNotifyJobsLoad); }; JobNotifier.onPendingJobsLoad = function() { var data = JSON.parse(this.responseText); if(data.length === 0) { JobNotifier.findJobs(); return; } JobNotifier.onNotify(data); JobNotifier.notifyJobs(); }; JobNotifier.onNotifyJobsLoad = function() { JobNotifier.findJobs(); }; JobNotifier.onNotify = function(data) { console.info('Override this method with your own logic. Data: ', data); }; JobNotifier.onError = function(err) { console.error('Error', err); }; return JobNotifier; } if(typeof(JobNotifier) === 'undefined'){ window.JobNotifier = defineLibrary(); } else{ console.log('JobNotifier already defined.'); } })(window); document.addEventListener('DOMContentLoaded', JobNotifier.init); ;T: metadata{ :dependencieso:Set: @hash{ I"environment-version;TTI"environment-paths;TTI"rails-env;TTI"Zprocessors:type=application/javascript&file_type=application/javascript&pipeline=self;TTI"bfile-digest:///Users/leandro/src/job_notifier/app/assets/javascripts/job_notifier/notifier.js;TT: requiredo;;{: stubbedo;;{: linkso;;{: charsetI" utf-8;F: digest"%iVl1)+zW;EtLoc9: lengthi:dependencies_digest"%R7 m%ٿ T~5j؃]:idI"E13f690d2455e89f4391ffc50984bd44f85798b99a0d91f368553f5cebe77cf1b;F: mtimel+fnW