Merge branch 'vcard' of github.com:jcbrand/converse.js
Conflicts: CHANGES.rst converse.js
15
CHANGES.rst
@ -1,7 +1,20 @@
|
|||||||
Changelog
|
Changelog
|
||||||
=========
|
=========
|
||||||
|
|
||||||
0.2 (unreleased)
|
0.3 (unreleased)
|
||||||
|
----------------
|
||||||
|
|
||||||
|
- Add vCard support [jcbrand]
|
||||||
|
- Remember custom status messages upon reload. [jcbrand]
|
||||||
|
- Remove jquery-ui dependency. [jcbrand]
|
||||||
|
- Use backbone.localStorage to store the contacts roster, open chatboxes and
|
||||||
|
chat messages. [jcbrand]
|
||||||
|
- Fixed user status handling, which wasn't 100% according to the
|
||||||
|
spec. [jcbrand]
|
||||||
|
- Separate messages according to day in chats. [jcbrand]
|
||||||
|
|
||||||
|
|
||||||
|
0.2 (2013-03-28)
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
- Performance enhancements and general script cleanup [ichim-david]
|
- Performance enhancements and general script cleanup [ichim-david]
|
||||||
|
192
Libraries/backbone.localStorage.js
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
/**
|
||||||
|
* Backbone localStorage Adapter
|
||||||
|
* Version 1.1.0
|
||||||
|
*
|
||||||
|
* https://github.com/jeromegn/Backbone.localStorage
|
||||||
|
*/
|
||||||
|
(function (root, factory) {
|
||||||
|
if (typeof define === "function" && define.amd) {
|
||||||
|
// AMD. Register as an anonymous module.
|
||||||
|
define(["underscore","backbone"], function(_, Backbone) {
|
||||||
|
// Use global variables if the locals is undefined.
|
||||||
|
return factory(_ || root._, Backbone || root.Backbone);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// RequireJS isn't being used. Assume underscore and backbone is loaded in <script> tags
|
||||||
|
factory(_, Backbone);
|
||||||
|
}
|
||||||
|
}(this, function(_, Backbone) {
|
||||||
|
// A simple module to replace `Backbone.sync` with *localStorage*-based
|
||||||
|
// persistence. Models are given GUIDS, and saved into a JSON object. Simple
|
||||||
|
// as that.
|
||||||
|
|
||||||
|
// Hold reference to Underscore.js and Backbone.js in the closure in order
|
||||||
|
// to make things work even if they are removed from the global namespace
|
||||||
|
|
||||||
|
// Generate four random hex digits.
|
||||||
|
function S4() {
|
||||||
|
return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Generate a pseudo-GUID by concatenating random hexadecimal.
|
||||||
|
function guid() {
|
||||||
|
return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());
|
||||||
|
};
|
||||||
|
|
||||||
|
// Our Store is represented by a single JS object in *localStorage*. Create it
|
||||||
|
// with a meaningful name, like the name you'd give a table.
|
||||||
|
// window.Store is deprectated, use Backbone.LocalStorage instead
|
||||||
|
Backbone.LocalStorage = window.Store = function(name) {
|
||||||
|
this.name = name;
|
||||||
|
var store = this.localStorage().getItem(this.name);
|
||||||
|
this.records = (store && store.split(",")) || [];
|
||||||
|
};
|
||||||
|
|
||||||
|
_.extend(Backbone.LocalStorage.prototype, {
|
||||||
|
|
||||||
|
// Save the current state of the **Store** to *localStorage*.
|
||||||
|
save: function() {
|
||||||
|
this.localStorage().setItem(this.name, this.records.join(","));
|
||||||
|
},
|
||||||
|
|
||||||
|
// Add a model, giving it a (hopefully)-unique GUID, if it doesn't already
|
||||||
|
// have an id of it's own.
|
||||||
|
create: function(model) {
|
||||||
|
if (!model.id) {
|
||||||
|
model.id = guid();
|
||||||
|
model.set(model.idAttribute, model.id);
|
||||||
|
}
|
||||||
|
this.localStorage().setItem(this.name+"-"+model.id, JSON.stringify(model));
|
||||||
|
this.records.push(model.id.toString());
|
||||||
|
this.save();
|
||||||
|
return this.find(model);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Update a model by replacing its copy in `this.data`.
|
||||||
|
update: function(model) {
|
||||||
|
this.localStorage().setItem(this.name+"-"+model.id, JSON.stringify(model));
|
||||||
|
if (!_.include(this.records, model.id.toString()))
|
||||||
|
this.records.push(model.id.toString()); this.save();
|
||||||
|
return this.find(model);
|
||||||
|
},
|
||||||
|
|
||||||
|
// Retrieve a model from `this.data` by id.
|
||||||
|
find: function(model) {
|
||||||
|
return this.jsonData(this.localStorage().getItem(this.name+"-"+model.id));
|
||||||
|
},
|
||||||
|
|
||||||
|
// Return the array of all models currently in storage.
|
||||||
|
findAll: function() {
|
||||||
|
return _(this.records).chain()
|
||||||
|
.map(function(id){
|
||||||
|
return this.jsonData(this.localStorage().getItem(this.name+"-"+id));
|
||||||
|
}, this)
|
||||||
|
.compact()
|
||||||
|
.value();
|
||||||
|
},
|
||||||
|
|
||||||
|
// Delete a model from `this.data`, returning it.
|
||||||
|
destroy: function(model) {
|
||||||
|
if (model.isNew())
|
||||||
|
return false
|
||||||
|
this.localStorage().removeItem(this.name+"-"+model.id);
|
||||||
|
this.records = _.reject(this.records, function(id){
|
||||||
|
return id === model.id.toString();
|
||||||
|
});
|
||||||
|
this.save();
|
||||||
|
return model;
|
||||||
|
},
|
||||||
|
|
||||||
|
localStorage: function() {
|
||||||
|
return localStorage;
|
||||||
|
},
|
||||||
|
|
||||||
|
// fix for "illegal access" error on Android when JSON.parse is passed null
|
||||||
|
jsonData: function (data) {
|
||||||
|
return data && JSON.parse(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
// localSync delegate to the model or collection's
|
||||||
|
// *localStorage* property, which should be an instance of `Store`.
|
||||||
|
// window.Store.sync and Backbone.localSync is deprectated, use Backbone.LocalStorage.sync instead
|
||||||
|
Backbone.LocalStorage.sync = window.Store.sync = Backbone.localSync = function(method, model, options) {
|
||||||
|
var store = model.localStorage || model.collection.localStorage;
|
||||||
|
|
||||||
|
var resp, errorMessage, syncDfd = $.Deferred && $.Deferred(); //If $ is having Deferred - use it.
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
switch (method) {
|
||||||
|
case "read":
|
||||||
|
resp = model.id != undefined ? store.find(model) : store.findAll();
|
||||||
|
break;
|
||||||
|
case "create":
|
||||||
|
resp = store.create(model);
|
||||||
|
break;
|
||||||
|
case "update":
|
||||||
|
resp = store.update(model);
|
||||||
|
break;
|
||||||
|
case "delete":
|
||||||
|
resp = store.destroy(model);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch(error) {
|
||||||
|
if (error.code === DOMException.QUOTA_EXCEEDED_ERR && window.localStorage.length === 0)
|
||||||
|
errorMessage = "Private browsing is unsupported";
|
||||||
|
else
|
||||||
|
errorMessage = error.message;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (resp) {
|
||||||
|
if (options && options.success)
|
||||||
|
if (Backbone.VERSION === "0.9.10") {
|
||||||
|
options.success(model, resp, options);
|
||||||
|
} else {
|
||||||
|
options.success(resp);
|
||||||
|
}
|
||||||
|
if (syncDfd)
|
||||||
|
syncDfd.resolve(resp);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
errorMessage = errorMessage ? errorMessage
|
||||||
|
: "Record Not Found";
|
||||||
|
|
||||||
|
if (options && options.error)
|
||||||
|
if (Backbone.VERSION === "0.9.10") {
|
||||||
|
options.error(model, errorMessage, options);
|
||||||
|
} else {
|
||||||
|
options.error(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (syncDfd)
|
||||||
|
syncDfd.reject(errorMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add compatibility with $.ajax
|
||||||
|
// always execute callback for success and error
|
||||||
|
if (options && options.complete) options.complete(resp);
|
||||||
|
|
||||||
|
return syncDfd && syncDfd.promise();
|
||||||
|
};
|
||||||
|
|
||||||
|
Backbone.ajaxSync = Backbone.sync;
|
||||||
|
|
||||||
|
Backbone.getSyncMethod = function(model) {
|
||||||
|
if(model.localStorage || (model.collection && model.collection.localStorage)) {
|
||||||
|
return Backbone.localSync;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Backbone.ajaxSync;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Override 'Backbone.sync' to default to localSync,
|
||||||
|
// the original 'Backbone.sync' is still available in 'Backbone.ajaxSync'
|
||||||
|
Backbone.sync = function(method, model, options) {
|
||||||
|
return Backbone.getSyncMethod(model).apply(this, [method, model, options]);
|
||||||
|
};
|
||||||
|
|
||||||
|
return Backbone.LocalStorage;
|
||||||
|
}));
|
@ -1,23 +0,0 @@
|
|||||||
Copyright (c) 2012 Yiorgis Gozadinos, Riot AS
|
|
||||||
Postboks 2236, 3103 Tønsberg, Norway
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person
|
|
||||||
obtaining a copy of this software and associated documentation
|
|
||||||
files (the "Software"), to deal in the Software without
|
|
||||||
restriction, including without limitation the rights to use,
|
|
||||||
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the
|
|
||||||
Software is furnished to do so, subject to the following
|
|
||||||
conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
|
||||||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
||||||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
||||||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
||||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
||||||
OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,80 +0,0 @@
|
|||||||
# burry.js
|
|
||||||
|
|
||||||
A simple caching layer on the browser's localStorage
|
|
||||||
|
|
||||||
## Usage
|
|
||||||
|
|
||||||
### Creation
|
|
||||||
|
|
||||||
Create a Burry `Store`, optionally passing a namespace. A default store is always available with no namespace:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var burry = new Burry.Store('mystuff');
|
|
||||||
```
|
|
||||||
|
|
||||||
If you want to also set a default time-to-live on a namespaced store, pass the time-to-live as a second parameter. For instance,
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var burrywithttl = new Burry.Store('mystuff', 10);
|
|
||||||
```
|
|
||||||
|
|
||||||
will create a store where the default time-to-live when you set items is 10 minutes.
|
|
||||||
|
|
||||||
You can obtain all available stores, by invoking `stores()`:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var stores = Burry.stores(); // stores is ['', 'mystuff']
|
|
||||||
```
|
|
||||||
|
|
||||||
### Getting/Setting
|
|
||||||
|
|
||||||
`set` and `get` JSON-serializable javascript objects easily to and from the cache.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
burry.set('foo', {bar: 'burry'});
|
|
||||||
var foo = burry.get('foo'); // foo is {bar: 'burry'}
|
|
||||||
foo = burry.get('unknown'); // foo is undefined
|
|
||||||
```
|
|
||||||
|
|
||||||
You can specify a time-to-live per key/value. This is expressed in minutes:
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
burry.set('foo', {bar: 'burry'}, 10);
|
|
||||||
var foo = burry.get('foo'); // foo is {bar: 'burry'}
|
|
||||||
...
|
|
||||||
// Ten minutes later...
|
|
||||||
foo = burry.get('foo'); // foo is undefined and also removed from localStorage
|
|
||||||
```
|
|
||||||
|
|
||||||
Attempting to `set` when the `localStorage` is full, will try again after flushing expired key/values from the cache. If this does not succeed either, your `set` will be ignored.
|
|
||||||
|
|
||||||
### Counters
|
|
||||||
|
|
||||||
You can increment/decrement persistent counters. If the counter does not exist, it is initialized with the value 0.
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
burry.incr('counter');
|
|
||||||
burry.incr('counter');
|
|
||||||
var counter = burry.get('counter'); // counter === 2
|
|
||||||
burry.decr('counter');
|
|
||||||
counter = burry.get('counter'); // counter === 1
|
|
||||||
```
|
|
||||||
|
|
||||||
### Helpers
|
|
||||||
|
|
||||||
The following more esoteric functions are also exposed:
|
|
||||||
|
|
||||||
* `burry.add(key, value, ttl)`, same as `set` except it will only add the key if it does not already exist, or it has already expired.
|
|
||||||
* `burry.replace(key, value, ttl)`, same as `set` except it will only add the key if it does already exist and has not expired.
|
|
||||||
* `burry.flush()`, removes from `localStorage` all Burry items.
|
|
||||||
* `burry.flushExpired()`, removes from `localStorage` all expired Burry items of the store.
|
|
||||||
* `Burry.flushExpired()`, removes from `localStorage` all expired Burry items of all stores.
|
|
||||||
* `burry.keys()`, returns all stored keys.
|
|
||||||
* `burry.expirableKeys()` return an dictionary of key/values where the values are the TTL of the keys from Epoch.
|
|
||||||
* `burry.hasExpired(key)`, returns whether a key has expired.
|
|
||||||
* `Burry.isSupported()`, returns whether `localStorage` and `JSON` serialization are supported on the browser.
|
|
||||||
|
|
||||||
## License
|
|
||||||
|
|
||||||
Backbone.xmpp.storage is Copyright (C) 2012 Yiorgis Gozadinos, Riot AS.
|
|
||||||
It is distributed under the MIT license.
|
|
@ -1,292 +0,0 @@
|
|||||||
// Burry.js Storage v0.1
|
|
||||||
|
|
||||||
// (c) 2012 Yiorgis Gozadinos, Riot AS.
|
|
||||||
// Burry.js is distributed under the MIT license.
|
|
||||||
// http://github.com/ggozad/burry.js
|
|
||||||
|
|
||||||
// AMD/global registrations
|
|
||||||
(function (root, factory) {
|
|
||||||
if (typeof define === 'function' && define.amd) {
|
|
||||||
// AMD. Register as an anonymous module.
|
|
||||||
define([], function () {
|
|
||||||
return factory();
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
// Browser globals
|
|
||||||
root.Burry = factory();
|
|
||||||
}
|
|
||||||
}(this, function () {
|
|
||||||
|
|
||||||
// Construct a new Burry store with an optional `namespace` and an optional default `ttl`.
|
|
||||||
var Burry = {
|
|
||||||
|
|
||||||
Store: function (ns, default_ttl) {
|
|
||||||
var stores = Burry.stores();
|
|
||||||
if (ns) {
|
|
||||||
this._CACHE_SUFFIX = this._CACHE_SUFFIX + ns;
|
|
||||||
this._EXPIRY_KEY = this._EXPIRY_KEY + ns;
|
|
||||||
if (stores.indexOf(ns) === -1)
|
|
||||||
stores.push(ns);
|
|
||||||
}
|
|
||||||
localStorage.setItem('_burry_stores_', JSON.stringify(stores));
|
|
||||||
this.default_ttl = default_ttl;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Time resolution in minutes
|
|
||||||
_EXPIRY_UNITS: 60 * 1000,
|
|
||||||
|
|
||||||
// Calculate the time since Epoch in minutes
|
|
||||||
_mEpoch: function () {
|
|
||||||
return Math.floor((new Date().getTime())/Burry._EXPIRY_UNITS);
|
|
||||||
},
|
|
||||||
|
|
||||||
stores: function () {
|
|
||||||
var stores = localStorage.getItem('_burry_stores_');
|
|
||||||
if (stores) {
|
|
||||||
stores = JSON.parse(stores);
|
|
||||||
} else {
|
|
||||||
stores = [''];
|
|
||||||
}
|
|
||||||
return stores;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Checks for localStorage & JSON support.
|
|
||||||
isSupported: function () {
|
|
||||||
// If this has been called before we already know.
|
|
||||||
if (Burry._isSupported) return Burry._isSupported;
|
|
||||||
|
|
||||||
try {
|
|
||||||
localStorage.setItem('_burry_', '_burry_');
|
|
||||||
localStorage.removeItem('_burry_');
|
|
||||||
} catch (e) {
|
|
||||||
return Burry._isSupported = false;
|
|
||||||
}
|
|
||||||
if (!JSON) {
|
|
||||||
return Burry._isSupported = false;
|
|
||||||
}
|
|
||||||
return Burry._isSupported = true;
|
|
||||||
},
|
|
||||||
|
|
||||||
flushExpired: function () {
|
|
||||||
var i, match, key, val, ns,
|
|
||||||
remove = [],
|
|
||||||
now = Burry._mEpoch();
|
|
||||||
|
|
||||||
for (i=0; i< localStorage.length; i++) {
|
|
||||||
key = localStorage.key(i);
|
|
||||||
match = key.match(/(.+)-_burry_exp_(.*)/);
|
|
||||||
if (match) {
|
|
||||||
val = localStorage.getItem(key);
|
|
||||||
if (val < now) {
|
|
||||||
key = match[1]; ns = match[2];
|
|
||||||
remove.push(key + Burry.Store.prototype._CACHE_SUFFIX + ns);
|
|
||||||
remove.push(key + Burry.Store.prototype._EXPIRY_KEY + ns);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i=0; i< remove.length; i++) {
|
|
||||||
localStorage.removeItem(remove[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Instance methods
|
|
||||||
|
|
||||||
Burry.Store.prototype = {
|
|
||||||
|
|
||||||
// Suffix to all keys in the cache
|
|
||||||
_CACHE_SUFFIX: '-_burry_',
|
|
||||||
|
|
||||||
// Key used to store expiration data
|
|
||||||
_EXPIRY_KEY: '-_burry_exp_',
|
|
||||||
|
|
||||||
// Return the internally used suffixed key.
|
|
||||||
_internalKey: function (key) {
|
|
||||||
return key + this._CACHE_SUFFIX;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Return the internally used suffixed expiration key.
|
|
||||||
_expirationKey: function (key) {
|
|
||||||
return key + this._EXPIRY_KEY;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Check if a key is a valid internal key
|
|
||||||
_isInternalKey: function (key) {
|
|
||||||
if (key.slice(-this._CACHE_SUFFIX.length) === this._CACHE_SUFFIX)
|
|
||||||
return key.slice(0, -this._CACHE_SUFFIX.length);
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Check if a key is a valid expiration key
|
|
||||||
_isExpirationKey: function (key) {
|
|
||||||
if (key.slice(-this._EXPIRY_KEY.length) === this._EXPIRY_KEY)
|
|
||||||
return key.slice(0, -this._EXPIRY_KEY.length);
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Returns in how many minutes after Epoch the key expires,
|
|
||||||
// or `undefined` if it does not expire.
|
|
||||||
_expiresOn: function (key) {
|
|
||||||
var expires = localStorage.getItem(this._expirationKey(key));
|
|
||||||
if (expires) {
|
|
||||||
return parseInt(expires, 10);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Parse the value of a key as an integer.
|
|
||||||
_getCounter: function (bkey) {
|
|
||||||
var value = localStorage.getItem(bkey);
|
|
||||||
if (value === null) return 0;
|
|
||||||
|
|
||||||
return parseInt(value, 10);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Returns the value of `key` from the cache, `undefined` if the `key` has
|
|
||||||
// expired or is not stored.
|
|
||||||
get: function (key) {
|
|
||||||
var value = localStorage.getItem(this._internalKey(key));
|
|
||||||
if (value === null) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (this.hasExpired(key)) {
|
|
||||||
this.remove(key);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
value = JSON.parse(value);
|
|
||||||
} catch (e) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Sets a `key`/`value` on the cache. Optionally, sets the expiration in `ttl` minutes.
|
|
||||||
set: function (key, value, ttl) {
|
|
||||||
var i, bkey, expires = {};
|
|
||||||
ttl = ttl || this.default_ttl;
|
|
||||||
if (ttl) ttl = parseInt(ttl, 10);
|
|
||||||
if (typeof key === undefined || typeof value === undefined) return;
|
|
||||||
value = JSON.stringify(value);
|
|
||||||
try {
|
|
||||||
localStorage.setItem(this._internalKey(key), value);
|
|
||||||
if (ttl) {
|
|
||||||
localStorage.setItem(this._expirationKey(key), Burry._mEpoch() + ttl);
|
|
||||||
} else {
|
|
||||||
localStorage.removeItem(this._expirationKey(key));
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
if (e.name === 'QUOTA_EXCEEDED_ERR' || e.name === 'NS_ERROR_DOM_QUOTA_REACHED') {
|
|
||||||
// No space left on localStorage, let's flush expired items and try agagin.
|
|
||||||
Burry.flushExpired();
|
|
||||||
try {
|
|
||||||
localStorage.setItem(this._internalKey(key), value);
|
|
||||||
if (ttl) {
|
|
||||||
localStorage.setItem(this._expirationKey(key), Burry._mEpoch() + ttl);
|
|
||||||
} else {
|
|
||||||
localStorage.removeItem(this._expirationKey(key));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
// Oh well. Let's forget about it.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Sets a `key`/`value` on the cache as does **set** but only if the key does not already exist or has expired.
|
|
||||||
add: function (key, value, ttl) {
|
|
||||||
if (localStorage.getItem(this._internalKey(key)) === null || this.hasExpired(key)) {
|
|
||||||
this.set(key, value, ttl);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Sets a `key`/`value` on the cache as does **set** but only if the key already exist and has not expired.
|
|
||||||
replace: function (key, value, ttl) {
|
|
||||||
if (localStorage.getItem(this._internalKey(key)) !== null && !this.hasExpired(key)) {
|
|
||||||
this.set(key, value, ttl);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
// Removes an item from the cache.
|
|
||||||
remove: function (key) {
|
|
||||||
localStorage.removeItem(this._internalKey(key));
|
|
||||||
localStorage.removeItem(this._expirationKey(key));
|
|
||||||
},
|
|
||||||
|
|
||||||
// Increments the integer value of `key` by 1
|
|
||||||
incr: function (key) {
|
|
||||||
var bkey = this._internalKey(key),
|
|
||||||
value = this._getCounter(bkey);
|
|
||||||
value++;
|
|
||||||
localStorage.setItem(bkey, value);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Decrements the integer value of `key` by 1
|
|
||||||
decr: function (key) {
|
|
||||||
var bkey = this._internalKey(key),
|
|
||||||
value = this._getCounter(bkey);
|
|
||||||
value--;
|
|
||||||
localStorage.setItem(bkey, value);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Returns whether `key` has expired.
|
|
||||||
hasExpired: function (key) {
|
|
||||||
var expireson = this._expiresOn(key);
|
|
||||||
if (expireson && (expireson < Burry._mEpoch())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Returns a list of all the cached keys
|
|
||||||
keys: function () {
|
|
||||||
var i, bkey, key, results = [];
|
|
||||||
for (i=0; i < localStorage.length ; i++) {
|
|
||||||
bkey = localStorage.key(i);
|
|
||||||
key = this._isInternalKey(bkey);
|
|
||||||
if (key) {
|
|
||||||
results.push(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Returns an object with all the expirable keys. The values are the ttl
|
|
||||||
// in minutes since Epoch.
|
|
||||||
expirableKeys: function () {
|
|
||||||
var i, bkey, key, results = {};
|
|
||||||
for (i=0; i < localStorage.length ; i++) {
|
|
||||||
bkey = localStorage.key(i);
|
|
||||||
key = this._isExpirationKey(bkey);
|
|
||||||
if (key) {
|
|
||||||
results[key] = parseInt(localStorage.getItem(bkey), 10);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
},
|
|
||||||
|
|
||||||
// Removes all Burry items from `localStorage`.
|
|
||||||
flush: function () {
|
|
||||||
var i, key, remove = [];
|
|
||||||
for (i=0; i < localStorage.length ; i++) {
|
|
||||||
key = localStorage.key(i);
|
|
||||||
if (this._isInternalKey(key) || this._isExpirationKey(key)) {
|
|
||||||
remove.push(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (i=0; i<remove.length; i++)
|
|
||||||
localStorage.removeItem(remove[i]);
|
|
||||||
},
|
|
||||||
|
|
||||||
// Removes all expired items.
|
|
||||||
flushExpired: function () {
|
|
||||||
var expirable = this.expirableKeys(), now = Burry._mEpoch(), key, val;
|
|
||||||
for (key in expirable) {
|
|
||||||
val = expirable[key];
|
|
||||||
if (val < now) this.remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return Burry;
|
|
||||||
}));
|
|
@ -1,601 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html>
|
|
||||||
<head>
|
|
||||||
<meta http-equiv="content-type" content="text/html;charset=utf-8">
|
|
||||||
<title>burry.js</title>
|
|
||||||
<link rel="stylesheet" href="pycco.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="background"></div>
|
|
||||||
<div id='container'>
|
|
||||||
<div class='section'>
|
|
||||||
<div class='docs'><h1>burry.js</h1></div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'>
|
|
||||||
<div class='section' id='section-0'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-0'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Burry.js Storage v0.1</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-1'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-1'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>(c) 2012 Yiorgis Gozadinos, Riot AS.
|
|
||||||
Burry.js is distributed under the MIT license.
|
|
||||||
http://github.com/ggozad/burry.js</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-2'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-2'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>AMD/global registrations</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre><span class="p">(</span><span class="kd">function</span> <span class="p">(</span><span class="nx">root</span><span class="p">,</span> <span class="nx">factory</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">define</span> <span class="o">===</span> <span class="s1">'function'</span> <span class="o">&&</span> <span class="nx">define</span><span class="p">.</span><span class="nx">amd</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-3'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-3'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>AMD. Register as an anonymous module.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">define</span><span class="p">([],</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
|
|
||||||
<span class="k">return</span> <span class="nx">factory</span><span class="p">();</span>
|
|
||||||
<span class="p">});</span>
|
|
||||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-4'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-4'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Browser globals</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">root</span><span class="p">.</span><span class="nx">Burry</span> <span class="o">=</span> <span class="nx">factory</span><span class="p">();</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}(</span><span class="k">this</span><span class="p">,</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-5'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-5'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Construct a new Burry store with an optional <code>namespace</code> and an optional default <code>ttl</code>.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="kd">var</span> <span class="nx">Burry</span> <span class="o">=</span> <span class="p">{</span>
|
|
||||||
|
|
||||||
<span class="nx">Store</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">ns</span><span class="p">,</span> <span class="nx">default_ttl</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">stores</span> <span class="o">=</span> <span class="nx">Burry</span><span class="p">.</span><span class="nx">stores</span><span class="p">();</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">ns</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">this</span><span class="p">.</span><span class="nx">_CACHE_SUFFIX</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_CACHE_SUFFIX</span> <span class="o">+</span> <span class="nx">ns</span><span class="p">;</span>
|
|
||||||
<span class="k">this</span><span class="p">.</span><span class="nx">_EXPIRY_KEY</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_EXPIRY_KEY</span> <span class="o">+</span> <span class="nx">ns</span><span class="p">;</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">stores</span><span class="p">.</span><span class="nx">indexOf</span><span class="p">(</span><span class="nx">ns</span><span class="p">)</span> <span class="o">===</span> <span class="o">-</span><span class="mi">1</span><span class="p">)</span>
|
|
||||||
<span class="nx">stores</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">ns</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="s1">'_burry_stores_'</span><span class="p">,</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">stores</span><span class="p">));</span>
|
|
||||||
<span class="k">this</span><span class="p">.</span><span class="nx">default_ttl</span> <span class="o">=</span> <span class="nx">default_ttl</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-6'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-6'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Time resolution in minutes</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">_EXPIRY_UNITS</span><span class="o">:</span> <span class="mi">60</span> <span class="o">*</span> <span class="mi">1000</span><span class="p">,</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-7'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-7'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Calculate the time since Epoch in minutes</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">_mEpoch</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
|
|
||||||
<span class="k">return</span> <span class="nb">Math</span><span class="p">.</span><span class="nx">floor</span><span class="p">((</span><span class="k">new</span> <span class="nb">Date</span><span class="p">().</span><span class="nx">getTime</span><span class="p">())</span><span class="o">/</span><span class="nx">Burry</span><span class="p">.</span><span class="nx">_EXPIRY_UNITS</span><span class="p">);</span>
|
|
||||||
<span class="p">},</span>
|
|
||||||
|
|
||||||
<span class="nx">stores</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">stores</span> <span class="o">=</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">getItem</span><span class="p">(</span><span class="s1">'_burry_stores_'</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">stores</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">stores</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">stores</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
||||||
<span class="nx">stores</span> <span class="o">=</span> <span class="p">[</span><span class="s1">''</span><span class="p">];</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">return</span> <span class="nx">stores</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-8'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-8'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Checks for localStorage & JSON support.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">isSupported</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
|
|
||||||
<span class="k">try</span> <span class="p">{</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="s1">'_burry_'</span><span class="p">,</span> <span class="s1">'_burry_'</span><span class="p">);</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">removeItem</span><span class="p">(</span><span class="s1">'_burry_'</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="o">!</span><span class="nx">JSON</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span>
|
|
||||||
|
|
||||||
<span class="nx">flushExpired</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">match</span><span class="p">,</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">val</span><span class="p">,</span> <span class="nx">ns</span><span class="p">,</span>
|
|
||||||
<span class="nx">remove</span> <span class="o">=</span> <span class="p">[],</span>
|
|
||||||
<span class="nx">now</span> <span class="o">=</span> <span class="nx">Burry</span><span class="p">.</span><span class="nx">_mEpoch</span><span class="p">();</span>
|
|
||||||
|
|
||||||
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o"><</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">key</span> <span class="o">=</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">key</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span>
|
|
||||||
<span class="nx">match</span> <span class="o">=</span> <span class="nx">key</span><span class="p">.</span><span class="nx">match</span><span class="p">(</span><span class="sr">/(.+)-_burry_exp_(.*)/</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">match</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">val</span> <span class="o">=</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">getItem</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">val</span> <span class="o"><</span> <span class="nx">now</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">key</span> <span class="o">=</span> <span class="nx">match</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span> <span class="nx">ns</span> <span class="o">=</span> <span class="nx">match</span><span class="p">[</span><span class="mi">2</span><span class="p">];</span>
|
|
||||||
<span class="nx">remove</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">key</span> <span class="o">+</span> <span class="nx">Burry</span><span class="p">.</span><span class="nx">Store</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_CACHE_SUFFIX</span> <span class="o">+</span> <span class="nx">ns</span><span class="p">);</span>
|
|
||||||
<span class="nx">remove</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">key</span> <span class="o">+</span> <span class="nx">Burry</span><span class="p">.</span><span class="nx">Store</span><span class="p">.</span><span class="nx">prototype</span><span class="p">.</span><span class="nx">_EXPIRY_KEY</span> <span class="o">+</span> <span class="nx">ns</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o"><</span> <span class="nx">remove</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">removeItem</span><span class="p">(</span><span class="nx">remove</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">};</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-9'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-9'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Instance methods</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">Burry</span><span class="p">.</span><span class="nx">Store</span><span class="p">.</span><span class="nx">prototype</span> <span class="o">=</span> <span class="p">{</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-10'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-10'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Suffix to all keys in the cache</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">_CACHE_SUFFIX</span><span class="o">:</span> <span class="s1">'-_burry_'</span><span class="p">,</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-11'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-11'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Key used to store expiration data</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">_EXPIRY_KEY</span><span class="o">:</span> <span class="s1">'-_burry_exp_'</span><span class="p">,</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-12'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-12'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Return the internally used suffixed key.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">_internalKey</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">return</span> <span class="nx">key</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">_CACHE_SUFFIX</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-13'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-13'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Return the internally used suffixed expiration key.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">_expirationKey</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">return</span> <span class="nx">key</span> <span class="o">+</span> <span class="k">this</span><span class="p">.</span><span class="nx">_EXPIRY_KEY</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-14'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-14'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Check if a key is a valid internal key</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">_isInternalKey</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">key</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="o">-</span><span class="k">this</span><span class="p">.</span><span class="nx">_CACHE_SUFFIX</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="o">===</span> <span class="k">this</span><span class="p">.</span><span class="nx">_CACHE_SUFFIX</span><span class="p">)</span>
|
|
||||||
<span class="k">return</span> <span class="nx">key</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="k">this</span><span class="p">.</span><span class="nx">_CACHE_SUFFIX</span><span class="p">.</span><span class="nx">length</span><span class="p">);</span>
|
|
||||||
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-15'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-15'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Check if a key is a valid expiration key</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">_isExpirationKey</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">key</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="o">-</span><span class="k">this</span><span class="p">.</span><span class="nx">_EXPIRY_KEY</span><span class="p">.</span><span class="nx">length</span><span class="p">)</span> <span class="o">===</span> <span class="k">this</span><span class="p">.</span><span class="nx">_EXPIRY_KEY</span><span class="p">)</span>
|
|
||||||
<span class="k">return</span> <span class="nx">key</span><span class="p">.</span><span class="nx">slice</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="o">-</span><span class="k">this</span><span class="p">.</span><span class="nx">_EXPIRY_KEY</span><span class="p">.</span><span class="nx">length</span><span class="p">);</span>
|
|
||||||
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-16'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-16'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Returns in how many minutes after Epoch the key expires,
|
|
||||||
or <code>undefined</code> if it does not expire.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">_expiresOn</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">expires</span> <span class="o">=</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">getItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_expirationKey</span><span class="p">(</span><span class="nx">key</span><span class="p">));</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">expires</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">return</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">expires</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-17'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-17'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Parse the value of a key as an integer.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">_getCounter</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">bkey</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">getItem</span><span class="p">(</span><span class="nx">bkey</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">value</span> <span class="o">===</span> <span class="kc">null</span><span class="p">)</span> <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
|
|
||||||
|
|
||||||
<span class="k">return</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">value</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-18'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-18'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Returns the value of <code>key</code> from the cache, <code>undefined</code> if the <code>key</code> has
|
|
||||||
expired or is not stored.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">get</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">value</span> <span class="o">=</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">getItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_internalKey</span><span class="p">(</span><span class="nx">key</span><span class="p">));</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">value</span> <span class="o">===</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">return</span> <span class="kc">undefined</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">hasExpired</span><span class="p">(</span><span class="nx">key</span><span class="p">))</span> <span class="p">{</span>
|
|
||||||
<span class="k">this</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
|
|
||||||
<span class="k">return</span> <span class="kc">undefined</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">try</span> <span class="p">{</span>
|
|
||||||
<span class="nx">value</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">parse</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">return</span> <span class="kc">undefined</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">return</span> <span class="nx">value</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-19'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-19'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Sets a <code>key</code>/<code>value</code> on the cache. Optionally, sets the expiration in <code>ttl</code> minutes.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">set</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">ttl</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">bkey</span><span class="p">,</span> <span class="nx">expires</span> <span class="o">=</span> <span class="p">{};</span>
|
|
||||||
<span class="nx">ttl</span> <span class="o">=</span> <span class="nx">ttl</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">default_ttl</span><span class="p">;</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">ttl</span><span class="p">)</span> <span class="nx">ttl</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">ttl</span><span class="p">,</span> <span class="mi">10</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="k">typeof</span> <span class="nx">key</span> <span class="o">===</span> <span class="kc">undefined</span> <span class="o">||</span> <span class="k">typeof</span> <span class="nx">value</span> <span class="o">===</span> <span class="kc">undefined</span><span class="p">)</span> <span class="k">return</span><span class="p">;</span>
|
|
||||||
<span class="nx">value</span> <span class="o">=</span> <span class="nx">JSON</span><span class="p">.</span><span class="nx">stringify</span><span class="p">(</span><span class="nx">value</span><span class="p">);</span>
|
|
||||||
<span class="k">try</span> <span class="p">{</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_internalKey</span><span class="p">(</span><span class="nx">key</span><span class="p">),</span> <span class="nx">value</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">ttl</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_expirationKey</span><span class="p">(</span><span class="nx">key</span><span class="p">),</span> <span class="nx">Burry</span><span class="p">.</span><span class="nx">_mEpoch</span><span class="p">()</span> <span class="o">+</span> <span class="nx">ttl</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">removeItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_expirationKey</span><span class="p">(</span><span class="nx">key</span><span class="p">));</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span> <span class="k">catch</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">e</span><span class="p">.</span><span class="nx">name</span> <span class="o">===</span> <span class="s1">'QUOTA_EXCEEDED_ERR'</span> <span class="o">||</span> <span class="nx">e</span><span class="p">.</span><span class="nx">name</span> <span class="o">===</span> <span class="s1">'NS_ERROR_DOM_QUOTA_REACHED'</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-20'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-20'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>No space left on localStorage, let's flush expired items and try agagin.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">Burry</span><span class="p">.</span><span class="nx">flushExpired</span><span class="p">();</span>
|
|
||||||
<span class="k">try</span> <span class="p">{</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_internalKey</span><span class="p">(</span><span class="nx">key</span><span class="p">),</span> <span class="nx">value</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">ttl</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_expirationKey</span><span class="p">(</span><span class="nx">key</span><span class="p">),</span> <span class="nx">Burry</span><span class="p">.</span><span class="nx">_mEpoch</span><span class="p">()</span> <span class="o">+</span> <span class="nx">ttl</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span> <span class="k">else</span> <span class="p">{</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">removeItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_expirationKey</span><span class="p">(</span><span class="nx">key</span><span class="p">));</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">catch</span> <span class="p">(</span><span class="nx">e</span><span class="p">)</span> <span class="p">{</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-21'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-21'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Oh well. Let's forget about it.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-22'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-22'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Sets a <code>key</code>/<code>value</code> on the cache as does <strong>set</strong> but only if the key does not already exist or has expired.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">add</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">ttl</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">localStorage</span><span class="p">.</span><span class="nx">getItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_internalKey</span><span class="p">(</span><span class="nx">key</span><span class="p">))</span> <span class="o">===</span> <span class="kc">null</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">hasExpired</span><span class="p">(</span><span class="nx">key</span><span class="p">))</span> <span class="p">{</span>
|
|
||||||
<span class="k">this</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">ttl</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-23'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-23'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Sets a <code>key</code>/<code>value</code> on the cache as does <strong>set</strong> but only if the key already exist and has not expired.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">replace</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">ttl</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">localStorage</span><span class="p">.</span><span class="nx">getItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_internalKey</span><span class="p">(</span><span class="nx">key</span><span class="p">))</span> <span class="o">!==</span> <span class="kc">null</span> <span class="o">&&</span> <span class="o">!</span><span class="k">this</span><span class="p">.</span><span class="nx">hasExpired</span><span class="p">(</span><span class="nx">key</span><span class="p">))</span> <span class="p">{</span>
|
|
||||||
<span class="k">this</span><span class="p">.</span><span class="nx">set</span><span class="p">(</span><span class="nx">key</span><span class="p">,</span> <span class="nx">value</span><span class="p">,</span> <span class="nx">ttl</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-24'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-24'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Removes an item from the cache.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">remove</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">removeItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_internalKey</span><span class="p">(</span><span class="nx">key</span><span class="p">));</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">removeItem</span><span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_expirationKey</span><span class="p">(</span><span class="nx">key</span><span class="p">));</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-25'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-25'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Increments the integer value of <code>key</code> by 1</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">incr</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">bkey</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_internalKey</span><span class="p">(</span><span class="nx">key</span><span class="p">),</span>
|
|
||||||
<span class="nx">value</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getCounter</span><span class="p">(</span><span class="nx">bkey</span><span class="p">);</span>
|
|
||||||
<span class="nx">value</span><span class="o">++</span><span class="p">;</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="nx">bkey</span><span class="p">,</span> <span class="nx">value</span><span class="p">);</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-26'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-26'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Decrements the integer value of <code>key</code> by 1</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">decr</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">bkey</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_internalKey</span><span class="p">(</span><span class="nx">key</span><span class="p">),</span>
|
|
||||||
<span class="nx">value</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_getCounter</span><span class="p">(</span><span class="nx">bkey</span><span class="p">);</span>
|
|
||||||
<span class="nx">value</span><span class="o">--</span><span class="p">;</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">setItem</span><span class="p">(</span><span class="nx">bkey</span><span class="p">,</span> <span class="nx">value</span><span class="p">);</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-27'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-27'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Returns whether <code>key</code> has expired.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">hasExpired</span><span class="o">:</span> <span class="kd">function</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">expireson</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_expiresOn</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">expireson</span> <span class="o">&&</span> <span class="p">(</span><span class="nx">expireson</span> <span class="o"><</span> <span class="nx">Burry</span><span class="p">.</span><span class="nx">_mEpoch</span><span class="p">()))</span> <span class="p">{</span>
|
|
||||||
<span class="k">return</span> <span class="kc">true</span><span class="p">;</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">return</span> <span class="kc">false</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-28'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-28'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Returns a list of all the cached keys</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">keys</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">bkey</span><span class="p">,</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">results</span> <span class="o">=</span> <span class="p">[];</span>
|
|
||||||
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">length</span> <span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">bkey</span> <span class="o">=</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">key</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span>
|
|
||||||
<span class="nx">key</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_isInternalKey</span><span class="p">(</span><span class="nx">bkey</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">results</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">return</span> <span class="nx">results</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-29'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-29'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Returns an object with all the expirable keys. The values are the ttl
|
|
||||||
in minutes since Epoch.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">expirableKeys</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">bkey</span><span class="p">,</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">results</span> <span class="o">=</span> <span class="p">{};</span>
|
|
||||||
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">length</span> <span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">bkey</span> <span class="o">=</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">key</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span>
|
|
||||||
<span class="nx">key</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">_isExpirationKey</span><span class="p">(</span><span class="nx">bkey</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">results</span><span class="p">[</span><span class="nx">key</span><span class="p">]</span> <span class="o">=</span> <span class="nb">parseInt</span><span class="p">(</span><span class="nx">localStorage</span><span class="p">.</span><span class="nx">getItem</span><span class="p">(</span><span class="nx">bkey</span><span class="p">),</span> <span class="mi">10</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">return</span> <span class="nx">results</span><span class="p">;</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-30'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-30'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Removes all Burry items from <code>localStorage</code>.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">flush</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">i</span><span class="p">,</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">remove</span> <span class="o">=</span> <span class="p">[];</span>
|
|
||||||
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span> <span class="o"><</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">length</span> <span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">key</span> <span class="o">=</span> <span class="nx">localStorage</span><span class="p">.</span><span class="nx">key</span><span class="p">(</span><span class="nx">i</span><span class="p">);</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="k">this</span><span class="p">.</span><span class="nx">_isInternalKey</span><span class="p">(</span><span class="nx">key</span><span class="p">)</span> <span class="o">||</span> <span class="k">this</span><span class="p">.</span><span class="nx">_isExpirationKey</span><span class="p">(</span><span class="nx">key</span><span class="p">))</span> <span class="p">{</span>
|
|
||||||
<span class="nx">remove</span><span class="p">.</span><span class="nx">push</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="k">for</span> <span class="p">(</span><span class="nx">i</span><span class="o">=</span><span class="mi">0</span><span class="p">;</span> <span class="nx">i</span><span class="o"><</span><span class="nx">remove</span><span class="p">.</span><span class="nx">length</span><span class="p">;</span> <span class="nx">i</span><span class="o">++</span><span class="p">)</span>
|
|
||||||
<span class="nx">localStorage</span><span class="p">.</span><span class="nx">removeItem</span><span class="p">(</span><span class="nx">remove</span><span class="p">[</span><span class="nx">i</span><span class="p">]);</span>
|
|
||||||
<span class="p">},</span></pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
<div class='section' id='section-31'>
|
|
||||||
<div class='docs'>
|
|
||||||
<div class='octowrap'>
|
|
||||||
<a class='octothorpe' href='#section-31'>#</a>
|
|
||||||
</div>
|
|
||||||
<p>Removes all expired items.</p>
|
|
||||||
</div>
|
|
||||||
<div class='code'>
|
|
||||||
<div class="highlight"><pre> <span class="nx">flushExpired</span><span class="o">:</span> <span class="kd">function</span> <span class="p">()</span> <span class="p">{</span>
|
|
||||||
<span class="kd">var</span> <span class="nx">expirable</span> <span class="o">=</span> <span class="k">this</span><span class="p">.</span><span class="nx">expirableKeys</span><span class="p">(),</span> <span class="nx">now</span> <span class="o">=</span> <span class="nx">Burry</span><span class="p">.</span><span class="nx">_mEpoch</span><span class="p">(),</span> <span class="nx">key</span><span class="p">,</span> <span class="nx">val</span><span class="p">;</span>
|
|
||||||
<span class="k">for</span> <span class="p">(</span><span class="nx">key</span> <span class="k">in</span> <span class="nx">expirable</span><span class="p">)</span> <span class="p">{</span>
|
|
||||||
<span class="nx">val</span> <span class="o">=</span> <span class="nx">expirable</span><span class="p">[</span><span class="nx">key</span><span class="p">];</span>
|
|
||||||
<span class="k">if</span> <span class="p">(</span><span class="nx">val</span> <span class="o"><</span> <span class="nx">now</span><span class="p">)</span> <span class="k">this</span><span class="p">.</span><span class="nx">remove</span><span class="p">(</span><span class="nx">key</span><span class="p">);</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">}</span>
|
|
||||||
<span class="p">};</span>
|
|
||||||
|
|
||||||
<span class="k">return</span> <span class="nx">Burry</span><span class="p">;</span>
|
|
||||||
<span class="p">}));</span>
|
|
||||||
|
|
||||||
</pre></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class='clearall'></div>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
@ -1,186 +0,0 @@
|
|||||||
/*--------------------- Layout and Typography ----------------------------*/
|
|
||||||
body {
|
|
||||||
font-family: 'Palatino Linotype', 'Book Antiqua', Palatino, FreeSerif, serif;
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 24px;
|
|
||||||
color: #252519;
|
|
||||||
margin: 0; padding: 0;
|
|
||||||
}
|
|
||||||
a {
|
|
||||||
color: #261a3b;
|
|
||||||
}
|
|
||||||
a:visited {
|
|
||||||
color: #261a3b;
|
|
||||||
}
|
|
||||||
p {
|
|
||||||
margin: 0 0 15px 0;
|
|
||||||
}
|
|
||||||
h1, h2, h3, h4, h5, h6 {
|
|
||||||
margin: 40px 0 15px 0;
|
|
||||||
}
|
|
||||||
h2, h3, h4, h5, h6 {
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
#container, div.section {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
#background {
|
|
||||||
position: fixed;
|
|
||||||
top: 0; left: 580px; right: 0; bottom: 0;
|
|
||||||
background: #f5f5ff;
|
|
||||||
border-left: 1px solid #e5e5ee;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
#jump_to, #jump_page {
|
|
||||||
background: white;
|
|
||||||
-webkit-box-shadow: 0 0 25px #777; -moz-box-shadow: 0 0 25px #777;
|
|
||||||
-webkit-border-bottom-left-radius: 5px; -moz-border-radius-bottomleft: 5px;
|
|
||||||
font: 10px Arial;
|
|
||||||
text-transform: uppercase;
|
|
||||||
cursor: pointer;
|
|
||||||
text-align: right;
|
|
||||||
}
|
|
||||||
#jump_to, #jump_wrapper {
|
|
||||||
position: fixed;
|
|
||||||
right: 0; top: 0;
|
|
||||||
padding: 5px 10px;
|
|
||||||
}
|
|
||||||
#jump_wrapper {
|
|
||||||
padding: 0;
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
#jump_to:hover #jump_wrapper {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
#jump_page {
|
|
||||||
padding: 5px 0 3px;
|
|
||||||
margin: 0 0 25px 25px;
|
|
||||||
}
|
|
||||||
#jump_page .source {
|
|
||||||
display: block;
|
|
||||||
padding: 5px 10px;
|
|
||||||
text-decoration: none;
|
|
||||||
border-top: 1px solid #eee;
|
|
||||||
}
|
|
||||||
#jump_page .source:hover {
|
|
||||||
background: #f5f5ff;
|
|
||||||
}
|
|
||||||
#jump_page .source:first-child {
|
|
||||||
}
|
|
||||||
div.docs {
|
|
||||||
float: left;
|
|
||||||
max-width: 500px;
|
|
||||||
min-width: 500px;
|
|
||||||
min-height: 5px;
|
|
||||||
padding: 10px 25px 1px 50px;
|
|
||||||
vertical-align: top;
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
.docs pre {
|
|
||||||
margin: 15px 0 15px;
|
|
||||||
padding-left: 15px;
|
|
||||||
}
|
|
||||||
.docs p tt, .docs p code {
|
|
||||||
background: #f8f8ff;
|
|
||||||
border: 1px solid #dedede;
|
|
||||||
font-size: 12px;
|
|
||||||
padding: 0 0.2em;
|
|
||||||
}
|
|
||||||
.octowrap {
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
.octothorpe {
|
|
||||||
font: 12px Arial;
|
|
||||||
text-decoration: none;
|
|
||||||
color: #454545;
|
|
||||||
position: absolute;
|
|
||||||
top: 3px; left: -20px;
|
|
||||||
padding: 1px 2px;
|
|
||||||
opacity: 0;
|
|
||||||
-webkit-transition: opacity 0.2s linear;
|
|
||||||
}
|
|
||||||
div.docs:hover .octothorpe {
|
|
||||||
opacity: 1;
|
|
||||||
}
|
|
||||||
div.code {
|
|
||||||
margin-left: 580px;
|
|
||||||
padding: 14px 15px 16px 50px;
|
|
||||||
vertical-align: top;
|
|
||||||
}
|
|
||||||
.code pre, .docs p code {
|
|
||||||
font-size: 12px;
|
|
||||||
}
|
|
||||||
pre, tt, code {
|
|
||||||
line-height: 18px;
|
|
||||||
font-family: Monaco, Consolas, "Lucida Console", monospace;
|
|
||||||
margin: 0; padding: 0;
|
|
||||||
}
|
|
||||||
div.clearall {
|
|
||||||
clear: both;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*---------------------- Syntax Highlighting -----------------------------*/
|
|
||||||
td.linenos { background-color: #f0f0f0; padding-right: 10px; }
|
|
||||||
span.lineno { background-color: #f0f0f0; padding: 0 5px 0 5px; }
|
|
||||||
body .hll { background-color: #ffffcc }
|
|
||||||
body .c { color: #408080; font-style: italic } /* Comment */
|
|
||||||
body .err { border: 1px solid #FF0000 } /* Error */
|
|
||||||
body .k { color: #954121 } /* Keyword */
|
|
||||||
body .o { color: #666666 } /* Operator */
|
|
||||||
body .cm { color: #408080; font-style: italic } /* Comment.Multiline */
|
|
||||||
body .cp { color: #BC7A00 } /* Comment.Preproc */
|
|
||||||
body .c1 { color: #408080; font-style: italic } /* Comment.Single */
|
|
||||||
body .cs { color: #408080; font-style: italic } /* Comment.Special */
|
|
||||||
body .gd { color: #A00000 } /* Generic.Deleted */
|
|
||||||
body .ge { font-style: italic } /* Generic.Emph */
|
|
||||||
body .gr { color: #FF0000 } /* Generic.Error */
|
|
||||||
body .gh { color: #000080; font-weight: bold } /* Generic.Heading */
|
|
||||||
body .gi { color: #00A000 } /* Generic.Inserted */
|
|
||||||
body .go { color: #808080 } /* Generic.Output */
|
|
||||||
body .gp { color: #000080; font-weight: bold } /* Generic.Prompt */
|
|
||||||
body .gs { font-weight: bold } /* Generic.Strong */
|
|
||||||
body .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
|
|
||||||
body .gt { color: #0040D0 } /* Generic.Traceback */
|
|
||||||
body .kc { color: #954121 } /* Keyword.Constant */
|
|
||||||
body .kd { color: #954121; font-weight: bold } /* Keyword.Declaration */
|
|
||||||
body .kn { color: #954121; font-weight: bold } /* Keyword.Namespace */
|
|
||||||
body .kp { color: #954121 } /* Keyword.Pseudo */
|
|
||||||
body .kr { color: #954121; font-weight: bold } /* Keyword.Reserved */
|
|
||||||
body .kt { color: #B00040 } /* Keyword.Type */
|
|
||||||
body .m { color: #666666 } /* Literal.Number */
|
|
||||||
body .s { color: #219161 } /* Literal.String */
|
|
||||||
body .na { color: #7D9029 } /* Name.Attribute */
|
|
||||||
body .nb { color: #954121 } /* Name.Builtin */
|
|
||||||
body .nc { color: #0000FF; font-weight: bold } /* Name.Class */
|
|
||||||
body .no { color: #880000 } /* Name.Constant */
|
|
||||||
body .nd { color: #AA22FF } /* Name.Decorator */
|
|
||||||
body .ni { color: #999999; font-weight: bold } /* Name.Entity */
|
|
||||||
body .ne { color: #D2413A; font-weight: bold } /* Name.Exception */
|
|
||||||
body .nf { color: #0000FF } /* Name.Function */
|
|
||||||
body .nl { color: #A0A000 } /* Name.Label */
|
|
||||||
body .nn { color: #0000FF; font-weight: bold } /* Name.Namespace */
|
|
||||||
body .nt { color: #954121; font-weight: bold } /* Name.Tag */
|
|
||||||
body .nv { color: #19469D } /* Name.Variable */
|
|
||||||
body .ow { color: #AA22FF; font-weight: bold } /* Operator.Word */
|
|
||||||
body .w { color: #bbbbbb } /* Text.Whitespace */
|
|
||||||
body .mf { color: #666666 } /* Literal.Number.Float */
|
|
||||||
body .mh { color: #666666 } /* Literal.Number.Hex */
|
|
||||||
body .mi { color: #666666 } /* Literal.Number.Integer */
|
|
||||||
body .mo { color: #666666 } /* Literal.Number.Oct */
|
|
||||||
body .sb { color: #219161 } /* Literal.String.Backtick */
|
|
||||||
body .sc { color: #219161 } /* Literal.String.Char */
|
|
||||||
body .sd { color: #219161; font-style: italic } /* Literal.String.Doc */
|
|
||||||
body .s2 { color: #219161 } /* Literal.String.Double */
|
|
||||||
body .se { color: #BB6622; font-weight: bold } /* Literal.String.Escape */
|
|
||||||
body .sh { color: #219161 } /* Literal.String.Heredoc */
|
|
||||||
body .si { color: #BB6688; font-weight: bold } /* Literal.String.Interpol */
|
|
||||||
body .sx { color: #954121 } /* Literal.String.Other */
|
|
||||||
body .sr { color: #BB6688 } /* Literal.String.Regex */
|
|
||||||
body .s1 { color: #219161 } /* Literal.String.Single */
|
|
||||||
body .ss { color: #19469D } /* Literal.String.Symbol */
|
|
||||||
body .bp { color: #954121 } /* Name.Builtin.Pseudo */
|
|
||||||
body .vc { color: #19469D } /* Name.Variable.Class */
|
|
||||||
body .vg { color: #19469D } /* Name.Variable.Global */
|
|
||||||
body .vi { color: #19469D } /* Name.Variable.Instance */
|
|
||||||
body .il { color: #666666 } /* Literal.Number.Integer.Long */
|
|
@ -1,17 +0,0 @@
|
|||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" xmlns:tal="http://xml.zope.org/namespaces/tal">
|
|
||||||
<head>
|
|
||||||
<title>Jasmine Spec Runner</title>
|
|
||||||
|
|
||||||
<link rel="stylesheet" type="text/css" href="./vendor/jasmine/jasmine.css"/>
|
|
||||||
<script src="./vendor/jquery.js"></script>
|
|
||||||
<script src="../burry.js"></script>
|
|
||||||
<script src="./vendor/jasmine/jasmine.js"></script>
|
|
||||||
<script src="./vendor/jasmine/jasmine-html.js"></script>
|
|
||||||
<script src="./specs/burry_spec.js"></script>
|
|
||||||
<script type="text/javascript" src="./index.js"></script>
|
|
||||||
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,14 +0,0 @@
|
|||||||
/*globals jasmine:false */
|
|
||||||
|
|
||||||
(function ($) {
|
|
||||||
$(function () {
|
|
||||||
var jasmineEnv = jasmine.getEnv();
|
|
||||||
jasmineEnv.updateInterval = 1000;
|
|
||||||
var htmlReporter = new jasmine.HtmlReporter();
|
|
||||||
jasmineEnv.addReporter(htmlReporter);
|
|
||||||
jasmineEnv.specFilter = function(spec) {
|
|
||||||
return htmlReporter.specFilter(spec);
|
|
||||||
};
|
|
||||||
jasmineEnv.execute();
|
|
||||||
});
|
|
||||||
})(this.jQuery);
|
|
@ -1,244 +0,0 @@
|
|||||||
(function (Burry) {
|
|
||||||
|
|
||||||
describe('burry.js Storage', function () {
|
|
||||||
|
|
||||||
afterEach(function () {
|
|
||||||
localStorage.clear();
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Static methods', function () {
|
|
||||||
|
|
||||||
it('returns the stores that have been created', function () {
|
|
||||||
var burryfoo, burrybar;
|
|
||||||
burryfoo = new Burry.Store('foo');
|
|
||||||
burrybar = new Burry.Store('bar');
|
|
||||||
burrybar2 = new Burry.Store('bar');
|
|
||||||
expect(Burry.stores()).toEqual(['', 'foo', 'bar']);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calculates time elapsed since epoch in minutues', function () {
|
|
||||||
var datea = new Date(10 * 60 * 1000);
|
|
||||||
spyOn(window, 'Date').andReturn(datea);
|
|
||||||
expect(Burry._mEpoch()).toEqual(10);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('supports localStorage', function () {
|
|
||||||
expect(Burry.isSupported()).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('flushes expired key/values from all stores', function () {
|
|
||||||
burryfoo = new Burry.Store('foo');
|
|
||||||
burrybar = new Burry.Store('bar');
|
|
||||||
burryfoo.set('expired1', {foo: 'bar'}, -1);
|
|
||||||
burryfoo.set('expired2', {foo: 'bar'}, -2);
|
|
||||||
burryfoo.set('not-expired', {foo: 'bar'}, 10);
|
|
||||||
burrybar.set('expired1', {foo: 'bar'}, -1);
|
|
||||||
burrybar.set('expired2', {foo: 'bar'}, -2);
|
|
||||||
burrybar.set('not-expired', {foo: 'bar'}, 10);
|
|
||||||
Burry.flushExpired();
|
|
||||||
expect(localStorage.getItem(burryfoo._internalKey('expired1'))).toBeNull();
|
|
||||||
expect(localStorage.getItem(burryfoo._expirationKey('expired1'))).toBeNull();
|
|
||||||
expect(localStorage.getItem(burryfoo._internalKey('expired2'))).toBeNull();
|
|
||||||
expect(localStorage.getItem(burryfoo._expirationKey('expired2'))).toBeNull();
|
|
||||||
expect(burryfoo.get('not-expired')).toBeDefined();
|
|
||||||
expect(localStorage.getItem(burrybar._internalKey('expired1'))).toBeNull();
|
|
||||||
expect(localStorage.getItem(burrybar._expirationKey('expired1'))).toBeNull();
|
|
||||||
expect(localStorage.getItem(burrybar._internalKey('expired2'))).toBeNull();
|
|
||||||
expect(localStorage.getItem(burrybar._expirationKey('expired2'))).toBeNull();
|
|
||||||
expect(burrybar.get('not-expired')).toBeDefined();
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('Instance methods', function () {
|
|
||||||
|
|
||||||
var burry;
|
|
||||||
|
|
||||||
beforeEach(function () {
|
|
||||||
burry = new Burry.Store('');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('allows to set a default ttl', function () {
|
|
||||||
burry = new Burry.Store('', 10);
|
|
||||||
burry.set('akey', {foo: 'bar'});
|
|
||||||
expect(localStorage.getItem('akey-_burry_')).toEqual('{"foo":"bar"}');
|
|
||||||
expect(parseInt(localStorage.getItem('akey-_burry_exp_'), 10)).toEqual(Burry._mEpoch() + 10);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calculates the key used internally', function () {
|
|
||||||
expect(burry._internalKey('akey')).toEqual('akey-_burry_');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('calculates the expiration key used internally', function () {
|
|
||||||
expect(burry._expirationKey(12345)).toEqual('12345-_burry_exp_');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('decides whether a key is a "burry" key', function () {
|
|
||||||
expect(burry._isInternalKey('foo-_burry_')).toEqual('foo');
|
|
||||||
expect(burry._isInternalKey('foo-_burry_bar')).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('decides whether a key is a "burry" expiration key', function () {
|
|
||||||
expect(burry._isExpirationKey('foo-_burry_exp_')).toEqual('foo');
|
|
||||||
expect(burry._isExpirationKey('foo-_burry_exp_bar')).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('applies correctly the namespace on the keys on construction', function () {
|
|
||||||
var nsburry = new Burry.Store('testing');
|
|
||||||
expect(nsburry._isInternalKey('foo-_burry_testing')).toEqual('foo');
|
|
||||||
expect(nsburry._isInternalKey('foo-_burry_')).toBeFalsy();
|
|
||||||
expect(nsburry._isExpirationKey('foo-_burry_exp_testing')).toEqual('foo');
|
|
||||||
expect(nsburry._isExpirationKey('foo-_burry_exp_')).toBeFalsy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('stores a key/value to localStorage', function () {
|
|
||||||
burry.set('akey', {foo: 'bar'});
|
|
||||||
expect(localStorage.getItem('akey-_burry_')).toEqual('{"foo":"bar"}');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('stores a key/value to localStorage with an expiration time', function () {
|
|
||||||
burry.set('akey', {foo: 'bar'}, 10);
|
|
||||||
expect(localStorage.getItem('akey-_burry_')).toEqual('{"foo":"bar"}');
|
|
||||||
expect(parseInt(localStorage.getItem('akey-_burry_exp_'), 10)).toEqual(Burry._mEpoch() + 10);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns the value from a stored key', function () {
|
|
||||||
burry.set('akey', {foo: 'bar'});
|
|
||||||
expect(burry.get('akey')).toEqual({foo: 'bar'});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns undefined for a non-existing key', function () {
|
|
||||||
expect(burry.get('akey')).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns undefined for an expired key, and removes it from localStorage', function () {
|
|
||||||
burry.set('akey', {foo: 'bar'}, -1);
|
|
||||||
expect(localStorage.getItem('akey-_burry_')).toEqual('{"foo":"bar"}');
|
|
||||||
expect(parseInt(localStorage.getItem('akey-_burry_exp_'), 10)).toEqual(Burry._mEpoch() - 1);
|
|
||||||
expect(burry.get('akey')).toBeUndefined();
|
|
||||||
expect(localStorage.getItem('akey-_burry_')).toBeNull();
|
|
||||||
expect(localStorage.getItem('akey-_burry_exp_')).toBeNull();
|
|
||||||
expect(burry.get('akey')).toBeUndefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('adds a key/value when the key does not already exist or has expired', function () {
|
|
||||||
burry.set('akey', {foo: 'bar'});
|
|
||||||
burry.add('akey', {bar: 'foo'});
|
|
||||||
expect(burry.get('akey')).toEqual({foo: 'bar'});
|
|
||||||
burry.add('otherkey', {foo: 'bar'});
|
|
||||||
expect(burry.get('otherkey')).toEqual({foo: 'bar'});
|
|
||||||
burry.set('akey', {foo: 'bar'}, -10);
|
|
||||||
burry.add('akey', {bar: 'foo'});
|
|
||||||
expect(burry.get('akey')).toEqual({bar: 'foo'});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('replaces a key/value only when the key already exists and has not expired', function () {
|
|
||||||
burry.set('akey', {foo: 'bar'});
|
|
||||||
burry.replace('akey', {bar: 'foo'});
|
|
||||||
expect(burry.get('akey')).toEqual({bar: 'foo'});
|
|
||||||
burry.replace('otherkey', {foo: 'bar'});
|
|
||||||
expect(burry.get('otherkey')).not.toBeDefined();
|
|
||||||
burry.set('akey', {foo: 'bar'}, -10);
|
|
||||||
burry.replace('akey', {bar: 'foo'});
|
|
||||||
expect(burry.get('akey')).not.toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('removes a key/value', function () {
|
|
||||||
burry.set('akey', {foo: 'bar'});
|
|
||||||
burry.remove('akey');
|
|
||||||
expect(burry.get('akey')).toBeUndefined();
|
|
||||||
expect(localStorage.getItem('akey-_burry_')).toBeNull();
|
|
||||||
expect(localStorage.getItem('akey-_burry_exp_')).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('increments a counter', function () {
|
|
||||||
burry.incr('counter');
|
|
||||||
expect(burry.get('counter')).toEqual(1);
|
|
||||||
burry.set('counter', 0);
|
|
||||||
burry.incr('counter');
|
|
||||||
burry.incr('counter');
|
|
||||||
expect(burry.get('counter')).toEqual(2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('decrements a counter', function () {
|
|
||||||
burry.decr('counter');
|
|
||||||
expect(burry.get('counter')).toEqual(-1);
|
|
||||||
burry.set('counter', 0);
|
|
||||||
burry.decr('counter');
|
|
||||||
burry.decr('counter');
|
|
||||||
expect(burry.get('counter')).toEqual(-2);
|
|
||||||
});
|
|
||||||
|
|
||||||
it('determines if an item has expired', function () {
|
|
||||||
burry.set('akey', {foo: 'bar'});
|
|
||||||
expect(burry.hasExpired('akey')).toBeFalsy();
|
|
||||||
burry.set('akey', {foo: 'bar'}, 10);
|
|
||||||
expect(burry.hasExpired('akey')).toBeFalsy();
|
|
||||||
burry.set('akey', {foo: 'bar'}, -10);
|
|
||||||
expect(burry.hasExpired('akey')).toBeTruthy();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns all cache keys', function () {
|
|
||||||
var keys;
|
|
||||||
burry.set('expirable1', {foo: 'bar'}, 10);
|
|
||||||
burry.set('expirable2', {foo: 'bar'}, -20);
|
|
||||||
burry.set('non-expirable', {foo: 'bar'});
|
|
||||||
expect(burry.keys().indexOf('expirable1')).not.toEqual(-1);
|
|
||||||
expect(burry.keys().indexOf('expirable2')).not.toEqual(-1);
|
|
||||||
expect(burry.keys().indexOf('non-expirable')).not.toEqual(-1);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns all expirable keys', function () {
|
|
||||||
var expirable, fakedate = new Date(0);
|
|
||||||
spyOn(window, 'Date').andReturn(fakedate);
|
|
||||||
burry.set('expirable1', {foo: 'bar'}, 10);
|
|
||||||
burry.set('expirable2', {foo: 'bar'}, 20);
|
|
||||||
burry.set('non-expirable', {foo: 'bar'});
|
|
||||||
expect(burry.expirableKeys()).toEqual({expirable1: 10, expirable2: 20});
|
|
||||||
});
|
|
||||||
|
|
||||||
it('flushes all Burry items', function () {
|
|
||||||
burry.set('expirable2', {foo: 'bar'}, 20);
|
|
||||||
burry.set('non-expirable', {foo: 'bar'});
|
|
||||||
localStorage.setItem('foo', 'bar');
|
|
||||||
burry.flush();
|
|
||||||
expect(localStorage.length).toEqual(2);
|
|
||||||
expect(localStorage.key(0)).toEqual('_burry_stores_');
|
|
||||||
expect(localStorage.key(1)).toEqual('foo');
|
|
||||||
});
|
|
||||||
|
|
||||||
it('flushes expired key/values', function () {
|
|
||||||
burry.set('expired1', {foo: 'bar'}, -1);
|
|
||||||
burry.set('expired2', {foo: 'bar'}, -2);
|
|
||||||
burry.set('not-expired', {foo: 'bar'}, 10);
|
|
||||||
burry.flushExpired();
|
|
||||||
expect(localStorage.getItem(burry._internalKey('expired1'))).toBeNull();
|
|
||||||
expect(localStorage.getItem(burry._expirationKey('expired1'))).toBeNull();
|
|
||||||
expect(localStorage.getItem(burry._internalKey('expired2'))).toBeNull();
|
|
||||||
expect(localStorage.getItem(burry._expirationKey('expired2'))).toBeNull();
|
|
||||||
expect(burry.get('not-expired')).toBeDefined();
|
|
||||||
});
|
|
||||||
|
|
||||||
it('removes expired objects when setting a value that does not fit in localStorage', function () {
|
|
||||||
var biggie = Array(1024*1024 + 1).join('0'),
|
|
||||||
key = '';
|
|
||||||
while (true) {
|
|
||||||
try {
|
|
||||||
key += 'key';
|
|
||||||
localStorage.setItem(burry._internalKey(key), JSON.stringify(biggie));
|
|
||||||
localStorage.setItem(burry._expirationKey(key), '0');
|
|
||||||
} catch (e) {
|
|
||||||
// The storage is now full.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
expect(localStorage.length > 0).toBeTruthy();
|
|
||||||
burry.set('biggie', biggie);
|
|
||||||
expect(localStorage.length).toEqual(2);
|
|
||||||
expect(burry.get('biggie')).toEqual(biggie);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
})(this.Burry);
|
|
@ -1,20 +0,0 @@
|
|||||||
Copyright (c) 2008-2011 Pivotal Labs
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
|
||||||
a copy of this software and associated documentation files (the
|
|
||||||
"Software"), to deal in the Software without restriction, including
|
|
||||||
without limitation the rights to use, copy, modify, merge, publish,
|
|
||||||
distribute, sublicense, and/or sell copies of the Software, and to
|
|
||||||
permit persons to whom the Software is furnished to do so, subject to
|
|
||||||
the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be
|
|
||||||
included in all copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
||||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
||||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
||||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
||||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
||||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
||||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,616 +0,0 @@
|
|||||||
jasmine.HtmlReporterHelpers = {};
|
|
||||||
|
|
||||||
jasmine.HtmlReporterHelpers.createDom = function(type, attrs, childrenVarArgs) {
|
|
||||||
var el = document.createElement(type);
|
|
||||||
|
|
||||||
for (var i = 2; i < arguments.length; i++) {
|
|
||||||
var child = arguments[i];
|
|
||||||
|
|
||||||
if (typeof child === 'string') {
|
|
||||||
el.appendChild(document.createTextNode(child));
|
|
||||||
} else {
|
|
||||||
if (child) {
|
|
||||||
el.appendChild(child);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var attr in attrs) {
|
|
||||||
if (attr == "className") {
|
|
||||||
el[attr] = attrs[attr];
|
|
||||||
} else {
|
|
||||||
el.setAttribute(attr, attrs[attr]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return el;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporterHelpers.getSpecStatus = function(child) {
|
|
||||||
var results = child.results();
|
|
||||||
var status = results.passed() ? 'passed' : 'failed';
|
|
||||||
if (results.skipped) {
|
|
||||||
status = 'skipped';
|
|
||||||
}
|
|
||||||
|
|
||||||
return status;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporterHelpers.appendToSummary = function(child, childElement) {
|
|
||||||
var parentDiv = this.dom.summary;
|
|
||||||
var parentSuite = (typeof child.parentSuite == 'undefined') ? 'suite' : 'parentSuite';
|
|
||||||
var parent = child[parentSuite];
|
|
||||||
|
|
||||||
if (parent) {
|
|
||||||
if (typeof this.views.suites[parent.id] == 'undefined') {
|
|
||||||
this.views.suites[parent.id] = new jasmine.HtmlReporter.SuiteView(parent, this.dom, this.views);
|
|
||||||
}
|
|
||||||
parentDiv = this.views.suites[parent.id].element;
|
|
||||||
}
|
|
||||||
|
|
||||||
parentDiv.appendChild(childElement);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
jasmine.HtmlReporterHelpers.addHelpers = function(ctor) {
|
|
||||||
for(var fn in jasmine.HtmlReporterHelpers) {
|
|
||||||
ctor.prototype[fn] = jasmine.HtmlReporterHelpers[fn];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporter = function(_doc) {
|
|
||||||
var self = this;
|
|
||||||
var doc = _doc || window.document;
|
|
||||||
|
|
||||||
var reporterView;
|
|
||||||
|
|
||||||
var dom = {};
|
|
||||||
|
|
||||||
// Jasmine Reporter Public Interface
|
|
||||||
self.logRunningSpecs = false;
|
|
||||||
|
|
||||||
self.reportRunnerStarting = function(runner) {
|
|
||||||
var specs = runner.specs() || [];
|
|
||||||
|
|
||||||
if (specs.length == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
createReporterDom(runner.env.versionString());
|
|
||||||
doc.body.appendChild(dom.reporter);
|
|
||||||
|
|
||||||
reporterView = new jasmine.HtmlReporter.ReporterView(dom);
|
|
||||||
reporterView.addSpecs(specs, self.specFilter);
|
|
||||||
};
|
|
||||||
|
|
||||||
self.reportRunnerResults = function(runner) {
|
|
||||||
reporterView && reporterView.complete();
|
|
||||||
};
|
|
||||||
|
|
||||||
self.reportSuiteResults = function(suite) {
|
|
||||||
reporterView.suiteComplete(suite);
|
|
||||||
};
|
|
||||||
|
|
||||||
self.reportSpecStarting = function(spec) {
|
|
||||||
if (self.logRunningSpecs) {
|
|
||||||
self.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
self.reportSpecResults = function(spec) {
|
|
||||||
reporterView.specComplete(spec);
|
|
||||||
};
|
|
||||||
|
|
||||||
self.log = function() {
|
|
||||||
var console = jasmine.getGlobal().console;
|
|
||||||
if (console && console.log) {
|
|
||||||
if (console.log.apply) {
|
|
||||||
console.log.apply(console, arguments);
|
|
||||||
} else {
|
|
||||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
self.specFilter = function(spec) {
|
|
||||||
if (!focusedSpecName()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return spec.getFullName().indexOf(focusedSpecName()) === 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
return self;
|
|
||||||
|
|
||||||
function focusedSpecName() {
|
|
||||||
var specName;
|
|
||||||
|
|
||||||
(function memoizeFocusedSpec() {
|
|
||||||
if (specName) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var paramMap = [];
|
|
||||||
var params = doc.location.search.substring(1).split('&');
|
|
||||||
|
|
||||||
for (var i = 0; i < params.length; i++) {
|
|
||||||
var p = params[i].split('=');
|
|
||||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
specName = paramMap.spec;
|
|
||||||
})();
|
|
||||||
|
|
||||||
return specName;
|
|
||||||
}
|
|
||||||
|
|
||||||
function createReporterDom(version) {
|
|
||||||
dom.reporter = self.createDom('div', { id: 'HTMLReporter', className: 'jasmine_reporter' },
|
|
||||||
dom.banner = self.createDom('div', { className: 'banner' },
|
|
||||||
self.createDom('span', { className: 'title' }, "Jasmine "),
|
|
||||||
self.createDom('span', { className: 'version' }, version)),
|
|
||||||
|
|
||||||
dom.symbolSummary = self.createDom('ul', {className: 'symbolSummary'}),
|
|
||||||
dom.alert = self.createDom('div', {className: 'alert'}),
|
|
||||||
dom.results = self.createDom('div', {className: 'results'},
|
|
||||||
dom.summary = self.createDom('div', { className: 'summary' }),
|
|
||||||
dom.details = self.createDom('div', { id: 'details' }))
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter);jasmine.HtmlReporter.ReporterView = function(dom) {
|
|
||||||
this.startedAt = new Date();
|
|
||||||
this.runningSpecCount = 0;
|
|
||||||
this.completeSpecCount = 0;
|
|
||||||
this.passedCount = 0;
|
|
||||||
this.failedCount = 0;
|
|
||||||
this.skippedCount = 0;
|
|
||||||
|
|
||||||
this.createResultsMenu = function() {
|
|
||||||
this.resultsMenu = this.createDom('span', {className: 'resultsMenu bar'},
|
|
||||||
this.summaryMenuItem = this.createDom('a', {className: 'summaryMenuItem', href: "#"}, '0 specs'),
|
|
||||||
' | ',
|
|
||||||
this.detailsMenuItem = this.createDom('a', {className: 'detailsMenuItem', href: "#"}, '0 failing'));
|
|
||||||
|
|
||||||
this.summaryMenuItem.onclick = function() {
|
|
||||||
dom.reporter.className = dom.reporter.className.replace(/ showDetails/g, '');
|
|
||||||
};
|
|
||||||
|
|
||||||
this.detailsMenuItem.onclick = function() {
|
|
||||||
showDetails();
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
this.addSpecs = function(specs, specFilter) {
|
|
||||||
this.totalSpecCount = specs.length;
|
|
||||||
|
|
||||||
this.views = {
|
|
||||||
specs: {},
|
|
||||||
suites: {}
|
|
||||||
};
|
|
||||||
|
|
||||||
for (var i = 0; i < specs.length; i++) {
|
|
||||||
var spec = specs[i];
|
|
||||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom, this.views);
|
|
||||||
if (specFilter(spec)) {
|
|
||||||
this.runningSpecCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
this.specComplete = function(spec) {
|
|
||||||
this.completeSpecCount++;
|
|
||||||
|
|
||||||
if (isUndefined(this.views.specs[spec.id])) {
|
|
||||||
this.views.specs[spec.id] = new jasmine.HtmlReporter.SpecView(spec, dom);
|
|
||||||
}
|
|
||||||
|
|
||||||
var specView = this.views.specs[spec.id];
|
|
||||||
|
|
||||||
switch (specView.status()) {
|
|
||||||
case 'passed':
|
|
||||||
this.passedCount++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'failed':
|
|
||||||
this.failedCount++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'skipped':
|
|
||||||
this.skippedCount++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
specView.refresh();
|
|
||||||
this.refresh();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.suiteComplete = function(suite) {
|
|
||||||
var suiteView = this.views.suites[suite.id];
|
|
||||||
if (isUndefined(suiteView)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
suiteView.refresh();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.refresh = function() {
|
|
||||||
|
|
||||||
if (isUndefined(this.resultsMenu)) {
|
|
||||||
this.createResultsMenu();
|
|
||||||
}
|
|
||||||
|
|
||||||
// currently running UI
|
|
||||||
if (isUndefined(this.runningAlert)) {
|
|
||||||
this.runningAlert = this.createDom('a', {href: "?", className: "runningAlert bar"});
|
|
||||||
dom.alert.appendChild(this.runningAlert);
|
|
||||||
}
|
|
||||||
this.runningAlert.innerHTML = "Running " + this.completeSpecCount + " of " + specPluralizedFor(this.totalSpecCount);
|
|
||||||
|
|
||||||
// skipped specs UI
|
|
||||||
if (isUndefined(this.skippedAlert)) {
|
|
||||||
this.skippedAlert = this.createDom('a', {href: "?", className: "skippedAlert bar"});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.skippedAlert.innerHTML = "Skipping " + this.skippedCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
|
||||||
|
|
||||||
if (this.skippedCount === 1 && isDefined(dom.alert)) {
|
|
||||||
dom.alert.appendChild(this.skippedAlert);
|
|
||||||
}
|
|
||||||
|
|
||||||
// passing specs UI
|
|
||||||
if (isUndefined(this.passedAlert)) {
|
|
||||||
this.passedAlert = this.createDom('span', {href: "?", className: "passingAlert bar"});
|
|
||||||
}
|
|
||||||
this.passedAlert.innerHTML = "Passing " + specPluralizedFor(this.passedCount);
|
|
||||||
|
|
||||||
// failing specs UI
|
|
||||||
if (isUndefined(this.failedAlert)) {
|
|
||||||
this.failedAlert = this.createDom('span', {href: "?", className: "failingAlert bar"});
|
|
||||||
}
|
|
||||||
this.failedAlert.innerHTML = "Failing " + specPluralizedFor(this.failedCount);
|
|
||||||
|
|
||||||
if (this.failedCount === 1 && isDefined(dom.alert)) {
|
|
||||||
dom.alert.appendChild(this.failedAlert);
|
|
||||||
dom.alert.appendChild(this.resultsMenu);
|
|
||||||
}
|
|
||||||
|
|
||||||
// summary info
|
|
||||||
this.summaryMenuItem.innerHTML = "" + specPluralizedFor(this.runningSpecCount);
|
|
||||||
this.detailsMenuItem.innerHTML = "" + this.failedCount + " failing";
|
|
||||||
};
|
|
||||||
|
|
||||||
this.complete = function() {
|
|
||||||
dom.alert.removeChild(this.runningAlert);
|
|
||||||
|
|
||||||
this.skippedAlert.innerHTML = "Ran " + this.runningSpecCount + " of " + specPluralizedFor(this.totalSpecCount) + " - run all";
|
|
||||||
|
|
||||||
if (this.failedCount === 0) {
|
|
||||||
dom.alert.appendChild(this.createDom('span', {className: 'passingAlert bar'}, "Passing " + specPluralizedFor(this.passedCount)));
|
|
||||||
} else {
|
|
||||||
showDetails();
|
|
||||||
}
|
|
||||||
|
|
||||||
dom.banner.appendChild(this.createDom('span', {className: 'duration'}, "finished in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s"));
|
|
||||||
};
|
|
||||||
|
|
||||||
return this;
|
|
||||||
|
|
||||||
function showDetails() {
|
|
||||||
if (dom.reporter.className.search(/showDetails/) === -1) {
|
|
||||||
dom.reporter.className += " showDetails";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function isUndefined(obj) {
|
|
||||||
return typeof obj === 'undefined';
|
|
||||||
}
|
|
||||||
|
|
||||||
function isDefined(obj) {
|
|
||||||
return !isUndefined(obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
function specPluralizedFor(count) {
|
|
||||||
var str = count + " spec";
|
|
||||||
if (count > 1) {
|
|
||||||
str += "s"
|
|
||||||
}
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.ReporterView);
|
|
||||||
|
|
||||||
|
|
||||||
jasmine.HtmlReporter.SpecView = function(spec, dom, views) {
|
|
||||||
this.spec = spec;
|
|
||||||
this.dom = dom;
|
|
||||||
this.views = views;
|
|
||||||
|
|
||||||
this.symbol = this.createDom('li', { className: 'pending' });
|
|
||||||
this.dom.symbolSummary.appendChild(this.symbol);
|
|
||||||
|
|
||||||
this.summary = this.createDom('div', { className: 'specSummary' },
|
|
||||||
this.createDom('a', {
|
|
||||||
className: 'description',
|
|
||||||
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
|
|
||||||
title: this.spec.getFullName()
|
|
||||||
}, this.spec.description)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.detail = this.createDom('div', { className: 'specDetail' },
|
|
||||||
this.createDom('a', {
|
|
||||||
className: 'description',
|
|
||||||
href: '?spec=' + encodeURIComponent(this.spec.getFullName()),
|
|
||||||
title: this.spec.getFullName()
|
|
||||||
}, this.spec.getFullName())
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporter.SpecView.prototype.status = function() {
|
|
||||||
return this.getSpecStatus(this.spec);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporter.SpecView.prototype.refresh = function() {
|
|
||||||
this.symbol.className = this.status();
|
|
||||||
|
|
||||||
switch (this.status()) {
|
|
||||||
case 'skipped':
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'passed':
|
|
||||||
this.appendSummaryToSuiteDiv();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'failed':
|
|
||||||
this.appendSummaryToSuiteDiv();
|
|
||||||
this.appendFailureDetail();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporter.SpecView.prototype.appendSummaryToSuiteDiv = function() {
|
|
||||||
this.summary.className += ' ' + this.status();
|
|
||||||
this.appendToSummary(this.spec, this.summary);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporter.SpecView.prototype.appendFailureDetail = function() {
|
|
||||||
this.detail.className += ' ' + this.status();
|
|
||||||
|
|
||||||
var resultItems = this.spec.results().getItems();
|
|
||||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
|
||||||
|
|
||||||
for (var i = 0; i < resultItems.length; i++) {
|
|
||||||
var result = resultItems[i];
|
|
||||||
|
|
||||||
if (result.type == 'log') {
|
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
|
||||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
|
||||||
|
|
||||||
if (result.trace.stack) {
|
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messagesDiv.childNodes.length > 0) {
|
|
||||||
this.detail.appendChild(messagesDiv);
|
|
||||||
this.dom.details.appendChild(this.detail);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SpecView);jasmine.HtmlReporter.SuiteView = function(suite, dom, views) {
|
|
||||||
this.suite = suite;
|
|
||||||
this.dom = dom;
|
|
||||||
this.views = views;
|
|
||||||
|
|
||||||
this.element = this.createDom('div', { className: 'suite' },
|
|
||||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(this.suite.getFullName()) }, this.suite.description)
|
|
||||||
);
|
|
||||||
|
|
||||||
this.appendToSummary(this.suite, this.element);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporter.SuiteView.prototype.status = function() {
|
|
||||||
return this.getSpecStatus(this.suite);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporter.SuiteView.prototype.refresh = function() {
|
|
||||||
this.element.className += " " + this.status();
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.HtmlReporterHelpers.addHelpers(jasmine.HtmlReporter.SuiteView);
|
|
||||||
|
|
||||||
/* @deprecated Use jasmine.HtmlReporter instead
|
|
||||||
*/
|
|
||||||
jasmine.TrivialReporter = function(doc) {
|
|
||||||
this.document = doc || document;
|
|
||||||
this.suiteDivs = {};
|
|
||||||
this.logRunningSpecs = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.createDom = function(type, attrs, childrenVarArgs) {
|
|
||||||
var el = document.createElement(type);
|
|
||||||
|
|
||||||
for (var i = 2; i < arguments.length; i++) {
|
|
||||||
var child = arguments[i];
|
|
||||||
|
|
||||||
if (typeof child === 'string') {
|
|
||||||
el.appendChild(document.createTextNode(child));
|
|
||||||
} else {
|
|
||||||
if (child) { el.appendChild(child); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var attr in attrs) {
|
|
||||||
if (attr == "className") {
|
|
||||||
el[attr] = attrs[attr];
|
|
||||||
} else {
|
|
||||||
el.setAttribute(attr, attrs[attr]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return el;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportRunnerStarting = function(runner) {
|
|
||||||
var showPassed, showSkipped;
|
|
||||||
|
|
||||||
this.outerDiv = this.createDom('div', { id: 'TrivialReporter', className: 'jasmine_reporter' },
|
|
||||||
this.createDom('div', { className: 'banner' },
|
|
||||||
this.createDom('div', { className: 'logo' },
|
|
||||||
this.createDom('span', { className: 'title' }, "Jasmine"),
|
|
||||||
this.createDom('span', { className: 'version' }, runner.env.versionString())),
|
|
||||||
this.createDom('div', { className: 'options' },
|
|
||||||
"Show ",
|
|
||||||
showPassed = this.createDom('input', { id: "__jasmine_TrivialReporter_showPassed__", type: 'checkbox' }),
|
|
||||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showPassed__" }, " passed "),
|
|
||||||
showSkipped = this.createDom('input', { id: "__jasmine_TrivialReporter_showSkipped__", type: 'checkbox' }),
|
|
||||||
this.createDom('label', { "for": "__jasmine_TrivialReporter_showSkipped__" }, " skipped")
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
this.runnerDiv = this.createDom('div', { className: 'runner running' },
|
|
||||||
this.createDom('a', { className: 'run_spec', href: '?' }, "run all"),
|
|
||||||
this.runnerMessageSpan = this.createDom('span', {}, "Running..."),
|
|
||||||
this.finishedAtSpan = this.createDom('span', { className: 'finished-at' }, ""))
|
|
||||||
);
|
|
||||||
|
|
||||||
this.document.body.appendChild(this.outerDiv);
|
|
||||||
|
|
||||||
var suites = runner.suites();
|
|
||||||
for (var i = 0; i < suites.length; i++) {
|
|
||||||
var suite = suites[i];
|
|
||||||
var suiteDiv = this.createDom('div', { className: 'suite' },
|
|
||||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, "run"),
|
|
||||||
this.createDom('a', { className: 'description', href: '?spec=' + encodeURIComponent(suite.getFullName()) }, suite.description));
|
|
||||||
this.suiteDivs[suite.id] = suiteDiv;
|
|
||||||
var parentDiv = this.outerDiv;
|
|
||||||
if (suite.parentSuite) {
|
|
||||||
parentDiv = this.suiteDivs[suite.parentSuite.id];
|
|
||||||
}
|
|
||||||
parentDiv.appendChild(suiteDiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.startedAt = new Date();
|
|
||||||
|
|
||||||
var self = this;
|
|
||||||
showPassed.onclick = function(evt) {
|
|
||||||
if (showPassed.checked) {
|
|
||||||
self.outerDiv.className += ' show-passed';
|
|
||||||
} else {
|
|
||||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-passed/, '');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
showSkipped.onclick = function(evt) {
|
|
||||||
if (showSkipped.checked) {
|
|
||||||
self.outerDiv.className += ' show-skipped';
|
|
||||||
} else {
|
|
||||||
self.outerDiv.className = self.outerDiv.className.replace(/ show-skipped/, '');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportRunnerResults = function(runner) {
|
|
||||||
var results = runner.results();
|
|
||||||
var className = (results.failedCount > 0) ? "runner failed" : "runner passed";
|
|
||||||
this.runnerDiv.setAttribute("class", className);
|
|
||||||
//do it twice for IE
|
|
||||||
this.runnerDiv.setAttribute("className", className);
|
|
||||||
var specs = runner.specs();
|
|
||||||
var specCount = 0;
|
|
||||||
for (var i = 0; i < specs.length; i++) {
|
|
||||||
if (this.specFilter(specs[i])) {
|
|
||||||
specCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var message = "" + specCount + " spec" + (specCount == 1 ? "" : "s" ) + ", " + results.failedCount + " failure" + ((results.failedCount == 1) ? "" : "s");
|
|
||||||
message += " in " + ((new Date().getTime() - this.startedAt.getTime()) / 1000) + "s";
|
|
||||||
this.runnerMessageSpan.replaceChild(this.createDom('a', { className: 'description', href: '?'}, message), this.runnerMessageSpan.firstChild);
|
|
||||||
|
|
||||||
this.finishedAtSpan.appendChild(document.createTextNode("Finished at " + new Date().toString()));
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportSuiteResults = function(suite) {
|
|
||||||
var results = suite.results();
|
|
||||||
var status = results.passed() ? 'passed' : 'failed';
|
|
||||||
if (results.totalCount === 0) { // todo: change this to check results.skipped
|
|
||||||
status = 'skipped';
|
|
||||||
}
|
|
||||||
this.suiteDivs[suite.id].className += " " + status;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportSpecStarting = function(spec) {
|
|
||||||
if (this.logRunningSpecs) {
|
|
||||||
this.log('>> Jasmine Running ' + spec.suite.description + ' ' + spec.description + '...');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.reportSpecResults = function(spec) {
|
|
||||||
var results = spec.results();
|
|
||||||
var status = results.passed() ? 'passed' : 'failed';
|
|
||||||
if (results.skipped) {
|
|
||||||
status = 'skipped';
|
|
||||||
}
|
|
||||||
var specDiv = this.createDom('div', { className: 'spec ' + status },
|
|
||||||
this.createDom('a', { className: 'run_spec', href: '?spec=' + encodeURIComponent(spec.getFullName()) }, "run"),
|
|
||||||
this.createDom('a', {
|
|
||||||
className: 'description',
|
|
||||||
href: '?spec=' + encodeURIComponent(spec.getFullName()),
|
|
||||||
title: spec.getFullName()
|
|
||||||
}, spec.description));
|
|
||||||
|
|
||||||
|
|
||||||
var resultItems = results.getItems();
|
|
||||||
var messagesDiv = this.createDom('div', { className: 'messages' });
|
|
||||||
for (var i = 0; i < resultItems.length; i++) {
|
|
||||||
var result = resultItems[i];
|
|
||||||
|
|
||||||
if (result.type == 'log') {
|
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage log'}, result.toString()));
|
|
||||||
} else if (result.type == 'expect' && result.passed && !result.passed()) {
|
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'resultMessage fail'}, result.message));
|
|
||||||
|
|
||||||
if (result.trace.stack) {
|
|
||||||
messagesDiv.appendChild(this.createDom('div', {className: 'stackTrace'}, result.trace.stack));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (messagesDiv.childNodes.length > 0) {
|
|
||||||
specDiv.appendChild(messagesDiv);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.suiteDivs[spec.suite.id].appendChild(specDiv);
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.log = function() {
|
|
||||||
var console = jasmine.getGlobal().console;
|
|
||||||
if (console && console.log) {
|
|
||||||
if (console.log.apply) {
|
|
||||||
console.log.apply(console, arguments);
|
|
||||||
} else {
|
|
||||||
console.log(arguments); // ie fix: console.log.apply doesn't exist on ie
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.getLocation = function() {
|
|
||||||
return this.document.location;
|
|
||||||
};
|
|
||||||
|
|
||||||
jasmine.TrivialReporter.prototype.specFilter = function(spec) {
|
|
||||||
var paramMap = {};
|
|
||||||
var params = this.getLocation().search.substring(1).split('&');
|
|
||||||
for (var i = 0; i < params.length; i++) {
|
|
||||||
var p = params[i].split('=');
|
|
||||||
paramMap[decodeURIComponent(p[0])] = decodeURIComponent(p[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!paramMap.spec) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return spec.getFullName().indexOf(paramMap.spec) === 0;
|
|
||||||
};
|
|
@ -1,81 +0,0 @@
|
|||||||
body { background-color: #eeeeee; padding: 0; margin: 5px; overflow-y: scroll; }
|
|
||||||
|
|
||||||
#HTMLReporter { font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333333; }
|
|
||||||
#HTMLReporter a { text-decoration: none; }
|
|
||||||
#HTMLReporter a:hover { text-decoration: underline; }
|
|
||||||
#HTMLReporter p, #HTMLReporter h1, #HTMLReporter h2, #HTMLReporter h3, #HTMLReporter h4, #HTMLReporter h5, #HTMLReporter h6 { margin: 0; line-height: 14px; }
|
|
||||||
#HTMLReporter .banner, #HTMLReporter .symbolSummary, #HTMLReporter .summary, #HTMLReporter .resultMessage, #HTMLReporter .specDetail .description, #HTMLReporter .alert .bar, #HTMLReporter .stackTrace { padding-left: 9px; padding-right: 9px; }
|
|
||||||
#HTMLReporter #jasmine_content { position: fixed; right: 100%; }
|
|
||||||
#HTMLReporter .version { color: #aaaaaa; }
|
|
||||||
#HTMLReporter .banner { margin-top: 14px; }
|
|
||||||
#HTMLReporter .duration { color: #aaaaaa; float: right; }
|
|
||||||
#HTMLReporter .symbolSummary { overflow: hidden; *zoom: 1; margin: 14px 0; }
|
|
||||||
#HTMLReporter .symbolSummary li { display: block; float: left; height: 7px; width: 14px; margin-bottom: 7px; font-size: 16px; }
|
|
||||||
#HTMLReporter .symbolSummary li.passed { font-size: 14px; }
|
|
||||||
#HTMLReporter .symbolSummary li.passed:before { color: #5e7d00; content: "\02022"; }
|
|
||||||
#HTMLReporter .symbolSummary li.failed { line-height: 9px; }
|
|
||||||
#HTMLReporter .symbolSummary li.failed:before { color: #b03911; content: "x"; font-weight: bold; margin-left: -1px; }
|
|
||||||
#HTMLReporter .symbolSummary li.skipped { font-size: 14px; }
|
|
||||||
#HTMLReporter .symbolSummary li.skipped:before { color: #bababa; content: "\02022"; }
|
|
||||||
#HTMLReporter .symbolSummary li.pending { line-height: 11px; }
|
|
||||||
#HTMLReporter .symbolSummary li.pending:before { color: #aaaaaa; content: "-"; }
|
|
||||||
#HTMLReporter .bar { line-height: 28px; font-size: 14px; display: block; color: #eee; }
|
|
||||||
#HTMLReporter .runningAlert { background-color: #666666; }
|
|
||||||
#HTMLReporter .skippedAlert { background-color: #aaaaaa; }
|
|
||||||
#HTMLReporter .skippedAlert:first-child { background-color: #333333; }
|
|
||||||
#HTMLReporter .skippedAlert:hover { text-decoration: none; color: white; text-decoration: underline; }
|
|
||||||
#HTMLReporter .passingAlert { background-color: #a6b779; }
|
|
||||||
#HTMLReporter .passingAlert:first-child { background-color: #5e7d00; }
|
|
||||||
#HTMLReporter .failingAlert { background-color: #cf867e; }
|
|
||||||
#HTMLReporter .failingAlert:first-child { background-color: #b03911; }
|
|
||||||
#HTMLReporter .results { margin-top: 14px; }
|
|
||||||
#HTMLReporter #details { display: none; }
|
|
||||||
#HTMLReporter .resultsMenu, #HTMLReporter .resultsMenu a { background-color: #fff; color: #333333; }
|
|
||||||
#HTMLReporter.showDetails .summaryMenuItem { font-weight: normal; text-decoration: inherit; }
|
|
||||||
#HTMLReporter.showDetails .summaryMenuItem:hover { text-decoration: underline; }
|
|
||||||
#HTMLReporter.showDetails .detailsMenuItem { font-weight: bold; text-decoration: underline; }
|
|
||||||
#HTMLReporter.showDetails .summary { display: none; }
|
|
||||||
#HTMLReporter.showDetails #details { display: block; }
|
|
||||||
#HTMLReporter .summaryMenuItem { font-weight: bold; text-decoration: underline; }
|
|
||||||
#HTMLReporter .summary { margin-top: 14px; }
|
|
||||||
#HTMLReporter .summary .suite .suite, #HTMLReporter .summary .specSummary { margin-left: 14px; }
|
|
||||||
#HTMLReporter .summary .specSummary.passed a { color: #5e7d00; }
|
|
||||||
#HTMLReporter .summary .specSummary.failed a { color: #b03911; }
|
|
||||||
#HTMLReporter .description + .suite { margin-top: 0; }
|
|
||||||
#HTMLReporter .suite { margin-top: 14px; }
|
|
||||||
#HTMLReporter .suite a { color: #333333; }
|
|
||||||
#HTMLReporter #details .specDetail { margin-bottom: 28px; }
|
|
||||||
#HTMLReporter #details .specDetail .description { display: block; color: white; background-color: #b03911; }
|
|
||||||
#HTMLReporter .resultMessage { padding-top: 14px; color: #333333; }
|
|
||||||
#HTMLReporter .resultMessage span.result { display: block; }
|
|
||||||
#HTMLReporter .stackTrace { margin: 5px 0 0 0; max-height: 224px; overflow: auto; line-height: 18px; color: #666666; border: 1px solid #ddd; background: white; white-space: pre; }
|
|
||||||
|
|
||||||
#TrivialReporter { padding: 8px 13px; position: absolute; top: 0; bottom: 0; left: 0; right: 0; overflow-y: scroll; background-color: white; font-family: "Helvetica Neue Light", "Lucida Grande", "Calibri", "Arial", sans-serif; /*.resultMessage {*/ /*white-space: pre;*/ /*}*/ }
|
|
||||||
#TrivialReporter a:visited, #TrivialReporter a { color: #303; }
|
|
||||||
#TrivialReporter a:hover, #TrivialReporter a:active { color: blue; }
|
|
||||||
#TrivialReporter .run_spec { float: right; padding-right: 5px; font-size: .8em; text-decoration: none; }
|
|
||||||
#TrivialReporter .banner { color: #303; background-color: #fef; padding: 5px; }
|
|
||||||
#TrivialReporter .logo { float: left; font-size: 1.1em; padding-left: 5px; }
|
|
||||||
#TrivialReporter .logo .version { font-size: .6em; padding-left: 1em; }
|
|
||||||
#TrivialReporter .runner.running { background-color: yellow; }
|
|
||||||
#TrivialReporter .options { text-align: right; font-size: .8em; }
|
|
||||||
#TrivialReporter .suite { border: 1px outset gray; margin: 5px 0; padding-left: 1em; }
|
|
||||||
#TrivialReporter .suite .suite { margin: 5px; }
|
|
||||||
#TrivialReporter .suite.passed { background-color: #dfd; }
|
|
||||||
#TrivialReporter .suite.failed { background-color: #fdd; }
|
|
||||||
#TrivialReporter .spec { margin: 5px; padding-left: 1em; clear: both; }
|
|
||||||
#TrivialReporter .spec.failed, #TrivialReporter .spec.passed, #TrivialReporter .spec.skipped { padding-bottom: 5px; border: 1px solid gray; }
|
|
||||||
#TrivialReporter .spec.failed { background-color: #fbb; border-color: red; }
|
|
||||||
#TrivialReporter .spec.passed { background-color: #bfb; border-color: green; }
|
|
||||||
#TrivialReporter .spec.skipped { background-color: #bbb; }
|
|
||||||
#TrivialReporter .messages { border-left: 1px dashed gray; padding-left: 1em; padding-right: 1em; }
|
|
||||||
#TrivialReporter .passed { background-color: #cfc; display: none; }
|
|
||||||
#TrivialReporter .failed { background-color: #fbb; }
|
|
||||||
#TrivialReporter .skipped { color: #777; background-color: #eee; display: none; }
|
|
||||||
#TrivialReporter .resultMessage span.result { display: block; line-height: 2em; color: black; }
|
|
||||||
#TrivialReporter .resultMessage .mismatch { color: black; }
|
|
||||||
#TrivialReporter .stackTrace { white-space: pre; font-size: .8em; margin-left: 10px; max-height: 5em; overflow: auto; border: 1px inset red; padding: 1em; background: #eef; }
|
|
||||||
#TrivialReporter .finished-at { padding-left: 1em; font-size: .6em; }
|
|
||||||
#TrivialReporter.show-passed .passed, #TrivialReporter.show-skipped .skipped { display: block; }
|
|
||||||
#TrivialReporter #jasmine_content { position: fixed; right: 100%; }
|
|
||||||
#TrivialReporter .runner { border: 1px solid gray; display: block; margin: 5px 0; padding: 2px 0 2px 10px; }
|
|
2529
Libraries/burry.js/tests/vendor/jasmine/jasmine.js
vendored
Before Width: | Height: | Size: 905 B |
9404
Libraries/burry.js/tests/vendor/jquery.js
vendored
Before Width: | Height: | Size: 260 B |
Before Width: | Height: | Size: 251 B |
Before Width: | Height: | Size: 178 B |
Before Width: | Height: | Size: 104 B |
Before Width: | Height: | Size: 125 B |
Before Width: | Height: | Size: 105 B |
Before Width: | Height: | Size: 3.7 KiB |
Before Width: | Height: | Size: 90 B |
Before Width: | Height: | Size: 129 B |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.3 KiB |
@ -1,461 +0,0 @@
|
|||||||
/*! jQuery UI - v1.9.1 - 2012-11-14
|
|
||||||
* http://jqueryui.com
|
|
||||||
* Includes: jquery.ui.core.css, jquery.ui.resizable.css, jquery.ui.selectable.css, jquery.ui.accordion.css, jquery.ui.autocomplete.css, jquery.ui.button.css, jquery.ui.datepicker.css, jquery.ui.dialog.css, jquery.ui.menu.css, jquery.ui.progressbar.css, jquery.ui.slider.css, jquery.ui.spinner.css, jquery.ui.tabs.css, jquery.ui.tooltip.css
|
|
||||||
* To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Trebuchet%20MS%2CTahoma%2CVerdana%2CArial%2Csans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=4px&bgColorHeader=f6a828&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=35&borderColorHeader=e78f08&fcHeader=ffffff&iconColorHeader=ffffff&bgColorContent=eeeeee&bgTextureContent=03_highlight_soft.png&bgImgOpacityContent=100&borderColorContent=dddddd&fcContent=333333&iconColorContent=222222&bgColorDefault=f6f6f6&bgTextureDefault=02_glass.png&bgImgOpacityDefault=100&borderColorDefault=cccccc&fcDefault=1c94c4&iconColorDefault=ef8c08&bgColorHover=fdf5ce&bgTextureHover=02_glass.png&bgImgOpacityHover=100&borderColorHover=fbcb09&fcHover=c77405&iconColorHover=ef8c08&bgColorActive=ffffff&bgTextureActive=02_glass.png&bgImgOpacityActive=65&borderColorActive=fbd850&fcActive=eb8f00&iconColorActive=ef8c08&bgColorHighlight=ffe45c&bgTextureHighlight=03_highlight_soft.png&bgImgOpacityHighlight=75&borderColorHighlight=fed22f&fcHighlight=363636&iconColorHighlight=228ef1&bgColorError=b81900&bgTextureError=08_diagonals_thick.png&bgImgOpacityError=18&borderColorError=cd0a0a&fcError=ffffff&iconColorError=ffd27a&bgColorOverlay=666666&bgTextureOverlay=08_diagonals_thick.png&bgImgOpacityOverlay=20&opacityOverlay=50&bgColorShadow=000000&bgTextureShadow=01_flat.png&bgImgOpacityShadow=10&opacityShadow=20&thicknessShadow=5px&offsetTopShadow=-5px&offsetLeftShadow=-5px&cornerRadiusShadow=5px
|
|
||||||
* Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */
|
|
||||||
|
|
||||||
/* Layout helpers
|
|
||||||
----------------------------------*/
|
|
||||||
.ui-helper-hidden { display: none; }
|
|
||||||
.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
|
|
||||||
.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
|
|
||||||
.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; }
|
|
||||||
.ui-helper-clearfix:after { clear: both; }
|
|
||||||
.ui-helper-clearfix { zoom: 1; }
|
|
||||||
.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
|
|
||||||
|
|
||||||
|
|
||||||
/* Interaction Cues
|
|
||||||
----------------------------------*/
|
|
||||||
.ui-state-disabled { cursor: default !important; }
|
|
||||||
|
|
||||||
|
|
||||||
/* Icons
|
|
||||||
----------------------------------*/
|
|
||||||
|
|
||||||
/* states and images */
|
|
||||||
.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; }
|
|
||||||
|
|
||||||
|
|
||||||
/* Misc visuals
|
|
||||||
----------------------------------*/
|
|
||||||
|
|
||||||
/* Overlays */
|
|
||||||
.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
|
|
||||||
.ui-resizable { position: relative;}
|
|
||||||
.ui-resizable-handle { position: absolute;font-size: 0.1px; display: block; }
|
|
||||||
.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; }
|
|
||||||
.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; }
|
|
||||||
.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; }
|
|
||||||
.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; }
|
|
||||||
.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; }
|
|
||||||
.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; }
|
|
||||||
.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; }
|
|
||||||
.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; }
|
|
||||||
.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; }
|
|
||||||
.ui-accordion .ui-accordion-header { display: block; cursor: pointer; position: relative; margin-top: 2px; padding: .5em .5em .5em .7em; zoom: 1; }
|
|
||||||
.ui-accordion .ui-accordion-icons { padding-left: 2.2em; }
|
|
||||||
.ui-accordion .ui-accordion-noicons { padding-left: .7em; }
|
|
||||||
.ui-accordion .ui-accordion-icons .ui-accordion-icons { padding-left: 2.2em; }
|
|
||||||
.ui-accordion .ui-accordion-header .ui-accordion-header-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; }
|
|
||||||
.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; overflow: auto; zoom: 1; }
|
|
||||||
.ui-autocomplete {
|
|
||||||
position: absolute;
|
|
||||||
top: 0; /* #8656 */
|
|
||||||
cursor: default;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* workarounds */
|
|
||||||
* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
|
|
||||||
.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
|
|
||||||
.ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; }
|
|
||||||
.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
|
|
||||||
button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
|
|
||||||
.ui-button-icons-only { width: 3.4em; }
|
|
||||||
button.ui-button-icons-only { width: 3.7em; }
|
|
||||||
|
|
||||||
/*button text element */
|
|
||||||
.ui-button .ui-button-text { display: block; line-height: 1.4; }
|
|
||||||
.ui-button-text-only .ui-button-text { padding: .4em 1em; }
|
|
||||||
.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; }
|
|
||||||
.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; }
|
|
||||||
.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; }
|
|
||||||
.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; }
|
|
||||||
/* no icon support for input elements, provide padding by default */
|
|
||||||
input.ui-button { padding: .4em 1em; }
|
|
||||||
|
|
||||||
/*button icon element(s) */
|
|
||||||
.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; }
|
|
||||||
.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; }
|
|
||||||
.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; }
|
|
||||||
.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
|
|
||||||
.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; }
|
|
||||||
|
|
||||||
/*button sets*/
|
|
||||||
.ui-buttonset { margin-right: 7px; }
|
|
||||||
.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; }
|
|
||||||
|
|
||||||
/* workarounds */
|
|
||||||
button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
|
|
||||||
.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; }
|
|
||||||
.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; }
|
|
||||||
.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; }
|
|
||||||
.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; }
|
|
||||||
.ui-datepicker .ui-datepicker-prev { left:2px; }
|
|
||||||
.ui-datepicker .ui-datepicker-next { right:2px; }
|
|
||||||
.ui-datepicker .ui-datepicker-prev-hover { left:1px; }
|
|
||||||
.ui-datepicker .ui-datepicker-next-hover { right:1px; }
|
|
||||||
.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; }
|
|
||||||
.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
|
|
||||||
.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
|
|
||||||
.ui-datepicker select.ui-datepicker-month-year {width: 100%;}
|
|
||||||
.ui-datepicker select.ui-datepicker-month,
|
|
||||||
.ui-datepicker select.ui-datepicker-year { width: 49%;}
|
|
||||||
.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
|
|
||||||
.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
|
|
||||||
.ui-datepicker td { border: 0; padding: 1px; }
|
|
||||||
.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; }
|
|
||||||
.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; }
|
|
||||||
.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; }
|
|
||||||
.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; }
|
|
||||||
|
|
||||||
/* with multiple calendars */
|
|
||||||
.ui-datepicker.ui-datepicker-multi { width:auto; }
|
|
||||||
.ui-datepicker-multi .ui-datepicker-group { float:left; }
|
|
||||||
.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; }
|
|
||||||
.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; }
|
|
||||||
.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; }
|
|
||||||
.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; }
|
|
||||||
.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; }
|
|
||||||
.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; }
|
|
||||||
.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; }
|
|
||||||
.ui-datepicker-row-break { clear:both; width:100%; font-size:0em; }
|
|
||||||
|
|
||||||
/* RTL support */
|
|
||||||
.ui-datepicker-rtl { direction: rtl; }
|
|
||||||
.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; }
|
|
||||||
.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; }
|
|
||||||
.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; }
|
|
||||||
.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; }
|
|
||||||
.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; }
|
|
||||||
.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; }
|
|
||||||
.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; }
|
|
||||||
.ui-datepicker-rtl .ui-datepicker-group { float:right; }
|
|
||||||
.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
|
||||||
.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; }
|
|
||||||
|
|
||||||
/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */
|
|
||||||
.ui-datepicker-cover {
|
|
||||||
position: absolute; /*must have*/
|
|
||||||
z-index: -1; /*must have*/
|
|
||||||
filter: mask(); /*must have*/
|
|
||||||
top: -4px; /*must have*/
|
|
||||||
left: -4px; /*must have*/
|
|
||||||
width: 200px; /*must have*/
|
|
||||||
height: 200px; /*must have*/
|
|
||||||
}.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
|
|
||||||
.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
|
|
||||||
.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
|
|
||||||
.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
|
|
||||||
.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
|
|
||||||
.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
|
|
||||||
.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
|
|
||||||
.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
|
|
||||||
.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; }
|
|
||||||
.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; }
|
|
||||||
.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; }
|
|
||||||
.ui-draggable .ui-dialog-titlebar { cursor: move; }
|
|
||||||
.ui-menu { list-style:none; padding: 2px; margin: 0; display:block; outline: none; }
|
|
||||||
.ui-menu .ui-menu { margin-top: -3px; position: absolute; }
|
|
||||||
.ui-menu .ui-menu-item { margin: 0; padding: 0; zoom: 1; width: 100%; }
|
|
||||||
.ui-menu .ui-menu-divider { margin: 5px -2px 5px -2px; height: 0; font-size: 0; line-height: 0; border-width: 1px 0 0 0; }
|
|
||||||
.ui-menu .ui-menu-item a { text-decoration: none; display: block; padding: 2px .4em; line-height: 1.5; zoom: 1; font-weight: normal; }
|
|
||||||
.ui-menu .ui-menu-item a.ui-state-focus,
|
|
||||||
.ui-menu .ui-menu-item a.ui-state-active { font-weight: normal; margin: -1px; }
|
|
||||||
|
|
||||||
.ui-menu .ui-state-disabled { font-weight: normal; margin: .4em 0 .2em; line-height: 1.5; }
|
|
||||||
.ui-menu .ui-state-disabled a { cursor: default; }
|
|
||||||
|
|
||||||
/* icon support */
|
|
||||||
.ui-menu-icons { position: relative; }
|
|
||||||
.ui-menu-icons .ui-menu-item a { position: relative; padding-left: 2em; }
|
|
||||||
|
|
||||||
/* left-aligned */
|
|
||||||
.ui-menu .ui-icon { position: absolute; top: .2em; left: .2em; }
|
|
||||||
|
|
||||||
/* right-aligned */
|
|
||||||
.ui-menu .ui-menu-icon { position: static; float: right; }
|
|
||||||
.ui-progressbar { height:2em; text-align: left; overflow: hidden; }
|
|
||||||
.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; }.ui-slider { position: relative; text-align: left; }
|
|
||||||
.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; }
|
|
||||||
.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; }
|
|
||||||
|
|
||||||
.ui-slider-horizontal { height: .8em; }
|
|
||||||
.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; }
|
|
||||||
.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; }
|
|
||||||
.ui-slider-horizontal .ui-slider-range-min { left: 0; }
|
|
||||||
.ui-slider-horizontal .ui-slider-range-max { right: 0; }
|
|
||||||
|
|
||||||
.ui-slider-vertical { width: .8em; height: 100px; }
|
|
||||||
.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; }
|
|
||||||
.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; }
|
|
||||||
.ui-slider-vertical .ui-slider-range-min { bottom: 0; }
|
|
||||||
.ui-slider-vertical .ui-slider-range-max { top: 0; }.ui-spinner { position:relative; display: inline-block; overflow: hidden; padding: 0; vertical-align: middle; }
|
|
||||||
.ui-spinner-input { border: none; background: none; padding: 0; margin: .2em 0; vertical-align: middle; margin-left: .4em; margin-right: 22px; }
|
|
||||||
.ui-spinner-button { width: 16px; height: 50%; font-size: .5em; padding: 0; margin: 0; text-align: center; position: absolute; cursor: default; display: block; overflow: hidden; right: 0; }
|
|
||||||
.ui-spinner a.ui-spinner-button { border-top: none; border-bottom: none; border-right: none; } /* more specificity required here to overide default borders */
|
|
||||||
.ui-spinner .ui-icon { position: absolute; margin-top: -8px; top: 50%; left: 0; } /* vertical centre icon */
|
|
||||||
.ui-spinner-up { top: 0; }
|
|
||||||
.ui-spinner-down { bottom: 0; }
|
|
||||||
|
|
||||||
/* TR overrides */
|
|
||||||
.ui-spinner .ui-icon-triangle-1-s {
|
|
||||||
/* need to fix icons sprite */
|
|
||||||
background-position:-65px -16px;
|
|
||||||
}
|
|
||||||
.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */
|
|
||||||
.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; }
|
|
||||||
.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 0; margin: 1px .2em 0 0; border-bottom: 0; padding: 0; white-space: nowrap; }
|
|
||||||
.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; }
|
|
||||||
.ui-tabs .ui-tabs-nav li.ui-tabs-active { margin-bottom: -1px; padding-bottom: 1px; }
|
|
||||||
.ui-tabs .ui-tabs-nav li.ui-tabs-active a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-tabs-loading a { cursor: text; }
|
|
||||||
.ui-tabs .ui-tabs-nav li a, .ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */
|
|
||||||
.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; }
|
|
||||||
.ui-tooltip {
|
|
||||||
padding: 8px;
|
|
||||||
position: absolute;
|
|
||||||
z-index: 9999;
|
|
||||||
max-width: 300px;
|
|
||||||
-webkit-box-shadow: 0 0 5px #aaa;
|
|
||||||
box-shadow: 0 0 5px #aaa;
|
|
||||||
}
|
|
||||||
/* Fades and background-images don't work well together in IE6, drop the image */
|
|
||||||
* html .ui-tooltip {
|
|
||||||
background-image: none;
|
|
||||||
}
|
|
||||||
body .ui-tooltip { border-width: 2px; }
|
|
||||||
|
|
||||||
/* Component containers
|
|
||||||
----------------------------------*/
|
|
||||||
.ui-widget { font-family: Trebuchet MS,Tahoma,Verdana,Arial,sans-serif; font-size: 1.1em; }
|
|
||||||
.ui-widget .ui-widget { font-size: 1em; }
|
|
||||||
.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Trebuchet MS,Tahoma,Verdana,Arial,sans-serif; font-size: 1em; }
|
|
||||||
.ui-widget-content { border: 1px solid #dddddd; background: #eeeeee url(images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x; color: #333333; }
|
|
||||||
.ui-widget-content a { color: #333333; }
|
|
||||||
.ui-widget-header { border: 1px solid #e78f08; background: #f6a828 url(images/ui-bg_gloss-wave_35_f6a828_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; }
|
|
||||||
.ui-widget-header a { color: #ffffff; }
|
|
||||||
|
|
||||||
/* Interaction states
|
|
||||||
----------------------------------*/
|
|
||||||
.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #cccccc; background: #f6f6f6 url(images/ui-bg_glass_100_f6f6f6_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1c94c4; }
|
|
||||||
.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #1c94c4; text-decoration: none; }
|
|
||||||
.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #fbcb09; background: #fdf5ce url(images/ui-bg_glass_100_fdf5ce_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #c77405; }
|
|
||||||
.ui-state-hover a, .ui-state-hover a:hover, .ui-state-hover a:link, .ui-state-hover a:visited { color: #c77405; text-decoration: none; }
|
|
||||||
.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #fbd850; background: #ffffff url(images/ui-bg_glass_65_ffffff_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #eb8f00; }
|
|
||||||
.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #eb8f00; text-decoration: none; }
|
|
||||||
|
|
||||||
/* Interaction Cues
|
|
||||||
----------------------------------*/
|
|
||||||
.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fed22f; background: #ffe45c url(images/ui-bg_highlight-soft_75_ffe45c_1x100.png) 50% top repeat-x; color: #363636; }
|
|
||||||
.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; }
|
|
||||||
.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #b81900 url(images/ui-bg_diagonals-thick_18_b81900_40x40.png) 50% 50% repeat; color: #ffffff; }
|
|
||||||
.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #ffffff; }
|
|
||||||
.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #ffffff; }
|
|
||||||
.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; }
|
|
||||||
.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; }
|
|
||||||
.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; }
|
|
||||||
.ui-state-disabled .ui-icon { filter:Alpha(Opacity=35); } /* For IE8 - See #6059 */
|
|
||||||
|
|
||||||
/* Icons
|
|
||||||
----------------------------------*/
|
|
||||||
|
|
||||||
/* states and images */
|
|
||||||
.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_222222_256x240.png); }
|
|
||||||
.ui-widget-content .ui-icon {background-image: url(images/ui-icons_222222_256x240.png); }
|
|
||||||
.ui-widget-header .ui-icon {background-image: url(images/ui-icons_ffffff_256x240.png); }
|
|
||||||
.ui-state-default .ui-icon { background-image: url(images/ui-icons_ef8c08_256x240.png); }
|
|
||||||
.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); }
|
|
||||||
.ui-state-active .ui-icon {background-image: url(images/ui-icons_ef8c08_256x240.png); }
|
|
||||||
.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_228ef1_256x240.png); }
|
|
||||||
.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_ffd27a_256x240.png); }
|
|
||||||
|
|
||||||
/* positioning */
|
|
||||||
.ui-icon-carat-1-n { background-position: 0 0; }
|
|
||||||
.ui-icon-carat-1-ne { background-position: -16px 0; }
|
|
||||||
.ui-icon-carat-1-e { background-position: -32px 0; }
|
|
||||||
.ui-icon-carat-1-se { background-position: -48px 0; }
|
|
||||||
.ui-icon-carat-1-s { background-position: -64px 0; }
|
|
||||||
.ui-icon-carat-1-sw { background-position: -80px 0; }
|
|
||||||
.ui-icon-carat-1-w { background-position: -96px 0; }
|
|
||||||
.ui-icon-carat-1-nw { background-position: -112px 0; }
|
|
||||||
.ui-icon-carat-2-n-s { background-position: -128px 0; }
|
|
||||||
.ui-icon-carat-2-e-w { background-position: -144px 0; }
|
|
||||||
.ui-icon-triangle-1-n { background-position: 0 -16px; }
|
|
||||||
.ui-icon-triangle-1-ne { background-position: -16px -16px; }
|
|
||||||
.ui-icon-triangle-1-e { background-position: -32px -16px; }
|
|
||||||
.ui-icon-triangle-1-se { background-position: -48px -16px; }
|
|
||||||
.ui-icon-triangle-1-s { background-position: -64px -16px; }
|
|
||||||
.ui-icon-triangle-1-sw { background-position: -80px -16px; }
|
|
||||||
.ui-icon-triangle-1-w { background-position: -96px -16px; }
|
|
||||||
.ui-icon-triangle-1-nw { background-position: -112px -16px; }
|
|
||||||
.ui-icon-triangle-2-n-s { background-position: -128px -16px; }
|
|
||||||
.ui-icon-triangle-2-e-w { background-position: -144px -16px; }
|
|
||||||
.ui-icon-arrow-1-n { background-position: 0 -32px; }
|
|
||||||
.ui-icon-arrow-1-ne { background-position: -16px -32px; }
|
|
||||||
.ui-icon-arrow-1-e { background-position: -32px -32px; }
|
|
||||||
.ui-icon-arrow-1-se { background-position: -48px -32px; }
|
|
||||||
.ui-icon-arrow-1-s { background-position: -64px -32px; }
|
|
||||||
.ui-icon-arrow-1-sw { background-position: -80px -32px; }
|
|
||||||
.ui-icon-arrow-1-w { background-position: -96px -32px; }
|
|
||||||
.ui-icon-arrow-1-nw { background-position: -112px -32px; }
|
|
||||||
.ui-icon-arrow-2-n-s { background-position: -128px -32px; }
|
|
||||||
.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; }
|
|
||||||
.ui-icon-arrow-2-e-w { background-position: -160px -32px; }
|
|
||||||
.ui-icon-arrow-2-se-nw { background-position: -176px -32px; }
|
|
||||||
.ui-icon-arrowstop-1-n { background-position: -192px -32px; }
|
|
||||||
.ui-icon-arrowstop-1-e { background-position: -208px -32px; }
|
|
||||||
.ui-icon-arrowstop-1-s { background-position: -224px -32px; }
|
|
||||||
.ui-icon-arrowstop-1-w { background-position: -240px -32px; }
|
|
||||||
.ui-icon-arrowthick-1-n { background-position: 0 -48px; }
|
|
||||||
.ui-icon-arrowthick-1-ne { background-position: -16px -48px; }
|
|
||||||
.ui-icon-arrowthick-1-e { background-position: -32px -48px; }
|
|
||||||
.ui-icon-arrowthick-1-se { background-position: -48px -48px; }
|
|
||||||
.ui-icon-arrowthick-1-s { background-position: -64px -48px; }
|
|
||||||
.ui-icon-arrowthick-1-sw { background-position: -80px -48px; }
|
|
||||||
.ui-icon-arrowthick-1-w { background-position: -96px -48px; }
|
|
||||||
.ui-icon-arrowthick-1-nw { background-position: -112px -48px; }
|
|
||||||
.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; }
|
|
||||||
.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; }
|
|
||||||
.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; }
|
|
||||||
.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; }
|
|
||||||
.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; }
|
|
||||||
.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; }
|
|
||||||
.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; }
|
|
||||||
.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; }
|
|
||||||
.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; }
|
|
||||||
.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; }
|
|
||||||
.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; }
|
|
||||||
.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; }
|
|
||||||
.ui-icon-arrowreturn-1-w { background-position: -64px -64px; }
|
|
||||||
.ui-icon-arrowreturn-1-n { background-position: -80px -64px; }
|
|
||||||
.ui-icon-arrowreturn-1-e { background-position: -96px -64px; }
|
|
||||||
.ui-icon-arrowreturn-1-s { background-position: -112px -64px; }
|
|
||||||
.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; }
|
|
||||||
.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; }
|
|
||||||
.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; }
|
|
||||||
.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; }
|
|
||||||
.ui-icon-arrow-4 { background-position: 0 -80px; }
|
|
||||||
.ui-icon-arrow-4-diag { background-position: -16px -80px; }
|
|
||||||
.ui-icon-extlink { background-position: -32px -80px; }
|
|
||||||
.ui-icon-newwin { background-position: -48px -80px; }
|
|
||||||
.ui-icon-refresh { background-position: -64px -80px; }
|
|
||||||
.ui-icon-shuffle { background-position: -80px -80px; }
|
|
||||||
.ui-icon-transfer-e-w { background-position: -96px -80px; }
|
|
||||||
.ui-icon-transferthick-e-w { background-position: -112px -80px; }
|
|
||||||
.ui-icon-folder-collapsed { background-position: 0 -96px; }
|
|
||||||
.ui-icon-folder-open { background-position: -16px -96px; }
|
|
||||||
.ui-icon-document { background-position: -32px -96px; }
|
|
||||||
.ui-icon-document-b { background-position: -48px -96px; }
|
|
||||||
.ui-icon-note { background-position: -64px -96px; }
|
|
||||||
.ui-icon-mail-closed { background-position: -80px -96px; }
|
|
||||||
.ui-icon-mail-open { background-position: -96px -96px; }
|
|
||||||
.ui-icon-suitcase { background-position: -112px -96px; }
|
|
||||||
.ui-icon-comment { background-position: -128px -96px; }
|
|
||||||
.ui-icon-person { background-position: -144px -96px; }
|
|
||||||
.ui-icon-print { background-position: -160px -96px; }
|
|
||||||
.ui-icon-trash { background-position: -176px -96px; }
|
|
||||||
.ui-icon-locked { background-position: -192px -96px; }
|
|
||||||
.ui-icon-unlocked { background-position: -208px -96px; }
|
|
||||||
.ui-icon-bookmark { background-position: -224px -96px; }
|
|
||||||
.ui-icon-tag { background-position: -240px -96px; }
|
|
||||||
.ui-icon-home { background-position: 0 -112px; }
|
|
||||||
.ui-icon-flag { background-position: -16px -112px; }
|
|
||||||
.ui-icon-calendar { background-position: -32px -112px; }
|
|
||||||
.ui-icon-cart { background-position: -48px -112px; }
|
|
||||||
.ui-icon-pencil { background-position: -64px -112px; }
|
|
||||||
.ui-icon-clock { background-position: -80px -112px; }
|
|
||||||
.ui-icon-disk { background-position: -96px -112px; }
|
|
||||||
.ui-icon-calculator { background-position: -112px -112px; }
|
|
||||||
.ui-icon-zoomin { background-position: -128px -112px; }
|
|
||||||
.ui-icon-zoomout { background-position: -144px -112px; }
|
|
||||||
.ui-icon-search { background-position: -160px -112px; }
|
|
||||||
.ui-icon-wrench { background-position: -176px -112px; }
|
|
||||||
.ui-icon-gear { background-position: -192px -112px; }
|
|
||||||
.ui-icon-heart { background-position: -208px -112px; }
|
|
||||||
.ui-icon-star { background-position: -224px -112px; }
|
|
||||||
.ui-icon-link { background-position: -240px -112px; }
|
|
||||||
.ui-icon-cancel { background-position: 0 -128px; }
|
|
||||||
.ui-icon-plus { background-position: -16px -128px; }
|
|
||||||
.ui-icon-plusthick { background-position: -32px -128px; }
|
|
||||||
.ui-icon-minus { background-position: -48px -128px; }
|
|
||||||
.ui-icon-minusthick { background-position: -64px -128px; }
|
|
||||||
.ui-icon-close { background-position: -80px -128px; }
|
|
||||||
.ui-icon-closethick { background-position: -96px -128px; }
|
|
||||||
.ui-icon-key { background-position: -112px -128px; }
|
|
||||||
.ui-icon-lightbulb { background-position: -128px -128px; }
|
|
||||||
.ui-icon-scissors { background-position: -144px -128px; }
|
|
||||||
.ui-icon-clipboard { background-position: -160px -128px; }
|
|
||||||
.ui-icon-copy { background-position: -176px -128px; }
|
|
||||||
.ui-icon-contact { background-position: -192px -128px; }
|
|
||||||
.ui-icon-image { background-position: -208px -128px; }
|
|
||||||
.ui-icon-video { background-position: -224px -128px; }
|
|
||||||
.ui-icon-script { background-position: -240px -128px; }
|
|
||||||
.ui-icon-alert { background-position: 0 -144px; }
|
|
||||||
.ui-icon-info { background-position: -16px -144px; }
|
|
||||||
.ui-icon-notice { background-position: -32px -144px; }
|
|
||||||
.ui-icon-help { background-position: -48px -144px; }
|
|
||||||
.ui-icon-check { background-position: -64px -144px; }
|
|
||||||
.ui-icon-bullet { background-position: -80px -144px; }
|
|
||||||
.ui-icon-radio-on { background-position: -96px -144px; }
|
|
||||||
.ui-icon-radio-off { background-position: -112px -144px; }
|
|
||||||
.ui-icon-pin-w { background-position: -128px -144px; }
|
|
||||||
.ui-icon-pin-s { background-position: -144px -144px; }
|
|
||||||
.ui-icon-play { background-position: 0 -160px; }
|
|
||||||
.ui-icon-pause { background-position: -16px -160px; }
|
|
||||||
.ui-icon-seek-next { background-position: -32px -160px; }
|
|
||||||
.ui-icon-seek-prev { background-position: -48px -160px; }
|
|
||||||
.ui-icon-seek-end { background-position: -64px -160px; }
|
|
||||||
.ui-icon-seek-start { background-position: -80px -160px; }
|
|
||||||
/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */
|
|
||||||
.ui-icon-seek-first { background-position: -80px -160px; }
|
|
||||||
.ui-icon-stop { background-position: -96px -160px; }
|
|
||||||
.ui-icon-eject { background-position: -112px -160px; }
|
|
||||||
.ui-icon-volume-off { background-position: -128px -160px; }
|
|
||||||
.ui-icon-volume-on { background-position: -144px -160px; }
|
|
||||||
.ui-icon-power { background-position: 0 -176px; }
|
|
||||||
.ui-icon-signal-diag { background-position: -16px -176px; }
|
|
||||||
.ui-icon-signal { background-position: -32px -176px; }
|
|
||||||
.ui-icon-battery-0 { background-position: -48px -176px; }
|
|
||||||
.ui-icon-battery-1 { background-position: -64px -176px; }
|
|
||||||
.ui-icon-battery-2 { background-position: -80px -176px; }
|
|
||||||
.ui-icon-battery-3 { background-position: -96px -176px; }
|
|
||||||
.ui-icon-circle-plus { background-position: 0 -192px; }
|
|
||||||
.ui-icon-circle-minus { background-position: -16px -192px; }
|
|
||||||
.ui-icon-circle-close { background-position: -32px -192px; }
|
|
||||||
.ui-icon-circle-triangle-e { background-position: -48px -192px; }
|
|
||||||
.ui-icon-circle-triangle-s { background-position: -64px -192px; }
|
|
||||||
.ui-icon-circle-triangle-w { background-position: -80px -192px; }
|
|
||||||
.ui-icon-circle-triangle-n { background-position: -96px -192px; }
|
|
||||||
.ui-icon-circle-arrow-e { background-position: -112px -192px; }
|
|
||||||
.ui-icon-circle-arrow-s { background-position: -128px -192px; }
|
|
||||||
.ui-icon-circle-arrow-w { background-position: -144px -192px; }
|
|
||||||
.ui-icon-circle-arrow-n { background-position: -160px -192px; }
|
|
||||||
.ui-icon-circle-zoomin { background-position: -176px -192px; }
|
|
||||||
.ui-icon-circle-zoomout { background-position: -192px -192px; }
|
|
||||||
.ui-icon-circle-check { background-position: -208px -192px; }
|
|
||||||
.ui-icon-circlesmall-plus { background-position: 0 -208px; }
|
|
||||||
.ui-icon-circlesmall-minus { background-position: -16px -208px; }
|
|
||||||
.ui-icon-circlesmall-close { background-position: -32px -208px; }
|
|
||||||
.ui-icon-squaresmall-plus { background-position: -48px -208px; }
|
|
||||||
.ui-icon-squaresmall-minus { background-position: -64px -208px; }
|
|
||||||
.ui-icon-squaresmall-close { background-position: -80px -208px; }
|
|
||||||
.ui-icon-grip-dotted-vertical { background-position: 0 -224px; }
|
|
||||||
.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; }
|
|
||||||
.ui-icon-grip-solid-vertical { background-position: -32px -224px; }
|
|
||||||
.ui-icon-grip-solid-horizontal { background-position: -48px -224px; }
|
|
||||||
.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; }
|
|
||||||
.ui-icon-grip-diagonal-se { background-position: -80px -224px; }
|
|
||||||
|
|
||||||
|
|
||||||
/* Misc visuals
|
|
||||||
----------------------------------*/
|
|
||||||
|
|
||||||
/* Corner radius */
|
|
||||||
.ui-corner-all, .ui-corner-top, .ui-corner-left, .ui-corner-tl { -moz-border-radius-topleft: 4px; -webkit-border-top-left-radius: 4px; -khtml-border-top-left-radius: 4px; border-top-left-radius: 4px; }
|
|
||||||
.ui-corner-all, .ui-corner-top, .ui-corner-right, .ui-corner-tr { -moz-border-radius-topright: 4px; -webkit-border-top-right-radius: 4px; -khtml-border-top-right-radius: 4px; border-top-right-radius: 4px; }
|
|
||||||
.ui-corner-all, .ui-corner-bottom, .ui-corner-left, .ui-corner-bl { -moz-border-radius-bottomleft: 4px; -webkit-border-bottom-left-radius: 4px; -khtml-border-bottom-left-radius: 4px; border-bottom-left-radius: 4px; }
|
|
||||||
.ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
|
|
||||||
|
|
||||||
/* Overlays */
|
|
||||||
.ui-widget-overlay { background: #666666 url(images/ui-bg_diagonals-thick_20_666666_40x40.png) 50% 50% repeat; opacity: .5;filter:Alpha(Opacity=50); }
|
|
||||||
.ui-widget-shadow { margin: -5px 0 0 -5px; padding: 5px; background: #000000 url(images/ui-bg_flat_10_000000_40x100.png) 50% 50% repeat-x; opacity: .2;filter:Alpha(Opacity=20); -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }
|
|
14823
Libraries/jquery-ui-1.9.1.custom.js
vendored
@ -17,8 +17,7 @@
|
|||||||
}
|
}
|
||||||
if (typeof define === 'function' && define.amd) {
|
if (typeof define === 'function' && define.amd) {
|
||||||
define([
|
define([
|
||||||
"Libraries/strophe",
|
"strophe"
|
||||||
"Libraries/underscore"
|
|
||||||
], function () {
|
], function () {
|
||||||
if (console===undefined || console.log===undefined) {
|
if (console===undefined || console.log===undefined) {
|
||||||
console = { log: function () {}, error: function () {} };
|
console = { log: function () {}, error: function () {} };
|
||||||
|
@ -98,6 +98,7 @@ Strophe.addConnectionPlugin('roster',
|
|||||||
};
|
};
|
||||||
|
|
||||||
Strophe.addNamespace('ROSTER_VER', 'urn:xmpp:features:rosterver');
|
Strophe.addNamespace('ROSTER_VER', 'urn:xmpp:features:rosterver');
|
||||||
|
Strophe.addNamespace('NICK', 'http://jabber.org/protocol/nick');
|
||||||
},
|
},
|
||||||
/** Function: supportVersioning
|
/** Function: supportVersioning
|
||||||
* return true if roster versioning is enabled on server
|
* return true if roster versioning is enabled on server
|
||||||
@ -183,13 +184,17 @@ Strophe.addConnectionPlugin('roster',
|
|||||||
*
|
*
|
||||||
* Parameters:
|
* Parameters:
|
||||||
* (String) jid
|
* (String) jid
|
||||||
* (String) message
|
* (String) message (optional)
|
||||||
|
* (String) nick (optional)
|
||||||
*/
|
*/
|
||||||
subscribe: function(jid, message)
|
subscribe: function(jid, message, nick) {
|
||||||
{
|
|
||||||
var pres = $pres({to: jid, type: "subscribe"});
|
var pres = $pres({to: jid, type: "subscribe"});
|
||||||
if (message && message != "")
|
if (message && message !== "") {
|
||||||
pres.c("status").t(message);
|
pres.c("status").t(message);
|
||||||
|
}
|
||||||
|
if (nick && nick !== "") {
|
||||||
|
pres.c('nick', {'xmlns': Strophe.NS.NICK}).t(nick);
|
||||||
|
}
|
||||||
this._connection.send(pres);
|
this._connection.send(pres);
|
||||||
},
|
},
|
||||||
/** Function: unsubscribe
|
/** Function: unsubscribe
|
||||||
|
66
Libraries/strophe.vcard.js
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
// Generated by CoffeeScript 1.3.3
|
||||||
|
/*
|
||||||
|
Plugin to implement the vCard extension.
|
||||||
|
http://xmpp.org/extensions/xep-0054.html
|
||||||
|
|
||||||
|
Author: Nathan Zorn (nathan.zorn@gmail.com)
|
||||||
|
CoffeeScript port: Andreas Guth (guth@dbis.rwth-aachen.de)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* jslint configuration:
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* global document, window, setTimeout, clearTimeout, console,
|
||||||
|
XMLHttpRequest, ActiveXObject,
|
||||||
|
Base64, MD5,
|
||||||
|
Strophe, $build, $msg, $iq, $pres
|
||||||
|
*/
|
||||||
|
|
||||||
|
var buildIq;
|
||||||
|
|
||||||
|
buildIq = function(type, jid, vCardEl) {
|
||||||
|
var iq;
|
||||||
|
iq = $iq(jid ? {
|
||||||
|
type: type,
|
||||||
|
to: jid
|
||||||
|
} : {
|
||||||
|
type: type
|
||||||
|
});
|
||||||
|
iq.c("vCard", {
|
||||||
|
xmlns: Strophe.NS.VCARD
|
||||||
|
});
|
||||||
|
if (vCardEl) {
|
||||||
|
iq.cnode(vCardEl);
|
||||||
|
}
|
||||||
|
return iq;
|
||||||
|
};
|
||||||
|
|
||||||
|
Strophe.addConnectionPlugin('vcard', {
|
||||||
|
_connection: null,
|
||||||
|
init: function(conn) {
|
||||||
|
this._connection = conn;
|
||||||
|
return Strophe.addNamespace('VCARD', 'vcard-temp');
|
||||||
|
},
|
||||||
|
/*Function
|
||||||
|
Retrieve a vCard for a JID/Entity
|
||||||
|
Parameters:
|
||||||
|
(Function) handler_cb - The callback function used to handle the request.
|
||||||
|
(String) jid - optional - The name of the entity to request the vCard
|
||||||
|
If no jid is given, this function retrieves the current user's vcard.
|
||||||
|
*/
|
||||||
|
|
||||||
|
get: function(handler_cb, jid, error_cb) {
|
||||||
|
var iq;
|
||||||
|
iq = buildIq("get", jid);
|
||||||
|
return this._connection.sendIQ(iq, handler_cb, error_cb);
|
||||||
|
},
|
||||||
|
/* Function
|
||||||
|
Set an entity's vCard.
|
||||||
|
*/
|
||||||
|
|
||||||
|
set: function(handler_cb, vCardEl, jid, error_cb) {
|
||||||
|
var iq;
|
||||||
|
iq = buildIq("set", jid, vCardEl);
|
||||||
|
return this._connection.sendIQ(iq, handler_cb, error_rb);
|
||||||
|
}
|
||||||
|
});
|
@ -1,600 +0,0 @@
|
|||||||
// Underscore.string
|
|
||||||
// (c) 2010 Esa-Matti Suuronen <esa-matti aet suuronen dot org>
|
|
||||||
// Underscore.string is freely distributable under the terms of the MIT license.
|
|
||||||
// Documentation: https://github.com/epeli/underscore.string
|
|
||||||
// Some code is borrowed from MooTools and Alexandru Marasteanu.
|
|
||||||
// Version '2.2.0rc'
|
|
||||||
|
|
||||||
!function(root, String){
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
// Defining helper functions.
|
|
||||||
|
|
||||||
var nativeTrim = String.prototype.trim;
|
|
||||||
var nativeTrimRight = String.prototype.trimRight;
|
|
||||||
var nativeTrimLeft = String.prototype.trimLeft;
|
|
||||||
|
|
||||||
var parseNumber = function(source) { return source * 1 || 0; };
|
|
||||||
|
|
||||||
var strRepeat = function(str, qty){
|
|
||||||
if (qty < 1) return '';
|
|
||||||
var result = '';
|
|
||||||
while (qty > 0) {
|
|
||||||
if (qty & 1) result += str;
|
|
||||||
qty >>= 1, str += str;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
};
|
|
||||||
|
|
||||||
var slice = [].slice;
|
|
||||||
|
|
||||||
var defaultToWhiteSpace = function(characters) {
|
|
||||||
if (characters == null)
|
|
||||||
return '\\s';
|
|
||||||
else if (characters.source)
|
|
||||||
return characters.source;
|
|
||||||
else
|
|
||||||
return '[' + _s.escapeRegExp(characters) + ']';
|
|
||||||
};
|
|
||||||
|
|
||||||
var escapeChars = {
|
|
||||||
lt: '<',
|
|
||||||
gt: '>',
|
|
||||||
quot: '"',
|
|
||||||
apos: "'",
|
|
||||||
amp: '&'
|
|
||||||
};
|
|
||||||
|
|
||||||
var reversedEscapeChars = {};
|
|
||||||
for(var key in escapeChars){ reversedEscapeChars[escapeChars[key]] = key; }
|
|
||||||
|
|
||||||
// sprintf() for JavaScript 0.7-beta1
|
|
||||||
// http://www.diveintojavascript.com/projects/javascript-sprintf
|
|
||||||
//
|
|
||||||
// Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
|
|
||||||
// All rights reserved.
|
|
||||||
|
|
||||||
var sprintf = (function() {
|
|
||||||
function get_type(variable) {
|
|
||||||
return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
|
|
||||||
}
|
|
||||||
|
|
||||||
var str_repeat = strRepeat;
|
|
||||||
|
|
||||||
var str_format = function() {
|
|
||||||
if (!str_format.cache.hasOwnProperty(arguments[0])) {
|
|
||||||
str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
|
|
||||||
}
|
|
||||||
return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
|
|
||||||
};
|
|
||||||
|
|
||||||
str_format.format = function(parse_tree, argv) {
|
|
||||||
var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
|
|
||||||
for (i = 0; i < tree_length; i++) {
|
|
||||||
node_type = get_type(parse_tree[i]);
|
|
||||||
if (node_type === 'string') {
|
|
||||||
output.push(parse_tree[i]);
|
|
||||||
}
|
|
||||||
else if (node_type === 'array') {
|
|
||||||
match = parse_tree[i]; // convenience purposes only
|
|
||||||
if (match[2]) { // keyword argument
|
|
||||||
arg = argv[cursor];
|
|
||||||
for (k = 0; k < match[2].length; k++) {
|
|
||||||
if (!arg.hasOwnProperty(match[2][k])) {
|
|
||||||
throw new Error(sprintf('[_.sprintf] property "%s" does not exist', match[2][k]));
|
|
||||||
}
|
|
||||||
arg = arg[match[2][k]];
|
|
||||||
}
|
|
||||||
} else if (match[1]) { // positional argument (explicit)
|
|
||||||
arg = argv[match[1]];
|
|
||||||
}
|
|
||||||
else { // positional argument (implicit)
|
|
||||||
arg = argv[cursor++];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
|
|
||||||
throw new Error(sprintf('[_.sprintf] expecting number but found %s', get_type(arg)));
|
|
||||||
}
|
|
||||||
switch (match[8]) {
|
|
||||||
case 'b': arg = arg.toString(2); break;
|
|
||||||
case 'c': arg = String.fromCharCode(arg); break;
|
|
||||||
case 'd': arg = parseInt(arg, 10); break;
|
|
||||||
case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
|
|
||||||
case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
|
|
||||||
case 'o': arg = arg.toString(8); break;
|
|
||||||
case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
|
|
||||||
case 'u': arg = Math.abs(arg); break;
|
|
||||||
case 'x': arg = arg.toString(16); break;
|
|
||||||
case 'X': arg = arg.toString(16).toUpperCase(); break;
|
|
||||||
}
|
|
||||||
arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
|
|
||||||
pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
|
|
||||||
pad_length = match[6] - String(arg).length;
|
|
||||||
pad = match[6] ? str_repeat(pad_character, pad_length) : '';
|
|
||||||
output.push(match[5] ? arg + pad : pad + arg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return output.join('');
|
|
||||||
};
|
|
||||||
|
|
||||||
str_format.cache = {};
|
|
||||||
|
|
||||||
str_format.parse = function(fmt) {
|
|
||||||
var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
|
|
||||||
while (_fmt) {
|
|
||||||
if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
|
|
||||||
parse_tree.push(match[0]);
|
|
||||||
}
|
|
||||||
else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
|
|
||||||
parse_tree.push('%');
|
|
||||||
}
|
|
||||||
else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
|
|
||||||
if (match[2]) {
|
|
||||||
arg_names |= 1;
|
|
||||||
var field_list = [], replacement_field = match[2], field_match = [];
|
|
||||||
if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
|
|
||||||
field_list.push(field_match[1]);
|
|
||||||
while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
|
|
||||||
if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
|
|
||||||
field_list.push(field_match[1]);
|
|
||||||
}
|
|
||||||
else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
|
|
||||||
field_list.push(field_match[1]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error('[_.sprintf] huh?');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error('[_.sprintf] huh?');
|
|
||||||
}
|
|
||||||
match[2] = field_list;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
arg_names |= 2;
|
|
||||||
}
|
|
||||||
if (arg_names === 3) {
|
|
||||||
throw new Error('[_.sprintf] mixing positional and named placeholders is not (yet) supported');
|
|
||||||
}
|
|
||||||
parse_tree.push(match);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new Error('[_.sprintf] huh?');
|
|
||||||
}
|
|
||||||
_fmt = _fmt.substring(match[0].length);
|
|
||||||
}
|
|
||||||
return parse_tree;
|
|
||||||
};
|
|
||||||
|
|
||||||
return str_format;
|
|
||||||
})();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Defining underscore.string
|
|
||||||
|
|
||||||
var _s = {
|
|
||||||
|
|
||||||
VERSION: '2.2.0rc',
|
|
||||||
|
|
||||||
isBlank: function(str){
|
|
||||||
if (str == null) str = '';
|
|
||||||
return (/^\s*$/).test(str);
|
|
||||||
},
|
|
||||||
|
|
||||||
stripTags: function(str){
|
|
||||||
if (str == null) return '';
|
|
||||||
return String(str).replace(/<\/?[^>]+>/g, '');
|
|
||||||
},
|
|
||||||
|
|
||||||
capitalize : function(str){
|
|
||||||
str = str == null ? '' : String(str);
|
|
||||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
||||||
},
|
|
||||||
|
|
||||||
chop: function(str, step){
|
|
||||||
if (str == null) return [];
|
|
||||||
str = String(str);
|
|
||||||
step = ~~step;
|
|
||||||
return step > 0 ? str.match(new RegExp('.{1,' + step + '}', 'g')) : [str];
|
|
||||||
},
|
|
||||||
|
|
||||||
clean: function(str){
|
|
||||||
return _s.strip(str).replace(/\s+/g, ' ');
|
|
||||||
},
|
|
||||||
|
|
||||||
count: function(str, substr){
|
|
||||||
if (str == null || substr == null) return 0;
|
|
||||||
return String(str).split(substr).length - 1;
|
|
||||||
},
|
|
||||||
|
|
||||||
chars: function(str) {
|
|
||||||
if (str == null) return [];
|
|
||||||
return String(str).split('');
|
|
||||||
},
|
|
||||||
|
|
||||||
swapCase: function(str) {
|
|
||||||
if (str == null) return '';
|
|
||||||
return String(str).replace(/\S/g, function(c){
|
|
||||||
return c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase();
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
escapeHTML: function(str) {
|
|
||||||
if (str == null) return '';
|
|
||||||
return String(str).replace(/[&<>"']/g, function(m){ return '&' + reversedEscapeChars[m] + ';'; });
|
|
||||||
},
|
|
||||||
|
|
||||||
unescapeHTML: function(str) {
|
|
||||||
if (str == null) return '';
|
|
||||||
return String(str).replace(/\&([^;]+);/g, function(entity, entityCode){
|
|
||||||
var match;
|
|
||||||
|
|
||||||
if (entityCode in escapeChars) {
|
|
||||||
return escapeChars[entityCode];
|
|
||||||
} else if (match = entityCode.match(/^#x([\da-fA-F]+)$/)) {
|
|
||||||
return String.fromCharCode(parseInt(match[1], 16));
|
|
||||||
} else if (match = entityCode.match(/^#(\d+)$/)) {
|
|
||||||
return String.fromCharCode(~~match[1]);
|
|
||||||
} else {
|
|
||||||
return entity;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
escapeRegExp: function(str){
|
|
||||||
if (str == null) return '';
|
|
||||||
return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
|
|
||||||
},
|
|
||||||
|
|
||||||
splice: function(str, i, howmany, substr){
|
|
||||||
var arr = _s.chars(str);
|
|
||||||
arr.splice(~~i, ~~howmany, substr);
|
|
||||||
return arr.join('');
|
|
||||||
},
|
|
||||||
|
|
||||||
insert: function(str, i, substr){
|
|
||||||
return _s.splice(str, i, 0, substr);
|
|
||||||
},
|
|
||||||
|
|
||||||
include: function(str, needle){
|
|
||||||
if (needle === '') return true;
|
|
||||||
if (str == null) return false;
|
|
||||||
return String(str).indexOf(needle) !== -1;
|
|
||||||
},
|
|
||||||
|
|
||||||
join: function() {
|
|
||||||
var args = slice.call(arguments),
|
|
||||||
separator = args.shift();
|
|
||||||
|
|
||||||
if (separator == null) separator = '';
|
|
||||||
|
|
||||||
return args.join(separator);
|
|
||||||
},
|
|
||||||
|
|
||||||
lines: function(str) {
|
|
||||||
if (str == null) return [];
|
|
||||||
return String(str).split("\n");
|
|
||||||
},
|
|
||||||
|
|
||||||
reverse: function(str){
|
|
||||||
return _s.chars(str).reverse().join('');
|
|
||||||
},
|
|
||||||
|
|
||||||
startsWith: function(str, starts){
|
|
||||||
if (starts === '') return true;
|
|
||||||
if (str == null || starts == null) return false;
|
|
||||||
str = String(str); starts = String(starts);
|
|
||||||
return str.length >= starts.length && str.slice(0, starts.length) === starts;
|
|
||||||
},
|
|
||||||
|
|
||||||
endsWith: function(str, ends){
|
|
||||||
if (ends === '') return true;
|
|
||||||
if (str == null || ends == null) return false;
|
|
||||||
str = String(str); ends = String(ends);
|
|
||||||
return str.length >= ends.length && str.slice(str.length - ends.length) === ends;
|
|
||||||
},
|
|
||||||
|
|
||||||
succ: function(str){
|
|
||||||
if (str == null) return '';
|
|
||||||
str = String(str);
|
|
||||||
return str.slice(0, -1) + String.fromCharCode(str.charCodeAt(str.length-1) + 1);
|
|
||||||
},
|
|
||||||
|
|
||||||
titleize: function(str){
|
|
||||||
if (str == null) return '';
|
|
||||||
return String(str).replace(/(?:^|\s)\S/g, function(c){ return c.toUpperCase(); });
|
|
||||||
},
|
|
||||||
|
|
||||||
camelize: function(str){
|
|
||||||
return _s.trim(str).replace(/[-_\s]+(.)?/g, function(match, c){ return c.toUpperCase(); });
|
|
||||||
},
|
|
||||||
|
|
||||||
underscored: function(str){
|
|
||||||
return _s.trim(str).replace(/([a-z\d])([A-Z]+)/g, '$1_$2').replace(/[-\s]+/g, '_').toLowerCase();
|
|
||||||
},
|
|
||||||
|
|
||||||
dasherize: function(str){
|
|
||||||
return _s.trim(str).replace(/([A-Z])/g, '-$1').replace(/[-_\s]+/g, '-').toLowerCase();
|
|
||||||
},
|
|
||||||
|
|
||||||
classify: function(str){
|
|
||||||
return _s.titleize(String(str).replace(/_/g, ' ')).replace(/\s/g, '');
|
|
||||||
},
|
|
||||||
|
|
||||||
humanize: function(str){
|
|
||||||
return _s.capitalize(_s.underscored(str).replace(/_id$/,'').replace(/_/g, ' '));
|
|
||||||
},
|
|
||||||
|
|
||||||
trim: function(str, characters){
|
|
||||||
if (str == null) return '';
|
|
||||||
if (!characters && nativeTrim) return nativeTrim.call(str);
|
|
||||||
characters = defaultToWhiteSpace(characters);
|
|
||||||
return String(str).replace(new RegExp('\^' + characters + '+|' + characters + '+$', 'g'), '');
|
|
||||||
},
|
|
||||||
|
|
||||||
ltrim: function(str, characters){
|
|
||||||
if (str == null) return '';
|
|
||||||
if (!characters && nativeTrimLeft) return nativeTrimLeft.call(str);
|
|
||||||
characters = defaultToWhiteSpace(characters);
|
|
||||||
return String(str).replace(new RegExp('^' + characters + '+'), '');
|
|
||||||
},
|
|
||||||
|
|
||||||
rtrim: function(str, characters){
|
|
||||||
if (str == null) return '';
|
|
||||||
if (!characters && nativeTrimRight) return nativeTrimRight.call(str);
|
|
||||||
characters = defaultToWhiteSpace(characters);
|
|
||||||
return String(str).replace(new RegExp(characters + '+$'), '');
|
|
||||||
},
|
|
||||||
|
|
||||||
truncate: function(str, length, truncateStr){
|
|
||||||
if (str == null) return '';
|
|
||||||
str = String(str); truncateStr = truncateStr || '...';
|
|
||||||
length = ~~length;
|
|
||||||
return str.length > length ? str.slice(0, length) + truncateStr : str;
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* _s.prune: a more elegant version of truncate
|
|
||||||
* prune extra chars, never leaving a half-chopped word.
|
|
||||||
* @author github.com/rwz
|
|
||||||
*/
|
|
||||||
prune: function(str, length, pruneStr){
|
|
||||||
if (str == null) return '';
|
|
||||||
|
|
||||||
str = String(str); length = ~~length;
|
|
||||||
pruneStr = pruneStr != null ? String(pruneStr) : '...';
|
|
||||||
|
|
||||||
if (str.length <= length) return str;
|
|
||||||
|
|
||||||
var tmpl = function(c){ return c.toUpperCase() !== c.toLowerCase() ? 'A' : ' '; },
|
|
||||||
template = str.slice(0, length+1).replace(/.(?=\W*\w*$)/g, tmpl); // 'Hello, world' -> 'HellAA AAAAA'
|
|
||||||
|
|
||||||
if (template.slice(template.length-2).match(/\w\w/))
|
|
||||||
template = template.replace(/\s*\S+$/, '');
|
|
||||||
else
|
|
||||||
template = _s.rtrim(template.slice(0, template.length-1));
|
|
||||||
|
|
||||||
return (template+pruneStr).length > str.length ? str : str.slice(0, template.length)+pruneStr;
|
|
||||||
},
|
|
||||||
|
|
||||||
words: function(str, delimiter) {
|
|
||||||
if (_s.isBlank(str)) return [];
|
|
||||||
return _s.trim(str, delimiter).split(delimiter || /\s+/);
|
|
||||||
},
|
|
||||||
|
|
||||||
pad: function(str, length, padStr, type) {
|
|
||||||
str = str == null ? '' : String(str);
|
|
||||||
length = ~~length;
|
|
||||||
|
|
||||||
var padlen = 0;
|
|
||||||
|
|
||||||
if (!padStr)
|
|
||||||
padStr = ' ';
|
|
||||||
else if (padStr.length > 1)
|
|
||||||
padStr = padStr.charAt(0);
|
|
||||||
|
|
||||||
switch(type) {
|
|
||||||
case 'right':
|
|
||||||
padlen = length - str.length;
|
|
||||||
return str + strRepeat(padStr, padlen);
|
|
||||||
case 'both':
|
|
||||||
padlen = length - str.length;
|
|
||||||
return strRepeat(padStr, Math.ceil(padlen/2)) + str
|
|
||||||
+ strRepeat(padStr, Math.floor(padlen/2));
|
|
||||||
default: // 'left'
|
|
||||||
padlen = length - str.length;
|
|
||||||
return strRepeat(padStr, padlen) + str;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
lpad: function(str, length, padStr) {
|
|
||||||
return _s.pad(str, length, padStr);
|
|
||||||
},
|
|
||||||
|
|
||||||
rpad: function(str, length, padStr) {
|
|
||||||
return _s.pad(str, length, padStr, 'right');
|
|
||||||
},
|
|
||||||
|
|
||||||
lrpad: function(str, length, padStr) {
|
|
||||||
return _s.pad(str, length, padStr, 'both');
|
|
||||||
},
|
|
||||||
|
|
||||||
sprintf: sprintf,
|
|
||||||
|
|
||||||
vsprintf: function(fmt, argv){
|
|
||||||
argv.unshift(fmt);
|
|
||||||
return sprintf.apply(null, argv);
|
|
||||||
},
|
|
||||||
|
|
||||||
toNumber: function(str, decimals) {
|
|
||||||
if (str == null || str == '') return 0;
|
|
||||||
str = String(str);
|
|
||||||
var num = parseNumber(parseNumber(str).toFixed(~~decimals));
|
|
||||||
return num === 0 && !str.match(/^0+$/) ? Number.NaN : num;
|
|
||||||
},
|
|
||||||
|
|
||||||
numberFormat : function(number, dec, dsep, tsep) {
|
|
||||||
if (isNaN(number) || number == null) return '';
|
|
||||||
|
|
||||||
number = number.toFixed(~~dec);
|
|
||||||
tsep = tsep || ',';
|
|
||||||
|
|
||||||
var parts = number.split('.'), fnums = parts[0],
|
|
||||||
decimals = parts[1] ? (dsep || '.') + parts[1] : '';
|
|
||||||
|
|
||||||
return fnums.replace(/(\d)(?=(?:\d{3})+$)/g, '$1' + tsep) + decimals;
|
|
||||||
},
|
|
||||||
|
|
||||||
strRight: function(str, sep){
|
|
||||||
if (str == null) return '';
|
|
||||||
str = String(str); sep = sep != null ? String(sep) : sep;
|
|
||||||
var pos = !sep ? -1 : str.indexOf(sep);
|
|
||||||
return ~pos ? str.slice(pos+sep.length, str.length) : str;
|
|
||||||
},
|
|
||||||
|
|
||||||
strRightBack: function(str, sep){
|
|
||||||
if (str == null) return '';
|
|
||||||
str = String(str); sep = sep != null ? String(sep) : sep;
|
|
||||||
var pos = !sep ? -1 : str.lastIndexOf(sep);
|
|
||||||
return ~pos ? str.slice(pos+sep.length, str.length) : str;
|
|
||||||
},
|
|
||||||
|
|
||||||
strLeft: function(str, sep){
|
|
||||||
if (str == null) return '';
|
|
||||||
str = String(str); sep = sep != null ? String(sep) : sep;
|
|
||||||
var pos = !sep ? -1 : str.indexOf(sep);
|
|
||||||
return ~pos ? str.slice(0, pos) : str;
|
|
||||||
},
|
|
||||||
|
|
||||||
strLeftBack: function(str, sep){
|
|
||||||
if (str == null) return '';
|
|
||||||
str += ''; sep = sep != null ? ''+sep : sep;
|
|
||||||
var pos = str.lastIndexOf(sep);
|
|
||||||
return ~pos ? str.slice(0, pos) : str;
|
|
||||||
},
|
|
||||||
|
|
||||||
toSentence: function(array, separator, lastSeparator, serial) {
|
|
||||||
separator = separator || ', '
|
|
||||||
lastSeparator = lastSeparator || ' and '
|
|
||||||
var a = array.slice(), lastMember = a.pop();
|
|
||||||
|
|
||||||
if (array.length > 2 && serial) lastSeparator = _s.rtrim(separator) + lastSeparator;
|
|
||||||
|
|
||||||
return a.length ? a.join(separator) + lastSeparator + lastMember : lastMember;
|
|
||||||
},
|
|
||||||
|
|
||||||
toSentenceSerial: function() {
|
|
||||||
var args = slice.call(arguments);
|
|
||||||
args[3] = true;
|
|
||||||
return _s.toSentence.apply(_s, args);
|
|
||||||
},
|
|
||||||
|
|
||||||
slugify: function(str) {
|
|
||||||
if (str == null) return '';
|
|
||||||
|
|
||||||
var from = "ąàáäâãåæćęèéëêìíïîłńòóöôõøùúüûñçżź",
|
|
||||||
to = "aaaaaaaaceeeeeiiiilnoooooouuuunczz",
|
|
||||||
regex = new RegExp(defaultToWhiteSpace(from), 'g');
|
|
||||||
|
|
||||||
str = String(str).toLowerCase().replace(regex, function(c){
|
|
||||||
var index = from.indexOf(c);
|
|
||||||
return to.charAt(index) || '-';
|
|
||||||
});
|
|
||||||
|
|
||||||
return _s.dasherize(str.replace(/[^\w\s-]/g, ''));
|
|
||||||
},
|
|
||||||
|
|
||||||
surround: function(str, wrapper) {
|
|
||||||
return [wrapper, str, wrapper].join('');
|
|
||||||
},
|
|
||||||
|
|
||||||
quote: function(str) {
|
|
||||||
return _s.surround(str, '"');
|
|
||||||
},
|
|
||||||
|
|
||||||
exports: function() {
|
|
||||||
var result = {};
|
|
||||||
|
|
||||||
for (var prop in this) {
|
|
||||||
if (!this.hasOwnProperty(prop) || prop.match(/^(?:include|contains|reverse)$/)) continue;
|
|
||||||
result[prop] = this[prop];
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
},
|
|
||||||
|
|
||||||
repeat: function(str, qty, separator){
|
|
||||||
if (str == null) return '';
|
|
||||||
|
|
||||||
qty = ~~qty;
|
|
||||||
|
|
||||||
// using faster implementation if separator is not needed;
|
|
||||||
if (separator == null) return strRepeat(String(str), qty);
|
|
||||||
|
|
||||||
// this one is about 300x slower in Google Chrome
|
|
||||||
for (var repeat = []; qty > 0; repeat[--qty] = str) {}
|
|
||||||
return repeat.join(separator);
|
|
||||||
},
|
|
||||||
|
|
||||||
levenshtein: function(str1, str2) {
|
|
||||||
if (str1 == null && str2 == null) return 0;
|
|
||||||
if (str1 == null) return String(str2).length;
|
|
||||||
if (str2 == null) return String(str1).length;
|
|
||||||
|
|
||||||
str1 = String(str1); str2 = String(str2);
|
|
||||||
|
|
||||||
var current = [], prev, value;
|
|
||||||
|
|
||||||
for (var i = 0; i <= str2.length; i++)
|
|
||||||
for (var j = 0; j <= str1.length; j++) {
|
|
||||||
if (i && j)
|
|
||||||
if (str1.charAt(j - 1) === str2.charAt(i - 1))
|
|
||||||
value = prev;
|
|
||||||
else
|
|
||||||
value = Math.min(current[j], current[j - 1], prev) + 1;
|
|
||||||
else
|
|
||||||
value = i + j;
|
|
||||||
|
|
||||||
prev = current[j];
|
|
||||||
current[j] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
return current.pop();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// Aliases
|
|
||||||
|
|
||||||
_s.strip = _s.trim;
|
|
||||||
_s.lstrip = _s.ltrim;
|
|
||||||
_s.rstrip = _s.rtrim;
|
|
||||||
_s.center = _s.lrpad;
|
|
||||||
_s.rjust = _s.lpad;
|
|
||||||
_s.ljust = _s.rpad;
|
|
||||||
_s.contains = _s.include;
|
|
||||||
_s.q = _s.quote;
|
|
||||||
|
|
||||||
// CommonJS module is defined
|
|
||||||
if (typeof exports !== 'undefined') {
|
|
||||||
if (typeof module !== 'undefined' && module.exports) {
|
|
||||||
// Export module
|
|
||||||
module.exports = _s;
|
|
||||||
}
|
|
||||||
exports._s = _s;
|
|
||||||
|
|
||||||
} else if (typeof define === 'function' && define.amd) {
|
|
||||||
// Register as a named module with AMD.
|
|
||||||
define('underscore.string', [], function() {
|
|
||||||
return _s;
|
|
||||||
});
|
|
||||||
|
|
||||||
} else {
|
|
||||||
// Integrate with Underscore.js if defined
|
|
||||||
// or create our own underscore object.
|
|
||||||
root._ = root._ || {};
|
|
||||||
root._.string = root._.str = _s;
|
|
||||||
}
|
|
||||||
|
|
||||||
}(this, String);
|
|
4
TODO
@ -5,4 +5,6 @@ TODO:
|
|||||||
* Add /leave command
|
* Add /leave command
|
||||||
* Inform users of /help via placeholder in textarea
|
* Inform users of /help via placeholder in textarea
|
||||||
* Create a single sprite image from the current images
|
* Create a single sprite image from the current images
|
||||||
|
* Add "keep me logged in" feature when logging in manually
|
||||||
|
* Add support for XMPP server feature detection
|
||||||
|
* Implement "Fetch user vCard" feature.
|
||||||
|
45
base.css
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
body {
|
||||||
|
font: 100% Arial, FreeSans, sans-serif;
|
||||||
|
font-family: "Helvetica Neue", Arial, FreeSans, sans-serif;
|
||||||
|
-webkit-font-smoothing: antialiased; /* Fix for webkit rendering */
|
||||||
|
-webkit-text-size-adjust: 100%;
|
||||||
|
text-shadow: 0 1px 0 rgba(250, 250, 250, 1);
|
||||||
|
background: url('images/bg.png');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* #Typography
|
||||||
|
================================================== */
|
||||||
|
h1, h2, h3, h4, h5, h6 {
|
||||||
|
color: #181818;
|
||||||
|
font-family: "Georgia", "Times New Roman", serif;
|
||||||
|
font-weight: normal; }
|
||||||
|
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a { font-weight: inherit; }
|
||||||
|
h1 { font-size: 46px; line-height: 50px; margin-bottom: 14px;}
|
||||||
|
h2 { font-size: 35px; line-height: 40px; margin-bottom: 10px; }
|
||||||
|
h3 { font-size: 28px; line-height: 34px; margin-bottom: 8px; }
|
||||||
|
h4 { font-size: 21px; line-height: 30px; margin-bottom: 4px; }
|
||||||
|
h5 { font-size: 17px; line-height: 24px; }
|
||||||
|
h6 { font-size: 14px; line-height: 21px; }
|
||||||
|
.subheader { color: #777; }
|
||||||
|
|
||||||
|
p { margin: 0 0 20px 0; }
|
||||||
|
p img { margin: 0; }
|
||||||
|
p.lead { font-size: 21px; line-height: 27px; color: #777; }
|
||||||
|
|
||||||
|
em { font-style: italic; }
|
||||||
|
strong { font-weight: bold; color: #333; }
|
||||||
|
small { font-size: 80%; }
|
||||||
|
|
||||||
|
blockquote, blockquote p { font-size: 17px; line-height: 24px; color: #777; font-style: italic; }
|
||||||
|
blockquote { margin: 0 0 20px; padding: 9px 20px 0 19px; border-left: 1px solid #ddd; }
|
||||||
|
blockquote cite { display: block; font-size: 12px; color: #555; }
|
||||||
|
blockquote cite:before { content: "\2014 \0020"; }
|
||||||
|
blockquote cite a, blockquote cite a:visited, blockquote cite a:visited { color: #555; }
|
||||||
|
hr { border: solid #ddd; border-width: 1px 0 0; clear: both; margin: 10px 0 30px; height: 0; }
|
||||||
|
|
||||||
|
/* #Links
|
||||||
|
================================================== */
|
||||||
|
a, a:visited { text-decoration: none; outline: 0; color: rgb(70, 70, 70); }
|
||||||
|
a:hover, a:focus {color: rgb(164, 72, 72);}
|
||||||
|
p a, p a:visited { line-height: inherit; }
|
||||||
|
|
52
converse.css
@ -25,10 +25,6 @@
|
|||||||
height: 1.1em;
|
height: 1.1em;
|
||||||
}
|
}
|
||||||
|
|
||||||
#toggle-online-users {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
#connecting-to-chat {
|
#connecting-to-chat {
|
||||||
background: url(images/spinner.gif) no-repeat left;
|
background: url(images/spinner.gif) no-repeat left;
|
||||||
padding-left: 1.4em;
|
padding-left: 1.4em;
|
||||||
@ -119,7 +115,6 @@ input.new-chatroom-name {
|
|||||||
.chat-textarea {
|
.chat-textarea {
|
||||||
border: 0;
|
border: 0;
|
||||||
height: 50px;
|
height: 50px;
|
||||||
width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-textarea-chatbox-selected {
|
.chat-textarea-chatbox-selected {
|
||||||
@ -152,14 +147,24 @@ input.new-chatroom-name {
|
|||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
color: #F62817;
|
color: #F62817;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
max-width: 100px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow: hidden;
|
||||||
|
display: inline-block;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chat-event, .chat-date, .chat-help {
|
.chat-event, .chat-date, .chat-help {
|
||||||
color: #808080;
|
color: #808080;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.chat-date {
|
||||||
|
display: inline-block;
|
||||||
|
padding-top: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
div#settings,
|
div#settings,
|
||||||
div#chatrooms {
|
div#chatrooms,
|
||||||
|
div#login-dialog {
|
||||||
height: 279px;
|
height: 279px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +189,6 @@ div.delayed .chat-message-me {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.chat-head .avatar {
|
.chat-head .avatar {
|
||||||
height: 35px;
|
|
||||||
float: left;
|
float: left;
|
||||||
margin-right: 6px;
|
margin-right: 6px;
|
||||||
}
|
}
|
||||||
@ -227,7 +231,7 @@ p.chatroom-topic {
|
|||||||
|
|
||||||
a.subscribe-to-user {
|
a.subscribe-to-user {
|
||||||
padding-left: 2em;
|
padding-left: 2em;
|
||||||
background: url('/add_icon.png') no-repeat 3px top;
|
background: url('images/add_icon.png') no-repeat 3px top;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,7 +241,7 @@ div.add-xmpp-contact {
|
|||||||
padding: 3px 3px 3px 3px;
|
padding: 3px 3px 3px 3px;
|
||||||
margin: 0 0.5em;
|
margin: 0 0.5em;
|
||||||
clear: both;
|
clear: both;
|
||||||
background: url('/add_icon.png') no-repeat 3px 3px;
|
background: url('images/add_icon.png') no-repeat 3px 3px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +252,7 @@ div.add-xmpp-contact a.add-xmpp-contact {
|
|||||||
|
|
||||||
#fancy-xmpp-status-select a.change-xmpp-status-message {
|
#fancy-xmpp-status-select a.change-xmpp-status-message {
|
||||||
text-shadow: 0 1px 0 rgba(250, 250, 250, 1);
|
text-shadow: 0 1px 0 rgba(250, 250, 250, 1);
|
||||||
background: url('/pencil_icon.png') no-repeat right top;
|
background: url('images/pencil_icon.png') no-repeat right top;
|
||||||
float: right;
|
float: right;
|
||||||
clear: right;
|
clear: right;
|
||||||
width: 1em;
|
width: 1em;
|
||||||
@ -353,8 +357,8 @@ form.search-xmpp-contact input {
|
|||||||
background: url(images/user_offline_panel.png) no-repeat 5px 2px;
|
background: url(images/user_offline_panel.png) no-repeat 5px 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#xmppchat-roster dd.current-xmpp-contact.busy,
|
#xmppchat-roster dd.current-xmpp-contact.dnd,
|
||||||
#xmppchat-roster dd.current-xmpp-contact.busy:hover {
|
#xmppchat-roster dd.current-xmpp-contact.dnd:hover {
|
||||||
background: url(images/user_busy_panel.png) no-repeat 5px 2px;
|
background: url(images/user_busy_panel.png) no-repeat 5px 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -368,8 +372,13 @@ form.search-xmpp-contact input {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#xmppchat-roster dd a {
|
#xmppchat-roster dd a {
|
||||||
margin-left: 2em;
|
margin-left: 1.5em;
|
||||||
text-shadow: 0 1px 0 rgba(250, 250, 250, 1);
|
text-shadow: 0 1px 0 rgba(250, 250, 250, 1);
|
||||||
|
display: inline-block;
|
||||||
|
width: 113px;
|
||||||
|
overflow: hidden;
|
||||||
|
white-space: nowrap;
|
||||||
|
text-overflow: ellipsis;
|
||||||
}
|
}
|
||||||
|
|
||||||
.remove-xmpp-contact-dialog .ui-dialog-buttonpane {
|
.remove-xmpp-contact-dialog .ui-dialog-buttonpane {
|
||||||
@ -418,9 +427,10 @@ dd.available-chatroom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#xmppchat-roster dd a.remove-xmpp-contact {
|
#xmppchat-roster dd a.remove-xmpp-contact {
|
||||||
background: url('/delete_icon.png') no-repeat right top;
|
background: url('images/delete_icon.png') no-repeat right top;
|
||||||
padding: 0 1em 1em 0;
|
padding: 0 1em 1em 0;
|
||||||
float: right;
|
float: right;
|
||||||
|
width: 22px;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,7 +445,7 @@ dd.available-chatroom,
|
|||||||
}
|
}
|
||||||
|
|
||||||
.chatbox {
|
.chatbox {
|
||||||
width: 200px;
|
width: 201px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.chatroom {
|
.chatroom {
|
||||||
@ -478,6 +488,14 @@ div#controlbox-panes {
|
|||||||
width: 199px;
|
width: 199px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
form#xmppchat-login {
|
||||||
|
padding: 2em 0 0.3em 0.5em;
|
||||||
|
}
|
||||||
|
|
||||||
|
form#xmppchat-login input {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
form.set-xmpp-status,
|
form.set-xmpp-status,
|
||||||
form.add-chatroom {
|
form.add-chatroom {
|
||||||
padding: 0.5em 0 0.3em 0.5em;
|
padding: 0.5em 0 0.3em 0.5em;
|
||||||
@ -545,6 +563,7 @@ ul#controlbox-tabs a.current, ul#controlbox-tabs a.current:hover {
|
|||||||
|
|
||||||
div#users,
|
div#users,
|
||||||
div#chatrooms,
|
div#chatrooms,
|
||||||
|
div#login-dialog,
|
||||||
div#settings {
|
div#settings {
|
||||||
border: 0;
|
border: 0;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
@ -565,6 +584,7 @@ form.sendXMPPMessage {
|
|||||||
background-clip: padding-box;
|
background-clip: padding-box;
|
||||||
border-top-left-radius: 0;
|
border-top-left-radius: 0;
|
||||||
border-top-right-radius: 0;
|
border-top-right-radius: 0;
|
||||||
|
height: 54px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#set-custom-xmpp-status {
|
#set-custom-xmpp-status {
|
||||||
@ -631,7 +651,7 @@ input.custom-xmpp-status {
|
|||||||
background: url(images/user_offline_panel.png) no-repeat left;
|
background: url(images/user_offline_panel.png) no-repeat left;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown a.busy {
|
.dropdown a.dnd {
|
||||||
background: url(images/user_busy_panel.png) no-repeat left;
|
background: url(images/user_busy_panel.png) no-repeat left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1530
converse.js
BIN
images/add_icon.png
Normal file
After Width: | Height: | Size: 249 B |
BIN
images/bg.png
Normal file
After Width: | Height: | Size: 723 B |
BIN
images/delete_icon.png
Normal file
After Width: | Height: | Size: 470 B |
BIN
images/pencil_icon.png
Normal file
After Width: | Height: | Size: 226 B |
52
index.html
@ -2,23 +2,51 @@
|
|||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>Converse.js Demo Page</title>
|
<title>Converse.js Demo Page</title>
|
||||||
<!-- This is a special version of jQuery with RequireJS built-in -->
|
<link rel="stylesheet" href="base.css" type="text/css" media="all">
|
||||||
<link rel="stylesheet" href="Libraries/css/jquery-ui-1.9.1.custom/ui-lightness/jquery-ui-1.9.1.custom.css" type="text/css" media="all">
|
|
||||||
<link rel="stylesheet" href="converse.css" type="text/css" media="all">
|
<link rel="stylesheet" href="converse.css" type="text/css" media="all">
|
||||||
|
<!-- This is a special version of jQuery with RequireJS built-in -->
|
||||||
<script data-main="main" src="Libraries/require-jquery.js"></script>
|
<script data-main="main" src="Libraries/require-jquery.js"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<h1>Converse.js Demo Page</h1>
|
<article>
|
||||||
Log in with your Jabber/XMPP ID and password.
|
<h1>Converse.js</h1>
|
||||||
<!-- login dialog -->
|
<div>
|
||||||
<div id='login_dialog' class='hidden'>
|
<p><tt>Converse.js</tt> implements an <a href="http://xmpp.org">XMPP</a> based instant messaging client in the browser.</p>
|
||||||
<label>Login ID:</label>
|
<p>It's used by <a href="http://github.com/collective/collective.xmpp.chat">collective.xmpp.chat</a>, which is a <a href="http://plone.org">Plone</a> instant messaging add-on.</p>
|
||||||
<input type='text' id='jid'>
|
<p>The ultimate goal is to enable anyone to add chat functionality to their websites, regardless of the server backend.</p>
|
||||||
<label>Password:</label>
|
<p>Currently this is not yet 100% the case, as the code makes ajax calls to the (Plone) backend to fetch user info.</p>
|
||||||
<input type='password' id='password'>
|
<h2>Features</h2>
|
||||||
<label>BOSH Service URL:</label>
|
<ul>
|
||||||
<input type='text' id='bosh_service_url'>
|
<li>Manually or automically subscribe to other users.</li>
|
||||||
|
<li>Accept or decline contact requests</li>
|
||||||
|
<li>Chat status (online, busy, away, offline)</li>
|
||||||
|
<li>Custom status messages</li>
|
||||||
|
<li>Typing notifications</li>
|
||||||
|
<li>Third person messages (/me )</li>
|
||||||
|
<li>Multi-user chat in chatrooms</li>
|
||||||
|
<li>Chatroom Topics</li>
|
||||||
|
<li>vCard support</li>
|
||||||
|
</ul>
|
||||||
|
<p>A screencast of (a very old version of) <tt>Converse.js</tt> in action via <tt>collective.xmpp.chat</tt>
|
||||||
|
can be seen <a href="http://opkode.com/media/blog/instant-messaging-for-plone-with-javascript-and-xmpp">here</a>.</p>
|
||||||
|
<h2>Dependencies</h2>
|
||||||
|
<p>It depends on quite a few third party libraries, including <a href="http://strophe.im/strophejs">strophe.js</a>,
|
||||||
|
<a href="http:/backbonejs.org">backbone.js</a> and <a href="http:/requirejs.org">require.js</a>.</p>
|
||||||
|
<h2>Licence</h2>
|
||||||
|
<p><tt>Converse.js</tt> is released under both the <a href="http://opensource.org/licenses/mit-license.php">MIT</a>
|
||||||
|
and <a href="http://opensource.org/licenses/gpl-license.php">GPL</a> licenses.</p>
|
||||||
|
<h2>Download</h2>
|
||||||
|
Head on down to our <a href="https://github.com/jcbrand/converse.js">Github repo</a>.
|
||||||
</div>
|
</div>
|
||||||
|
</article>
|
||||||
|
<div id="chatpanel" i18n:domain="collective.xmpp.chat">
|
||||||
<div id="collective-xmpp-chat-data"></div>
|
<div id="collective-xmpp-chat-data"></div>
|
||||||
|
<div id="toggle-controlbox">
|
||||||
|
<a href="#" class="chat" id="toggle-online-users">
|
||||||
|
<span i18n:translate="">Online Users</span> (<strong id="online-count">0</strong>)
|
||||||
|
</a>
|
||||||
|
<span id="connecting-to-chat" i18n:translate="">Connecting to chat ...</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
51
main.js
@ -1,50 +1 @@
|
|||||||
require(["jquery", "converse"], function($) {
|
require(["jquery", "converse"], function($) {});
|
||||||
$(function() {
|
|
||||||
$('#login_dialog').dialog({
|
|
||||||
autoOpen: true,
|
|
||||||
draggable: false,
|
|
||||||
modal: true,
|
|
||||||
title: 'Connect to XMPP',
|
|
||||||
buttons: {
|
|
||||||
"Connect": function () {
|
|
||||||
$(document).trigger('connect', {
|
|
||||||
jid: $('#jid').val(),
|
|
||||||
password: $('#password').val(),
|
|
||||||
bosh_service_url: $('#bosh_service_url').val()
|
|
||||||
});
|
|
||||||
$('#password').val('');
|
|
||||||
$(this).dialog('close');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).bind('connect', function (ev, data) {
|
|
||||||
var connection = new Strophe.Connection(data.bosh_service_url);
|
|
||||||
|
|
||||||
connection.connect(data.jid, data.password, function (status) {
|
|
||||||
if (status === Strophe.Status.CONNECTED) {
|
|
||||||
console.log('Connected');
|
|
||||||
$(document).trigger('jarnxmpp.connected', connection);
|
|
||||||
} else if (status === Strophe.Status.DISCONNECTED) {
|
|
||||||
console.log('Disconnected');
|
|
||||||
$(document).trigger('jarnxmpp.disconnected');
|
|
||||||
} else if (status === Strophe.Status.Error) {
|
|
||||||
console.log('Error');
|
|
||||||
} else if (status === Strophe.Status.CONNECTING) {
|
|
||||||
console.log('Connecting');
|
|
||||||
} else if (status === Strophe.Status.CONNFAIL) {
|
|
||||||
console.log('Connection Failed');
|
|
||||||
} else if (status === Strophe.Status.AUTHENTICATING) {
|
|
||||||
console.log('Authenticating');
|
|
||||||
} else if (status === Strophe.Status.AUTHFAIL) {
|
|
||||||
console.log('Authenticating Failed');
|
|
||||||
} else if (status === Strophe.Status.DISCONNECTING) {
|
|
||||||
console.log('Disconnecting');
|
|
||||||
} else if (status === Strophe.Status.ATTACHED) {
|
|
||||||
console.log('Attached');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|