|
14 | 14 | * MIT License | (c) Dustin Diaz 2014
|
15 | 15 | */
|
16 | 16 |
|
17 |
| - !function (name, definition) { |
18 |
| - if (typeof module != 'undefined' && module.exports) module.exports['browser'] = definition() |
19 |
| - else if (typeof define == 'function') define(definition) |
20 |
| - else this[name] = definition() |
21 |
| - }('bowser', function () { |
| 17 | + (function () { |
22 | 18 | /**
|
23 | 19 | * See useragents.js for examples of navigator.userAgent
|
24 | 20 | */
|
|
245 | 241 | */
|
246 | 242 | bowser._detect = detect;
|
247 | 243 |
|
248 |
| - return bowser |
249 |
| - }); |
| 244 | + this.bowser = bowser; |
| 245 | + }).call(this); |
| 246 | + |
250 | 247 | /*
|
251 | 248 | TraceKit - Cross brower stack traces - github.com/occ/TraceKit
|
252 | 249 | MIT license
|
|
1534 | 1531 | };
|
1535 | 1532 | };
|
1536 | 1533 |
|
1537 |
| - (function() { |
1538 |
| - this.Lockr = {}; |
| 1534 | + (function(root, factory) { |
| 1535 | + |
| 1536 | + if (typeof define === 'function' && define.amd) { |
| 1537 | + define(['exports'], function(exports) { |
| 1538 | + root.Lockr = factory(root, exports); |
| 1539 | + }); |
| 1540 | + } else { |
| 1541 | + root.Lockr = factory(root, {}); |
| 1542 | + } |
| 1543 | + |
| 1544 | + }(this, function(root, Lockr) { |
| 1545 | + 'use strict'; |
| 1546 | + |
| 1547 | + root.Lockr = Lockr; |
| 1548 | + |
| 1549 | + if (!Array.prototype.indexOf) { |
| 1550 | + Array.prototype.indexOf = function(elt /*, from*/) |
| 1551 | + { |
| 1552 | + var len = this.length >>> 0; |
| 1553 | + |
| 1554 | + var from = Number(arguments[1]) || 0; |
| 1555 | + from = (from < 0) |
| 1556 | + ? Math.ceil(from) |
| 1557 | + : Math.floor(from); |
| 1558 | + if (from < 0) |
| 1559 | + from += len; |
| 1560 | + |
| 1561 | + for (; from < len; from++) |
| 1562 | + { |
| 1563 | + if (from in this && |
| 1564 | + this[from] === elt) |
| 1565 | + return from; |
| 1566 | + } |
| 1567 | + return -1; |
| 1568 | + }; |
| 1569 | + } |
| 1570 | + |
| 1571 | + Lockr.prefix = ""; |
| 1572 | + |
| 1573 | + Lockr._getPrefixedKey = function(key, options) { |
| 1574 | + options = options || {}; |
| 1575 | + |
| 1576 | + if (options.noPrefix) { |
| 1577 | + return key; |
| 1578 | + } else { |
| 1579 | + return this.prefix + key; |
| 1580 | + } |
1539 | 1581 |
|
1540 |
| - Lockr.set = function (key, value) { |
1541 |
| - localStorage.setItem(key, value); |
1542 | 1582 | };
|
1543 | 1583 |
|
1544 |
| - Lockr.hset = function (key, hashObj) { |
1545 |
| - localStorage.setItem(key, JSON.stringify(hashObj)); |
| 1584 | + Lockr.set = function (key, value, options) { |
| 1585 | + var query_key = this._getPrefixedKey(key, options); |
| 1586 | + |
| 1587 | + try { |
| 1588 | + localStorage.setItem(query_key, JSON.stringify({"data": value})); |
| 1589 | + } catch (e) { |
| 1590 | + if (console) console.warn("Lockr didn't successfully save the '{"+ key +": "+ value +"}' pair, because the localStorage is full."); |
| 1591 | + } |
1546 | 1592 | };
|
1547 |
| - Lockr.get = function (key, callback) { |
1548 |
| - var value = localStorage.getItem(key); |
1549 |
| - if (value == null) |
1550 |
| - return undefined; |
1551 |
| - if (value.match(/[\{\}\:\[\]]/)) /* hash objects */ |
1552 |
| - return JSON.parse(value); |
1553 |
| - else if (value.match(/^\d+(?:\.\d+$)/)) /* floating number */ |
1554 |
| - return parseFloat(value); |
1555 |
| - else if (value.match(/^\d+$/)) /* integer number */ |
1556 |
| - return parseInt(value); |
| 1593 | + |
| 1594 | + Lockr.get = function (key, missing, options) { |
| 1595 | + var query_key = this._getPrefixedKey(key, options), |
| 1596 | + value; |
| 1597 | + |
| 1598 | + try { |
| 1599 | + value = JSON.parse(localStorage.getItem(query_key)); |
| 1600 | + } catch (e) { |
| 1601 | + value = null; |
| 1602 | + } |
| 1603 | + if(value === null) |
| 1604 | + return missing; |
1557 | 1605 | else
|
1558 |
| - return value; |
| 1606 | + return (value.data || missing); |
| 1607 | + }; |
| 1608 | + |
| 1609 | + Lockr.sadd = function(key, value, options) { |
| 1610 | + var query_key = this._getPrefixedKey(key, options), |
| 1611 | + json; |
| 1612 | + |
| 1613 | + var values = Lockr.smembers(key); |
| 1614 | + |
| 1615 | + if (values.indexOf(value) > -1) { |
| 1616 | + return null; |
| 1617 | + } |
| 1618 | + |
| 1619 | + try { |
| 1620 | + values.push(value); |
| 1621 | + json = JSON.stringify({"data": values}); |
| 1622 | + localStorage.setItem(query_key, json); |
| 1623 | + } catch (e) { |
| 1624 | + console.log(e); |
| 1625 | + if (console) console.warn("Lockr didn't successfully add the "+ value +" to "+ key +" set, because the localStorage is full."); |
| 1626 | + } |
| 1627 | + }; |
| 1628 | + |
| 1629 | + Lockr.smembers = function(key, options) { |
| 1630 | + var query_key = this._getPrefixedKey(key, options), |
| 1631 | + value; |
| 1632 | + |
| 1633 | + try { |
| 1634 | + value = JSON.parse(localStorage.getItem(query_key)); |
| 1635 | + } catch (e) { |
| 1636 | + value = null; |
| 1637 | + } |
| 1638 | + |
| 1639 | + if (value === null) |
| 1640 | + return []; |
| 1641 | + else |
| 1642 | + return (value.data || []); |
| 1643 | + }; |
| 1644 | + |
| 1645 | + Lockr.sismember = function(key, value, options) { |
| 1646 | + var query_key = this._getPrefixedKey(key, options); |
| 1647 | + |
| 1648 | + return Lockr.smembers(key).indexOf(value) > -1; |
1559 | 1649 | };
|
1560 | 1650 |
|
1561 | 1651 | Lockr.getAll = function () {
|
|
1566 | 1656 | });
|
1567 | 1657 | };
|
1568 | 1658 |
|
| 1659 | + Lockr.srem = function(key, value, options) { |
| 1660 | + var query_key = this._getPrefixedKey(key, options), |
| 1661 | + json, |
| 1662 | + index; |
| 1663 | + |
| 1664 | + var values = Lockr.smembers(key, value); |
| 1665 | + |
| 1666 | + index = values.indexOf(value); |
| 1667 | + |
| 1668 | + if (index > -1) |
| 1669 | + values.splice(index, 1); |
| 1670 | + |
| 1671 | + json = JSON.stringify({"data": values}); |
| 1672 | + |
| 1673 | + try { |
| 1674 | + localStorage.setItem(query_key, json); |
| 1675 | + } catch (e) { |
| 1676 | + if (console) console.warn("Lockr couldn't remove the "+ value +" from the set "+ key); |
| 1677 | + } |
| 1678 | + }; |
| 1679 | + |
| 1680 | + Lockr.rm = function (key) { |
| 1681 | + localStorage.removeItem(key); |
| 1682 | + }; |
| 1683 | + |
1569 | 1684 | Lockr.flush = function () {
|
1570 | 1685 | localStorage.clear();
|
1571 | 1686 | };
|
1572 | 1687 | return Lockr;
|
1573 | 1688 |
|
1574 |
| - }).call(this); |
| 1689 | + })); |
1575 | 1690 |
|
1576 | 1691 | var md5cycle = function(x, k) {
|
1577 | 1692 | var a = x[0], b = x[1], c = x[2], d = x[3];
|
|
1746 | 1861 | appVersion: null,
|
1747 | 1862 | appname: null,
|
1748 | 1863 | osver: null,
|
1749 |
| - url: 'https://www.bugsense.com/api/errors', |
| 1864 | + url: 'https://mint.splunk.com/api/errors', |
1750 | 1865 | disableOnError: false,
|
1751 | 1866 | context: window
|
1752 | 1867 | };
|
|
1971 | 2086 | this.sendCachedReport();
|
1972 | 2087 | },
|
1973 | 2088 | update: function () {
|
1974 |
| - Lockr.hset('bugsense_cache', this._queue); |
| 2089 | + Lockr.set('bugsense_cache', this._queue); |
1975 | 2090 | },
|
1976 | 2091 | sendCachedReport: function() {
|
1977 | 2092 | // do stuff here
|
|
0 commit comments