Sha256: 42ba27de4030262395b4bd31af066f7eb5b84a0f0990f2a6b43b1691ecbad89d
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
/* // Custom JS | written by https://github.com/wdzajicek // © 2020 Kankakee Community College // =================================================== */ // Module to retrieve our cached Google Sheet response from sessionStorage // 1. Create an object that replicates an API response where `response.result.values` // is an array containing an array representing each row in the sheet. // 2. Then we pass our mock-sheet response object to the `createAlertsHtml` module to // build and inject the alert into the DOM. import createAlertsHtml from './createAlertsHtml.js'; import contentHashLink from './contentHashLink.js'; const cache = window.sessionStorage; function createCachedResponseObject(Collapse) { let cachedResponse = { // Reconstructing our own Google Sheet-like response from the sessionStorage items result: { values: [ 0, // First two rows aren't used by the `createAlertsHtml()` function 0, [ cache.Visible, cache.getItem('All-Pages'), cache.getItem('Alert-Content'), cache.getItem('Alert-Expiration'), cache.Start, cache.End ] ] } } createAlertsHtml(cachedResponse, Collapse); contentHashLink(Collapse); } function getCachedResponse(Collapse) { try { createCachedResponseObject(Collapse); } catch (error) { contentHashLink(Collapse); console.error(`Error retrieving cached response in sessionStorage:\nName: ${error.name}\nMessage: ${error.message}\n${error}`); } } export default getCachedResponse;
Version data entries
3 entries across 3 versions & 1 rubygems