| // Generated by CoffeeScript 1.9.1 |
| (function() { |
| var activities, defaults, extend, getParameterByName, userale, |
| slice = [].slice, |
| indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; |
| |
| activities = ['add', 'remove', 'create', 'delete', 'select', 'deselect', 'enter', 'leave', 'inspect', 'alter', 'hide', 'show']; |
| |
| console.log('in userale'); |
| |
| extend = function() { |
| var i, key, len, object, objects, value; |
| objects = 1 <= arguments.length ? slice.call(arguments, 0) : []; |
| for (i = 0, len = objects.length; i < len; i++) { |
| object = objects[i]; |
| for (key in object) { |
| value = object[key]; |
| objects[0][key] = value; |
| } |
| } |
| return objects[0]; |
| }; |
| |
| getParameterByName = function(name) { |
| var regex, results; |
| name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]"); |
| regex = new RegExp("[\\?&]" + name + "=([^&#]*)"); |
| results = regex.exec(location.search); |
| console.log(results); |
| return results = results ? decodeURIComponent(results[1].replace(/\+/g, " ")) : ""; |
| }; |
| |
| defaults = { |
| loggingUrl: '', |
| toolName: 'UNK', |
| toolVersion: 'UNK', |
| workerUrl: 'userale-worker.js', |
| debug: true, |
| sendLogs: true, |
| componentGroups: [] |
| }; |
| |
| userale = (function() { |
| function userale(options) { |
| this.options = extend(defaults, options); |
| if (this.options.component_groups.contructor === !Array) { |
| this.options.component_groups = [this.options.component_groups]; |
| } |
| this.options.version = '3.0.0'; |
| this.worker = new Worker(this.options.workerUrl); |
| } |
| |
| userale.prototype.register = function() { |
| this.sessionID = getParameterByName('USID'); |
| this.client = getParameterByName('client'); |
| console.log(this.sessionID); |
| if (!this.sessionID) { |
| this.sessionID = this.toolName.slice(0, 3).toUpperCase() + new Date().getTime(); |
| console.warn('USERALE: NO SESSION ID, MAKING ONE UP. You can pass one in as url parameter (127.0.0.1?USID=12345)'); |
| } |
| if (!this.client) { |
| this.client = 'UNK'; |
| console.warn('USERALE: NO CLIENT, MAKING ONE UP. You can pass one in as url parameter (127.0.0.1?client=roger)'); |
| } |
| return this.worker.postMessage({ |
| cmd: 'sendBuffer', |
| msg: '' |
| }); |
| }; |
| |
| userale.prototype.log = function(msg) { |
| var key, ref, results1, value; |
| results1 = []; |
| for (key in msg) { |
| value = msg[key]; |
| if (key === 'component') { |
| if (ref = value.group, indexOf.call(this.options.component_groups, ref) >= 0) { |
| results1.push(console.log(value.group + " is in component groups")); |
| } else { |
| results1.push(console.warn(value.group + " is NOT in component groups")); |
| } |
| } else { |
| results1.push(void 0); |
| } |
| } |
| return results1; |
| }; |
| |
| return userale; |
| |
| })(); |
| |
| window.userale = userale; |
| |
| }).call(this); |
| |
| //# sourceMappingURL=userale.js.map |