Use localStorage to cache images on client side

parent ae09f0b1
Pipeline #1504 passed with stage
in 40 seconds
......@@ -37,11 +37,11 @@ let get = function(url, cb) {
}
let getImage = function(id, cb) {
if (cachedImages[id])
cb(cachedImages[id]);
if (localStorage.getItem('img:' + id))
cb(localStorage.getItem('img:' + id));
else {
get('./imgs/' + id + '.svg', function(res) {
cachedImages[id] = res;
localStorage.setItem('img:' + id, res);
cb(res);
});
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment