<commit_before>/*jslint browser: true, for: true */
/*global dashjs, flowplayer, MediaPlayer, window */

/*!

   MPEG-DASH engine plugin for Flowplayer HTML5

   Copyright (c) 2015-2016, Flowplayer Oy

   Released under the MIT License:
   http://www.opensource.org/licenses/mit-license.php

   Includes hls.js
   Copyright (c) 2015 Dailymotion (http://www.dailymotion.com)
   https://github.com/dailymotion/hls.js/blob/master/LICENSE

   Includes es5.js
   https://github.com/inexorabletash/polyfill/blob/master/es5.js
   for compatibility with legacy browsers

   Requires Flowplayer HTML5 version 6.x
   $GIT_DESC$

*/
(function () {
    "use strict";
    var extension = function (dashjs, flowplayer) {
        var engineName = "dash",
            mse = window.MediaSource || window.WebKitMediaSource,
            common = flowplayer.common,
            extend = flowplayer.extend,
            version = flowplayer.version,
            coreV6 = version.indexOf("6.") === 0,
            dashconf,

            dashCanPlay = function (sourceType, dashType, dashCodecs) {
                return sourceType.toLowerCase() === "application/dash+xml" &&
                        mse.isTypeSupported(dashType + ';codecs="' + dashCodecs + '"') &&
                        // Android MSE advertises he-aac, but fails
                        (dashCodecs.indexOf("mp4a.40.5") < 0 || navigator.userAgent.indexOf("Android") < 0);
            },

            engineImpl = function dashjsEngine(player, root) {
                var bean = flowplayer.bean,
                    mediaPlayer,
                    videoTag,
                    bc,
                    has_bg,

                    engine = {
                        engineName: engineName,

                        pick: function (sources) {
                            var i,
                                source,
                                dashType,
                                dashCodecs;

                            for (i = 0; i < sources.length; i += 1) {
                                source = sources[i];
                                dashType = source.dashType || dashconf.type;
                                dashCodecs = source.dashCodecs || dashconf.codecs;
                                if (dashCanPlay(source.type, dashType, dashCodecs)) {
                                    if (typeof source.src === 'string') {
                                        source.src = common.createAbsoluteUrl(source.src);
                                    }
                                    return source;
                                }
                            }
                        },

                        load: function (video) {
                            var conf = player.conf,
                                dashUpdatedConf = extend(dashconf, conf.dash, conf.clip.dash),
                                EVENTS = {
                                    ended: "finish",
                                    loadeddata: "ready",
                                    pause: "pause",
                                    play: "resume",
                                    progress: "buffer",
                                    ratechange: "speed",
                                    seeked: "seek",
                                    timeupdate: "progress",
                                    volumechange: "volume"
                                },
                                DASHEVENTS = dashjs.MediaPlayer.events,
                                autoplay = !!video.autoplay || !!conf.autoplay,
                                posterClass = "is-poster",
                                livestartpos = 0;

                            if (!mediaPlayer) {
                                videoTag = common.findDirect("video", root)[0]
                                        || common.find(".fp-player > video", root)[0];

                                if (videoTag) {
                                    // destroy video tag
                                    // otherwise <video autoplay> continues to play
                                    common.find("source", videoTag).forEach(function (source) {
                                        source.removeAttribute("src");
                                    });
                                    videoTag.removeAttribute("src");
                                    videoTag.load();
                                    common.removeNode(videoTag);
                                }

                                // dash.js enforces preload="auto" and
                                // autoplay depending on initialization
                                // so setting the attributes here will have no effect
                                videoTag = common.createElement("video", {
                                    "class": "fp-engine " + engineName + "-engine",
                                    "volume": player.volumeLevel,
                                    "x-webkit-airplay": "allow"
                                });

                                Object.keys(EVENTS).forEach(function (key) {
                                    var flow = EVENTS[key],
                                        type = key + "." + engineName,
                                        arg;

                                    bean.on(videoTag, type, function (e) {
                                        if (conf.debug && flow.indexOf("progress") < 0) {
                                            console.log(type, "->", flow, e.originalEvent);
                                        }

                                        var ct = videoTag.currentTime,
                                            mct = mediaPlayer.time(),
                                            buffer = 0,
                                            buffend = 0,
                                            buffered,
                                            i;

                                        switch (flow) {
                                        case "ready":
                                            arg = extend(player.video, {
                                                duration: mediaPlayer.duration(),
                                                seekable: videoTag.seekable.end(null),
                                                width: videoTag.videoWidth,
                                                height: videoTag.videoHeight,
                                                url: player.video.src
                                            });
                                            break;
                                        case "resume":
                                            if (coreV6 && player.poster) {
                                                common.removeClass(root, posterClass);
                                                player.poster = false;
                                            }
                                            break;
                                        case "seek":
                                            arg = mct;
                                            break;
                                        case "progress":
                                            if (player.live && !player.dvr && !livestartpos && ct > 0) {
                                                livestartpos = ct;
                                            }
                                            arg = (player.dvr || !player.live)
                                                ? mct
                                                : livestartpos
                                                    ? ct - livestartpos
                                                    : 0;
                                            break;
                                        case "speed":
                                            arg = videoTag.playbackRate;
                                            break;
                                        case "volume":
                                            arg = videoTag.volume;
                                            break;
                                        case "buffer":
                                            try {
                                                // cycle through time ranges to obtain buffer
                                                // nearest current time
                                                if (mct) {
                                                    buffered = videoTag.buffered;
                                                    for (i = buffered.length - 1; i > -1; i -= 1) {
                                                        buffend = buffered.end(i);

                                                        if (buffend >= mct) {
                                                            buffer = buffend;
                                                        }
                                                    }
                                                }
                                            } catch (ignore) {}
                                            video.buffer = buffer;
                                            arg = buffer;
                                            break;
                                        }

                                        player.trigger(flow, [player, arg]);
                                    });
                                });

                                if (coreV6 && conf.poster) {
                                    var posterHack = function (e) {
                                        if (e.type === "stop" || !autoplay) {
                                            setTimeout(function () {
                                                if (!player.poster) {
                                                    common.addClass(root, posterClass);
                                                    player.poster = true;
                                                }
                                            });
                                        }
                                    };

                                    player.one("ready." + engineName, posterHack).on("stop." + engineName, posterHack);
                                }
                                player.on("error." + engineName, function () {
                                    if (mediaPlayer) {
                                        mediaPlayer.reset();
                                        mediaPlayer = 0;
                                    }
                                });

                                mediaPlayer = dashjs.MediaPlayer().create();
                                player.engine[engineName] = mediaPlayer;

                                // new ABR algo
                                mediaPlayer.enableBufferOccupancyABR(dashUpdatedConf.bufferOccupancyABR);
                                // caching can cause failures in playlists
                                // for the moment disable entirely
                                mediaPlayer.enableLastBitrateCaching(false);
                                // for seeking in paused state
                                mediaPlayer.setScheduleWhilePaused(true);
                                mediaPlayer.getDebug().setLogToBrowserConsole(dashUpdatedConf.debug);

                                Object.keys(DASHEVENTS).forEach(function (key) {
                                    var etype = DASHEVENTS[key],
                                        fpEventType = engineName + etype.charAt(0).toUpperCase() + etype.slice(1),
                                        listeners = dashUpdatedConf.listeners,
                                        expose = listeners && listeners.indexOf(fpEventType) > -1;

                                    mediaPlayer.on(etype, function (e) {
                                        var data = extend({}, e),
                                            src = player.video.src,
                                            fperr,
                                            errobj;

                                        delete data.type;
                                        switch (key) {
                                        case "ERROR":
                                            switch (data.error) {
                                            case "download":
                                                fperr = 4;
                                                break;
                                            case "manifestError":
                                                fperr = 5;
                                                break;
                                            case "mediasource":
                                                switch (e.event) {
                                                case "MEDIA_ERR_DECODE":
                                                    fperr = 3;
                                                    break;
                                                case "MEDIA_ERR_SRC_NOT_SUPPORTED":
                                                    fperr = 5;
                                                    break;
                                                case "MEDIA_ERR_NETWORK":
                                                    fperr = 2;
                                                    break;
                                                case "MEDIA_ERR_ABORTED":
                                                    fperr = 1;
                                                    break;
                                                }
                                                break;
                                            }
                                            if (fperr) {
                                                errobj = {code: fperr};
                                                if (fperr > 2) {
                                                    errobj.video = extend(video, {
                                                        src: src,
                                                        url: data.event.url || src
                                                    });
                                                }
                                                player.trigger('error', [player, errobj]);
                                                return;
                                            }
                                            break;
                                        }

                                        if (expose) {
                                            player.trigger(fpEventType, [player, data]);
                                        }
                                    });
                                });

                                common.prepend(common.find(".fp-player", root)[0], videoTag);
                                mediaPlayer.initialize(videoTag, video.src, autoplay);

                            } else {
                                if ((player.video.src && video.src !== player.video.src) || video.index) {
                                    mediaPlayer.setAutoPlay(true);
                                }
                                mediaPlayer.attachSource(video.src);

                            }

                            // update video object before ready
                            player.video = video;

                            // devices not allowing autoplay:
                            // detect videoTag.paused and nudge videoTag
                            // to avoid complaint about lacking user gesture
                            // before initializing dashjs playback
                            if (videoTag.paused && autoplay) {
                                if (flowplayer.support.firstframe) {
                                    mediaPlayer.play();
                                } else {
                                    videoTag.play();
                                    videoTag.pause();
                                    mediaPlayer.play();
                                }
                            }
                        },

                        resume: function () {
                            mediaPlayer.play();
                        },

                        pause: function () {
                            mediaPlayer.pause();
                        },

                        seek: function (time) {
                            mediaPlayer.seek(time);
                        },

                        volume: function (level) {
                            if (videoTag) {
                                videoTag.volume = level;
                            }
                        },

                        speed: function (val) {
                            videoTag.playbackRate = val;
                            player.trigger('speed', [player, val]);
                        },

                        unload: function () {
                            if (mediaPlayer) {
                                var listeners = "." + engineName;

                                mediaPlayer.reset();
                                mediaPlayer = 0;
                                player.off(listeners);
                                bean.off(root, listeners);
                                bean.off(videoTag, listeners);
                                common.removeNode(videoTag);
                                videoTag = 0;
                            }
                        }
                    };

                // pre 6.0.4: no boolean api.conf.poster and no poster with autoplay
                if (/^6\.0\.[0-3]$/.test(version) &&
                        !player.conf.splash && !player.conf.poster && !player.conf.autoplay) {
                    bc = common.css(root, 'backgroundColor');
                    // spaces in rgba arg mandatory for recognition
                    has_bg = common.css(root, 'backgroundImage') !== "none" ||
                            (bc && bc !== "rgba(0, 0, 0, 0)" && bc !== "transparent");
                    if (has_bg) {
                        player.conf.poster = true;
                    }
                }

                return engine;
            };

        if (mse && typeof mse.isTypeSupported === "function" && version.indexOf("5.") !== 0) {
            // only load engine if it can be used
            engineImpl.engineName = engineName; // must be exposed
            engineImpl.canPlay = function (type, conf) {
                /*
                  WARNING: MediaSource.isTypeSupported very inconsistent!
                  e.g. Safari ignores codecs entirely, even bogus, like codecs="XYZ"
                  example avc3 main level 3.1 + aac_he: avc3.4d401f; mp4a.40.5
                  example avc1 high level 4.1 + aac_lc: avc1.640029; mp4a.40.2
                  default: avc1 baseline level 3.0 + aac_lc
                */
                // inject dash conf at earliest opportunity
                dashconf = extend({
                    type: "video/mp4",
                    codecs: "avc1.42c01e,mp4a.40.2"
                }, flowplayer.conf[engineName], conf[engineName], conf.clip[engineName]);

                return dashCanPlay(type, dashconf.type, dashconf.codecs);
            };

            // put on top of engine stack
            // so mpegedash is tested before html5
            flowplayer.engines.unshift(engineImpl);

        }

    };
    if (typeof module === 'object' && module.exports) {
        module.exports = extension.bind(undefined, require('dashjs'));
    } else if (window.dashjs && window.flowplayer) {
        extension(window.dashjs, window.flowplayer);
    }
}());
<commit_msg>Update company name in header, remove obsolete mention of es5 shim<commit_after>/*jslint browser: true, for: true */
/*global dashjs, flowplayer, MediaPlayer, window */

/*!

   MPEG-DASH engine plugin for Flowplayer HTML5

   Copyright (c) 2015-2016, Flowplayer Drive Oy

   Released under the MIT License:
   http://www.opensource.org/licenses/mit-license.php

   Includes hls.js
   Copyright (c) 2015 Dailymotion (http://www.dailymotion.com)
   https://github.com/dailymotion/hls.js/blob/master/LICENSE

   Requires Flowplayer HTML5 version 6.x
   $GIT_DESC$

*/
(function () {
    "use strict";
    var extension = function (dashjs, flowplayer) {
        var engineName = "dash",
            mse = window.MediaSource || window.WebKitMediaSource,
            common = flowplayer.common,
            extend = flowplayer.extend,
            version = flowplayer.version,
            coreV6 = version.indexOf("6.") === 0,
            dashconf,

            dashCanPlay = function (sourceType, dashType, dashCodecs) {
                return sourceType.toLowerCase() === "application/dash+xml" &&
                        mse.isTypeSupported(dashType + ';codecs="' + dashCodecs + '"') &&
                        // Android MSE advertises he-aac, but fails
                        (dashCodecs.indexOf("mp4a.40.5") < 0 || navigator.userAgent.indexOf("Android") < 0);
            },

            engineImpl = function dashjsEngine(player, root) {
                var bean = flowplayer.bean,
                    mediaPlayer,
                    videoTag,
                    bc,
                    has_bg,

                    engine = {
                        engineName: engineName,

                        pick: function (sources) {
                            var i,
                                source,
                                dashType,
                                dashCodecs;

                            for (i = 0; i < sources.length; i += 1) {
                                source = sources[i];
                                dashType = source.dashType || dashconf.type;
                                dashCodecs = source.dashCodecs || dashconf.codecs;
                                if (dashCanPlay(source.type, dashType, dashCodecs)) {
                                    if (typeof source.src === 'string') {
                                        source.src = common.createAbsoluteUrl(source.src);
                                    }
                                    return source;
                                }
                            }
                        },

                        load: function (video) {
                            var conf = player.conf,
                                dashUpdatedConf = extend(dashconf, conf.dash, conf.clip.dash),
                                EVENTS = {
                                    ended: "finish",
                                    loadeddata: "ready",
                                    pause: "pause",
                                    play: "resume",
                                    progress: "buffer",
                                    ratechange: "speed",
                                    seeked: "seek",
                                    timeupdate: "progress",
                                    volumechange: "volume"
                                },
                                DASHEVENTS = dashjs.MediaPlayer.events,
                                autoplay = !!video.autoplay || !!conf.autoplay,
                                posterClass = "is-poster",
                                livestartpos = 0;

                            if (!mediaPlayer) {
                                videoTag = common.findDirect("video", root)[0]
                                        || common.find(".fp-player > video", root)[0];

                                if (videoTag) {
                                    // destroy video tag
                                    // otherwise <video autoplay> continues to play
                                    common.find("source", videoTag).forEach(function (source) {
                                        source.removeAttribute("src");
                                    });
                                    videoTag.removeAttribute("src");
                                    videoTag.load();
                                    common.removeNode(videoTag);
                                }

                                // dash.js enforces preload="auto" and
                                // autoplay depending on initialization
                                // so setting the attributes here will have no effect
                                videoTag = common.createElement("video", {
                                    "class": "fp-engine " + engineName + "-engine",
                                    "volume": player.volumeLevel,
                                    "x-webkit-airplay": "allow"
                                });

                                Object.keys(EVENTS).forEach(function (key) {
                                    var flow = EVENTS[key],
                                        type = key + "." + engineName,
                                        arg;

                                    bean.on(videoTag, type, function (e) {
                                        if (conf.debug && flow.indexOf("progress") < 0) {
                                            console.log(type, "->", flow, e.originalEvent);
                                        }

                                        var ct = videoTag.currentTime,
                                            mct = mediaPlayer.time(),
                                            buffer = 0,
                                            buffend = 0,
                                            buffered,
                                            i;

                                        switch (flow) {
                                        case "ready":
                                            arg = extend(player.video, {
                                                duration: mediaPlayer.duration(),
                                                seekable: videoTag.seekable.end(null),
                                                width: videoTag.videoWidth,
                                                height: videoTag.videoHeight,
                                                url: player.video.src
                                            });
                                            break;
                                        case "resume":
                                            if (coreV6 && player.poster) {
                                                common.removeClass(root, posterClass);
                                                player.poster = false;
                                            }
                                            break;
                                        case "seek":
                                            arg = mct;
                                            break;
                                        case "progress":
                                            if (player.live && !player.dvr && !livestartpos && ct > 0) {
                                                livestartpos = ct;
                                            }
                                            arg = (player.dvr || !player.live)
                                                ? mct
                                                : livestartpos
                                                    ? ct - livestartpos
                                                    : 0;
                                            break;
                                        case "speed":
                                            arg = videoTag.playbackRate;
                                            break;
                                        case "volume":
                                            arg = videoTag.volume;
                                            break;
                                        case "buffer":
                                            try {
                                                // cycle through time ranges to obtain buffer
                                                // nearest current time
                                                if (mct) {
                                                    buffered = videoTag.buffered;
                                                    for (i = buffered.length - 1; i > -1; i -= 1) {
                                                        buffend = buffered.end(i);

                                                        if (buffend >= mct) {
                                                            buffer = buffend;
                                                        }
                                                    }
                                                }
                                            } catch (ignore) {}
                                            video.buffer = buffer;
                                            arg = buffer;
                                            break;
                                        }

                                        player.trigger(flow, [player, arg]);
                                    });
                                });

                                if (coreV6 && conf.poster) {
                                    var posterHack = function (e) {
                                        if (e.type === "stop" || !autoplay) {
                                            setTimeout(function () {
                                                if (!player.poster) {
                                                    common.addClass(root, posterClass);
                                                    player.poster = true;
                                                }
                                            });
                                        }
                                    };

                                    player.one("ready." + engineName, posterHack).on("stop." + engineName, posterHack);
                                }
                                player.on("error." + engineName, function () {
                                    if (mediaPlayer) {
                                        mediaPlayer.reset();
                                        mediaPlayer = 0;
                                    }
                                });

                                mediaPlayer = dashjs.MediaPlayer().create();
                                player.engine[engineName] = mediaPlayer;

                                // new ABR algo
                                mediaPlayer.enableBufferOccupancyABR(dashUpdatedConf.bufferOccupancyABR);
                                // caching can cause failures in playlists
                                // for the moment disable entirely
                                mediaPlayer.enableLastBitrateCaching(false);
                                // for seeking in paused state
                                mediaPlayer.setScheduleWhilePaused(true);
                                mediaPlayer.getDebug().setLogToBrowserConsole(dashUpdatedConf.debug);

                                Object.keys(DASHEVENTS).forEach(function (key) {
                                    var etype = DASHEVENTS[key],
                                        fpEventType = engineName + etype.charAt(0).toUpperCase() + etype.slice(1),
                                        listeners = dashUpdatedConf.listeners,
                                        expose = listeners && listeners.indexOf(fpEventType) > -1;

                                    mediaPlayer.on(etype, function (e) {
                                        var data = extend({}, e),
                                            src = player.video.src,
                                            fperr,
                                            errobj;

                                        delete data.type;
                                        switch (key) {
                                        case "ERROR":
                                            switch (data.error) {
                                            case "download":
                                                fperr = 4;
                                                break;
                                            case "manifestError":
                                                fperr = 5;
                                                break;
                                            case "mediasource":
                                                switch (e.event) {
                                                case "MEDIA_ERR_DECODE":
                                                    fperr = 3;
                                                    break;
                                                case "MEDIA_ERR_SRC_NOT_SUPPORTED":
                                                    fperr = 5;
                                                    break;
                                                case "MEDIA_ERR_NETWORK":
                                                    fperr = 2;
                                                    break;
                                                case "MEDIA_ERR_ABORTED":
                                                    fperr = 1;
                                                    break;
                                                }
                                                break;
                                            }
                                            if (fperr) {
                                                errobj = {code: fperr};
                                                if (fperr > 2) {
                                                    errobj.video = extend(video, {
                                                        src: src,
                                                        url: data.event.url || src
                                                    });
                                                }
                                                player.trigger('error', [player, errobj]);
                                                return;
                                            }
                                            break;
                                        }

                                        if (expose) {
                                            player.trigger(fpEventType, [player, data]);
                                        }
                                    });
                                });

                                common.prepend(common.find(".fp-player", root)[0], videoTag);
                                mediaPlayer.initialize(videoTag, video.src, autoplay);

                            } else {
                                if ((player.video.src && video.src !== player.video.src) || video.index) {
                                    mediaPlayer.setAutoPlay(true);
                                }
                                mediaPlayer.attachSource(video.src);

                            }

                            // update video object before ready
                            player.video = video;

                            // devices not allowing autoplay:
                            // detect videoTag.paused and nudge videoTag
                            // to avoid complaint about lacking user gesture
                            // before initializing dashjs playback
                            if (videoTag.paused && autoplay) {
                                if (flowplayer.support.firstframe) {
                                    mediaPlayer.play();
                                } else {
                                    videoTag.play();
                                    videoTag.pause();
                                    mediaPlayer.play();
                                }
                            }
                        },

                        resume: function () {
                            mediaPlayer.play();
                        },

                        pause: function () {
                            mediaPlayer.pause();
                        },

                        seek: function (time) {
                            mediaPlayer.seek(time);
                        },

                        volume: function (level) {
                            if (videoTag) {
                                videoTag.volume = level;
                            }
                        },

                        speed: function (val) {
                            videoTag.playbackRate = val;
                            player.trigger('speed', [player, val]);
                        },

                        unload: function () {
                            if (mediaPlayer) {
                                var listeners = "." + engineName;

                                mediaPlayer.reset();
                                mediaPlayer = 0;
                                player.off(listeners);
                                bean.off(root, listeners);
                                bean.off(videoTag, listeners);
                                common.removeNode(videoTag);
                                videoTag = 0;
                            }
                        }
                    };

                // pre 6.0.4: no boolean api.conf.poster and no poster with autoplay
                if (/^6\.0\.[0-3]$/.test(version) &&
                        !player.conf.splash && !player.conf.poster && !player.conf.autoplay) {
                    bc = common.css(root, 'backgroundColor');
                    // spaces in rgba arg mandatory for recognition
                    has_bg = common.css(root, 'backgroundImage') !== "none" ||
                            (bc && bc !== "rgba(0, 0, 0, 0)" && bc !== "transparent");
                    if (has_bg) {
                        player.conf.poster = true;
                    }
                }

                return engine;
            };

        if (mse && typeof mse.isTypeSupported === "function" && version.indexOf("5.") !== 0) {
            // only load engine if it can be used
            engineImpl.engineName = engineName; // must be exposed
            engineImpl.canPlay = function (type, conf) {
                /*
                  WARNING: MediaSource.isTypeSupported very inconsistent!
                  e.g. Safari ignores codecs entirely, even bogus, like codecs="XYZ"
                  example avc3 main level 3.1 + aac_he: avc3.4d401f; mp4a.40.5
                  example avc1 high level 4.1 + aac_lc: avc1.640029; mp4a.40.2
                  default: avc1 baseline level 3.0 + aac_lc
                */
                // inject dash conf at earliest opportunity
                dashconf = extend({
                    type: "video/mp4",
                    codecs: "avc1.42c01e,mp4a.40.2"
                }, flowplayer.conf[engineName], conf[engineName], conf.clip[engineName]);

                return dashCanPlay(type, dashconf.type, dashconf.codecs);
            };

            // put on top of engine stack
            // so mpegedash is tested before html5
            flowplayer.engines.unshift(engineImpl);

        }

    };
    if (typeof module === 'object' && module.exports) {
        module.exports = extension.bind(undefined, require('dashjs'));
    } else if (window.dashjs && window.flowplayer) {
        extension(window.dashjs, window.flowplayer);
    }
}());
<|endoftext|>


<commit_before>'use strict';

var clear          = require('es5-ext/array/#/clear')
  , assign         = require('es5-ext/object/assign')
  , normalizeOpts  = require('es5-ext/object/normalize-options')
  , Set            = require('es6-set')
  , d              = require('d')
  , autoBind       = require('d/auto-bind')
  , lazy           = require('d/lazy')
  , memoizeMethods = require('memoizee/methods-plain')
  , replaceContent = require('dom-ext/element/#/replace-content')
  , DOMCheckbox    = require('../_controls/checkbox')
  , toIdent        = require('../utils/to-ident')
  , DOMInput       = require('./')

  , map = Array.prototype.map
  , notSupported = function () { throw new Error('Not supported'); }

  , DOMMultiple;

module.exports = DOMMultiple = function (document, type/*, options*/) {
	var options = Object(arguments[2]);
	DOMInput.call(this, document, type, options);
	this.itemOptions = Object(options.items);
	this.listItemIdPrefix = options.listItemIdPrefix;
	this.allItems = [];
	this.reload();
};

DOMMultiple.prototype = Object.create(DOMInput.prototype, assign({
	constructor: d(DOMMultiple),
	onChange: d(function () {
		var value, changed, valid, emitChanged, emitValid;
		value = this.value;
		changed = this.items.some(function (item) { return item.changed; });
		valid = this.required ? Boolean(value.length) : true;

		if (this.changed !== changed) {
			this.changed = changed;
			emitChanged = true;
		}
		if (this.valid !== valid) {
			this.valid = valid;
			emitValid = true;
		}

		this.emit('change', value);
		if (emitChanged) this.emit('change:changed', this.changed);
		if (emitValid) this.emit('change:valid', this.valid);
	}),
	inputValue: d.gs(function () {
		return this.items.map(function (item) { return item.value; })
			.filter(Boolean);
	}, function (value) {
		if (value == null) value = new Set();
		this._value = value;
		this.allItems.forEach(function (item) {
			var obj = this.type.fromInputValue(item.control.value);
			item.value = value.has(obj) ? obj : null;
		}, this);
		this.onChange();
	}),
	_render: d(function () {
		this.dom = this.document.createElement('ul');
		this.dom.className = 'dbjs multiple';
	}),
	safeRemoveItem: d(notSupported),
	addItem: d(notSupported),
	removeItem: d(notSupported)
}, lazy({
	markEmpty: d(function () {
		return this.make('input', { type: 'hidden', value: '', name: this.name });
	})
}), autoBind({
	reload: d(function () {
		clear.call(this.items);
		replaceContent.call(this.dom, map.call(this.dbList, function (item) {
			var data = this.renderItem(item.value, item.label);
			this.items.push(data.input);
			return data.dom;
		}, this), this.markEmpty);
		this.items.push(this.markEmpty);
	})
}), memoizeMethods({
	renderItem: d(function (value, label) {
		var el = this.make, input, dom, options, itemAttrs;
		options = this.itemOptions[value]
			? normalizeOpts(this.options, this.itemOptions[value]) : this.options;
		input = new DOMCheckbox(this.document, this.type, options);
		if (this.listItemIdPrefix) itemAttrs = { id: this.listItemIdPrefix + toIdent(value) };
		dom = el('li', itemAttrs, el('label', input, " ", label));

		if (this.name) input.name = this.name;
		input.parent = this;
		input.listItem = dom;
		input.control.setAttribute('value', value);
		input.on('change', this.onChange);
		this.allItems.push(input);
		return { dom: dom, input: input };
	})
})));
<commit_msg>Allow customizable renderItem<commit_after>'use strict';

var clear          = require('es5-ext/array/#/clear')
  , callable       = require('es5-ext/object/valid-callable')
  , assign         = require('es5-ext/object/assign')
  , normalizeOpts  = require('es5-ext/object/normalize-options')
  , Set            = require('es6-set')
  , d              = require('d')
  , autoBind       = require('d/auto-bind')
  , lazy           = require('d/lazy')
  , memoizeMethods = require('memoizee/methods-plain')
  , replaceContent = require('dom-ext/element/#/replace-content')
  , DOMCheckbox    = require('../_controls/checkbox')
  , toIdent        = require('../utils/to-ident')
  , DOMInput       = require('./')

  , map = Array.prototype.map
  , notSupported = function () { throw new Error('Not supported'); }

  , DOMMultiple;

module.exports = DOMMultiple = function (document, type/*, options*/) {
	var options = Object(arguments[2]);
	DOMInput.call(this, document, type, options);
	this.itemOptions = Object(options.items);
	if (options.renderItem !== undefined) this.customRenderItem = callable(options.renderItem);
	this.listItemIdPrefix = options.listItemIdPrefix;
	this.allItems = [];
	this.reload();
};

DOMMultiple.prototype = Object.create(DOMInput.prototype, assign({
	constructor: d(DOMMultiple),
	onChange: d(function () {
		var value, changed, valid, emitChanged, emitValid;
		value = this.value;
		changed = this.items.some(function (item) { return item.changed; });
		valid = this.required ? Boolean(value.length) : true;

		if (this.changed !== changed) {
			this.changed = changed;
			emitChanged = true;
		}
		if (this.valid !== valid) {
			this.valid = valid;
			emitValid = true;
		}

		this.emit('change', value);
		if (emitChanged) this.emit('change:changed', this.changed);
		if (emitValid) this.emit('change:valid', this.valid);
	}),
	inputValue: d.gs(function () {
		return this.items.map(function (item) { return item.value; })
			.filter(Boolean);
	}, function (value) {
		if (value == null) value = new Set();
		this._value = value;
		this.allItems.forEach(function (item) {
			var obj = this.type.fromInputValue(item.control.value);
			item.value = value.has(obj) ? obj : null;
		}, this);
		this.onChange();
	}),
	_render: d(function () {
		this.dom = this.document.createElement('ul');
		this.dom.className = 'dbjs multiple';
	}),
	safeRemoveItem: d(notSupported),
	addItem: d(notSupported),
	removeItem: d(notSupported)
}, lazy({
	markEmpty: d(function () {
		return this.make('input', { type: 'hidden', value: '', name: this.name });
	})
}), autoBind({
	reload: d(function () {
		clear.call(this.items);
		replaceContent.call(this.dom, map.call(this.dbList, function (item) {
			var data = this.renderItem(item.value, item.label);
			this.items.push(data.input);
			return data.dom;
		}, this), this.markEmpty);
		this.items.push(this.markEmpty);
	})
}), memoizeMethods({
	renderItem: d(function (value, label) {
		var el = this.make, input, dom, options, itemAttrs;
		options = this.itemOptions[value]
			? normalizeOpts(this.options, this.itemOptions[value]) : this.options;
		input = new DOMCheckbox(this.document, this.type, options);
		if (this.customRenderItem) {
			dom = this.customRenderItem(input);
			if (this.listItemIdPrefix) dom.id = this.listItemIdPrefix + toIdent(value);
		} else {
			if (this.listItemIdPrefix) itemAttrs = { id: this.listItemIdPrefix + toIdent(value) };
			dom = el('li', itemAttrs, el('label', input, " ", label));
		}

		if (this.name) input.name = this.name;
		input.parent = this;
		input.listItem = dom;
		input.control.setAttribute('value', value);
		input.on('change', this.onChange);
		this.allItems.push(input);
		return { dom: dom, input: input };
	})
})));
<|endoftext|>


<commit_before>const routes = {
  '/': 'Home',
  '/private': 'Area Privata',
  '/private/home': 'DAF - Data Analytics Framework',
  '/private/dashboard/list': 'Dashboard',
  '/private/userstory/list': 'Storie',
  '/private/ingestionform': 'Ingestion',
  '/private/vocabulary/list': 'Vocabolari e standard',
  '/private/dataset':'Dataset',
  '/private/widget' : 'Widget',
  '/private/search': 'Ricerca',
};
export default routes;
<commit_msg>Polish 'old-semantics' routes<commit_after>const routes = {
  '/': 'Home',
  '/private': 'Area Privata',
  '/private/home': 'DAF - Data Analytics Framework',
  '/private/dashboard/list': 'Dashboard',
  '/private/userstory/list': 'Storie',
  '/private/ingestionform': 'Ingestion',
  '/private/dataset':'Dataset',
  '/private/widget' : 'Widget',
  '/private/search': 'Ricerca',
};
export default routes;
<|endoftext|>


<commit_before>var m_rad = 5;
var marker_icon_path = 'M 0, 0 m -' + m_rad + ', 0 a ' + m_rad + ',' + m_rad + ' 0 1,0 ' + 2 * m_rad + ',0 a ' + m_rad + ',' + m_rad + ' 0 1,0 -' + 2 * m_rad + ',0';
var startTime = 0;
var DRONES = [];
var polylines = [];
var map;
var beacon_filter = [];
var clusters = [];

var cluster_styles =
    [
        [{
            url: 'http://localhost:8000/static/m1.png',
            width: 40,
            height: 40,
            textColor: '#ffffff',
            textSize: 11
        }],
        [{
            url: 'http://localhost:8000/static/m2.png',
            height: 40,
            width: 40,
            textColor: '#ffffff',
            textSize: 11
        }],
        [{
            url: 'http://localhost:8000/static/m3.png',
            height: 40,
            width: 40,
            textColor: '#525252',
            textSize: 11
        }],
        [{
            url: 'http://localhost:8000/static/m4.png',
            height: 40,
            width: 40,
            textColor: '#ffffff',
            textSize: 11
        }]
    ];

clearMarkers();

setInterval(
    function getPoint() {
        $.ajax({
            type: "GET",
            url: "http://localhost:8000/map/getData/?StartTime=" + startTime,
            dataType: "json",
            success: parseSuccess,
            error: errorHandler
        });
    }, 500);

function errorHandler(response, options, error) {
    console.error("Error while trying to retrieve beacon and drone data from server.");
    console.error(response);
    console.error(response.responseText);
    console.log(error);
}

function parseSuccess(response) {
    startTime = response.current_time;
    updateDrones(response.drones);
    addDronesPolyline(response.drones_positions);
    addBeaconPoints(response.beacons_positions);
    createClusters();
}

function median(values) {
    values.sort(function (a, b) {
        return a - b;
    });
    var half = Math.floor(values.length / 2);
    if (values.length % 2)
        return values[half];
    else
        return (values[half - 1] + values[half]) / 2.0;
}

function createClusters() {
    markers.map(function (beacon_markers, i) {
        if (beacon_filter[i] === true) {
            var cluster = new MarkerClusterer(
                map,
                beacon_markers,
                {
                    gridSize: 40,
                    averageCenter: true,
                    ignoreHidden: true,
                    styles: cluster_styles[i === 0 ? 0 : i < 3 ? 1 : i < 6 ? 2 : 3],
                    visible: false
                });
            cluster.setCalculator(function (markers, numStyles) {
                var rssiSum = 0;
                var min = 255;
                var max = 0;
                var rssiArr = [];
                for (var i = 0; i < markers.length; i++) {
                    var rssi = parseInt(markers[i].label.split(" ")[0]);
                    if (rssi > max) max = rssi;
                    if (rssi < min) min = rssi;
                    rssiArr.push(rssi);
                    rssiSum += rssi;
                }
                var med = median(rssiArr);
                var minor = markers[0].label.split(" ")[1];
                var major = markers[0].label.split(" ")[2];
                return {
                    text: minor + " " + major + " " + markers.length + "
" + max + " " + min + "
" + Math.round(rssiSum / markers.length) + " " + Math.round(med),
                    index: 0
                };
            });
            clusters[i] = cluster;
        }
    });
}

function updateDrones(drones) {
    var found = false;
    for (var i = 0; i < drones.length; i++) {
        for (var j = 0; j < DRONES.length; j++) {
            if (DRONES[j].pk === drones[i].pk) {
                found = true;
            }
        }
        if (!found) {
            DRONES.push(drones[i]);
        }
        found = false;
    }
    updateLegend();
}

function findDrone(id) {
    for (var i = 0; i < DRONES.length; i++) {
        if (DRONES[i].pk === id) return DRONES[i];
    }
    console.error("Any drone with id " + id + " found.");
}

function addDronesPolyline(points) {
    for (var i = 0; i < points.length; i++) {
        var latitude = parseFloat(points[i].fields.latitude);
        var longitude = parseFloat(points[i].fields.longitude);
        var drone = findDrone(points[i].fields.drone);
        var lastPoint = drone.fields.last_position;
        drone.fields.last_position = {
            lat: latitude,
            lng: longitude
        };
        if (typeof lastPoint !== "undefined") {
            addPolyline(lastPoint, drone.fields.last_position, drone.fields.color);
        } else {
            addPoint(latitude, longitude, drone.fields.color, "", drone.fields.name, 1); //add point if just one point (start point)
        }
    }
}

function addBeaconPoints(beacons) {
    for (var i = 0; i < beacons.length; i++) {
        var latitude = beacons[i].fields.latitude;
        var longitude = beacons[i].fields.longitude;
        var altitude = beacons[i].fields.altitude;
        var scale = (100 - beacons[i].fields.altitude) / 30;
        var color = beacons[i].fields.major === 4 ? "red" :
            beacons[i].fields.major === 3 ? "yellow" :
                beacons[i].fields.major === 2 ? "green" :
                    beacons[i].fields.major === 1 ? "#696969" : "white";
        var label = beacons[i].fields.rssi + " " + beacons[i].fields.minor + " " + beacons[i].fields.major;
        var title = Math.round(altitude * 100) / 100 + " m";
        var marker = addPoint(latitude, longitude, color, label, title, 3.0);
        addMarkerToInternalCollection(marker, beacons[i].fields.major, beacons[i].fields.minor);
    }
}

function addMarkerToInternalCollection(marker, major, minor) {
    markers[indexInMarkersCollection(major, minor)].push(marker);
}

function indexInMarkersCollection(major, minor) {
    switch (major) {
        case 1:
            return 0;
        case 2:
            return 0 + minor;
        case 3:
            return 2 + minor;
        case 4:
            return 5 + minor;
    }
}

function addPoint(latitude, longitude, color, label, title, scale) {
    return new google.maps.Marker({
        position: {lat: latitude, lng: longitude},
        map: map,
        icon: {
            path: marker_icon_path,
            fillColor: color,
            fillOpacity: 1.0,
            strokeOpacity: 0.0,
            scale: scale
        },
        label: label,
        title: title
    });
}

function addPolyline(p1, p2, color) {
    var polyline = new google.maps.Polyline({
        path: [
            p1,
            p2
        ],
        map: map,
        geodesic: true,
        strokeColor: color,
        strokeOpacity: 1.0,
        strokeWeight: 2
    });
    polylines.push(polyline);
}

function initMap() {
    var center_pos = {lat: 50.089684, lng: 20.202649};
    map = new google.maps.Map(document.getElementById('map'), {
        zoom: 16,
        center: center_pos,
        scrollwheel: true,
        draggable: true,
        mapTypeId: 'satellite'
    });

    /* north-west corner, clockwise direction */
    var areaCoords = [
        {lat: 50.0931667, lng: 20.1916000},
        {lat: 50.0931667, lng: 20.2000000},
        {lat: 50.0931667, lng: 20.2066167},
        {lat: 50.0903500, lng: 20.2090667},
        {lat: 50.0883333, lng: 20.2090667},
        {lat: 50.0883333, lng: 20.2029000},
        {lat: 50.0883333, lng: 20.2000000},
        {lat: 50.0883333, lng: 20.1970000},
        {lat: 50.0883333, lng: 20.1926833},
        {lat: 50.0906167, lng: 20.1919500},
        {lat: 50.0916333, lng: 20.1916000}
    ];

    var area = new google.maps.Polygon({
        paths: areaCoords,
        strokeColor: '#FFA500',
        strokeOpacity: 1,
        strokeWeight: 5,
        fillColor: 'green',
        fillOpacity: 0.2
    });

    var infoWindow = new google.maps.InfoWindow({
        pixelOffset: new google.maps.Size(0, 0)
    });

    function popup(event) {
        var latitude = event.latLng.lat();
        var longitude = event.latLng.lng();
        var latLng = event.latLng;

        infoWindowHtml = '
' +
            '' +
            latitude +
            '' + ', ' +
            '' +
            longitude +
            '' +
            '
';
        infoWindow.setContent(infoWindowHtml);
        infoWindow.setPosition(latLng);

        infoWindow.open(map);
        selectText('iw-text');
        document.execCommand('copy');
        clearSelection('iw-text');
        $('#lat').click({elementId: 'lat'}, copyElementText);
        $('#lng').click({elementId: 'lng'}, copyElementText);

    }

    //Add listener
    google.maps.event.addListener(map, "click", popup); //end addListener

    //Add listener
    google.maps.event.addListener(area, "click", popup); //end addListener

    var legend = document.getElementById('legend');
    map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(legend);

    var beacons = document.getElementById('beacons');
    map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(beacons);

    for (var i = 0; i < 10; i++) {
        var div = document.createElement('div');
        var color = i === 0 ? "#525252" : i < 3 ? "#2bb128" : i < 6 ? "#fff600" : "#ff0612";
        var major = i === 0 ? 1 : i < 3 ? 2 : i < 6 ? 3 : 4;
        var minor = i === 9 ? 4 : ( i === 8 || i === 5 ) ? 3 : ( i === 2 || i === 4 || i === 7) ? 2 : 1;
        div.innerHTML = '╼  ' + major + "." + minor + '<input class="custom-checkbox" type="checkbox" checked="true" onchange="checkboxChanged(event,' + major + ',' + minor + ');"/>';
        beacons.appendChild(div);
    }

    area.setMap(map);
}

function checkboxChanged(event, major, minor) {
    if (event.target.checked) {
        check(major, minor);
    } else {
        uncheck(major, minor);
    }
}

function check(major, minor) {
    var indx = indexInMarkersCollection(major, minor);
    beacon_filter[indx] = false;
    //clusters[indx].visible = true;
    setMarkersMap(indx, map);
}

function uncheck(major, minor) {
    var indx = indexInMarkersCollection(major, minor);
    beacon_filter[indx] = true;
    //clusters[indx].visible = false;
    setMarkersMap(indx, null);
}

$(function () {
    var d = new Date();
    var month = d.getMonth();
    var day = d.getDate();
    var year = d.getFullYear();
    var hour = d.getHours();
    var minute = d.getMinutes();

    $('#datetimepicker1')
        .datetimepicker({
            locale: 'pl',
            defaultDate: new Date()
        });

    startTime = d.getTime();
});

function buttonEvent() {
    for (var i = 0; i < markers.length; i++) {
        setMarkersMap(i, null);
    }
    clearMarkers();
    for (var i = 0; i < polylines.length; i++) {
        polylines[i].setMap(null);
    }
    polylines = [];
    var date = $("#datetimepicker1").find("input").val();
    var parts = date.split(".");
    var tail = parts[2].split(" ");
    var hours = tail[1].split(":");
    var dateP = new Date(tail[0], parts[1] - 1, parts[0], hours[0], hours[1]);
    startTime = dateP.getTime();
}

function setMarkersMap(i, map) {
    for (var j = 0; j < markers[i].length; j++) {
        markers[i][j].setMap(map);
        markers[i][j].visible = (map !== null);
    }
}

function clearMarkers() {
    markers = [];
    var beacons = document.getElementById('beacons');
    for (var i = 0; i < 10; i++) {
        markers[i] = [];
        beacon_filter[i] = false;
        if (beacons !== null) beacons.childNodes[i].childNodes[3].checked = true;
    }
}

function copyElementText(event) {
    selectText(event.data.elementId);
    document.execCommand('copy');
    clearSelection(event.data.elementId);
}

function selectText(element) {
    var text = document.getElementById(element);
    var selection = window.getSelection();
    var range = document.createRange();
    range.selectNodeContents(text);
    selection.removeAllRanges();
    selection.addRange(range);
}

function clearSelection(element) {
    var text = document.getElementById(element);
    var selection = window.getSelection();
    var range = document.createRange();
    range.selectNodeContents(text);
    selection.removeAllRanges();
}

function updateLegend() {
    var legend = document.getElementById('legend');
    while (legend.firstChild) {
        legend.removeChild(legend.firstChild);
    }
    for (var i = 0; i < DRONES.length; i++) {
        var div = document.createElement('div');
        var color = DRONES[i].fields.color;
        var name = DRONES[i].fields.name;
        div.innerHTML = '╼  ' + name + '';
        legend.appendChild(div);
    }
}
<commit_msg>making beacons on and off<commit_after>var m_rad = 5;
var marker_icon_path = 'M 0, 0 m -' + m_rad + ', 0 a ' + m_rad + ',' + m_rad + ' 0 1,0 ' + 2 * m_rad + ',0 a ' + m_rad + ',' + m_rad + ' 0 1,0 -' + 2 * m_rad + ',0';
var startTime = 0;
var DRONES = [];
var polylines = [];
var map;
var beacon_filter = [];
clearMarkers();

setInterval(
    function getPoint() {
        $.ajax({
            type: "GET",
            url: "http://localhost:8000/map/getData/?StartTime=" + startTime,
            dataType: "json",
            success: parseSuccess,
            error: errorHandler
        });
    }, 500);

function errorHandler(response, options, error) {
    console.error("Error while trying to retrieve beacon and drone data from server.");
    console.error(response);
    console.error(response.responseText);
    console.log(error);
}

function parseSuccess(response) {
    startTime = response.current_time;
    updateDrones(response.drones);
    addDronesPolyline(response.drones_positions);
    addBeaconPoints(response.beacons_positions);
}

function median(values) {
    values.sort(function (a, b) {
        return a - b;
    });
    var half = Math.floor(values.length / 2);
    if (values.length % 2)
        return values[half];
    else
        return (values[half - 1] + values[half]) / 2.0;
}

function updateDrones(drones) {
    var found = false;
    for (var i = 0; i < drones.length; i++) {
        for (var j = 0; j < DRONES.length; j++) {
            if (DRONES[j].pk === drones[i].pk) {
                found = true;
            }
        }
        if (!found) {
            DRONES.push(drones[i]);
        }
        found = false;
    }
    updateLegend();
}

function findDrone(id) {
    for (var i = 0; i < DRONES.length; i++) {
        if (DRONES[i].pk === id) return DRONES[i];
    }
    console.error("Any drone with id " + id + " found.");
}

function addDronesPolyline(points) {
    for (var i = 0; i < points.length; i++) {
        var latitude = parseFloat(points[i].fields.latitude);
        var longitude = parseFloat(points[i].fields.longitude);
        var drone = findDrone(points[i].fields.drone);
        var lastPoint = drone.fields.last_position;
        drone.fields.last_position = {
            lat: latitude,
            lng: longitude
        };
        if (typeof lastPoint !== "undefined") {
            addPolyline(lastPoint, drone.fields.last_position, drone.fields.color);
        } else {
            addPoint(latitude, longitude, drone.fields.color, "", drone.fields.name, 1); //add point if just one point (start point)
        }
    }
}

function addBeaconPoints(beacons) {
    for (var i = 0; i < beacons.length; i++) {
        var latitude = beacons[i].fields.latitude;
        var longitude = beacons[i].fields.longitude;
        var altitude = beacons[i].fields.altitude;
        var scale = (100 - beacons[i].fields.altitude) / 30;
        var color = beacons[i].fields.major === 4 ? "red" :
            beacons[i].fields.major === 3 ? "yellow" :
                beacons[i].fields.major === 2 ? "green" :
                    beacons[i].fields.major === 1 ? "#696969" : "white";
        var label = beacons[i].fields.rssi + " " + beacons[i].fields.minor + " " + beacons[i].fields.major;
        var title = Math.round(altitude * 100) / 100 + " m";
        var marker = addPoint(latitude, longitude, color, label, title, 3.0);
        addMarkerToInternalCollection(marker, beacons[i].fields.major, beacons[i].fields.minor);
    }
}

function addMarkerToInternalCollection(marker, major, minor) {
    markers[indexInMarkersCollection(major, minor)].push(marker);
}

function indexInMarkersCollection(major, minor) {
    switch (major) {
        case 1:
            return 0;
        case 2:
            return 0 + minor;
        case 3:
            return 2 + minor;
        case 4:
            return 5 + minor;
    }
}

function addPoint(latitude, longitude, color, label, title, scale) {
    return new google.maps.Marker({
        position: {lat: latitude, lng: longitude},
        map: map,
        icon: {
            path: marker_icon_path,
            fillColor: color,
            fillOpacity: 1.0,
            strokeOpacity: 0.0,
            scale: scale
        },
        label: label,
        title: title
    });
}

function addPolyline(p1, p2, color) {
    var polyline = new google.maps.Polyline({
        path: [
            p1,
            p2
        ],
        map: map,
        geodesic: true,
        strokeColor: color,
        strokeOpacity: 1.0,
        strokeWeight: 2
    });
    polylines.push(polyline);
}

function initMap() {
    var center_pos = {lat: 50.089684, lng: 20.202649};
    map = new google.maps.Map(document.getElementById('map'), {
        zoom: 16,
        center: center_pos,
        scrollwheel: true,
        draggable: true,
        mapTypeId: 'satellite'
    });

    /* north-west corner, clockwise direction */
    var areaCoords = [
        {lat: 50.0931667, lng: 20.1916000},
        {lat: 50.0931667, lng: 20.2000000},
        {lat: 50.0931667, lng: 20.2066167},
        {lat: 50.0903500, lng: 20.2090667},
        {lat: 50.0883333, lng: 20.2090667},
        {lat: 50.0883333, lng: 20.2029000},
        {lat: 50.0883333, lng: 20.2000000},
        {lat: 50.0883333, lng: 20.1970000},
        {lat: 50.0883333, lng: 20.1926833},
        {lat: 50.0906167, lng: 20.1919500},
        {lat: 50.0916333, lng: 20.1916000}
    ];

    var area = new google.maps.Polygon({
        paths: areaCoords,
        strokeColor: '#FFA500',
        strokeOpacity: 1,
        strokeWeight: 5,
        fillColor: 'green',
        fillOpacity: 0.2
    });

    var infoWindow = new google.maps.InfoWindow({
        pixelOffset: new google.maps.Size(0, 0)
    });

    function popup(event) {
        var latitude = event.latLng.lat();
        var longitude = event.latLng.lng();
        var latLng = event.latLng;

        infoWindowHtml = '
' +
            '' +
            latitude +
            '' + ', ' +
            '' +
            longitude +
            '' +
            '
';
        infoWindow.setContent(infoWindowHtml);
        infoWindow.setPosition(latLng);

        infoWindow.open(map);
        selectText('iw-text');
        document.execCommand('copy');
        clearSelection('iw-text');
        $('#lat').click({elementId: 'lat'}, copyElementText);
        $('#lng').click({elementId: 'lng'}, copyElementText);

    }

    //Add listener
    google.maps.event.addListener(map, "click", popup); //end addListener

    //Add listener
    google.maps.event.addListener(area, "click", popup); //end addListener

    var legend = document.getElementById('legend');
    map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(legend);

    var beacons = document.getElementById('beacons');
    map.controls[google.maps.ControlPosition.RIGHT_BOTTOM].push(beacons);

    for (var i = 0; i < 10; i++) {
        var div = document.createElement('div');
        var color = i === 0 ? "#525252" : i < 3 ? "#2bb128" : i < 6 ? "#fff600" : "#ff0612";
        var major = i === 0 ? 1 : i < 3 ? 2 : i < 6 ? 3 : 4;
        var minor = i === 9 ? 4 : ( i === 8 || i === 5 ) ? 3 : ( i === 2 || i === 4 || i === 7) ? 2 : 1;
        div.innerHTML = '╼  ' + major + "." + minor + '<input class="custom-checkbox" type="checkbox" checked="true" onchange="checkboxChanged(event,' + major + ',' + minor + ');"/>';
        beacons.appendChild(div);
    }

    area.setMap(map);
}

function checkboxChanged(event, major, minor) {
    if (event.target.checked) {
        check(major, minor);
    } else {
        uncheck(major, minor);
    }
}

function check(major, minor) {
    var indx = indexInMarkersCollection(major, minor);
    beacon_filter[indx] = false;
    setMarkersMap(indx, map);
}

function uncheck(major, minor) {
    var indx = indexInMarkersCollection(major, minor);
    beacon_filter[indx] = true;
    setMarkersMap(indx, null);
}

$(function () {
    var d = new Date();
    var month = d.getMonth();
    var day = d.getDate();
    var year = d.getFullYear();
    var hour = d.getHours();
    var minute = d.getMinutes();

    $('#datetimepicker1')
        .datetimepicker({
            locale: 'pl',
            defaultDate: new Date()
        });

    startTime = d.getTime();
});

function buttonEvent() {
    for (var i = 0; i < markers.length; i++) {
        setMarkersMap(i, null);
    }
    clearMarkers();
    for (var i = 0; i < polylines.length; i++) {
        polylines[i].setMap(null);
    }
    polylines = [];
    var date = $("#datetimepicker1").find("input").val();
    var parts = date.split(".");
    var tail = parts[2].split(" ");
    var hours = tail[1].split(":");
    var dateP = new Date(tail[0], parts[1] - 1, parts[0], hours[0], hours[1]);
    startTime = dateP.getTime();
}

function setMarkersMap(i, map) {
    for (var j = 0; j < markers[i].length; j++) {
        markers[i][j].setMap(map);
        markers[i][j].visible = (map !== null);
    }
}

function clearMarkers() {
    markers = [];
    var beacons = document.getElementById('beacons');
    for (var i = 0; i < 10; i++) {
        markers[i] = [];
        beacon_filter[i] = false;
        if (beacons !== null) beacons.childNodes[i].childNodes[3].checked = true;
    }
}

function copyElementText(event) {
    selectText(event.data.elementId);
    document.execCommand('copy');
    clearSelection(event.data.elementId);
}

function selectText(element) {
    var text = document.getElementById(element);
    var selection = window.getSelection();
    var range = document.createRange();
    range.selectNodeContents(text);
    selection.removeAllRanges();
    selection.addRange(range);
}

function clearSelection(element) {
    var text = document.getElementById(element);
    var selection = window.getSelection();
    var range = document.createRange();
    range.selectNodeContents(text);
    selection.removeAllRanges();
}

function updateLegend() {
    var legend = document.getElementById('legend');
    while (legend.firstChild) {
        legend.removeChild(legend.firstChild);
    }
    for (var i = 0; i < DRONES.length; i++) {
        var div = document.createElement('div');
        var color = DRONES[i].fields.color;
        var name = DRONES[i].fields.name;
        div.innerHTML = '╼  ' + name + '';
        legend.appendChild(div);
    }
}
<|endoftext|>


<commit_before>/////////////////////////////// global variables ///////////////////////////////

var bundle = null;
window.addEventListener("load", function() {
  // init the global string bundle
  bundle = document.getElementById("gm-browser-bundle");

  // load default namespace from pref
  document.getElementById("namespace").value =
      GM_prefRoot.getValue("newscript_namespace", "");

  // default the includes with the current page's url
  document.getElementById("includes").value =
      window.opener.document.getElementById("content").selectedBrowser
      .contentWindow.location.href;
}, false);

////////////////////////////////// functions ///////////////////////////////////

function doInstall() {
  var script = createScriptSource();
  if (!script) return false;

  // put this created script into a file -- only way to install it
  var tempFile = getTempFile();
  var foStream = getWriteStream(tempFile);
  foStream.write(script, script.length);
  foStream.close();

  var config = GM_getConfig();

  // create a script object with parsed metadata,
  script = config.parse(script, tempFile);

  // make sure entered details will not ruin an existing file
  if (config.installIsUpdate(script)) {
    var overwrite = confirm(bundle.getString("newscript.exists"));
    if (!overwrite) return false;
  }

  // finish making the script object ready to install
  script.setDownloadedFile(tempFile);

  // install this script
  config.install(script);

  // and fire up the editor!
  openInEditor(script);

  // persist namespace value
  GM_prefRoot.setValue("newscript_namespace", script.namespace);

  return true;
}

// assemble the XUL fields into a script template
function createScriptSource() {
  var script = ["// ==UserScript=="];

  var name = document.getElementById("name").value;
  if ("" == name) {
    alert(bundle.getString("newscript.noname"));
    return false;
  } else {
    script.push("// @name           " + name);
  }

  var namespace = document.getElementById("namespace").value;
  if ("" == namespace) {
    alert(bundle.getString("newscript.nonamespace"));
    return false;
  } else {
    script.push("// @namespace      " + namespace);
  }

  var descr = document.getElementById("descr").value;
  if ("" != descr) {
    script.push("// @description    " + descr);
  }

  var includes = document.getElementById("includes").value;
  if ("" != includes) {
    includes = includes.match(/.+/g);
    includes = "// @include        " + includes.join("\n// @include        ");
    script.push(includes);
  }

  var excludes = document.getElementById("excludes").value;
  if ("" != excludes) {
    excludes = excludes.match(/.+/g);
    excludes = "// @exclude        " + excludes.join("\n// @exclude        ");
    script.push(excludes);
  }

  script.push("// ==/UserScript==");

  var ending = "\n";
  if (window.navigator.platform.match(/^Win/)) ending = "\r\n";
  if (window.navigator.platform.match(/^Mac/)) ending = "\r";
  script = script.join(ending);

  return script;
}
<commit_msg>As per Johan's comment, no old-style (pre-OSX) Mac line endings.<commit_after>/////////////////////////////// global variables ///////////////////////////////

var bundle = null;
window.addEventListener("load", function() {
  // init the global string bundle
  bundle = document.getElementById("gm-browser-bundle");

  // load default namespace from pref
  document.getElementById("namespace").value =
      GM_prefRoot.getValue("newscript_namespace", "");

  // default the includes with the current page's url
  document.getElementById("includes").value =
      window.opener.document.getElementById("content").selectedBrowser
      .contentWindow.location.href;
}, false);

////////////////////////////////// functions ///////////////////////////////////

function doInstall() {
  var script = createScriptSource();
  if (!script) return false;

  // put this created script into a file -- only way to install it
  var tempFile = getTempFile();
  var foStream = getWriteStream(tempFile);
  foStream.write(script, script.length);
  foStream.close();

  var config = GM_getConfig();

  // create a script object with parsed metadata,
  script = config.parse(script, tempFile);

  // make sure entered details will not ruin an existing file
  if (config.installIsUpdate(script)) {
    var overwrite = confirm(bundle.getString("newscript.exists"));
    if (!overwrite) return false;
  }

  // finish making the script object ready to install
  script.setDownloadedFile(tempFile);

  // install this script
  config.install(script);

  // and fire up the editor!
  openInEditor(script);

  // persist namespace value
  GM_prefRoot.setValue("newscript_namespace", script.namespace);

  return true;
}

// assemble the XUL fields into a script template
function createScriptSource() {
  var script = ["// ==UserScript=="];

  var name = document.getElementById("name").value;
  if ("" == name) {
    alert(bundle.getString("newscript.noname"));
    return false;
  } else {
    script.push("// @name           " + name);
  }

  var namespace = document.getElementById("namespace").value;
  if ("" == namespace) {
    alert(bundle.getString("newscript.nonamespace"));
    return false;
  } else {
    script.push("// @namespace      " + namespace);
  }

  var descr = document.getElementById("descr").value;
  if ("" != descr) {
    script.push("// @description    " + descr);
  }

  var includes = document.getElementById("includes").value;
  if ("" != includes) {
    includes = includes.match(/.+/g);
    includes = "// @include        " + includes.join("\n// @include        ");
    script.push(includes);
  }

  var excludes = document.getElementById("excludes").value;
  if ("" != excludes) {
    excludes = excludes.match(/.+/g);
    excludes = "// @exclude        " + excludes.join("\n// @exclude        ");
    script.push(excludes);
  }

  script.push("// ==/UserScript==");

  var ending = "\n";
  if (window.navigator.platform.match(/^Win/)) ending = "\r\n";
  script = script.join(ending);

  return script;
}
<|endoftext|>


<commit_before><commit_msg>update map<commit_after><|endoftext|>


<commit_before>var httpConfig = require('./support/httpConfig');
var assert = require('assert');
var eventstore = require('../index.js');

describe('Http Client - Ping', function() {
    it('Should return successful when OK', function() {
        var client = eventstore.http(httpConfig);

        return client.ping().catch(function(err) {
            assert.fail(err.message);
        });
    });

    it('Should fail when not OK', function() {
        this.timeout(5000);
        var config = JSON.parse(JSON.stringify(httpConfig));
        config.hostname = 'MadeToFailHostName';

        var client = eventstore.http(config);

        return client.ping().then(function() {
            assert.fail('Should not succeed');
        }).catch(function(err) {
            assert(err.message);
        });
    });
});
<commit_msg>[fix] increase test timeout to 30s<commit_after>var httpConfig = require('./support/httpConfig');
var assert = require('assert');
var eventstore = require('../index.js');

describe('Http Client - Ping', function() {
    it('Should return successful when OK', function() {
        var client = eventstore.http(httpConfig);

        return client.ping().catch(function(err) {
            assert.fail(err.message);
        });
    });

    it('Should fail when not OK', function() {
        this.timeout(30000);
        var config = JSON.parse(JSON.stringify(httpConfig));
        config.hostname = 'MadeToFailHostName';

        var client = eventstore.http(config);

        return client.ping().then(function() {
            assert.fail('Should not succeed');
        }).catch(function(err) {
            assert(err.message);
        });
    });
});
<|endoftext|>


<commit_before>import React from 'react';
import { IndexRoute, Route } from 'react-router';
import { isLoaded as isAuthLoaded, load as loadAuth } from 'redux/modules/auth';

// export default (store) => {
export default store => {
  function checkAuth(logged, replace, cb) {
    const {
      auth: {
        user
      },
      routing: {
        locationBeforeTransitions: {
          pathname
        }
      }
    } = store.getState();

    if (!!user === !logged) replace('/');
    if (!user) {
      replace(`/login?r=${pathname}`);
    }
    cb();
  }

  const requireLogin = (nextState, replace, cb) => {
    if (!isAuthLoaded(store.getState())) {
      store.dispatch(loadAuth()).then(() => checkAuth(true, replace, cb));
    } else {
      checkAuth(true, replace, cb);
    }
  };
  //
  // const requireNotLogged = (nextState, replace, cb) => {
  //   if (!isAuthLoaded(store.getState())) {
  //     store.dispatch(loadAuth()).then(() => checkAuth(false, replace, cb));
  //   } else {
  //     checkAuth(false, replace, cb);
  //   }
  // };
  /**
   * Please keep routes in alphabetical order
   */
  // const syncLoad = (typeof require.ensure !== 'function' || __DEVELOPMENT__);
  // return (
  //   <Route path="/" component={require('./containers/App/App')}>
  //     {/* Home (main) route */}
  //     <IndexRoute component={require('./containers/Home/Home')} />
  //
  //     {/* Routes disallow login */}
  //     <Route path="*" component={require('./containers/NotFound/NotFound')} status={404} />
  //   </Route>
  // );
  // if (typeof require.ensure !== 'function' || __DEVELOPMENT__) require.ensure = (deps, cb) => cb(require);
  // return {
  //   path: '/',
  //   component: require('./containers/App/App'),
  //   indexRoute: {
  //     component: require('./containers/Home/Home')
  //   },
  //   childRoutes: [{
  //     path: 'login',
  //     getComponent(nextState, cb) {
  //       console.time('gettingComponent');
  //       store.dispatch({
  //         type: 'WEBPACK_LOAD'
  //       });
  //       require.ensure([], (require) => {
  //         cb(null, require('./containers/Login/Login'));
  //         store.dispatch({
  //           type: 'WEBPACK_LOAD_END'
  //         });
  //         console.timeEnd('gettingComponent');
  //       });
  //     }
  //
  //   }, {
  //     path: 'about',
  //     getComponent(nextState, cb) {
  //       console.time('gettingComponent');
  //       store.dispatch({
  //         type: 'WEBPACK_LOAD'
  //       });
  //       require.ensure([], (require) => {
  //         cb(null, require('./containers/About/About'));
  //         store.dispatch({
  //           type: 'WEBPACK_LOAD_END'
  //         });
  //         console.timeEnd('gettingComponent');
  //       });
  //     }
  //
  //   }, {
  //     path: 'survey',
  //     getComponent(nextState, cb) {
  //       require.ensure([], (require) =>
  //         cb(null, require('./containers/Survey/Survey')));
  //     }
  //   }, {
  //     path: 'widgets',
  //     getComponent(nextState, cb) {
  //       store.dispatch({
  //         type: 'WEBPACK_LOAD'
  //       });
  //       require.ensure([], (require) => {
  //         cb(null, require('./containers/Widgets/Widgets'));
  //         store.dispatch({
  //           type: 'WEBPACK_LOAD_END'
  //         });
  //       });
  //     }
  //   }, {
  //     onEnter: requireLogin,
  //     childRoutes: [
  //       {
  //         path: 'chat',
  //         getComponent(nextState, cb) {
  //           require.ensure([], (require) =>
  //             cb(null, require('./containers/Chat/Chat')));
  //         }
  //       },
  //       {
  //         path: 'loginSuccess',
  //         getComponent(nextState, cb) {
  //           require.ensure([], (require) =>
  //             cb(null, require('./containers/LoginSuccess/LoginSuccess')));
  //         }
  //       }
  //     ]
  //   }, {
  //     path: '*',
  //     getComponent(nextState, cb) {
  //       require.ensure([], (require) =>
  //         cb(null, require('./containers/NotFound/NotFound')));
  //     }
  //   }]
  // };
// };
//
  return (
    <Route path="/" component={require('./containers/App/App')}>
      {/* Home (main) route */}
      <IndexRoute onEnter={requireLogin} components={{
          content: require('./containers/Home/Home'),
          sidebar: require('./components/Sidebar')
        }} />
      <Route onEnter={requireLogin} path="gallery" component={require('./containers/Home/Home')}>
        <Route path=":index" component={require('./components/Gallery/Gallery')} />
      </Route>
      <Route onEnter={requireLogin} path="tumblrize" component={require('./containers/Tumblrize/Tumblrize')} />
      <Route
        onEnter={requireLogin}
        path="/archive"
        components={{
          content: require('./containers/Archive/Archive'),
          sidebar: require('./components/Sidebar')
        }}
      >
        <Route path="tag/:id">
          <Route path="gallery/:index" component={require('./components/Gallery/Gallery')} />
        </Route>
        <Route path="gallery/:index" component={require('./components/Gallery/Gallery')} />
      </Route>
      <Route
        onEnter={requireLogin}
        path="/videos"
        components={{
          content: require('./containers/Videos/Videos'),
          sidebar: require('./components/Sidebar')
        }}
      />

      <Route path="login" component={require('./containers/Login/Login')} />

      {/* Routes disallow login */}
      <Route path="*" component={require('./containers/NotFound/NotFound')} status={404} />
    </Route>
  );
};
<commit_msg>maintenence.<commit_after>import React from 'react';
import { IndexRoute, Route } from 'react-router';
import { isLoaded as isAuthLoaded, load as loadAuth } from 'redux/modules/auth';

// export default (store) => {
export default store => {
  function checkAuth(logged, replace, cb) {
    const {
      auth: {
        user
      },
      routing: {
        locationBeforeTransitions: {
          pathname
        }
      }
    } = store.getState();

    if (!!user === !logged) replace('/');
    if (!user) {
      replace(`/login?r=${pathname}`);
    }
    cb();
  }

  const requireLogin = (nextState, replace, cb) => {
    if (!isAuthLoaded(store.getState())) {
      store.dispatch(loadAuth()).then(() => checkAuth(true, replace, cb));
    } else {
      checkAuth(true, replace, cb);
    }
  };
  //
  // const requireNotLogged = (nextState, replace, cb) => {
  //   if (!isAuthLoaded(store.getState())) {
  //     store.dispatch(loadAuth()).then(() => checkAuth(false, replace, cb));
  //   } else {
  //     checkAuth(false, replace, cb);
  //   }
  // };
  /**
   * Please keep routes in alphabetical order
   */
  // const syncLoad = (typeof require.ensure !== 'function' || __DEVELOPMENT__);
  // return (
  //   <Route path="/" component={require('./containers/App/App')}>
  //     {/* Home (main) route */}
  //     <IndexRoute component={require('./containers/Home/Home')} />
  //
  //     {/* Routes disallow login */}
  //     <Route path="*" component={require('./containers/NotFound/NotFound')} status={404} />
  //   </Route>
  // );
  // if (typeof require.ensure !== 'function' || __DEVELOPMENT__) require.ensure = (deps, cb) => cb(require);
  // return {
  //   path: '/',
  //   component: require('./containers/App/App'),
  //   indexRoute: {
  //     component: require('./containers/Home/Home')
  //   },
  //   childRoutes: [{
  //     path: 'login',
  //     getComponent(nextState, cb) {
  //       console.time('gettingComponent');
  //       store.dispatch({
  //         type: 'WEBPACK_LOAD'
  //       });
  //       require.ensure([], (require) => {
  //         cb(null, require('./containers/Login/Login'));
  //         store.dispatch({
  //           type: 'WEBPACK_LOAD_END'
  //         });
  //         console.timeEnd('gettingComponent');
  //       });
  //     }
  //
  //   }, {
  //     path: 'about',
  //     getComponent(nextState, cb) {
  //       console.time('gettingComponent');
  //       store.dispatch({
  //         type: 'WEBPACK_LOAD'
  //       });
  //       require.ensure([], (require) => {
  //         cb(null, require('./containers/About/About'));
  //         store.dispatch({
  //           type: 'WEBPACK_LOAD_END'
  //         });
  //         console.timeEnd('gettingComponent');
  //       });
  //     }
  //
  //   }, {
  //     path: 'survey',
  //     getComponent(nextState, cb) {
  //       require.ensure([], (require) =>
  //         cb(null, require('./containers/Survey/Survey')));
  //     }
  //   }, {
  //     path: 'widgets',
  //     getComponent(nextState, cb) {
  //       store.dispatch({
  //         type: 'WEBPACK_LOAD'
  //       });
  //       require.ensure([], (require) => {
  //         cb(null, require('./containers/Widgets/Widgets'));
  //         store.dispatch({
  //           type: 'WEBPACK_LOAD_END'
  //         });
  //       });
  //     }
  //   }, {
  //     onEnter: requireLogin,
  //     childRoutes: [
  //       {
  //         path: 'chat',
  //         getComponent(nextState, cb) {
  //           require.ensure([], (require) =>
  //             cb(null, require('./containers/Chat/Chat')));
  //         }
  //       },
  //       {
  //         path: 'loginSuccess',
  //         getComponent(nextState, cb) {
  //           require.ensure([], (require) =>
  //             cb(null, require('./containers/LoginSuccess/LoginSuccess')));
  //         }
  //       }
  //     ]
  //   }, {
  //     path: '*',
  //     getComponent(nextState, cb) {
  //       require.ensure([], (require) =>
  //         cb(null, require('./containers/NotFound/NotFound')));
  //     }
  //   }]
  // };
// };
//
  return (
    <Route path="*" component={require('./containers/NotFound/NotFound')} status={404}>
      {/* Home (main) route
      <IndexRoute onEnter={requireLogin} components={{
          content: require('./containers/Home/Home'),
          sidebar: require('./components/Sidebar')
        }} />
      <Route onEnter={requireLogin} path="gallery" component={require('./containers/Home/Home')}>
        <Route path=":index" component={require('./components/Gallery/Gallery')} />
      </Route>
      <Route onEnter={requireLogin} path="tumblrize" component={require('./containers/Tumblrize/Tumblrize')} />
      <Route
        onEnter={requireLogin}
        path="/archive"
        components={{
          content: require('./containers/Archive/Archive'),
          sidebar: require('./components/Sidebar')
        }}
      >
        <Route path="tag/:id">
          <Route path="gallery/:index" component={require('./components/Gallery/Gallery')} />
        </Route>
        <Route path="gallery/:index" component={require('./components/Gallery/Gallery')} />
      </Route>
      <Route
        onEnter={requireLogin}
        path="/videos"
        components={{
          content: require('./containers/Videos/Videos'),
          sidebar: require('./components/Sidebar')
        }}
      />

      <Route path="login" component={require('./containers/Login/Login')} />
      <Route path="*" component={require('./containers/NotFound/NotFound')} status={404} />
      */}

    </Route>
  );
};
<|endoftext|>


<commit_before>/**
 * Returns None for phone and SingleSelectMaster for other devices
 *
 * @public
 * @param bIsPhone
 * @returns {sap.m.ListMode}
 */
export var listMode = function (bIsPhone) {
    return (bIsPhone ? "None" : "SingleSelectMaster");
};

/**
 * Returns Active for phone and Inactive for other devices
 *
 * @public
 * @param bIsPhone
 * @returns {string}
 */
export var listItemType = function (bIsPhone) {
    return (bIsPhone ? "Active" : "Inactive");
};

/**
 * Rounds the currency value to 2 digits
 *
 * @public
 * @param sValue
 * @returns {string}
 */
export var currencyValue = function (sValue) {
    if (!sValue) {
        return "";
    }

    return parseFloat(sValue).toFixed(2);
};<commit_msg>use ES6 arrow functions for formatter functions<commit_after>/**
 * Returns None for phone and SingleSelectMaster for other devices
 *
 * @public
 * @param bIsPhone
 * @returns {sap.m.ListMode}
 */
export var listMode = bIsPhone => bIsPhone ? "None" : "SingleSelectMaster";

/**
 * Returns Active for phone and Inactive for other devices
 *
 * @public
 * @param bIsPhone
 * @returns {string}
 */
export var listItemType = bIsPhone => bIsPhone ? "Active" : "Inactive";

/**
 * Rounds the currency value to 2 digits
 *
 * @public
 * @param sValue
 * @returns {string}
 */
export var currencyValue = sValue => !sValue ? '' : parseFloat(sValue).toFixed(2);<|endoftext|>


<commit_before>'use strict';

const util = require('../service/util');
const config = require('config');

module.exports = function () {
  let hkpLink = util.hkpUrl(this);
  this.body =
  `
  <!DOCTYPE html>

    <meta charset="utf-8">
    <title>${config.ui.title}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">

${config.ui.title}

Try it out

Upload your public OpenPGP key using the form below.

Check your inbox and click on the verification link inside the encrypted message.

You can delete all your data from the server at any time using the form below.

Configure this key server in your HKP compatible OpenPGP client using this url: ${hkpLink}

Documentation and code

Please refer to the documentation to learn more about the REST api.

License AGPL v3.0

      Find OpenPGP Key

    <form action="/pks/lookup" method="get">

        Get:
        <input type="radio" name="op" value="get" checked="checked">
        Index:
        <input type="radio" name="op" value="index">

        Search:
        <input name="search" type="email" spellcheck="false" size="40" placeholder="Email address, long key ID or fingerprint">

        <input type="reset" value="Reset">
        <input type="submit" value="Search">

    </form>

      Upload a new OpenPGP Key

    <form action="/pks/add" method="post">

Paste ASCII-armored OpenPGP key block here:

        <textarea name="keytext" rows="20" cols="50"></textarea>

        <input type="reset" value="Reset">
        <input type="submit" value="Upload">

    </form>

      Delete your OpenPGP Key

    <form action="/api/v1/removeKey" method="get">

        Remove:
        <input name="email" type="email" spellcheck="false" size="40" placeholder="Email address">

        <input type="reset" value="Reset">
        <input type="submit" value="Remove">

    </form>

  `;

  this.set('Content-Type', 'text/html; charset=utf-8');
};<commit_msg>Fix search input<commit_after>'use strict';

const util = require('../service/util');
const config = require('config');

module.exports = function () {
  let hkpLink = util.hkpUrl(this);
  this.body =
  `
  <!DOCTYPE html>

    <meta charset="utf-8">
    <title>${config.ui.title}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">

${config.ui.title}

Try it out

Upload your public OpenPGP key using the form below.

Check your inbox and click on the verification link inside the encrypted message.

You can delete all your data from the server at any time using the form below.

Configure this key server in your HKP compatible OpenPGP client using this url: ${hkpLink}

Documentation and code

Please refer to the documentation to learn more about the REST api.

License AGPL v3.0

      Find OpenPGP Key

    <form action="/pks/lookup" method="get">

        Get:
        <input type="radio" name="op" value="get" checked="checked">
        Index:
        <input type="radio" name="op" value="index">

        Search:
        <input name="search" spellcheck="false" size="40" placeholder="Email address, long key ID or fingerprint">

        <input type="reset" value="Reset">
        <input type="submit" value="Search">

    </form>

      Upload a new OpenPGP Key

    <form action="/pks/add" method="post">

Paste ASCII-armored OpenPGP key block here:

        <textarea name="keytext" rows="20" cols="50"></textarea>

        <input type="reset" value="Reset">
        <input type="submit" value="Upload">

    </form>

      Delete your OpenPGP Key

    <form action="/api/v1/removeKey" method="get">

        Remove:
        <input name="email" type="email" spellcheck="false" size="40" placeholder="Email address">

        <input type="reset" value="Reset">
        <input type="submit" value="Remove">

    </form>

  `;

  this.set('Content-Type', 'text/html; charset=utf-8');
};<|endoftext|>