diff --git a/dist/infragram.js b/dist/infragram.js index bbd3d83e..0332cc9f 100644 --- a/dist/infragram.js +++ b/dist/infragram.js @@ -1,14 +1,15 @@ -function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + isVideo = false,isCamera=false; // Turns off camera feed + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } -function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } + function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } + function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } -function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } + function _sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } -function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } + function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return _sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } } -(function () { + (function () { function r(e, n, t) { function o(i, f) { if (!n[i]) { @@ -307,7 +308,7 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i }; }; }, { - "../util/JsImage.js": 17, + "../util/JsImage.js": 18, "./colormapFunctionGenerator.js": 3, "./colormaps.json": 4 }], @@ -333,27 +334,27 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i switch (i) { case 0: - rgb = [v, t, p]; - break; + rgb = [v, t, p]; + break; case 1: - rgb = [q, v, p]; - break; + rgb = [q, v, p]; + break; case 2: - rgb = [p, v, t]; - break; + rgb = [p, v, t]; + break; case 3: - rgb = [p, q, v]; - break; + rgb = [p, q, v]; + break; case 4: - rgb = [t, p, v]; - break; + rgb = [t, p, v]; + break; default: - rgb = [v, p, q]; + rgb = [v, p, q]; } } @@ -372,15 +373,15 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i } else { switch (max) { case r: - h = (g - b) / d + (g < b ? 6 : 0); - break; + h = (g - b) / d + (g < b ? 6 : 0); + break; case g: - h = (b - r) / d + 2; - break; + h = (b - r) / d + 2; + break; case b: - h = (r - g) / d + 4; + h = (r - g) / d + 4; } h /= 6; @@ -395,12 +396,12 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i // http://github.com/p-v-o-s/infragram-js. module.exports = function Camera(options) { var canvas, ctx; // Initialize getUserMedia with options - function initialize() { - getUserMedia(webRtcOptions, success, deviceError); // iOS Safari 11 compatibility: https://github.com/webrtc/adapter/issues/685 - - webRtcOptions.videoEl.setAttribute('autoplay', 'autoplay'); - webRtcOptions.videoEl.setAttribute('playsinline', 'playsinline'); + getUserMedia(webRtcOptions, success, deviceError); // iOS Safari 11 compatibility: https://github.com/webrtc/adapter/issues/685 + webRtcOptions.videoEl.setAttribute('id', 'webCamVideoEl'); + var webCamVideoEl = document.getElementById('webCamVideoEl') + webCamVideoEl.setAttribute('autoplay', 'autoplay'); + webCamVideoEl.setAttribute('playsinline', 'playsinline'); window.webcam = webRtcOptions; // this is weird but maybe used for flash fallback? canvas = options.canvas || document.getElementById("image"); @@ -416,7 +417,6 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i // events that are triggered onCapture and onSave (for the fallback) // and so on. - var webRtcOptions = options.webRtcOptions || { "audio": false, "video": true, @@ -447,14 +447,14 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i function onSaveGetUserMedia(data) { var col, - h, - i, - img, - j, - ref, - tmp, - w, - pos = 0; + h, + i, + img, + j, + ref, + tmp, + w, + pos = 0; col = data.split(""); img = camera.image; tmp = null; @@ -475,19 +475,19 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i return pos = 0; } } - function success(stream) { var video; + //localStream = this.stream; + window.localStream = stream; + isCamera = true; if (webRtcOptions.context === "webrtc") { - video = webRtcOptions.videoEl; - + video = document.getElementById("webCamVideoEl"); if (navigator.mozGetUserMedia) { video.mozSrcObject = stream; } else { video.srcObject = stream; } - return video.onerror = function (e) { return stream.stop(); }; @@ -522,9 +522,9 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i return { getSnapshot: getSnapshot, - initialize: initialize, + initialize: initialize, onSaveGetUserMedia: onSaveGetUserMedia, - webRtcOptions: webRtcOptions + webRtcOptions: webRtcOptions, }; }; }, {}], @@ -532,45 +532,6 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i // This file was adapted from infragram-js: // http://github.com/p-v-o-s/infragram-js. module.exports = function File(options, processor) { - var _getMouseEvent = function getMouseEvent() { - var getParams = function getParams() { - return { - bubbles: false, - cancelable: false, - screenX: 0, - screenY: 0, - clientX: 0, - clientY: 0 - }; - }; - - try { - // eslint-disable-next-line no-new - new MouseEvent("t"); - - _getMouseEvent = function getMouseEvent() { - return function (eventType) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getParams(); - return new MouseEvent(eventType, params); - }; - }; - } catch (e) { - // Polyfills DOM4 MouseEvent - _getMouseEvent = function getMouseEvent() { - return function (eventType) { - var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getParams(); - var mouseEvent = document.createEvent("MouseEvent"); // https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/initMouseEvent - - mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, window, 0, // the event's mouse click count - params.screenX, params.screenY, params.clientX, params.clientY, false, false, false, false, 0, null); - return mouseEvent; - }; - }; - } - - return _getMouseEvent(); - }; - function downloadImage() { var event, format, lnk; // create an "off-screen" anchor tag @@ -587,14 +548,9 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i lnk.download = new Date().toISOString().replace(/:/g, "_") + "." + format; // create a "fake" click-event to trigger the download if (document.createEvent) { - var mouseEvent = _getMouseEvent(); - - lnk.dispatchEvent(mouseEvent("click", { - screenX: 0, - screenY: 0, - clientX: 0, - clientY: 0 - })); + event = document.createEvent("MouseEvents"); + event.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); + lnk.dispatchEvent(event); } else if (lnk.fireEvent) { lnk.fireEvent("onclick"); } @@ -732,17 +688,17 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i // https://github.com/publiclab/image-sequencer module.exports = function javascriptProcessor() { var b_exp = "", - g_exp = "", - get_channels, - Colormaps = require('../color/colormaps')(JsImage), - colormap = Colormaps.colormap1, - converters = require('../color/converters'), - image = null, - mode = "raw", - ndvi, - r_exp = "", - set_mode, - update_colorbar; + g_exp = "", + get_channels, + Colormaps = require('../color/colormaps')(JsImage), + colormap = Colormaps.colormap1, + converters = require('../color/converters'), + image = null, + mode = "raw", + ndvi, + r_exp = "", + set_mode, + update_colorbar; var JsImage = require('../util/JsImage.js'); @@ -1023,7 +979,7 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i }, { "../color/colormaps": 5, "../color/converters": 6, - "../util/JsImage.js": 17 + "../util/JsImage.js": 18 }], 11: [function (require, module, exports) { // Generated by CoffeeScript 2.1.0 @@ -1031,10 +987,10 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i // http://github.com/p-v-o-s/infragram-js. module.exports = function webglProcessor(options) { var imgContext = null, - mapContext = null, - inputImage, + mapContext = null, + inputImage, // the pre-processed image - vertices = [-1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0], + vertices = [-1.0, -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0], waitForShadersToLoad = 0, webglUtils = require('../util/webgl-utils')(), colorized = false, @@ -1048,7 +1004,7 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i stretched: 2, grey: 1 }, - colormap = colormaps.default; + colormap = colormaps.default; vertices.itemSize = 2; @@ -1347,7 +1303,7 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i }; }; }, { - "../util/webgl-utils": 18 + "../util/webgl-utils": 19 }], 12: [function (require, module, exports) { module.exports = function Analysis(options, save_infragrammar_inputs) { @@ -1498,9 +1454,10 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i Presets = require('../ui/presets')(options, save_infragrammar_inputs); Analysis = require('../ui/analysis')(options, save_infragrammar_inputs); Colorize = require('../ui/colorize')(options); + Saving = require('../ui/saving')(options); $(options.imageSelector).ready(function () { var src, - idNameMap = { + idNameMap = { "#m_exp": "m", "#r_exp": "r", "#g_exp": "g", @@ -1546,6 +1503,11 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i return true; }); $("#webcam-activate").click(function () { + if(isVideo){ + $("#localVideo").remove(); + } + isVideo = false; + isCamera = true; $('.choose-prompt').hide(); $("#save-modal-btn").show(); $("#save-zone").show(); @@ -1554,6 +1516,40 @@ function _slicedToArray(arr, i) { if (Array.isArray(arr)) { return arr; } else i $('#preset-modal').modal('show'); return true; }); + + $("#local-video-activate").click(function () { + if(isCamera){ + localStream.getVideoTracks()[0].stop(); + } + isCamera = false; + if(!isVideo){ //Prevent Creation of Duplicate video Elements + localVideo = document.createElement('video'); + localVideo.setAttribute("src", "../video.mp4"); + localVideo.setAttribute("id", "localVideo"); + localVideo.style.display = "none" + localVideo.style.width = "100px"; + localVideo.style.height = "50px"; + document.getElementById("video-container").appendChild(localVideo); + localVideo.play(); + localVideo.muted = true; + localVideo.loop = true; + document.getElementById("localVideoControls").style.display="block"; + //Attach video Element tocustom Sleek Bar + localVideo.ontimeupdate = function(){ + var percentage = ( localVideo.currentTime / localVideo.duration ) * 100; + $("#custom-seekbar span").css("width", percentage+"%"); + }; + //Create video controls + //document.getElementById("localVideoControls").innerHTML='
' + ' ' + ' ' + '' + msg + ' ' + ' |