Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export const getBackdrops = () => {
- let xPath = '.backdrop-pending[data-image-src][data-image-key]';
- let id = '';
- const onNoIDB = (el, url) => {
- $(el).removeClass('backdrop-pending').css('background-image', `url('${url}')`);
- if($(xPath).length) setTimeout(getBackdrops, 25);
- }
- const onUndefined = (el, result) => { localImageStore(dbName, storeName.images, id, el, 'ADD', localImageDisplay); }
- const onOutdated = (el, result) => { localImageStore(dbName, storeName.images, id, el, 'PUT', localImageDisplay); }
- const onDefined = (el, blob) => { localImageDisplay(el, blob, false); }
- const localImageDisplay = (el, blob, pulled) => {
- $(`.backdrop-pending[data-image-src="${$(el).data('image-src')}"]`)
- .removeClass('backdrop-pending')
- //.data('image-key-idb', id); // Testing purposes
- .css('background-image', `url('${URL.createObjectURL(blob)}')`)
- if($(xPath).length) {
- if(pulled) setTimeout(getBackdrops, 25);
- else getBackdrops();
- }
- }
- if($(xPath).length) {
- id = $(`${xPath}:first`).data('image-key');
- localImageCheck(dbName, storeName.images, id, $(`${xPath}:first`), onNoIDB, onUndefined, onOutdated, onDefined);
- }
- }
- export const getPosters = () => {
- let xPath = 'img[data-image-src][data-image-key][src=""]';
- let id = '';
- const onNoIDB = (el, url) => {
- $(el).removeClass('d-none').attr('src', url);
- if($(xPath).length) setTimeout(getPosters, 25);
- }
- const onUndefined = (el, result) => { localImageStore(dbName, storeName.images, id, el, 'ADD', localImageDisplay); }
- const onOutdated = (el, result) => { localImageStore(dbName, storeName.images, id, el, 'PUT', localImageDisplay); }
- const onDefined = (el, blob) => { localImageDisplay(el, blob, false); }
- const localImageDisplay = (el, blob, pulled) => {
- $(`img[data-image-src="${$(el).data('image-src')}"][src=""]`)
- .removeClass('d-none')
- //.data('image-key-idb', id) // Testing purposes
- .attr('src', URL.createObjectURL(blob));
- if($(xPath).length) {
- if(pulled) setTimeout(getPosters, 25);
- else getPosters();
- }
- }
- if($(xPath).length) {
- id = $(`${xPath}:first`).data('image-key');
- localImageCheck(dbName, storeName.images, id, $(`${xPath}:first`), onNoIDB, onUndefined, onOutdated, onDefined);
- }
- }
- getBackdrops();
- getPosters();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement