{:uriI"Äfile:///Users/leandro/src/job_notifier/app/assets/javascripts/job_notifier/notifier.js?type=application/javascript&pipeline=self&id=a89428e18fe83771badac7a8864e50bd05ee2d77c9ac9ad1f30311f9ee322a9f: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; setTimeout(JobNotifier.findPendingJobs, MILLISECONDS_TO_GET_JOBS); }; JobNotifier.findPendingJobs = function() { var oReq = new XMLHttpRequest(); oReq.onload = JobNotifier.onPendingJobsLoad; oReq.onerror = JobNotifier.onError; var url = JobNotifier.rootUrl + 'job_notifier/' + JobNotifier.jobIdentifier + '/jobs/pending.json'; oReq.open('get', url, true); oReq.send(); }; JobNotifier.notifyJobs = function() { var oReq = new XMLHttpRequest(); oReq.onload = JobNotifier.onNotifyJobsLoad; oReq.onerror = JobNotifier.onError; var url = JobNotifier.rootUrl + 'job_notifier/' + JobNotifier.jobIdentifier + '/jobs/notify.json'; oReq.open('put', url, true); oReq.send(); }; JobNotifier.onPendingJobsLoad = function() { var data = JSON.parse(this.responseText); if(data.length === 0) { setTimeout(JobNotifier.findPendingJobs, MILLISECONDS_TO_GET_JOBS); return; } JobNotifier.onNotify(data); JobNotifier.notifyJobs(); }; JobNotifier.onNotifyJobsLoad = function() { setTimeout(JobNotifier.findPendingJobs, MILLISECONDS_TO_GET_JOBS); }; 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"% ™9†¸MåëÿÐmç×é]ê\ò»«Ø­Â=«Õþ¶ºî¹: lengthi :dependencies_digest"%U Ø  {Îñz}¡jD_`,š‡?>ïüñtEÐÞ:idI"Ea89428e18fe83771badac7a8864e50bd05ee2d77c9ac9ad1f30311f9ee322a9f;F: mtimel+rçnW