Commit 1f719461 authored by Thibaut Broggi's avatar Thibaut Broggi

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) { ...@@ -37,11 +37,11 @@ let get = function(url, cb) {
} }
let getImage = function(id, cb) { let getImage = function(id, cb) {
if (cachedImages[id]) if (localStorage.getItem('img:' + id))
cb(cachedImages[id]); cb(localStorage.getItem('img:' + id));
else { else {
get('./imgs/' + id + '.svg', function(res) { get('./imgs/' + id + '.svg', function(res) {
cachedImages[id] = res; localStorage.setItem('img:' + id, res);
cb(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