12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- function TrinStorage() {
- }
- TrinStorage.prototype.supportsStorage = false;
- TrinStorage.prototype.save = function(name, value) {
- if (this.supportsStorage) {
- try {
- localStorage.setItem(name, value);
- } catch (e) {
- this.supportsStorage = false;
- }
- }
- };
- TrinStorage.prototype.load = function(name) {
- if (this.supportsStorage) {
- try {
- return localStorage.getItem(name);
- } catch (e) {
- this.supportsStorage = false;
- }
- }
- return null;
- };
- TrinStorage.prototype.remove = function(name) {
- if (this.supportsStorage) {
- try {
- localStorage.removeItem(name);
- } catch (e) {
- this.supportsStorage = false;
- }
- }
- };
- TrinStorage.prototype.clear = function() {
- if (this.supportsStorage) {
- try {
- localStorage.clear();
- } catch (e) {
- this.supportsStorage = false;
- }
- }
- };
- TrinStorage.prototype.length = function() {
- if (this.supportsStorage) {
- try {
- return localStorage.length;
- } catch (e) {
- this.supportsStorage = false;
- }
- }
- return 0;
- };
- TrinStorage.prototype.getKey = function(index) {
- if (this.supportsStorage && index >= 0 && index < this.length) {
- try {
- return localStorage.key(key);
- } catch (e) {
- this.supportsStorage = false;
- }
- }
- return null;
- };
|