Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PouchDB & Leaflet & Google Drive</title>
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" ></script>
    <script src="http://cdn.kendostatic.com/2013.1.514/js/kendo.all.min.js"></script>
    <script src="https://googledrive.com/host/0B2Ay-nw1QSW2SHhjR0VBZXE2bUU/PouchTest/pouchdb-nightly.js"></script>
    <script src="https://googledrive.com/host/0B2Ay-nw1QSW2SHhjR0VBZXE2bUU/Leaflet/leaflet.js"></script>
    <script src="https://googledrive.com/host/0B2Ay-nw1QSW2SHhjR0VBZXE2bUU/Leaflet/L.FunctionalLayer.js"></script>
    <link href="http://cdn.kendostatic.com/2013.1.514/styles/kendo.common.min.css" rel="stylesheet" />
    <link href="http://cdn.kendostatic.com/2013.1.514/styles/kendo.metroblack.min.css" rel="stylesheet" />
    <link href="http://cdn.kendostatic.com/2013.1.514/styles/kendo.dataviz.metroblack.min.css" rel="stylesheet" />
    <link href="https://googledrive.com/host/0B2Ay-nw1QSW2SHhjR0VBZXE2bUU/Leaflet/leaflet.css" rel="stylesheet" />
</head>
<body>
    <div id="map"></div>
    <div id="commands">
        <div class="CSSTableGenerator">
            <table>
                <tr>
                    <td>Status
                    </td>
                    <td data-bind="text: status">xxx
                    </td>
                </tr>
                <tr>
                    <td>DB Manifest:
                    </td>
                    <td data-bind="text: dbManifest">xxx
                    </td>
                </tr>
                <tr>
                    <td>Tile Count:
                    </td>
                    <td data-bind="text: tileCount">xxx
                    </td>
                </tr>
            </table>
        </div>
    </div>
</body>
</html>
              
            
!

CSS

              
                html
{
    font: 14px "Verdana", "Helvetica", sans-serif;
    margin: 0px;
    height: 100%;
    background-image: linear-gradient(bottom, rgb(83,181,217) 17%, rgb(147,208,219) 59%);
    background-image: -o-linear-gradient(bottom, rgb(83,181,217) 17%, rgb(147,208,219) 59%);
    background-image: -moz-linear-gradient(bottom, rgb(83,181,217) 17%, rgb(147,208,219) 59%);
    background-image: -webkit-linear-gradient(bottom, rgb(83,181,217) 17%, rgb(147,208,219) 59%);
    background-image: -ms-linear-gradient(bottom, rgb(83,181,217) 17%, rgb(147,208,219) 59%);
    background-image: -webkit-gradient( linear, left bottom, left top, color-stop(0.17, rgb(83,181,217)), color-stop(0.59, rgb(147,208,219)) );
}

html
{
    margin: 0px;
    height: 100%;
}

body
{
    margin: 0px;
    height: 100%;
}

#commands
{
    position: absolute;
    top: 15px;
    left: 50px;
    padding: 3px;
    border-style: solid;
    border-width: 1px;
    border-color: black;
}

#map
{
    padding: 0px;
    height: 100%;
}


.gap
{
    display: block;
    height: 10px;
}

.shadow
{
    box-shadow: 0 1px 7px rgba(0, 0, 0, 0.65);
}

TableGenerat

.CSSTableGenerator


.CSSTableGenerator
{
    margin: 0px;
    padding: 0px;
    width:  1p%;
    box-shadow: 0 1px 7px rgba(0, 0, 0, 0.65);
    border: 1px solid #000000;
    -moz-border-radius-bottomleft: 0px;
    -webkit-border-bottom-left-radius: 0px;
    border-bottom-left-radius: 0px;
    -moz-border-radius-bottomright: 0px;
    -webkit-border-bottom-right-radius: 0px;
    border-bottom-right-radius: 0px;
    -moz-border-radius-topright: 0px;
    -webkit-border-top-right-radius: 0px;
    border-top-right-radius: 0px;
    -moz-border-radius-topleft: 0px;
    -webkit-border-top-left-radius: 0px;
    border-top-left-radius: 0px;
}

    .CSSTableGenerator table
    {
        width: 100%;
        height: 100%;
        margin: 0px;
        padding: 0px;
    }

    .CSSTableGenerator tr:last-child td:last-child
    {
        -moz-border-radius-bottomright: 0px;
        -webkit-border-bottom-right-radius: 0px;
        border-bottom-right-radius: 0px;
    }

    .CSSTableGenerator table tr:first-child td:first-child
    {
        -moz-border-radius-topleft: 0px;
        -webkit-border-top-left-radius: 0px;
        border-top-left-radius: 0px;
    }

    .CSSTableGenerator table tr:first-child td:last-child
    {
        -moz-border-radius-topright: 0px;
        -webkit-border-top-right-radius: 0px;
        border-top-right-radius: 0px;
    }

    .CSSTableGenerator tr:last-child td:first-child
    {
        -moz-border-radius-bottomleft: 0px;
        -webkit-border-bottom-left-radius: 0px;
        border-bottom-left-radius: 0px;
    }

    .CSSTableGenerator tr:hover td
    {
    }

    .CSSTableGenerator tr:nth-child(odd)
    {
        background-color: #aad4ff;
    }

    .CSSTableGenerator tr:nth-child(even)
    {
        background-color: #ffffff;
    }

    .CSSTableGenerator td
    {
        vertical-align: middle;
        border: 1px solid #000000;
        border-width: 0px 1px 1px 0px;
        text-align: left;
        padding: 8px;
        font-size: 14px;
        font-family: Verdana;
        font-weight: normal;
        color: #000000;
    }

    .CSSTableGenerator tr:last-child td
    {
        border-width: 0px 1px 0px 0px;
    }

    .CSSTableGenerator tr td:last-child
    {
        border-width: 0px 0px 1px 0px;
    }

    .CSSTableGenerator tr:last-child td:last-child
    {
        border-width: 0px 0px 0px 0px;
    }

    .CSSTableGenerator tr:first-child td
    {
        background: -o-linear-gradient(bottom, #005fbf 5%, #003f7f 100%);
        background: -webkit-gradient( linear, left top, left bottom, color-stop(0.05, #005fbf), color-stop(1, #003f7f) );
        background: -moz-linear-gradient( center top, #005fbf 5%, #003f7f 100% );
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#005fbf", endColorstr="#003f7f");
        background: -o-linear-gradient(top,#005fbf,003f7f);
        background-color: #005fbf;
        border: 0px solid #000000;
        text-align: center;
        border-width: 0px 0px 1px 1px;
        font-size: 16px;
        font-family: Verdana;
        font-weight: bold;
        color: #ffffff;
    }

    .CSSTableGenerator tr:first-child:hover td
    {
        background: -o-linear-gradient(bottom, #005fbf 5%, #003f7f 100%);
        background: -webkit-gradient( linear, left top, left bottom, color-stop(0.05, #005fbf), color-stop(1, #003f7f) );
        background: -moz-linear-gradient( center top, #005fbf 5%, #003f7f 100% );
        filter: progid:DXImageTransform.Microsoft.gradient(startColorstr="#005fbf", endColorstr="#003f7f");
        background: -o-linear-gradient(top,#005fbf,003f7f);
        background-color: #005fbf;
    }

    .CSSTableGenerator tr:first-child td:first-child
    {
        border-width: 0px 0px 1px 0px;
    }

    .CSSTableGenerator tr:first-child td:last-child
    {
        border-width: 0px 0px 1px 1px;
    }

              
            
!

JS

              
                // executed when all js and css is loaded (i.e. document ready event)

var DBNAME = "MapTiles";
var DB = null;
var manifest = null;
var vm = null;
var fetchCnt = 0;
var imageType = "png";
var MAP = null;
var BaseLayers = {};
var OverLayers = {};

window.indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
if (!window.indexedDB) {
    window.alert("Your browser doesn't support a stable version of IndexedDB.");
}

$(function () {
    makeVM();
    vm.set("status", "DB Check");
    openDB();
    setup();
});

function makeVM() {
    vm = kendo.observable({
        status: "Initializing",
        dbManifest: false,
        tileCount: 0,
        startTime: "",
        fetchTime: "0",
        blobCount: 0,
        totalTime: "0",
        blobRate: 0
    });
    kendo.bind(document.body, vm);
}

function setup() {
    initMap();
    baseMap();
    dbMap();
    addControls();
}

function openDB() {
    DB = Pouch(DBNAME);
    DB.get("MANIFEST", function (err, doc) {
        if (err) {
            console.log("Manifest fetch error: " + err.error + " reason: " + err.reason + " status: " + err.status);
            manifest = null;
            vm.set("dbManifest", false);
        } else {
            manifest = doc.data;
            vm.set("dbManifest", true);
            vm.set("tileCount", manifest.files.length);
            vm.set("status", "Ready");
        }
    });
}

function debug() {
    alert("debug");
}

function initMap() {
    var krakow = new L.LatLng(50.056, 19.937);
    var mapOptions = {
        center: krakow,
        zoom: 4,
        crs: L.CRS.EPSG3857,
        attributionControl: true,
    };
    MAP = L.map('map', mapOptions);
}

function baseMap() {
    var label = {};
    var layer = L.tileLayer("http://{s}.tile.cloudmade.com/9c844409f5b845ae93ac38388077f90a/997/256/{z}/{x}/{y}.png", {
        attribution: 'CloudMade OSM'
    });
    MAP.addLayer(layer);
    label["OSM"] = layer;
    $.extend(BaseLayers, label);
}

function dbMap() {
    var label = {};
    var settings = {
        tms: false,
        opacity: 0.6,
        errorTileUrl: "./images/EmptyTile.png"
    };
    var layer = new L.TileLayer.Functional(function (view) {
        var deferred = new jQuery.Deferred(); // this is what gets returned
        var id = view.zoom + "-" + view.tile.column + "-" + view.tile.row;
        DB.getAttachment(id + "/pic", function (err, response) {
            if (err) {
                console.warn("Could find blob id: ", id, " error: ", err.error, " reason: ", err.reason, " status: ", err.status);
            } else {
                var blob = response;
                var imgURL = URL.createObjectURL(blob);
                deferred.resolve(imgURL); // let leaflet know we're done, and give it the URL
                URL.revokeObjectURL(imgURL); // not sure if we're revoking it too soon here
            }
        });
        return deferred;
    }, settings);
    MAP.addLayer(layer);
    label["Pouch DB"] = layer;
    $.extend(OverLayers, label);
}

function addControls() {
    var layersControl = new L.Control.Layers(BaseLayers, OverLayers);
    MAP.addControl(layersControl);
}


function ms2Time(ms) {
    var secs = ms / 1000;
    ms = Math.floor(ms % 1000);
    var minutes = secs / 60;
    secs = Math.floor(secs % 60);
    var hours = minutes / 60;
    minutes = Math.floor(minutes % 60);
    hours = Math.floor(hours % 24);
    return hours + ":" + minutes + ":" + secs + "." + ms;
}
              
            
!
999px

Console