You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
6.5 KiB

2 years ago
  1. (function(n){"use strict";function u(n){var t=null;switch(n){case 0:case 1:case"readwrite":case"readonly":t=n;break;default:t=r.READ_WRITE||"readwrite"}return t}var t=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,f=window.IDBKeyRange||window.webkitIDBKeyRange,i=window.IDBCursor||window.webkitIDBCursor||{},r;typeof i.PREV=="undefined"&&(i.PREV="prev");typeof i.NEXT=="undefined"&&(i.NEXT="next");r=window.IDBTransaction||window.webkitIDBTransaction;n.extend({indexedDB:function(i,r){var s,h,c,e,o;if(r&&(typeof r=="number"&&(r={version:r}),s=r.version,r.schema&&!s)){h=-1;for(c in r.schema)h=h>c?h:c;s=r.version||h}return e={request:function(t,i){return n.Deferred(function(n){try{var r=typeof t=="function"?t(i):t;r.onsuccess=function(t){n.resolveWith(r,[r.result,t])};r.onerror=function(t){n.rejectWith(r,[r.error,t])};typeof r.onblocked!="undefined"&&r.onblocked===null&&(r.onblocked=function(t){var i;try{i=r.result}catch(t){i=null}n.notifyWith(r,[i,t])});typeof r.onupgradeneeded!="undefined"&&r.onupgradeneeded===null&&(r.onupgradeneeded=function(t){n.notifyWith(r,[r.result,t])})}catch(u){u.name="exception";n.rejectWith(r,["exception",u])}})},transaction:function(n){return{objectStore:function(t){try{return e.objectStore(n.objectStore(t))}catch(i){return n.readyState!==n.DONE&&n.abort(),e.objectStore(null)}},createObjectStore:function(t,i){try{return e.objectStore(n.db.createObjectStore(t,i))}catch(r){n.readyState!==n.DONE&&n.abort()}},deleteObjectStore:function(t){try{n.db.deleteObjectStore(t)}catch(i){n.readyState!==n.DONE&&n.abort()}},abort:function(){n.abort()}}},objectStore:function(n){for(var t={},r=["add","put","get","delete","clear","count"],i=0;i<r.length;i++)t[r[i]]=function(t){return function(){return e.request(function(i){return n[t].apply(n,i)},arguments)}}(r[i]);return t.each=function(t,i,r){return e.cursor(function(){return r?n.openCursor(e.range(i),r):n.openCursor(e.range(i))},t)},t.index=function(t){return e.index(function(){return n.index(t)})},t.createIndex=function(t,i,r){return arguments.length===2&&typeof i=="string"&&(r=arguments[1],i=null),r||(r=t),e.index(function(){return n.createIndex(r,t,i)})},t.deleteIndex=function(t){return n.deleteIndex(t)},t},range:function(t){return n.isArray(t)?t.length===1?f.only(t[0]):f.bound(t[0],t[1],typeof t[2]=="undefined"?!1:t[2],typeof t[3]=="undefined"?!1:t[3]):typeof t=="undefined"?null:t},cursor:function(t,i){return n.Deferred(function(n){try{var r=typeof t=="function"?t():t;r.onsuccess=function(t){var u,f;if(!r.result){n.resolveWith(r,[null,t]);return}u={"delete":function(){return e.request(function(){return r.result["delete"]()})},update:function(n){return e.request(function(){return r.result.update(n)})},next:function(n){this.data=n},key:r.result.key,value:r.result.value};n.notifyWith(r,[u,t]);f=i.apply(r,[u]);try{f===!1?n.resolveWith(r,[null,t]):typeof f=="number"?r.result.advance.apply(r.result,[f]):u.data?r.result["continue"].apply(r.result,[u.data]):r.result["continue"]()}catch(t){n.rejectWith(r,[r.result,t])}};r.onerror=function(t){n.rejectWith(r,[r.result,t])}}catch(u){u.type="exception";n.rejectWith(r,[null,u])}})},index:function(n){try{var t=typeof n=="function"?n():n}catch(i){t=null}return{each:function(n,i,r){return e.cursor(function(){return r?t.openCursor(e.range(i),r):t.openCursor(e.range(i))},n)},eachKey:function(n,i,r){return e.cursor(function(){return r?t.openKeyCursor(e.range(i),r):t.openKeyCursor(e.range(i))},n)},get:function(n){return typeof t.get=="function"?e.request(t.get(n)):t.openCursor(e.range(n))},count:function(){if(typeof t.count=="function")return e.request(t.count());throw"Count not implemented for cursors";},getKey:function(n){return typeof t.getKey=="function"?e.request(t.getKey(n)):t.openKeyCursor(e.range(n))}}}},o=e.request(function(){return s?t.open(i,parseInt(s)):t.open(i)}),o.then(function(n){n.onversionchange=function(){r&&r.onversionchange&&r.onversionchange()!==!1||n.close()}},function(){},function(n,t){if(t&&t.type==="upgradeneeded"){if(r&&r.schema)for(var i=t.oldVersion+1;i<=t.newVersion;