JSFiddle - React, Tailwind, and code Playground

by acarlon

HTML

<button onclick="storeAndShowIt();">Store and show it!</button>
<button onclick="showIt();">Show It!</button>

CSS

body
{
    background:black;
}

JavaScript

// ReSharper disable once UnusedParameter
(function(bb, undefined)
{    
    bb.PersistentImages = function()
    {
        this.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
        this.idbTransaction = window.IDBTransaction || window.webkitIDBTransaction || window.msIDBTransaction;
        this.idbKeyRange = window.IDBKeyRange || window.wekbitIDBKeyRange || window.msIDBKeyRange;
        this.db = null;        
        this.dbName = "testFiddleDBxyza";
        this.objectStoreName = "testFiddleObjxyza";
    };
    bb.PersistentImages.prototype.open = function( completion )
    {
        var that = this;
        var request = this.indexedDB.open( this.dbName, 1 );
        request.onerror = function(event)
        {
            console.log( "error opening DB", event );
            completion();
        };
        request.onsuccess = function()
        {
            that.db = request.result;
            completion();
        };
        request.onupgradeneeded = function( event )
        {
            var db = event.currentTarget.result;                        
//db.deleteObjectStore( persistentImageSizeString + persistentStashString + bb.PersistentImageTag );
            var objectStore = db.createObjectStore( that.objectStoreName, { keyPath: 'ItemId', autoIncrement: false } );                    
            objectStore.createIndex( 'Image', 'Image', { unique: false } );
        };
    };
    bb.PersistentImages.prototype.close = function()
    {
        this.db.close();
    };
    bb.PersistentImages.prototype.get = function( itemId, completion )
    {        
        var transaction = this.db.transaction( [this.objectStoreName], "readonly" );        
        var objectStore = transaction.objectStore( this.objectStoreName );      
        var request = objectStore.get( itemId );        
        request.onsuccess = function()
        {
            var blob = null;            
            var record =...