language
stringclasses
6 values
original_string
stringlengths
25
887k
text
stringlengths
25
887k
JavaScript
static _convertAttrNameToPropName(attrName) { for (let prop in this.allProperties) { if (this.allProperties[prop].attr === attrName) { return prop; } } // Convert the property name to kebab case const propName = attrName.replace( /-([A-Za-z])/g, (l) => l[1].toUpperCase(), ); return propName; }
static _convertAttrNameToPropName(attrName) { for (let prop in this.allProperties) { if (this.allProperties[prop].attr === attrName) { return prop; } } // Convert the property name to kebab case const propName = attrName.replace( /-([A-Za-z])/g, (l) => l[1].toUpperCase(), ); return propName; }
JavaScript
_cascadeAttribute(name, to) { const recipients = [ ...this.querySelectorAll(to), ...this.shadowRoot.querySelectorAll(to), ]; for (const node of recipients) { this._copyAttribute(name, node); } }
_cascadeAttribute(name, to) { const recipients = [ ...this.querySelectorAll(to), ...this.shadowRoot.querySelectorAll(to), ]; for (const node of recipients) { this._copyAttribute(name, node); } }
JavaScript
_copyAttribute(name, el) { this.log(`copying ${name} to ${el}`); const value = this.getAttribute(name); const fname = value == null ? "removeAttribute" : "setAttribute"; el[fname](name, value); }
_copyAttribute(name, el) { this.log(`copying ${name} to ${el}`); const value = this.getAttribute(name); const fname = value == null ? "removeAttribute" : "setAttribute"; el[fname](name, value); }
JavaScript
static _populateCache(pfe) { // @TODO add a warning when a component property conflicts with a global property. const mergedProperties = { ...pfe.properties, ...PFElement.properties }; pfe._setCache("componentProperties", pfe.properties); pfe._setCache("globalProperties", PFElement.properties); pfe._setCache("properties", mergedProperties); // create mapping objects to go from prop name to attrname and back const prop2attr = {}; const attr2prop = {}; for (let propName in mergedProperties) { const attrName = this._convertPropNameToAttrName(propName); prop2attr[propName] = attrName; attr2prop[attrName] = propName; } pfe._setCache("attr2prop", attr2prop); pfe._setCache("prop2attr", prop2attr); const cascadingProperties = this._parsePropertiesForCascade( mergedProperties, ); if (Object.keys(cascadingProperties)) { pfe._setCache("cascadingProperties", cascadingProperties); } }
static _populateCache(pfe) { // @TODO add a warning when a component property conflicts with a global property. const mergedProperties = { ...pfe.properties, ...PFElement.properties }; pfe._setCache("componentProperties", pfe.properties); pfe._setCache("globalProperties", PFElement.properties); pfe._setCache("properties", mergedProperties); // create mapping objects to go from prop name to attrname and back const prop2attr = {}; const attr2prop = {}; for (let propName in mergedProperties) { const attrName = this._convertPropNameToAttrName(propName); prop2attr[propName] = attrName; attr2prop[attrName] = propName; } pfe._setCache("attr2prop", attr2prop); pfe._setCache("prop2attr", prop2attr); const cascadingProperties = this._parsePropertiesForCascade( mergedProperties, ); if (Object.keys(cascadingProperties)) { pfe._setCache("cascadingProperties", cascadingProperties); } }
JavaScript
static get breakpoint() { return { xs: "0px", // $pf-global--breakpoint--xs: 0 !default; sm: "576px", // $pf-global--breakpoint--sm: 576px !default; md: "768px", // $pf-global--breakpoint--md: 768px !default; lg: "992px", // $pf-global--breakpoint--lg: 992px !default; xl: "1200px", // $pf-global--breakpoint--xl: 1200px !default; "2xl": "1450px", // $pf-global--breakpoint--2xl: 1450px !default; }; }
static get breakpoint() { return { xs: "0px", // $pf-global--breakpoint--xs: 0 !default; sm: "576px", // $pf-global--breakpoint--sm: 576px !default; md: "768px", // $pf-global--breakpoint--md: 768px !default; lg: "992px", // $pf-global--breakpoint--lg: 992px !default; xl: "1200px", // $pf-global--breakpoint--xl: 1200px !default; "2xl": "1450px", // $pf-global--breakpoint--2xl: 1450px !default; }; }
JavaScript
function hideScrollArrows(slider) { let maxScroll = slider.scrollWidth - slider.clientWidth; if (slider.scrollLeft === 0) { document.getElementById("hfc__arrow-left").classList.add("no-button--inactive"); } else { document.getElementById("hfc__arrow-left").classList.remove("no-button--inactive"); } if (slider.scrollLeft === maxScroll) { document.getElementById("hfc__arrow-right").classList.add("no-button--inactive"); } else { document.getElementById("hfc__arrow-right").classList.remove("no-button--inactive"); } }
function hideScrollArrows(slider) { let maxScroll = slider.scrollWidth - slider.clientWidth; if (slider.scrollLeft === 0) { document.getElementById("hfc__arrow-left").classList.add("no-button--inactive"); } else { document.getElementById("hfc__arrow-left").classList.remove("no-button--inactive"); } if (slider.scrollLeft === maxScroll) { document.getElementById("hfc__arrow-right").classList.add("no-button--inactive"); } else { document.getElementById("hfc__arrow-right").classList.remove("no-button--inactive"); } }
JavaScript
function initializeState() { const allTones = [ "C3", "D3", "E3", "F3", "G3", "A3", "B3", "C4" ]; return { interval: generateInterval(allTones), allTones: allTones } }
function initializeState() { const allTones = [ "C3", "D3", "E3", "F3", "G3", "A3", "B3", "C4" ]; return { interval: generateInterval(allTones), allTones: allTones } }
JavaScript
function nextInterval(currentInterval, allTones) { let interval = generateInterval(allTones); while (intervalsEqual(interval, currentInterval)) { interval = generateInterval(allTones); } return interval; }
function nextInterval(currentInterval, allTones) { let interval = generateInterval(allTones); while (intervalsEqual(interval, currentInterval)) { interval = generateInterval(allTones); } return interval; }
JavaScript
function updateUI(p) { p = p || {}; var scrollTop = app.display.scrollTop; // In builder, always recompute display infos for editing if (app.isInBuilder) { computeDisplayInfos(); } app.display.scrollTop = scrollTop; // Ignore event without actual scroll if (_currentScrollTop == scrollTop && ! p.forceUpdate) { return; } _currentScrollTop = scrollTop; var sectionsDisplayInfos = getActiveAndVisibleSections(scrollTop, scrollTop + app.display.windowHeight), currentSectionDisplayInfos = sectionsDisplayInfos.activeSection; if (! currentSectionDisplayInfos) { return; } var currentSectionIndex = currentSectionDisplayInfos.index, $currentSection = currentSectionDisplayInfos.node, currentSectionScroll = scrollTop - currentSectionDisplayInfos.top; //nextSection = app.display.sections[currentSectionIndex + 1] // // Story // app.Controller.onScroll({ currentSectionIndex: currentSectionIndex, scrollTop: scrollTop, windowWidth: app.display.windowWidth, windowHeight: app.display.windowHeight, $currentSection: $currentSection, sectionHeight: app.display.sectionHeight, currentSectionScroll: currentSectionScroll, visibleSections: sectionsDisplayInfos.visibleSections }); // // Header // var headerCompact = false; if (scrollTop <= app.display.windowHeight) { var newPos = app.display.windowHeight - scrollTop - 50; if (newPos < 40) { newPos = 0; } headerCompact = newPos !== 0; } _header.update({ headerCompact: headerCompact, storyProgress: (scrollTop + app.display.windowHeight) / app.display.storyHeight * 100, sectionIndex: currentSectionIndex }); }
function updateUI(p) { p = p || {}; var scrollTop = app.display.scrollTop; // In builder, always recompute display infos for editing if (app.isInBuilder) { computeDisplayInfos(); } app.display.scrollTop = scrollTop; // Ignore event without actual scroll if (_currentScrollTop == scrollTop && ! p.forceUpdate) { return; } _currentScrollTop = scrollTop; var sectionsDisplayInfos = getActiveAndVisibleSections(scrollTop, scrollTop + app.display.windowHeight), currentSectionDisplayInfos = sectionsDisplayInfos.activeSection; if (! currentSectionDisplayInfos) { return; } var currentSectionIndex = currentSectionDisplayInfos.index, $currentSection = currentSectionDisplayInfos.node, currentSectionScroll = scrollTop - currentSectionDisplayInfos.top; //nextSection = app.display.sections[currentSectionIndex + 1] // // Story // app.Controller.onScroll({ currentSectionIndex: currentSectionIndex, scrollTop: scrollTop, windowWidth: app.display.windowWidth, windowHeight: app.display.windowHeight, $currentSection: $currentSection, sectionHeight: app.display.sectionHeight, currentSectionScroll: currentSectionScroll, visibleSections: sectionsDisplayInfos.visibleSections }); // // Header // var headerCompact = false; if (scrollTop <= app.display.windowHeight) { var newPos = app.display.windowHeight - scrollTop - 50; if (newPos < 40) { newPos = 0; } headerCompact = newPos !== 0; } _header.update({ headerCompact: headerCompact, storyProgress: (scrollTop + app.display.windowHeight) / app.display.storyHeight * 100, sectionIndex: currentSectionIndex }); }
JavaScript
function computeDisplayInfos() { // Sections display info var sections = []; $('.section').each(function(index) { var node = $(this); sections.push({ top: node.hasClass('hidden') ? Number.MAX_VALUE : node.position().top, node: node, type: app.data.sections[index].type }); }); // Videos in Sequence var inlineVideos = []; /* // Video autoplay $('.block .video').each(function() { var node = $(this), nodeBlock = node.parents('.block').eq(0); inlineVideos.push({ id: node.attr('id'), top: nodeBlock.position().top, bottom: nodeBlock.position().top + node.height(), sectionIndex: node.parents('.section').index(), // TODO: KO with after-block like image caption! blockIndex: nodeBlock.index() }); }); */ //var hasTouch = app.display ? app.display.hasTouch : has('touch'); //var isMobile = app.display ? app.display.isMobile : UIUtils.isMobileBrowser(); var $window = $(window), windowWidth = $window.width(), windowHeight = $window.height(), headerHeight = _header.getHeight(); app.display = { browserWidth: windowWidth, windowWidth: windowWidth - (app.isInBuilder ? $('.section-builder-panel').width() : 0), windowHeight: windowHeight, headerHeight: headerHeight, sectionHeight: windowHeight - headerHeight, storyHeight: $('body').height(), scrollTop: app.display ? app.display.scrollTop : 0, sections: sections, inlineVideos: inlineVideos /*, hasTouch: hasTouch, isMobile: isMobile*/ }; }
function computeDisplayInfos() { // Sections display info var sections = []; $('.section').each(function(index) { var node = $(this); sections.push({ top: node.hasClass('hidden') ? Number.MAX_VALUE : node.position().top, node: node, type: app.data.sections[index].type }); }); // Videos in Sequence var inlineVideos = []; /* // Video autoplay $('.block .video').each(function() { var node = $(this), nodeBlock = node.parents('.block').eq(0); inlineVideos.push({ id: node.attr('id'), top: nodeBlock.position().top, bottom: nodeBlock.position().top + node.height(), sectionIndex: node.parents('.section').index(), // TODO: KO with after-block like image caption! blockIndex: nodeBlock.index() }); }); */ //var hasTouch = app.display ? app.display.hasTouch : has('touch'); //var isMobile = app.display ? app.display.isMobile : UIUtils.isMobileBrowser(); var $window = $(window), windowWidth = $window.width(), windowHeight = $window.height(), headerHeight = _header.getHeight(); app.display = { browserWidth: windowWidth, windowWidth: windowWidth - (app.isInBuilder ? $('.section-builder-panel').width() : 0), windowHeight: windowHeight, headerHeight: headerHeight, sectionHeight: windowHeight - headerHeight, storyHeight: $('body').height(), scrollTop: app.display ? app.display.scrollTop : 0, sections: sections, inlineVideos: inlineVideos /*, hasTouch: hasTouch, isMobile: isMobile*/ }; }
JavaScript
function processLoginClick (response) { var uid = response.authResponse.userID; var access_token = response.authResponse.accessToken; var permissions = response.authResponse.grantedScopes; var data = { uid:uid, access_token:access_token, _token:$('meta[name="_token"]').attr('content'), // this is important for Laravel to receive the data permissions:permissions }; postData(window.location.href, data, "post"); }
function processLoginClick (response) { var uid = response.authResponse.userID; var access_token = response.authResponse.accessToken; var permissions = response.authResponse.grantedScopes; var data = { uid:uid, access_token:access_token, _token:$('meta[name="_token"]').attr('content'), // this is important for Laravel to receive the data permissions:permissions }; postData(window.location.href, data, "post"); }
JavaScript
function postData(url, data, method) { method = method || "post"; var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", url); for(var key in data) { if(data.hasOwnProperty(key)) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", key); hiddenField.setAttribute("value", data[key]); form.appendChild(hiddenField); } } document.body.appendChild(form); form.submit(); }
function postData(url, data, method) { method = method || "post"; var form = document.createElement("form"); form.setAttribute("method", method); form.setAttribute("action", url); for(var key in data) { if(data.hasOwnProperty(key)) { var hiddenField = document.createElement("input"); hiddenField.setAttribute("type", "hidden"); hiddenField.setAttribute("name", key); hiddenField.setAttribute("value", data[key]); form.appendChild(hiddenField); } } document.body.appendChild(form); form.submit(); }
JavaScript
function SoundcloudLoader(player) { var self = this; var client_id = SOUNDCLOUD_ID; // to get an ID go to http://developers.soundcloud.com/ this.sound = {}; this.streamUrl = ""; this.errorMessage = ""; this.player = player; this.successfullyLoaded = false; /** * Loads the JSON stream data object from the URL of the track (as given in the location bar of the browser when browsing Soundcloud), * and on success it calls the callback passed to it (for example, used to then send the stream_url to the audiosource object). * @param track_url * @param callback */ this.loadStream = function(track_url, successCallback, errorCallback) { if (typeof SC !== 'undefined') { SC.initialize({ client_id: client_id }); SC.get('/resolve', {url: track_url}, function (sound) { if (sound) { if (sound.errors) { self.errorMessage = ""; for (var i = 0; i < sound.errors.length; i++) { self.errorMessage += sound.errors[i].error_message + '<br>'; } self.errorMessage += 'Make sure the URL has the correct format: https://soundcloud.com/user/title-of-the-track'; errorCallback(); } else { self.successfullyLoaded = true; console.log('music loaded'); if (sound.kind == "playlist") { self.sound = sound; self.streamPlaylistIndex = 0; self.streamUrl = function () { return sound.tracks[self.streamPlaylistIndex].stream_url + '?client_id=' + client_id; }; successCallback(); } else { self.sound = sound; self.streamUrl = function () { return sound.stream_url + '?client_id=' + client_id; }; successCallback(); } } } else { console.log('An unspecified error occurred. No music could be loaded'); successCallback(); // call success just so the game will still run } }); } else { console.log('SoundCloud library not found. No music could be loaded'); successCallback(); // call success just so the game will still run } }; this.directStream = function(direction){ if(direction=='toggle'){ if (this.player.paused) { this.player.play(); } else { this.player.pause(); } } else if(this.sound.kind=="playlist"){ if(direction=='coasting') { this.streamPlaylistIndex++; }else if(direction=='forward') { if(this.streamPlaylistIndex>=this.sound.track_count-1) this.streamPlaylistIndex = 0; else this.streamPlaylistIndex++; }else{ if(this.streamPlaylistIndex<=0) this.streamPlaylistIndex = this.sound.track_count-1; else this.streamPlaylistIndex--; } if(this.streamPlaylistIndex>=0 && this.streamPlaylistIndex<=this.sound.track_count-1) { this.player.setAttribute('src',this.streamUrl()); this.player.play(); } } } }
function SoundcloudLoader(player) { var self = this; var client_id = SOUNDCLOUD_ID; // to get an ID go to http://developers.soundcloud.com/ this.sound = {}; this.streamUrl = ""; this.errorMessage = ""; this.player = player; this.successfullyLoaded = false; /** * Loads the JSON stream data object from the URL of the track (as given in the location bar of the browser when browsing Soundcloud), * and on success it calls the callback passed to it (for example, used to then send the stream_url to the audiosource object). * @param track_url * @param callback */ this.loadStream = function(track_url, successCallback, errorCallback) { if (typeof SC !== 'undefined') { SC.initialize({ client_id: client_id }); SC.get('/resolve', {url: track_url}, function (sound) { if (sound) { if (sound.errors) { self.errorMessage = ""; for (var i = 0; i < sound.errors.length; i++) { self.errorMessage += sound.errors[i].error_message + '<br>'; } self.errorMessage += 'Make sure the URL has the correct format: https://soundcloud.com/user/title-of-the-track'; errorCallback(); } else { self.successfullyLoaded = true; console.log('music loaded'); if (sound.kind == "playlist") { self.sound = sound; self.streamPlaylistIndex = 0; self.streamUrl = function () { return sound.tracks[self.streamPlaylistIndex].stream_url + '?client_id=' + client_id; }; successCallback(); } else { self.sound = sound; self.streamUrl = function () { return sound.stream_url + '?client_id=' + client_id; }; successCallback(); } } } else { console.log('An unspecified error occurred. No music could be loaded'); successCallback(); // call success just so the game will still run } }); } else { console.log('SoundCloud library not found. No music could be loaded'); successCallback(); // call success just so the game will still run } }; this.directStream = function(direction){ if(direction=='toggle'){ if (this.player.paused) { this.player.play(); } else { this.player.pause(); } } else if(this.sound.kind=="playlist"){ if(direction=='coasting') { this.streamPlaylistIndex++; }else if(direction=='forward') { if(this.streamPlaylistIndex>=this.sound.track_count-1) this.streamPlaylistIndex = 0; else this.streamPlaylistIndex++; }else{ if(this.streamPlaylistIndex<=0) this.streamPlaylistIndex = this.sound.track_count-1; else this.streamPlaylistIndex--; } if(this.streamPlaylistIndex>=0 && this.streamPlaylistIndex<=this.sound.track_count-1) { this.player.setAttribute('src',this.streamUrl()); this.player.play(); } } } }
JavaScript
function Sound(buffer, context) { this.context = context; this.buffer = buffer; this.panner = context.createPanner(); this.gain = context.createGain(); this.playbackRate = 1; this.setPannerParameters = function(options) { for(var option in options) { if (options.hasOwnProperty(option)) { this.panner[option] = options[option]; } } }; this.setPlaybackRate = function(value) { this.playbackRate = value; }; this.setGain = function(value) { this.gain.gain.value = value; }; this.setPosition = function(x, y, z) { this.panner.setPosition(x, y, z); }; this.setVelocity = function(vx, vy, vz) { // this.panner.setVelocity(vx, vy, vz); }; this.play = function(outputNode, loop) { loop = loop || false; this.source = this.context.createBufferSource(); this.source.buffer = this.buffer; this.source.playbackRate.value = this.playbackRate; if (loop) { this.source.loop = true; } this.source.connect(this.gain); this.gain.connect(this.panner); this.panner.connect(outputNode); this.source.start(); }; this.stop = function() { this.source.stop(); }; }
function Sound(buffer, context) { this.context = context; this.buffer = buffer; this.panner = context.createPanner(); this.gain = context.createGain(); this.playbackRate = 1; this.setPannerParameters = function(options) { for(var option in options) { if (options.hasOwnProperty(option)) { this.panner[option] = options[option]; } } }; this.setPlaybackRate = function(value) { this.playbackRate = value; }; this.setGain = function(value) { this.gain.gain.value = value; }; this.setPosition = function(x, y, z) { this.panner.setPosition(x, y, z); }; this.setVelocity = function(vx, vy, vz) { // this.panner.setVelocity(vx, vy, vz); }; this.play = function(outputNode, loop) { loop = loop || false; this.source = this.context.createBufferSource(); this.source.buffer = this.buffer; this.source.playbackRate.value = this.playbackRate; if (loop) { this.source.loop = true; } this.source.connect(this.gain); this.gain.connect(this.panner); this.panner.connect(outputNode); this.source.start(); }; this.stop = function() { this.source.stop(); }; }
JavaScript
function mapInactives() { var mappedStates = {}; angular.forEach(inactiveStates, function (state, name) { var stickyAncestors = getStickyStateStack(state); for (var i = 0; i < stickyAncestors.length; i++) { var parent = stickyAncestors[i].parent; mappedStates[parent.name] = mappedStates[parent.name] || []; mappedStates[parent.name].push(state); } if (mappedStates['']) { // This is necessary to compute Transition.inactives when there are sticky states are children to root state. mappedStates['__inactives'] = mappedStates['']; // jshint ignore:line } }); return mappedStates; }
function mapInactives() { var mappedStates = {}; angular.forEach(inactiveStates, function (state, name) { var stickyAncestors = getStickyStateStack(state); for (var i = 0; i < stickyAncestors.length; i++) { var parent = stickyAncestors[i].parent; mappedStates[parent.name] = mappedStates[parent.name] || []; mappedStates[parent.name].push(state); } if (mappedStates['']) { // This is necessary to compute Transition.inactives when there are sticky states are children to root state. mappedStates['__inactives'] = mappedStates['']; // jshint ignore:line } }); return mappedStates; }
JavaScript
function expose(promise) { // Don't add hooks to the same promise twice (shouldn't happen anyway) if (!promise.hasOwnProperty('$$resolved')) { promise.$$resolved = false; promise.then(function (value) { promise.$$resolved = { success: true, value: value }; }, function (error) { promise.$$resolved = { success: false, error: error }; }); // We need to expose() any then()ed promises recursively var qThen = promise.then; promise.then = function () { return expose(qThen.apply(this, arguments)); }; } return promise; }
function expose(promise) { // Don't add hooks to the same promise twice (shouldn't happen anyway) if (!promise.hasOwnProperty('$$resolved')) { promise.$$resolved = false; promise.then(function (value) { promise.$$resolved = { success: true, value: value }; }, function (error) { promise.$$resolved = { success: false, error: error }; }); // We need to expose() any then()ed promises recursively var qThen = promise.then; promise.then = function () { return expose(qThen.apply(this, arguments)); }; } return promise; }
JavaScript
function decorateInjector(tData) { var oldinvoke = $injector.invoke; var oldinstantiate = $injector.instantiate; $injector.invoke = function (fn, self, locals) { return oldinvoke(fn, self, angular.extend({$transition$: tData}, locals)); }; $injector.instantiate = function (fn, locals) { return oldinstantiate(fn, angular.extend({$transition$: tData}, locals)); }; return function restoreItems() { $injector.invoke = oldinvoke; $injector.instantiate = oldinstantiate; }; }
function decorateInjector(tData) { var oldinvoke = $injector.invoke; var oldinstantiate = $injector.instantiate; $injector.invoke = function (fn, self, locals) { return oldinvoke(fn, self, angular.extend({$transition$: tData}, locals)); }; $injector.instantiate = function (fn, locals) { return oldinstantiate(fn, angular.extend({$transition$: tData}, locals)); }; return function restoreItems() { $injector.invoke = oldinvoke; $injector.instantiate = oldinstantiate; }; }
JavaScript
function transitionSuccess(deferred, tSuccess) { return function successFn(data) { popStack(); $rootScope.$broadcast("$transitionSuccess", tSuccess); deferred.resolve(data); // $transition$ deferred return data; }; }
function transitionSuccess(deferred, tSuccess) { return function successFn(data) { popStack(); $rootScope.$broadcast("$transitionSuccess", tSuccess); deferred.resolve(data); // $transition$ deferred return data; }; }
JavaScript
function transitionFailure(deferred, tFail) { return function failureFn(error) { popStack(); $rootScope.$broadcast("$transitionError", tFail, error); deferred.reject(error); // $transition$ deferred return $q.reject(error); }; }
function transitionFailure(deferred, tFail) { return function failureFn(error) { popStack(); $rootScope.$broadcast("$transitionError", tFail, error); deferred.reject(error); // $transition$ deferred return $q.reject(error); }; }
JavaScript
function fieldLink(scope, el, attrs) { init(scope); // Hook in our watched items scope.$watchCollection('[page,pageSize,total]', function () { build(scope); }); }
function fieldLink(scope, el, attrs) { init(scope); // Hook in our watched items scope.$watchCollection('[page,pageSize,total]', function () { build(scope); }); }
JavaScript
function fieldTemplate(el, attrs){ return '<ul data-ng-hide="Hide" data-ng-class="options.ulClass"> ' + '<li ' + 'data-ng-class="Item.liClass" ' + 'data-ng-repeat="Item in List"> ' + '<a href="javascript:void(0)"' + 'data-ng-class="Item.aClass" ' + 'data-ng-click="Item.action()" ' + 'data-ng-bind="Item.value">'+ '</a> ' + '</li>' + '</ul>'; }
function fieldTemplate(el, attrs){ return '<ul data-ng-hide="Hide" data-ng-class="options.ulClass"> ' + '<li ' + 'data-ng-class="Item.liClass" ' + 'data-ng-repeat="Item in List"> ' + '<a href="javascript:void(0)"' + 'data-ng-class="Item.aClass" ' + 'data-ng-click="Item.action()" ' + 'data-ng-bind="Item.value">'+ '</a> ' + '</li>' + '</ul>'; }
JavaScript
function validateScopeValues(scope) { scope.List = []; scope.page = parseInt(scope.page, 10) || 1; scope.pageSize = parseInt(scope.pageSize, 10) || 10; scope.total = parseInt(scope.total) || 0; scope.Hide = scope.options.hideIfEmpty && scope.total == 0; scope.totalPages = Math.ceil(scope.total / scope.pageSize) || 1; // Block where the page is larger than the pageCount if (scope.page > scope.totalPages) { scope.page = scope.totalPages; } // Block where the page is less than 0 if (scope.page <= 0) { scope.page = 1; } }
function validateScopeValues(scope) { scope.List = []; scope.page = parseInt(scope.page, 10) || 1; scope.pageSize = parseInt(scope.pageSize, 10) || 10; scope.total = parseInt(scope.total) || 0; scope.Hide = scope.options.hideIfEmpty && scope.total == 0; scope.totalPages = Math.ceil(scope.total / scope.pageSize) || 1; // Block where the page is larger than the pageCount if (scope.page > scope.totalPages) { scope.page = scope.totalPages; } // Block where the page is less than 0 if (scope.page <= 0) { scope.page = 1; } }
JavaScript
function internalAction(scope, page) { // Block clicks we try to load the active page if (scope.page == page) { return; } // Update the page in scope scope.page = page; // Pass our parameters to the paging action scope.pagingAction({ page: scope.page, pageSize: scope.pageSize, total: scope.total }); }
function internalAction(scope, page) { // Block clicks we try to load the active page if (scope.page == page) { return; } // Update the page in scope scope.page = page; // Pass our parameters to the paging action scope.pagingAction({ page: scope.page, pageSize: scope.pageSize, total: scope.total }); }
JavaScript
function addPrevNext(scope, mode) { var options = scope.options; // Ignore if we are not showing // or there are not more than maxVisible pages to display if ((!options.showPrevNext) || scope.totalPages <= 2 * (options.endPoint + options.adjacent) + 1) { return; } // Local variables to help determine logic var disabled; // Determine logic based on the mode of interest // Calculate the previous / next page and if the click actions are allowed if (mode === 'prev') { disabled = scope.page == 1; scope.List.push({ value: options.textPrevClass ? '' : options.textPrev, liClass: disabled ? options.disabledClass: '', aClass: options.textPrevClass, action: function() { if (!disabled) { internalAction(scope, scope.page - 1); } } }); } else { disabled = scope.page == scope.totalPages; scope.List.push({ value: options.textNextClass ? '' : options.textNext, liClass: disabled ? options.disabledClass: '', aClass: options.textNextClass, action: function() { if (!disabled) { internalAction(scope, scope.page + 1); } } }); } }
function addPrevNext(scope, mode) { var options = scope.options; // Ignore if we are not showing // or there are not more than maxVisible pages to display if ((!options.showPrevNext) || scope.totalPages <= 2 * (options.endPoint + options.adjacent) + 1) { return; } // Local variables to help determine logic var disabled; // Determine logic based on the mode of interest // Calculate the previous / next page and if the click actions are allowed if (mode === 'prev') { disabled = scope.page == 1; scope.List.push({ value: options.textPrevClass ? '' : options.textPrev, liClass: disabled ? options.disabledClass: '', aClass: options.textPrevClass, action: function() { if (!disabled) { internalAction(scope, scope.page - 1); } } }); } else { disabled = scope.page == scope.totalPages; scope.List.push({ value: options.textNextClass ? '' : options.textNext, liClass: disabled ? options.disabledClass: '', aClass: options.textNextClass, action: function() { if (!disabled) { internalAction(scope, scope.page + 1); } } }); } }
JavaScript
function addRange(start, finish, scope) { for (var i = start; i <= finish; i++) { scope.List.push({ value: i, liClass: scope.page == i ? scope.options.activeClass : '', action: function() { internalAction(scope, this.value); } }); } }
function addRange(start, finish, scope) { for (var i = start; i <= finish; i++) { scope.List.push({ value: i, liClass: scope.page == i ? scope.options.activeClass : '', action: function() { internalAction(scope, this.value); } }); } }
JavaScript
function addFirst(scope, next) { addRange(1, scope.options.endPoint, scope); // We ignore dots if the next value is 3 // ie: 1 2 [...] 3 4 5 becomes just 1 2 3 4 5 if (next != scope.options.endPoint + 1) { addDots(scope); } }
function addFirst(scope, next) { addRange(1, scope.options.endPoint, scope); // We ignore dots if the next value is 3 // ie: 1 2 [...] 3 4 5 becomes just 1 2 3 4 5 if (next != scope.options.endPoint + 1) { addDots(scope); } }
JavaScript
function build(scope) { validateScopeValues(scope); var start, end, totalPages = scope.totalPages, page = scope.page, endPoint = scope.options.endPoint, adjacent = scope.options.adjacent, maxVisible = 2 * (endPoint + adjacent) + 1; // Add the Next and Previous buttons to our list addPrevNext(scope, 'prev'); // If the page count is less than the maxVisible size // Then we simply display all the pages, Otherwise we calculate the proper paging display if (totalPages <= maxVisible) { addRange(1, totalPages, scope); } else { // Determine if we are showing the beginning of the paging list if (page <= endPoint + adjacent + 1) { start = 1; end = page <= adjacent + 1 ? 2 * adjacent + 1 : page + adjacent; addRange(start, end, scope); addLast(scope, end); } // Determine if we are showing the end of the paging list else if (page >= totalPages - endPoint - adjacent) { start = page >= totalPages - adjacent ? totalPages - 2 * adjacent : page - adjacent; end = totalPages; addFirst(scope, start); addRange(start, end, scope); } // If nothing else we conclude we are at the middle of the paging list else { start = page - adjacent; end = page + adjacent; addFirst(scope, start); addRange(start, end, scope); addLast(scope, end); } } // Add the next and last buttons to our paging list addPrevNext(scope, 'next'); }
function build(scope) { validateScopeValues(scope); var start, end, totalPages = scope.totalPages, page = scope.page, endPoint = scope.options.endPoint, adjacent = scope.options.adjacent, maxVisible = 2 * (endPoint + adjacent) + 1; // Add the Next and Previous buttons to our list addPrevNext(scope, 'prev'); // If the page count is less than the maxVisible size // Then we simply display all the pages, Otherwise we calculate the proper paging display if (totalPages <= maxVisible) { addRange(1, totalPages, scope); } else { // Determine if we are showing the beginning of the paging list if (page <= endPoint + adjacent + 1) { start = 1; end = page <= adjacent + 1 ? 2 * adjacent + 1 : page + adjacent; addRange(start, end, scope); addLast(scope, end); } // Determine if we are showing the end of the paging list else if (page >= totalPages - endPoint - adjacent) { start = page >= totalPages - adjacent ? totalPages - 2 * adjacent : page - adjacent; end = totalPages; addFirst(scope, start); addRange(start, end, scope); } // If nothing else we conclude we are at the middle of the paging list else { start = page - adjacent; end = page + adjacent; addFirst(scope, start); addRange(start, end, scope); addLast(scope, end); } } // Add the next and last buttons to our paging list addPrevNext(scope, 'next'); }
JavaScript
function p7DSRFunction($dsr$) { // allow standard DSR behavior by returning true if $dsr$.redirect has a state set if ($dsr$.redirect.state) return true; // Otherwise, return a redirect object {state: "foo", params: {} } for the default case return { state: ($dsr$.to.params.param == 2) ? "p7.child2" : "p7.child1", params: {} }; }
function p7DSRFunction($dsr$) { // allow standard DSR behavior by returning true if $dsr$.redirect has a state set if ($dsr$.redirect.state) return true; // Otherwise, return a redirect object {state: "foo", params: {} } for the default case return { state: ($dsr$.to.params.param == 2) ? "p7.child2" : "p7.child1", params: {} }; }
JavaScript
function addBook(request, response) { let { title, author, description, image_url, isbn, bookshelf } = request.body; console.log(bookshelf); let sql = 'INSERT INTO books (title, author, description, image_url, isbn, bookshelf) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id;'; let safeValues = [title, author, description, image_url, isbn, bookshelf]; client.query(sql, safeValues) .then(results => { let id = results.rows[0].id; response.redirect(`/books/${id}`) // customize this catch to send you back to favorites or find books }).catch(error => { response.render('pages/error.ejs', { error: error }); }); }
function addBook(request, response) { let { title, author, description, image_url, isbn, bookshelf } = request.body; console.log(bookshelf); let sql = 'INSERT INTO books (title, author, description, image_url, isbn, bookshelf) VALUES ($1, $2, $3, $4, $5, $6) RETURNING id;'; let safeValues = [title, author, description, image_url, isbn, bookshelf]; client.query(sql, safeValues) .then(results => { let id = results.rows[0].id; response.redirect(`/books/${id}`) // customize this catch to send you back to favorites or find books }).catch(error => { response.render('pages/error.ejs', { error: error }); }); }
JavaScript
function createWindow() { mainWindow = new BrowserWindow({ width: 1000, height: 800, webPreferences: { nodeIntegration: true }, frame: false, }); // Remove the Menu Bar mainWindow.removeMenu(); // Load index.html into the new BrowserWindow mainWindow.loadFile("./templates/index.html"); // Open DevTools - Remove for PRODUCTION! mainWindow.webContents.openDevTools(); // Listen for window being closed mainWindow.on("closed", () => { mainWindow = null; }); }
function createWindow() { mainWindow = new BrowserWindow({ width: 1000, height: 800, webPreferences: { nodeIntegration: true }, frame: false, }); // Remove the Menu Bar mainWindow.removeMenu(); // Load index.html into the new BrowserWindow mainWindow.loadFile("./templates/index.html"); // Open DevTools - Remove for PRODUCTION! mainWindow.webContents.openDevTools(); // Listen for window being closed mainWindow.on("closed", () => { mainWindow = null; }); }
JavaScript
gainMult() { // Calculate the multiplier for main currency from bonuses mult = new Decimal(1) if(player.ap.activeChallenge==31)return new Decimal(0); if(player.m.points.gte(6))mult=mult.mul(tmp.m.milestone6Effect); if(hasUpgrade("p",13))mult=mult.mul(upgradeEffect("p",13)); if(hasUpgrade("p",14))mult=mult.mul(upgradeEffect("p",14)); if(player.m.points.gte(22))mult=mult.mul(22); if(hasUpgrade("sp",13))mult=mult.mul(upgradeEffect("sp",13)); if(hasUpgrade("sp",14))mult=mult.mul(upgradeEffect("sp",14)); if(hasUpgrade("hp",13))mult=mult.mul(upgradeEffect("hp",13)); if(hasUpgrade("hp",14))mult=mult.mul(upgradeEffect("hp",14)); if(hasUpgrade("ap",12))mult=mult.mul(upgradeEffect("ap",12)); mult=mult.mul(tmp.sp.buyables[11].effect); mult=mult.mul(tmp.hp.buyables[11].effect); return mult }
gainMult() { // Calculate the multiplier for main currency from bonuses mult = new Decimal(1) if(player.ap.activeChallenge==31)return new Decimal(0); if(player.m.points.gte(6))mult=mult.mul(tmp.m.milestone6Effect); if(hasUpgrade("p",13))mult=mult.mul(upgradeEffect("p",13)); if(hasUpgrade("p",14))mult=mult.mul(upgradeEffect("p",14)); if(player.m.points.gte(22))mult=mult.mul(22); if(hasUpgrade("sp",13))mult=mult.mul(upgradeEffect("sp",13)); if(hasUpgrade("sp",14))mult=mult.mul(upgradeEffect("sp",14)); if(hasUpgrade("hp",13))mult=mult.mul(upgradeEffect("hp",13)); if(hasUpgrade("hp",14))mult=mult.mul(upgradeEffect("hp",14)); if(hasUpgrade("ap",12))mult=mult.mul(upgradeEffect("ap",12)); mult=mult.mul(tmp.sp.buyables[11].effect); mult=mult.mul(tmp.hp.buyables[11].effect); return mult }
JavaScript
gainMult() { // Calculate the multiplier for main currency from bonuses mult = new Decimal(1) if(player.ap.activeChallenge==12)return new Decimal(0); if(player.m.points.gte(27))mult=mult.mul(tmp.m.milestone27Effect); if(hasUpgrade("sp",21))mult=mult.mul(upgradeEffect("sp",21)); if(hasUpgrade("sp",22))mult=mult.mul(upgradeEffect("sp",22)); if(hasUpgrade("hp",21))mult=mult.mul(upgradeEffect("hp",21)); if(hasUpgrade("hp",22))mult=mult.mul(upgradeEffect("hp",22)); if(hasUpgrade("ap",13))mult=mult.mul(upgradeEffect("ap",13)); mult=mult.mul(tmp.hp.buyables[12].effect); return mult }
gainMult() { // Calculate the multiplier for main currency from bonuses mult = new Decimal(1) if(player.ap.activeChallenge==12)return new Decimal(0); if(player.m.points.gte(27))mult=mult.mul(tmp.m.milestone27Effect); if(hasUpgrade("sp",21))mult=mult.mul(upgradeEffect("sp",21)); if(hasUpgrade("sp",22))mult=mult.mul(upgradeEffect("sp",22)); if(hasUpgrade("hp",21))mult=mult.mul(upgradeEffect("hp",21)); if(hasUpgrade("hp",22))mult=mult.mul(upgradeEffect("hp",22)); if(hasUpgrade("ap",13))mult=mult.mul(upgradeEffect("ap",13)); mult=mult.mul(tmp.hp.buyables[12].effect); return mult }
JavaScript
effect() { // Calculate bonuses from the upgrade. Can return a single value or an object with multiple values let base=50; if(player.m.points.gte(31))base+=5; if(player.m.points.gte(49))base+=5; if(player.m.points.gte(59))base+=5; if(player.m.points.gte(69))base+=5; if(player.m.points.gte(79))base+=10; if(player.m.points.gte(89))base+=5; if(hasUpgrade("sp",44))base+=10; let ret = Decimal.pow(base,Decimal.log10(player[this.layer].points.add(1)).pow(0.9).add(1)) return ret; }
effect() { // Calculate bonuses from the upgrade. Can return a single value or an object with multiple values let base=50; if(player.m.points.gte(31))base+=5; if(player.m.points.gte(49))base+=5; if(player.m.points.gte(59))base+=5; if(player.m.points.gte(69))base+=5; if(player.m.points.gte(79))base+=10; if(player.m.points.gte(89))base+=5; if(hasUpgrade("sp",44))base+=10; let ret = Decimal.pow(base,Decimal.log10(player[this.layer].points.add(1)).pow(0.9).add(1)) return ret; }
JavaScript
effect() { // Calculate bonuses from the upgrade. Can return a single value or an object with multiple values let base=10; if(player.m.points.gte(32))base+=1; if(player.m.points.gte(49))base+=1; if(player.m.points.gte(59))base+=2; if(player.m.points.gte(69))base+=1; if(player.m.points.gte(79))base+=2; if(player.m.points.gte(89))base+=1; if(hasUpgrade("sp",44))base+=2; let ret = Decimal.pow(base,Decimal.log10(player[this.layer].points.add(1)).pow(0.9).add(1)) return ret; }
effect() { // Calculate bonuses from the upgrade. Can return a single value or an object with multiple values let base=10; if(player.m.points.gte(32))base+=1; if(player.m.points.gte(49))base+=1; if(player.m.points.gte(59))base+=2; if(player.m.points.gte(69))base+=1; if(player.m.points.gte(79))base+=2; if(player.m.points.gte(89))base+=1; if(hasUpgrade("sp",44))base+=2; let ret = Decimal.pow(base,Decimal.log10(player[this.layer].points.add(1)).pow(0.9).add(1)) return ret; }
JavaScript
effect() { // Calculate bonuses from the upgrade. Can return a single value or an object with multiple values let base=3; if(player.m.points.gte(33))base+=0.5; if(player.m.points.gte(49))base+=0.5; if(player.m.points.gte(59))base+=0.92; if(player.m.points.gte(69))base+=0.58; if(player.m.points.gte(79))base+=1; if(player.m.points.gte(89))base+=0.5; if(hasUpgrade("sp",44))base+=1; let ret = Decimal.pow(base,Decimal.log10(player[this.layer].points.add(1)).pow(0.9).add(1)) return ret; }
effect() { // Calculate bonuses from the upgrade. Can return a single value or an object with multiple values let base=3; if(player.m.points.gte(33))base+=0.5; if(player.m.points.gte(49))base+=0.5; if(player.m.points.gte(59))base+=0.92; if(player.m.points.gte(69))base+=0.58; if(player.m.points.gte(79))base+=1; if(player.m.points.gte(89))base+=0.5; if(hasUpgrade("sp",44))base+=1; let ret = Decimal.pow(base,Decimal.log10(player[this.layer].points.add(1)).pow(0.9).add(1)) return ret; }
JavaScript
effect() { // Calculate bonuses from the upgrade. Can return a single value or an object with multiple values let base=1.5; if(player.m.points.gte(34))base+=0.5; if(player.m.points.gte(49))base+=0.5; if(player.m.points.gte(59))base+=0.5; if(player.m.points.gte(69))base+=0.5; if(player.m.points.gte(79))base+=0.766; if(player.m.points.gte(89))base+=0.234; if(hasUpgrade("sp",44))base+=1; let ret = Decimal.pow(base,Decimal.log10(player[this.layer].points.add(1)).pow(0.9).add(1)) return ret; }
effect() { // Calculate bonuses from the upgrade. Can return a single value or an object with multiple values let base=1.5; if(player.m.points.gte(34))base+=0.5; if(player.m.points.gte(49))base+=0.5; if(player.m.points.gte(59))base+=0.5; if(player.m.points.gte(69))base+=0.5; if(player.m.points.gte(79))base+=0.766; if(player.m.points.gte(89))base+=0.234; if(hasUpgrade("sp",44))base+=1; let ret = Decimal.pow(base,Decimal.log10(player[this.layer].points.add(1)).pow(0.9).add(1)) return ret; }
JavaScript
effect() { let e=0.1; if(hasUpgrade("pb",32))e+=0.1; if(hasUpgrade("pb",33))e+=0.1; if(hasUpgrade("pb",34))e+=0.1; if(hasUpgrade("pb",43))e+=0.1; let p=tmp.pb.effect.pow(e); return p; }
effect() { let e=0.1; if(hasUpgrade("pb",32))e+=0.1; if(hasUpgrade("pb",33))e+=0.1; if(hasUpgrade("pb",34))e+=0.1; if(hasUpgrade("pb",43))e+=0.1; let p=tmp.pb.effect.pow(e); return p; }
JavaScript
gainMult() { // Calculate the multiplier for main currency from bonuses mult = new Decimal(1) if(hasUpgrade("hp",22))mult=mult.mul(upgradeEffect("hp",22)); if(hasUpgrade("ap",14))mult=mult.mul(upgradeEffect("ap",14)); return mult }
gainMult() { // Calculate the multiplier for main currency from bonuses mult = new Decimal(1) if(hasUpgrade("hp",22))mult=mult.mul(upgradeEffect("hp",22)); if(hasUpgrade("ap",14))mult=mult.mul(upgradeEffect("ap",14)); return mult }
JavaScript
effect() { let p=player.hp.points.add(1e20).log10().log10().div(56.17); if(hasUpgrade("hp",24))p=p.mul(2); if(hasUpgrade("hp",33))p=p.mul(1.5); if(hasUpgrade("hp",34))p=p.mul(1.2); return p.add(1); }
effect() { let p=player.hp.points.add(1e20).log10().log10().div(56.17); if(hasUpgrade("hp",24))p=p.mul(2); if(hasUpgrade("hp",33))p=p.mul(1.5); if(hasUpgrade("hp",34))p=p.mul(1.2); return p.add(1); }
JavaScript
gainMult() { // Calculate the multiplier for main currency from bonuses mult = new Decimal(1) if(hasUpgrade("ap",21))mult=mult.mul(upgradeEffect("ap",21)); if(hasUpgrade("t",62))mult=mult.mul(upgradeEffect("t",62)); return mult }
gainMult() { // Calculate the multiplier for main currency from bonuses mult = new Decimal(1) if(hasUpgrade("ap",21))mult=mult.mul(upgradeEffect("ap",21)); if(hasUpgrade("t",62))mult=mult.mul(upgradeEffect("t",62)); return mult }
JavaScript
effect() { let p=player.ap.points.add(1e20).log10().log10().div(200); if(hasUpgrade("ap",24))p=p.mul(4); if(hasUpgrade("ap",33))p=p.mul(2); if(hasUpgrade("ap",34))p=p.mul(1.2); return p.add(1); }
effect() { let p=player.ap.points.add(1e20).log10().log10().div(200); if(hasUpgrade("ap",24))p=p.mul(4); if(hasUpgrade("ap",33))p=p.mul(2); if(hasUpgrade("ap",34))p=p.mul(1.2); return p.add(1); }
JavaScript
effect() { let p=player.ap.points.add(1e20).log10().log10().div(57); if(hasUpgrade("ap",33))p=p.mul(2); if(hasUpgrade("ap",34))p=p.mul(1.2); return p.add(1); }
effect() { let p=player.ap.points.add(1e20).log10().log10().div(57); if(hasUpgrade("ap",33))p=p.mul(2); if(hasUpgrade("ap",34))p=p.mul(1.2); return p.add(1); }
JavaScript
effect() { let b=player.pe.points.add(1).log10().div(100); if(hasUpgrade("pe",13))b=b.mul(1.5); if(hasUpgrade("pe",23))b=b.mul(1.5); return b.add(1); }
effect() { let b=player.pe.points.add(1).log10().div(100); if(hasUpgrade("pe",13))b=b.mul(1.5); if(hasUpgrade("pe",23))b=b.mul(1.5); return b.add(1); }
JavaScript
effect() { let b=player.pe.points.add(1).log10().div(200); if(hasUpgrade("pe",14))b=b.mul(1.5); if(hasUpgrade("pe",22))b=b.mul(1.5); return b.add(1); }
effect() { let b=player.pe.points.add(1).log10().div(200); if(hasUpgrade("pe",14))b=b.mul(1.5); if(hasUpgrade("pe",22))b=b.mul(1.5); return b.add(1); }
JavaScript
effect() { let base=1.1; if(hasUpgrade("pe",24))base+=0.05; let ret = Decimal.pow(base,Decimal.log10(player[this.layer].points.add(1)).pow(0.9).add(1)) return ret; }
effect() { let base=1.1; if(hasUpgrade("pe",24))base+=0.05; let ret = Decimal.pow(base,Decimal.log10(player[this.layer].points.add(1)).pow(0.9).add(1)) return ret; }
JavaScript
function OnDialogTabChange( tabCode ) { ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; dialog.SetAutoSize( true ) ; }
function OnDialogTabChange( tabCode ) { ShowE('divUpload' , ( tabCode == 'Upload' ) ) ; dialog.SetAutoSize( true ) ; }
JavaScript
function Ok() { oEditor.FCKUndo.SaveUndoStep() ; return true ; }
function Ok() { oEditor.FCKUndo.SaveUndoStep() ; return true ; }
JavaScript
function _lastPos( txtid, idx ) { if( idx > 0 ) return this.indexes[txtid][idx-1] + this.originalSpellings[txtid][idx-1].length; else return 0; }
function _lastPos( txtid, idx ) { if( idx > 0 ) return this.indexes[txtid][idx-1] + this.originalSpellings[txtid][idx-1].length; else return 0; }
JavaScript
function Captcha() { for (var i = 0; i < 6; i++) { var a = alpha[Math.floor(Math.random() * alpha.length)]; var b = alpha[Math.floor(Math.random() * alpha.length)]; var c = alpha[Math.floor(Math.random() * alpha.length)]; var d = alpha[Math.floor(Math.random() * alpha.length)]; var e = alpha[Math.floor(Math.random() * alpha.length)]; var f = alpha[Math.floor(Math.random() * alpha.length)]; var g = alpha[Math.floor(Math.random() * alpha.length)]; } captcha_text = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' ' + f + ' ' + g; document.fonts.load(font) .then(function() { tCtx.font = font; tCtx.canvas.width = tCtx.measureText(captcha_text).width; tCtx.canvas.height = 40; tCtx.font = font; tCtx.fillStyle = '#444'; tCtx.fillText(captcha_text, 0, 20); var c = document.getElementById("textCanvas"); var ctx = c.getContext("2d"); // Draw lines for (var i = 0; i < 7; i++) { ctx.beginPath(); ctx.moveTo(c.width * Math.random(), c.height * Math.random()); ctx.lineTo(c.width * Math.random(), c.height * Math.random()); ctx.strokeStyle = "rgb(" + Math.round(256 * Math.random()) + "," + Math.round(256 * Math.random()) + "," + Math.round(256 * Math.random()) + ")"; ctx.stroke(); } imageElem.src = tCtx.canvas.toDataURL(); }); document.getElementById('textCaptcha').value=removeSpaces(captcha_text); }
function Captcha() { for (var i = 0; i < 6; i++) { var a = alpha[Math.floor(Math.random() * alpha.length)]; var b = alpha[Math.floor(Math.random() * alpha.length)]; var c = alpha[Math.floor(Math.random() * alpha.length)]; var d = alpha[Math.floor(Math.random() * alpha.length)]; var e = alpha[Math.floor(Math.random() * alpha.length)]; var f = alpha[Math.floor(Math.random() * alpha.length)]; var g = alpha[Math.floor(Math.random() * alpha.length)]; } captcha_text = a + ' ' + b + ' ' + ' ' + c + ' ' + d + ' ' + e + ' ' + f + ' ' + g; document.fonts.load(font) .then(function() { tCtx.font = font; tCtx.canvas.width = tCtx.measureText(captcha_text).width; tCtx.canvas.height = 40; tCtx.font = font; tCtx.fillStyle = '#444'; tCtx.fillText(captcha_text, 0, 20); var c = document.getElementById("textCanvas"); var ctx = c.getContext("2d"); // Draw lines for (var i = 0; i < 7; i++) { ctx.beginPath(); ctx.moveTo(c.width * Math.random(), c.height * Math.random()); ctx.lineTo(c.width * Math.random(), c.height * Math.random()); ctx.strokeStyle = "rgb(" + Math.round(256 * Math.random()) + "," + Math.round(256 * Math.random()) + "," + Math.round(256 * Math.random()) + ")"; ctx.stroke(); } imageElem.src = tCtx.canvas.toDataURL(); }); document.getElementById('textCaptcha').value=removeSpaces(captcha_text); }
JavaScript
function Conv2dTranspose( config ) { // "Conv2dTranspose" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * The dimension of the convolution window. * The 2d convolutional window is rectangle. * Default to [ 1, 1 ]. * * @type { int } */ this.kernelSize = [ 1, 1 ]; /** * The depth of the layer output. * * @type { int } */ this.filters = undefined; /** * The strides of the convolution. * Strides in both dimensions may be different. * Default to [ 1, 1 ]. * * @type { int } */ this.strides = [ 1, 1 ]; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; this.layerType = "Conv2dTranspose"; }
function Conv2dTranspose( config ) { // "Conv2dTranspose" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * The dimension of the convolution window. * The 2d convolutional window is rectangle. * Default to [ 1, 1 ]. * * @type { int } */ this.kernelSize = [ 1, 1 ]; /** * The depth of the layer output. * * @type { int } */ this.filters = undefined; /** * The strides of the convolution. * Strides in both dimensions may be different. * Default to [ 1, 1 ]. * * @type { int } */ this.strides = [ 1, 1 ]; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; this.layerType = "Conv2dTranspose"; }
JavaScript
function Cropping1d( config ) { // "Cropping1d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * Dimension of the cropping along the width. * * @type { Array } */ this.cropping = undefined; /** * Actual cropping size to width. * * @type { int } */ this.croppingWidth = undefined; this.layerType = "Cropping1d"; }
function Cropping1d( config ) { // "Cropping1d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * Dimension of the cropping along the width. * * @type { Array } */ this.cropping = undefined; /** * Actual cropping size to width. * * @type { int } */ this.croppingWidth = undefined; this.layerType = "Cropping1d"; }
JavaScript
function Pooling2d( config ) { // "Pooling2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * Factors by which to downscale in each dimension. * For example: [2, 3], 2 for width, 3 for height. * Default to [ 1, 1 ]. * * @type { Array } */ this.poolSize = [ 1, 1 ]; /** * The size of the stride in each dimension of the pooling window. * For example: [2, 2] * Default to [ 1, 1 ]. * * @type { Array } */ this.strides = [ 1, 1 ]; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; this.layerType = "Pooling2d"; }
function Pooling2d( config ) { // "Pooling2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * Factors by which to downscale in each dimension. * For example: [2, 3], 2 for width, 3 for height. * Default to [ 1, 1 ]. * * @type { Array } */ this.poolSize = [ 1, 1 ]; /** * The size of the stride in each dimension of the pooling window. * For example: [2, 2] * Default to [ 1, 1 ]. * * @type { Array } */ this.strides = [ 1, 1 ]; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; this.layerType = "Pooling2d"; }
JavaScript
function Activation1d( config ) { // "Activation1d" inherits from abstract layer "NativeLayer1d". NativeLayer1d.call( this, config ); /** * Name of the activation function to use. * * @type { string } */ this.activation = undefined; this.layerType = "Activation1d"; }
function Activation1d( config ) { // "Activation1d" inherits from abstract layer "NativeLayer1d". NativeLayer1d.call( this, config ); /** * Name of the activation function to use. * * @type { string } */ this.activation = undefined; this.layerType = "Activation1d"; }
JavaScript
function Output1d( config ) { // Output1d inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * Layer's output units. * * @type { int } */ this.width = undefined; /** * Class names for each output unit. * * @type { Array } */ this.outputs = undefined; /** * Output group's handler. * * @type { Object } */ this.outputHandler = undefined; /** * aggregation's width and height. * aggregation is an element which is displayed on the screen when Output1d is closed. * * @type { number } */ this.aggregationWidth = undefined; this.aggregationHeight = undefined; /** * Decide how to display hint text. * * @type { boolean } */ this.overview = false; /** * mode for how to display queue element * If there is too many output units, use "paging" mode may have better visualization effect. * * @type { boolean } */ this.paging = false; /** * Only take effect when this.paging = true. * Segment length for "one page". * Default to 200. * * @type { int } */ this.segmentLength = 200; /** * Only take effect when this.paging = true. * Which page NativeLayer1d displays now. * Can be update when "last" or "next" buttons are clicked, initial value can be defined by user. * Default to 0. * * @type { int } */ this.segmentIndex = 0; /** * Only take effect when this.paging = true. * How many pages in NativeLayer1d. * * @type { int } */ this.totalSegments = undefined; /** * Only take effect when this.paging = true. * Store handler for last button. * * @type { Object } */ this.lastButtonHandler = undefined; /** * Only take effect when this.paging = true. * Store handler for next button. * * @type { Object } */ this.nextButtonHandler = undefined; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for Output1d when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; this.layerType = "Output1d"; }
function Output1d( config ) { // Output1d inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * Layer's output units. * * @type { int } */ this.width = undefined; /** * Class names for each output unit. * * @type { Array } */ this.outputs = undefined; /** * Output group's handler. * * @type { Object } */ this.outputHandler = undefined; /** * aggregation's width and height. * aggregation is an element which is displayed on the screen when Output1d is closed. * * @type { number } */ this.aggregationWidth = undefined; this.aggregationHeight = undefined; /** * Decide how to display hint text. * * @type { boolean } */ this.overview = false; /** * mode for how to display queue element * If there is too many output units, use "paging" mode may have better visualization effect. * * @type { boolean } */ this.paging = false; /** * Only take effect when this.paging = true. * Segment length for "one page". * Default to 200. * * @type { int } */ this.segmentLength = 200; /** * Only take effect when this.paging = true. * Which page NativeLayer1d displays now. * Can be update when "last" or "next" buttons are clicked, initial value can be defined by user. * Default to 0. * * @type { int } */ this.segmentIndex = 0; /** * Only take effect when this.paging = true. * How many pages in NativeLayer1d. * * @type { int } */ this.totalSegments = undefined; /** * Only take effect when this.paging = true. * Store handler for last button. * * @type { Object } */ this.lastButtonHandler = undefined; /** * Only take effect when this.paging = true. * Store handler for next button. * * @type { Object } */ this.nextButtonHandler = undefined; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for Output1d when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; this.layerType = "Output1d"; }
JavaScript
function BasicLineGroup( layer, context, neuralGroup, color, minOpacity ) { this.layer = layer; this.context = context; this.neuralGroup = neuralGroup; this.color = color; this.minOpacity = minOpacity; // actual relative lines element for layer this.lineGroup = undefined; this.init(); }
function BasicLineGroup( layer, context, neuralGroup, color, minOpacity ) { this.layer = layer; this.context = context; this.neuralGroup = neuralGroup; this.color = color; this.minOpacity = minOpacity; // actual relative lines element for layer this.lineGroup = undefined; this.init(); }
JavaScript
function Sequential( container, config ) { // "Sequential" inherits from abstract Model "AbstractModel". AbstractModel.call( this, container, config ); this.modelType = "Sequential"; }
function Sequential( container, config ) { // "Sequential" inherits from abstract Model "AbstractModel". AbstractModel.call( this, container, config ); this.modelType = "Sequential"; }
JavaScript
function Cropping2d( config ) { // "Cropping2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * Dimension of the cropping along the width and the height. * * @type { Array } */ this.cropping = undefined; /** * Actual cropping size to width and height. * * @type { int } */ this.croppingWidth = undefined; this.croppingHeight = undefined; this.layerType = "Cropping2d"; }
function Cropping2d( config ) { // "Cropping2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * Dimension of the cropping along the width and the height. * * @type { Array } */ this.cropping = undefined; /** * Actual cropping size to width and height. * * @type { int } */ this.croppingWidth = undefined; this.croppingHeight = undefined; this.layerType = "Cropping2d"; }
JavaScript
function Padding2d( config ) { // "Padding2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * padding parameters. * * @type { int } */ this.paddingWidth = undefined; this.paddingHeight = undefined; this.paddingLeft = undefined; this.paddingRight = undefined; this.paddingTop = undefined; this.paddingBottom = undefined; /** * Actual content parameters. * * @type { int } */ this.contentWidth = undefined; this.contentHeight = undefined; this.layerType = "Padding2d"; }
function Padding2d( config ) { // "Padding2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * padding parameters. * * @type { int } */ this.paddingWidth = undefined; this.paddingHeight = undefined; this.paddingLeft = undefined; this.paddingRight = undefined; this.paddingTop = undefined; this.paddingBottom = undefined; /** * Actual content parameters. * * @type { int } */ this.contentWidth = undefined; this.contentHeight = undefined; this.layerType = "Padding2d"; }
JavaScript
function MergedLayer3d( config ) { // NativeLayer3d inherits from abstract layer "MergedLayer" MergedLayer.call( this, config ); /** * mergedLayer3d has three output dimensions: [ width, height, depth ]. * * @type { int } */ this.width = undefined; this.height = undefined; this.depth = undefined; /** * Feature map's handlers list. * * @type { Array } */ this.segregationHandlers = []; /** * Feature maps's centers when layer is totally open. * * @type { Array } */ this.openFmCenters = []; /** * Feature maps' centers when layer is closed. * * @type { Array } */ this.closeFmCenters = []; /** * Concrete strategy in runtime. * Initialized in MergedLayer3d's initStrategy period. * Applicable strategy: Add3d, Average3d, Concatenate3d, Dot3d, Maximum3d, Multiply3d, Subtract3d. * * @type { Object }, MergeStrategy3d */ this.operationStrategy = undefined; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for MergedLayer3d when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; // Init concrete strategy based on config. this.initStrategy( config ); this.layerDimension = 3; }
function MergedLayer3d( config ) { // NativeLayer3d inherits from abstract layer "MergedLayer" MergedLayer.call( this, config ); /** * mergedLayer3d has three output dimensions: [ width, height, depth ]. * * @type { int } */ this.width = undefined; this.height = undefined; this.depth = undefined; /** * Feature map's handlers list. * * @type { Array } */ this.segregationHandlers = []; /** * Feature maps's centers when layer is totally open. * * @type { Array } */ this.openFmCenters = []; /** * Feature maps' centers when layer is closed. * * @type { Array } */ this.closeFmCenters = []; /** * Concrete strategy in runtime. * Initialized in MergedLayer3d's initStrategy period. * Applicable strategy: Add3d, Average3d, Concatenate3d, Dot3d, Maximum3d, Multiply3d, Subtract3d. * * @type { Object }, MergeStrategy3d */ this.operationStrategy = undefined; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for MergedLayer3d when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; // Init concrete strategy based on config. this.initStrategy( config ); this.layerDimension = 3; }
JavaScript
function Conv1d( config ) { // "Conv1d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * The depth of the layer output. * * @type { int } */ this.filters = undefined; /** * The strides length of the convolution. * * @type { int } */ this.strides = undefined; /** * The width of the convolution window. * * @type { int } */ this.kernelSize = undefined; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; /** * Whether user directly define the layer shape. * Set "true" if Conv1d's shape is predefined by user. * * @type { boolean } */ this.isShapePredefined = false; this.layerType = "Conv1d"; }
function Conv1d( config ) { // "Conv1d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * The depth of the layer output. * * @type { int } */ this.filters = undefined; /** * The strides length of the convolution. * * @type { int } */ this.strides = undefined; /** * The width of the convolution window. * * @type { int } */ this.kernelSize = undefined; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; /** * Whether user directly define the layer shape. * Set "true" if Conv1d's shape is predefined by user. * * @type { boolean } */ this.isShapePredefined = false; this.layerType = "Conv1d"; }
JavaScript
function BasicLayer3d( config ) { // "BasicLayer3d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); this.layerType = "BasicLayer3d"; }
function BasicLayer3d( config ) { // "BasicLayer3d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); this.layerType = "BasicLayer3d"; }
JavaScript
function AbstractModel( container, config ) { /** * TensorSpace Model will be rendered in this HTML Dom element. * * @type { HTMLElement } */ this.container = undefined; /** * Store loader. * Four kinds of loader: TfLoader, TfjsLoader, KerasLoader, LiveLoader. * * @type { Loader } */ this.loader = undefined; /** * Sign showing whether model has a preload loader. * true -- has a preload loader * false -- empty model, do not have a preload loader * * @type { boolean } */ this.hasLoader = false; /** * Whether model has loaded a prediction model. * true -- A loader has already load a prediction to TSP model * false -- Empty model, do not have a prediction for prediction * * @type { boolean } */ this.isInitialized = false; /** * Actual prediction model. * undefined means no prediction model. * * @type { model } */ this.resource = undefined; /** * Store user's input value for prediction. * * @type { Array } */ this.inputValue = undefined; /** * Store prediction result from prediction model. * * @type { undefined } */ this.predictResult = undefined; /** * Used to trigger model prediction and get predict result * * @type { Predictor } */ this.predictor = undefined; /** * Prediction model type. * Two types now: "Model", "Sequential" * * @type { string } */ this.modelType = undefined; /** * Store all layers in Model. * * @type { Layer[] } */ this.layers = []; /** * Model's depth in visualization. * * @type { Int } */ this.depth = undefined; /** * Model configuration. * Initialized with user's model config and default model config. * * @type { ModelConfiguration } */ this.configuration = undefined; /** * Model's context, containing all THREE.Object for a TSP model. * * @type { THREE.Object } */ this.modelContext = new THREE.Object3D(); this.loadConfiguration( container, config ); }
function AbstractModel( container, config ) { /** * TensorSpace Model will be rendered in this HTML Dom element. * * @type { HTMLElement } */ this.container = undefined; /** * Store loader. * Four kinds of loader: TfLoader, TfjsLoader, KerasLoader, LiveLoader. * * @type { Loader } */ this.loader = undefined; /** * Sign showing whether model has a preload loader. * true -- has a preload loader * false -- empty model, do not have a preload loader * * @type { boolean } */ this.hasLoader = false; /** * Whether model has loaded a prediction model. * true -- A loader has already load a prediction to TSP model * false -- Empty model, do not have a prediction for prediction * * @type { boolean } */ this.isInitialized = false; /** * Actual prediction model. * undefined means no prediction model. * * @type { model } */ this.resource = undefined; /** * Store user's input value for prediction. * * @type { Array } */ this.inputValue = undefined; /** * Store prediction result from prediction model. * * @type { undefined } */ this.predictResult = undefined; /** * Used to trigger model prediction and get predict result * * @type { Predictor } */ this.predictor = undefined; /** * Prediction model type. * Two types now: "Model", "Sequential" * * @type { string } */ this.modelType = undefined; /** * Store all layers in Model. * * @type { Layer[] } */ this.layers = []; /** * Model's depth in visualization. * * @type { Int } */ this.depth = undefined; /** * Model configuration. * Initialized with user's model config and default model config. * * @type { ModelConfiguration } */ this.configuration = undefined; /** * Model's context, containing all THREE.Object for a TSP model. * * @type { THREE.Object } */ this.modelContext = new THREE.Object3D(); this.loadConfiguration( container, config ); }
JavaScript
function RGBInput( config ) { // RGBInput inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * RGBInput has three output dimensions: [ width, height, depth ]. * * @type { int } */ this.width = undefined; this.height = undefined; this.depth = 3; /** * As RGBInput is the first layer model, actualWidth is defined as a const. * Use actualWidth to calculate actualHeight. * * @type { double } */ this.actualWidth = ModelInitWidth; this.actualHeight = undefined; /** * Calculate unitLength for latter layers. * * @type { double } */ this.unitLength = undefined; /** * Channel maps's centers when layer is totally open. * * @type { Array } */ this.openFmCenters = FmCenterGenerator.getFmCenters( "line", 3, this.actualWidth, this.actualHeight ); /** * Channel maps' centers when layer is closed. * * @type { Array } */ this.closeFmCenters = []; for ( let i = 0; i < 3; i ++ ) { this.closeFmCenters.push( { x: 0, y: 0, z: 0 } ); } // Predefined position for channel map when separate from close position. this.separateTopPos = { x: 0, y: 20, z: 0 }; this.separateBottomPos = { x: 0, y: -20, z: 0 }; /** * Channel map's handlers list. * * @type { Array } */ this.segregationHandlers = []; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for RGBInput when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; this.layerDimension = 3; this.layerType = "RGBInput"; }
function RGBInput( config ) { // RGBInput inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * RGBInput has three output dimensions: [ width, height, depth ]. * * @type { int } */ this.width = undefined; this.height = undefined; this.depth = 3; /** * As RGBInput is the first layer model, actualWidth is defined as a const. * Use actualWidth to calculate actualHeight. * * @type { double } */ this.actualWidth = ModelInitWidth; this.actualHeight = undefined; /** * Calculate unitLength for latter layers. * * @type { double } */ this.unitLength = undefined; /** * Channel maps's centers when layer is totally open. * * @type { Array } */ this.openFmCenters = FmCenterGenerator.getFmCenters( "line", 3, this.actualWidth, this.actualHeight ); /** * Channel maps' centers when layer is closed. * * @type { Array } */ this.closeFmCenters = []; for ( let i = 0; i < 3; i ++ ) { this.closeFmCenters.push( { x: 0, y: 0, z: 0 } ); } // Predefined position for channel map when separate from close position. this.separateTopPos = { x: 0, y: 20, z: 0 }; this.separateBottomPos = { x: 0, y: -20, z: 0 }; /** * Channel map's handlers list. * * @type { Array } */ this.segregationHandlers = []; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for RGBInput when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; this.layerDimension = 3; this.layerType = "RGBInput"; }
JavaScript
function NativeLayer2d(config ) { // NativeLayer2d inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * NativeLayer2d has one output dimensions: [ width, depth ]. * * @type { int } */ this.width = undefined; this.depth = undefined; /** * grid lines' handlers list * * @type { Array } */ this.queueHandlers = []; /** * grid lines' centers when layer is closed. * * @type { Array } */ this.closeCenterList = []; /** * grid lines' centers when layer is totally open. * * @type { Array } */ this.openCenterList = []; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for NativeLayer2d when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; this.layerDimension = 2; }
function NativeLayer2d(config ) { // NativeLayer2d inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * NativeLayer2d has one output dimensions: [ width, depth ]. * * @type { int } */ this.width = undefined; this.depth = undefined; /** * grid lines' handlers list * * @type { Array } */ this.queueHandlers = []; /** * grid lines' centers when layer is closed. * * @type { Array } */ this.closeCenterList = []; /** * grid lines' centers when layer is totally open. * * @type { Array } */ this.openCenterList = []; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for NativeLayer2d when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; this.layerDimension = 2; }
JavaScript
function OutputDetection( config ) { // OutputDetection inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * OutputDetection has three output dimensions: [ width, height, depth ] * * @type { int } */ this.width = undefined; this.height = undefined; this.depth = 3; /** * Store outputMap handler. * * @type { Object } */ this.outputHandler = undefined; /** * Store rectangle parameters drawn on it. * Each rectangle has a JSON parameter, the parameter is like: * { * x: x, * y: y, * width: width, * height: height, * } * * @type { Array } */ this.rectangleList = []; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * True means that user do not need to add value for OutputDetection value when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = true; this.layerType = "OutputDetection"; }
function OutputDetection( config ) { // OutputDetection inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * OutputDetection has three output dimensions: [ width, height, depth ] * * @type { int } */ this.width = undefined; this.height = undefined; this.depth = 3; /** * Store outputMap handler. * * @type { Object } */ this.outputHandler = undefined; /** * Store rectangle parameters drawn on it. * Each rectangle has a JSON parameter, the parameter is like: * { * x: x, * y: y, * width: width, * height: height, * } * * @type { Array } */ this.rectangleList = []; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * True means that user do not need to add value for OutputDetection value when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = true; this.layerType = "OutputDetection"; }
JavaScript
function Padding1d( config ) { // "Pooling1d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * padding parameters. * * @type { int } */ this.paddingLeft = undefined; this.paddingRight = undefined; this.paddingWidth = undefined; /** * Actual content parameters. * * @type { int } */ this.contentWidth = undefined; this.layerType = "Padding1d"; }
function Padding1d( config ) { // "Pooling1d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * padding parameters. * * @type { int } */ this.paddingLeft = undefined; this.paddingRight = undefined; this.paddingWidth = undefined; /** * Actual content parameters. * * @type { int } */ this.contentWidth = undefined; this.layerType = "Padding1d"; }
JavaScript
function MergedLayer( config ) { // NativeLayer inherits from abstract layer "Layer" Layer.call( this, config.userConfig ); /** * Store handler for line group. * * @type { Object } */ this.lineGroupHandler = undefined; /** * Operator for merge function. * Seven kinds of merge function: add, average, concatenate, dot, maximum, multiply, subtract. * * @type { string } */ this.operator = undefined; /** * Identity whether the layer is merged layer. * The different between native layer and merge layer is that the the merged layer's "isMerged" attribute is true. * * @type { boolean } */ this.isMerged = true; /** * Elements participle in merge function. * * @type { Array } */ this.mergedElements = []; /** * layerType will be set based on operation strategy. * For example: Add3d, Subtract1d, Maximum2d * * @type { String } */ this.layerType = undefined; }
function MergedLayer( config ) { // NativeLayer inherits from abstract layer "Layer" Layer.call( this, config.userConfig ); /** * Store handler for line group. * * @type { Object } */ this.lineGroupHandler = undefined; /** * Operator for merge function. * Seven kinds of merge function: add, average, concatenate, dot, maximum, multiply, subtract. * * @type { string } */ this.operator = undefined; /** * Identity whether the layer is merged layer. * The different between native layer and merge layer is that the the merged layer's "isMerged" attribute is true. * * @type { boolean } */ this.isMerged = true; /** * Elements participle in merge function. * * @type { Array } */ this.mergedElements = []; /** * layerType will be set based on operation strategy. * For example: Add3d, Subtract1d, Maximum2d * * @type { String } */ this.layerType = undefined; }
JavaScript
function Reshape( config ) { this.config = config; if ( this.config !== undefined ) { this.name = this.config.name; } else { this.name = undefined; } /** * Use State Pattern to handle reshape cases. * Three States: Reshape1d, Reshape2d and Reshape3d * Based on different states, create different `actualLayer`. * * @type { String } */ this.reshapeType = undefined; /** * Reshape layer is a proxy, store reference of actual layer. * Three types of actual layers: Reshape1d, Reshape2d, Reshape3d. * * @type { Layer } */ this.actualLayer = undefined; /** * Attributes below are important layer metrics for a TensorSpace Layers, * These metrics will be injected or updated by calling updateLayerMetric() */ this.neuralValue = undefined; this.inputShape = undefined; this.outputShape = undefined; this.autoOutputDetect = false; this.actualWidth = undefined; this.actualHeight = undefined; this.actualDepth = undefined; this.depth = undefined; this.layerDimension = undefined; this.openFmCenters = undefined; this.lastLayer = undefined; if ( config !== undefined && ( config.targetShape !== undefined || config.shape !== undefined ) ) { this.setReshapeType(); this.createActualLayer(); this.updateLayerMetric(); } }
function Reshape( config ) { this.config = config; if ( this.config !== undefined ) { this.name = this.config.name; } else { this.name = undefined; } /** * Use State Pattern to handle reshape cases. * Three States: Reshape1d, Reshape2d and Reshape3d * Based on different states, create different `actualLayer`. * * @type { String } */ this.reshapeType = undefined; /** * Reshape layer is a proxy, store reference of actual layer. * Three types of actual layers: Reshape1d, Reshape2d, Reshape3d. * * @type { Layer } */ this.actualLayer = undefined; /** * Attributes below are important layer metrics for a TensorSpace Layers, * These metrics will be injected or updated by calling updateLayerMetric() */ this.neuralValue = undefined; this.inputShape = undefined; this.outputShape = undefined; this.autoOutputDetect = false; this.actualWidth = undefined; this.actualHeight = undefined; this.actualDepth = undefined; this.depth = undefined; this.layerDimension = undefined; this.openFmCenters = undefined; this.lastLayer = undefined; if ( config !== undefined && ( config.targetShape !== undefined || config.shape !== undefined ) ) { this.setReshapeType(); this.createActualLayer(); this.updateLayerMetric(); } }
JavaScript
function Layer( config ) { /** * model object of THREE.js. * * @type { THREE.Object } */ this.context = undefined; /** * Order index number of the layer in model. * * @type { number } */ this.layerIndex = undefined; /** * The center (x, y, z) coordinates of the layer, related to the model. * * @type { Object } {x: double, y: double, z: double} */ this.center = undefined; /** * last layer in model relative to this layer. * * @type { Layer } */ this.lastLayer = undefined; /** * Store all neural value as an array. * "undefined" means no value. * * @type { double[] } */ this.neuralValue = undefined; /** * Important property * Shape describes input and output dimensions of the layer. * * @type { Array } */ this.inputShape = []; this.outputShape = []; /** * Wrapper object represented the layer object in scene. * All Three.js objects within the layer should be added to neuralGroup. * * @type { THREE.Object } */ this.neuralGroup = undefined; /** * Color of the layer for visualization. * * @type { HEX } */ this.color = undefined; /** * Handler for layer aggregation. * * @type { Object } */ this.aggregationHandler = undefined; /** * Handler for close button. * * @type { Object } */ this.closeButtonHandler = undefined; /** * Config to control whether to show close button. * true -- show close button when layer is open. * false -- never show close button. * * @type { boolean } */ this.hasCloseButton = true; /** * Config of close button size. * Close button size is multiplied by the ratio number * * @type { number } */ this.closeButtonSizeRatio = 1; /** * Minimum opacity of the layer. * * @type { double } [0, 1] */ this.minOpacity = undefined; /** * Width and height in Three.js scene. * actualWidth = unitLength * width * (1d layer and 2d layer do not have actualHeight). * * @type { double } */ this.actualWidth = undefined; this.actualHeight = undefined; /** * Depth of the layer object in the scene. * * @type { double } */ this.actualDepth = undefined; /** * Unit length used to render layer object. * * If the layer is not the first layer in model, value is from last layer. * this.unitLength = this.lastLayer.unitLength; * * If layer is the first layer in model, checkout input layer for more information. * this.unitLength = this.actualWidth / this.width; * * @type { double } */ this.unitLength = undefined; /** * Handler for object which is showing text. * * @type { Object } */ this.textElementHandler = undefined; /** * Handler for line group. * * @type { Object } */ this.lineGroupHandler = undefined; /** * Config to control showing text in layer. * * @type { boolean } */ this.textSystem = undefined; /** * Config of whether show relation line or not. * true -- show relation lines. * false -- do not show relation lines. * * @type { boolean } */ this.relationSystem = undefined; /** * Layer status on whether the layer is expanded or collapsed. * true -- expanded; * false -- collapsed. * * @type { boolean } */ this.isOpen = undefined; /** * Config on the speed of layer expansion and collapsion. * * @type { number } */ this.openTime = undefined; this.separateTime = undefined; /** * Whether the layer is a group or not. * * @type { boolean } */ this.isGroup = false; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * For example, YoloGrid can automatically detect the output from last layer, * users do not need to add value for YoloGrid value when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = undefined; /** * name of the layer. * * @type { String } */ this.name = undefined; /** * Type of layer, each layer class has a specific layerType. * For example, "Conv2d", "Pooling2d". * * @type { String } */ this.layerType = undefined; /** * The place for Layer in model, measured by y-axis in 3d scene. * For Sequential model: * the "layerLevel" will be the same as "layerIndex". * the layerLevel will be unique for all layers. * For Functional model: * the "layerLevel" may be the same for several layers. * these layers has different "layerIndex". * * @type { Int } */ this.layerLevel = undefined; /** * True - layer has closeLayer() method, and this method can be called. * False - layer do not has closeLayer() method, or closeLayer() can not be called. * Default to True. * * @type { boolean } */ this.closeable = true; /** * Layer's initial status, only take effect when layer is closeable. * For example, for input1d layer this attribute will not take effect. * * "open": show all feature maps, or neural lines, or grid lines. * "close": show aggregation when layer is initialized * * @type { String } */ this.initStatus = "close"; /** * Whether user directly define the layer shape. * Set "true" if Layer's shape is predefined by user. * * @type { boolean } */ this.isShapePredefined = false; this.config = config; this.isEmissive = false; // Load layer config. this.loadBasicLayerConfig( config ); }
function Layer( config ) { /** * model object of THREE.js. * * @type { THREE.Object } */ this.context = undefined; /** * Order index number of the layer in model. * * @type { number } */ this.layerIndex = undefined; /** * The center (x, y, z) coordinates of the layer, related to the model. * * @type { Object } {x: double, y: double, z: double} */ this.center = undefined; /** * last layer in model relative to this layer. * * @type { Layer } */ this.lastLayer = undefined; /** * Store all neural value as an array. * "undefined" means no value. * * @type { double[] } */ this.neuralValue = undefined; /** * Important property * Shape describes input and output dimensions of the layer. * * @type { Array } */ this.inputShape = []; this.outputShape = []; /** * Wrapper object represented the layer object in scene. * All Three.js objects within the layer should be added to neuralGroup. * * @type { THREE.Object } */ this.neuralGroup = undefined; /** * Color of the layer for visualization. * * @type { HEX } */ this.color = undefined; /** * Handler for layer aggregation. * * @type { Object } */ this.aggregationHandler = undefined; /** * Handler for close button. * * @type { Object } */ this.closeButtonHandler = undefined; /** * Config to control whether to show close button. * true -- show close button when layer is open. * false -- never show close button. * * @type { boolean } */ this.hasCloseButton = true; /** * Config of close button size. * Close button size is multiplied by the ratio number * * @type { number } */ this.closeButtonSizeRatio = 1; /** * Minimum opacity of the layer. * * @type { double } [0, 1] */ this.minOpacity = undefined; /** * Width and height in Three.js scene. * actualWidth = unitLength * width * (1d layer and 2d layer do not have actualHeight). * * @type { double } */ this.actualWidth = undefined; this.actualHeight = undefined; /** * Depth of the layer object in the scene. * * @type { double } */ this.actualDepth = undefined; /** * Unit length used to render layer object. * * If the layer is not the first layer in model, value is from last layer. * this.unitLength = this.lastLayer.unitLength; * * If layer is the first layer in model, checkout input layer for more information. * this.unitLength = this.actualWidth / this.width; * * @type { double } */ this.unitLength = undefined; /** * Handler for object which is showing text. * * @type { Object } */ this.textElementHandler = undefined; /** * Handler for line group. * * @type { Object } */ this.lineGroupHandler = undefined; /** * Config to control showing text in layer. * * @type { boolean } */ this.textSystem = undefined; /** * Config of whether show relation line or not. * true -- show relation lines. * false -- do not show relation lines. * * @type { boolean } */ this.relationSystem = undefined; /** * Layer status on whether the layer is expanded or collapsed. * true -- expanded; * false -- collapsed. * * @type { boolean } */ this.isOpen = undefined; /** * Config on the speed of layer expansion and collapsion. * * @type { number } */ this.openTime = undefined; this.separateTime = undefined; /** * Whether the layer is a group or not. * * @type { boolean } */ this.isGroup = false; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * For example, YoloGrid can automatically detect the output from last layer, * users do not need to add value for YoloGrid value when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = undefined; /** * name of the layer. * * @type { String } */ this.name = undefined; /** * Type of layer, each layer class has a specific layerType. * For example, "Conv2d", "Pooling2d". * * @type { String } */ this.layerType = undefined; /** * The place for Layer in model, measured by y-axis in 3d scene. * For Sequential model: * the "layerLevel" will be the same as "layerIndex". * the layerLevel will be unique for all layers. * For Functional model: * the "layerLevel" may be the same for several layers. * these layers has different "layerIndex". * * @type { Int } */ this.layerLevel = undefined; /** * True - layer has closeLayer() method, and this method can be called. * False - layer do not has closeLayer() method, or closeLayer() can not be called. * Default to True. * * @type { boolean } */ this.closeable = true; /** * Layer's initial status, only take effect when layer is closeable. * For example, for input1d layer this attribute will not take effect. * * "open": show all feature maps, or neural lines, or grid lines. * "close": show aggregation when layer is initialized * * @type { String } */ this.initStatus = "close"; /** * Whether user directly define the layer shape. * Set "true" if Layer's shape is predefined by user. * * @type { boolean } */ this.isShapePredefined = false; this.config = config; this.isEmissive = false; // Load layer config. this.loadBasicLayerConfig( config ); }
JavaScript
function Activation2d( config ) { // "Activation2d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * Name of the activation function to use. * * @type { string } */ this.activation = undefined; this.layerType = "Activation2d"; }
function Activation2d( config ) { // "Activation2d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * Name of the activation function to use. * * @type { string } */ this.activation = undefined; this.layerType = "Activation2d"; }
JavaScript
function DepthwiseConv2d( config ) { // "DepthwiseConv2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * The dimension of the convolution window. * The 2d convolutional window is rectangle. * Default to [ 1, 1 ]. * * @type { int } */ this.kernelSize = [ 1, 1 ]; /** * The number of depthwise convolution output channels for each input channel. * Default to 1. * * @type { int } */ this.depthMultiplier = 1; /** * The strides of the convolution. * Strides in both dimensions may be different. * Default to [ 1, 1 ]. * * @type { int } */ this.strides = [ 1, 1 ]; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; this.layerType = "DepthwiseConv2d"; }
function DepthwiseConv2d( config ) { // "DepthwiseConv2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * The dimension of the convolution window. * The 2d convolutional window is rectangle. * Default to [ 1, 1 ]. * * @type { int } */ this.kernelSize = [ 1, 1 ]; /** * The number of depthwise convolution output channels for each input channel. * Default to 1. * * @type { int } */ this.depthMultiplier = 1; /** * The strides of the convolution. * Strides in both dimensions may be different. * Default to [ 1, 1 ]. * * @type { int } */ this.strides = [ 1, 1 ]; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; this.layerType = "DepthwiseConv2d"; }
JavaScript
function Reshape1d( config ) { // "Reshape1d" inherits from abstract layer "NativeLayer1d". NativeLayer1d.call( this, config ); /** * Certain 1d shape the input will be reshape into. * For example: [ 3 ] * * @type { Array } */ this.targetShape = undefined; /** * Total Neural number in layer, calculated in assemble period based on input shape. * Set init size to be 1. * * @type { int } */ this.totalSize = 1; this.layerType = "Reshape1d"; }
function Reshape1d( config ) { // "Reshape1d" inherits from abstract layer "NativeLayer1d". NativeLayer1d.call( this, config ); /** * Certain 1d shape the input will be reshape into. * For example: [ 3 ] * * @type { Array } */ this.targetShape = undefined; /** * Total Neural number in layer, calculated in assemble period based on input shape. * Set init size to be 1. * * @type { int } */ this.totalSize = 1; this.layerType = "Reshape1d"; }
JavaScript
function UpSampling2d( config ) { // "UpSampling2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * The upsampling factors for width and height. * For example: [ 2, 2 ]. * * @type { Array } */ this.size = undefined; /** * The upsampling factors for width and height separately. * * @type { int } */ this.widthSize = undefined; this.heightSize = undefined; this.layerType = "UpSampling2d"; }
function UpSampling2d( config ) { // "UpSampling2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * The upsampling factors for width and height. * For example: [ 2, 2 ]. * * @type { Array } */ this.size = undefined; /** * The upsampling factors for width and height separately. * * @type { int } */ this.widthSize = undefined; this.heightSize = undefined; this.layerType = "UpSampling2d"; }
JavaScript
function BasicLayer2d( config ) { // "BasicLayer2d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); this.layerType = "BasicLayer2d"; }
function BasicLayer2d( config ) { // "BasicLayer2d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); this.layerType = "BasicLayer2d"; }
JavaScript
function Model( container, config ) { // "Model" inherits from abstract Model "AbstractModel". AbstractModel.call( this, container, config ); this.inputs = undefined; this.outputs = undefined; this.outputsOrder = undefined; this.levelMap = undefined; this.layerLookupMap = undefined; this.modelDepth = undefined; this.levelCenters = undefined; this.modelType = "Model"; this.loadModelConfig( config ); }
function Model( container, config ) { // "Model" inherits from abstract Model "AbstractModel". AbstractModel.call( this, container, config ); this.inputs = undefined; this.outputs = undefined; this.outputsOrder = undefined; this.levelMap = undefined; this.layerLookupMap = undefined; this.modelDepth = undefined; this.levelCenters = undefined; this.modelType = "Model"; this.loadModelConfig( config ); }
JavaScript
function KerasPredictor( model, config ) { // "KerasPredictor" inherits from abstract predictor "Predictor". Predictor.call( this, model, config ); this.predictorType = "KerasPredictor"; }
function KerasPredictor( model, config ) { // "KerasPredictor" inherits from abstract predictor "Predictor". Predictor.call( this, model, config ); this.predictorType = "KerasPredictor"; }
JavaScript
function Pooling1d( config ) { // "Pooling1d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * Size of the window to pool over. * * @type { int } */ this.poolSize = undefined; /** * Period at which to sample the pooled values. * * @type { int } */ this.strides = undefined; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; /** * Whether user directly define the layer shape. * Set "true" if Pooling1d's shape is predefined by user. * * @type { boolean } */ this.isShapePredefined = false; this.layerType = "Pooling1d"; }
function Pooling1d( config ) { // "Pooling1d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * Size of the window to pool over. * * @type { int } */ this.poolSize = undefined; /** * Period at which to sample the pooled values. * * @type { int } */ this.strides = undefined; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; /** * Whether user directly define the layer shape. * Set "true" if Pooling1d's shape is predefined by user. * * @type { boolean } */ this.isShapePredefined = false; this.layerType = "Pooling1d"; }
JavaScript
function Conv2d( config ) { // "Conv2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * The dimension of the convolution window. * The 2d convolutional window is rectangle. * Default to [ 1, 1 ]. * * @type { int } */ this.kernelSize = [ 1, 1 ]; /** * The depth of the layer output. * * @type { int } */ this.filters = undefined; /** * The strides of the convolution. * Strides in both dimensions may be different. * Default to [ 1, 1 ]. * * @type { int } */ this.strides = [ 1, 1 ]; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; this.layerType = "Conv2d"; }
function Conv2d( config ) { // "Conv2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * The dimension of the convolution window. * The 2d convolutional window is rectangle. * Default to [ 1, 1 ]. * * @type { int } */ this.kernelSize = [ 1, 1 ]; /** * The depth of the layer output. * * @type { int } */ this.filters = undefined; /** * The strides of the convolution. * Strides in both dimensions may be different. * Default to [ 1, 1 ]. * * @type { int } */ this.strides = [ 1, 1 ]; /** * Padding mode. * "valid" or "same", default to "valid". * * @type { string } */ this.padding = "valid"; this.layerType = "Conv2d"; }
JavaScript
function BasicLayer1d( config ) { // "BasicLayer1d" inherits from abstract layer "NativeLayer1d". NativeLayer1d.call( this, config ); this.layerType = "BasicLayer1d"; }
function BasicLayer1d( config ) { // "BasicLayer1d" inherits from abstract layer "NativeLayer1d". NativeLayer1d.call( this, config ); this.layerType = "BasicLayer1d"; }
JavaScript
function TfLoader( model, config ) { // "TfLoader" inherits from abstract Loader "Loader". Loader.call( this, model, config ); /** * tensorflow model's url (.pb file's url). * Important parameter for TfLoader to get tensorflow model. * * @type { url } */ this.url = undefined; /** * User's predefined outputsName list. * If set, TfLoader will set this name list to TfPredictor. * * @type { Array } */ this.outputsName = undefined; // Load TfLoader's configuration. this.loadTfConfig( config ); this.loaderType = "TfLoader"; }
function TfLoader( model, config ) { // "TfLoader" inherits from abstract Loader "Loader". Loader.call( this, model, config ); /** * tensorflow model's url (.pb file's url). * Important parameter for TfLoader to get tensorflow model. * * @type { url } */ this.url = undefined; /** * User's predefined outputsName list. * If set, TfLoader will set this name list to TfPredictor. * * @type { Array } */ this.outputsName = undefined; // Load TfLoader's configuration. this.loadTfConfig( config ); this.loaderType = "TfLoader"; }
JavaScript
function UpSampling1d( config ) { // "UpSampling1d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * The upsampling factors for width. * * @type { int } */ this.size = undefined; this.layerType = "UpSampling1d"; }
function UpSampling1d( config ) { // "UpSampling1d" inherits from abstract layer "NativeLayer2d". NativeLayer2d.call( this, config ); /** * The upsampling factors for width. * * @type { int } */ this.size = undefined; this.layerType = "UpSampling1d"; }
JavaScript
function Maximum( layerList, config ) { let operatorType = "maximum"; // Create a merged Layer proxy, the actual layer in proxy based on input layer list and config for maximum operation. let maximumLayer = new MergeProxy( operatorType, layerList, config ); return maximumLayer; }
function Maximum( layerList, config ) { let operatorType = "maximum"; // Create a merged Layer proxy, the actual layer in proxy based on input layer list and config for maximum operation. let maximumLayer = new MergeProxy( operatorType, layerList, config ); return maximumLayer; }
JavaScript
function NativeLayer1d(config ) { // NativeLayer1d inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * NativeLayer1d has one output dimensions: [ width ]. * * @type { int } */ this.width = undefined; /** * queue element's handler. * queue is an element which is displayed on the screen when layer1d is open. * * @type { Object } */ this.queueHandler = undefined; /** * Decide how to display hint text. * * @type { boolean } */ this.overview = false; /** * mode for how to display queue element * If queue element is too long, use "paging" mode may have better visualization effect. * * @type { boolean } */ this.paging = false; /** * Only take effect when this.paging = true. * Segment length for "one page". * Default to 200. * * @type { number } */ this.segmentLength = 200; /** * Only take effect when this.paging = true. * Which page NativeLayer1d displays now. * Can be update when "last" or "next" buttons are clicked, initial value can be defined by user. * Default to 0. * * @type { number } */ this.segmentIndex = 0; /** * Only take effect when this.paging = true. * How many pages in NativeLayer1d. * * @type { number } */ this.totalSegments = undefined; /** * Only take effect when this.paging = true. * Store handler for last button. * * @type { Object } */ this.lastButtonHandler = undefined; /** * Only take effect when this.paging = true. * Store handler for next button. * * @type { Object } */ this.nextButtonHandler = undefined; /** * Only take effect when this.paging = true. * Attribute used by tween in QueueTransitionFactory. * * @type { number } */ this.queueLength = this.segmentLength; /** * aggregation's width and height. * aggregation is an element which is displayed on the screen when layer1d is closed. * * @type { number } */ this.aggregationWidth = undefined; this.aggregationHeight = undefined; /** * An indicator whether layer1d is in an transition status. * NativeLayer1d has a transition period between "close" and "open" when openLayer is called. * * @type { boolean } */ this.isTransition = false; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for NativeLayer1d when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; // Load user's layer1d config into some layer1d's attribute. this.loadLayer1dConfig( config ); this.layerDimension = 1; }
function NativeLayer1d(config ) { // NativeLayer1d inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * NativeLayer1d has one output dimensions: [ width ]. * * @type { int } */ this.width = undefined; /** * queue element's handler. * queue is an element which is displayed on the screen when layer1d is open. * * @type { Object } */ this.queueHandler = undefined; /** * Decide how to display hint text. * * @type { boolean } */ this.overview = false; /** * mode for how to display queue element * If queue element is too long, use "paging" mode may have better visualization effect. * * @type { boolean } */ this.paging = false; /** * Only take effect when this.paging = true. * Segment length for "one page". * Default to 200. * * @type { number } */ this.segmentLength = 200; /** * Only take effect when this.paging = true. * Which page NativeLayer1d displays now. * Can be update when "last" or "next" buttons are clicked, initial value can be defined by user. * Default to 0. * * @type { number } */ this.segmentIndex = 0; /** * Only take effect when this.paging = true. * How many pages in NativeLayer1d. * * @type { number } */ this.totalSegments = undefined; /** * Only take effect when this.paging = true. * Store handler for last button. * * @type { Object } */ this.lastButtonHandler = undefined; /** * Only take effect when this.paging = true. * Store handler for next button. * * @type { Object } */ this.nextButtonHandler = undefined; /** * Only take effect when this.paging = true. * Attribute used by tween in QueueTransitionFactory. * * @type { number } */ this.queueLength = this.segmentLength; /** * aggregation's width and height. * aggregation is an element which is displayed on the screen when layer1d is closed. * * @type { number } */ this.aggregationWidth = undefined; this.aggregationHeight = undefined; /** * An indicator whether layer1d is in an transition status. * NativeLayer1d has a transition period between "close" and "open" when openLayer is called. * * @type { boolean } */ this.isTransition = false; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for NativeLayer1d when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; // Load user's layer1d config into some layer1d's attribute. this.loadLayer1dConfig( config ); this.layerDimension = 1; }
JavaScript
function GlobalPooling2d( config ) { // "GlobalPooling2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * Global pooling's width and height is const ( 1 ). * * @type { int } */ this.width = 1; this.height = 1; this.layerType = "GlobalPooling2d"; }
function GlobalPooling2d( config ) { // "GlobalPooling2d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * Global pooling's width and height is const ( 1 ). * * @type { int } */ this.width = 1; this.height = 1; this.layerType = "GlobalPooling2d"; }
JavaScript
function NativeLayer3d( config ) { // NativeLayer3d inherits from abstract layer "NativeLayer" NativeLayer.call( this, config ); /** * NativeLayer3d has three output dimensions: [ width, height, depth ] * * @type { int } */ this.width = undefined; this.height = undefined; this.depth = undefined; /** * Handler list of feature map. * * @type { Array } */ this.segregationHandlers = []; /** * Feature map centers while this.isOpen === true. * * @type { Array } */ this.openFmCenters = []; /** * Feature map centers while this.isOpen === false. * * @type { Array } */ this.closeFmCenters = []; /** * Feature map shapes while expanded * "line" or "rect", default to "rect". * Check "ModelConfiguration.js" for more details. * * @type { string } */ this.layerShape = undefined; /** * Aggregation mode. * "max" or "average", default to "average". * Check "ModelConfiguration.js" for more details. * * @type { string } */ this.aggregationStrategy = undefined; /** * Label to define whether layer need an "output value" from ML model (tfjs, keras, or tf). * False means that user need to add value for NativeLayer3d when they are preprocessing multi-output for the model. * * Config on whether to calculate the output shape automatically or not. * "false" means user has to provide outputShape while preprocessing ML model. * * @type { boolean } */ this.autoOutputDetect = false; this.layerDimension = 3; }
function NativeLayer3d( config ) { // NativeLayer3d inherits from abstract layer "NativeLayer" NativeLayer.call( this, config ); /** * NativeLayer3d has three output dimensions: [ width, height, depth ] * * @type { int } */ this.width = undefined; this.height = undefined; this.depth = undefined; /** * Handler list of feature map. * * @type { Array } */ this.segregationHandlers = []; /** * Feature map centers while this.isOpen === true. * * @type { Array } */ this.openFmCenters = []; /** * Feature map centers while this.isOpen === false. * * @type { Array } */ this.closeFmCenters = []; /** * Feature map shapes while expanded * "line" or "rect", default to "rect". * Check "ModelConfiguration.js" for more details. * * @type { string } */ this.layerShape = undefined; /** * Aggregation mode. * "max" or "average", default to "average". * Check "ModelConfiguration.js" for more details. * * @type { string } */ this.aggregationStrategy = undefined; /** * Label to define whether layer need an "output value" from ML model (tfjs, keras, or tf). * False means that user need to add value for NativeLayer3d when they are preprocessing multi-output for the model. * * Config on whether to calculate the output shape automatically or not. * "false" means user has to provide outputShape while preprocessing ML model. * * @type { boolean } */ this.autoOutputDetect = false; this.layerDimension = 3; }
JavaScript
function GreyscaleInput( config ) { // GreyscaleInput inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * GreyscaleInput has two output dimensions: [ width, height ]. * * @type { int } */ this.width = undefined; this.height = undefined; /** * This attribute not for output, for latter layer, * for example, padding2d. * * @type { int } */ this.depth = 1; /** * As GreyscaleInput is the first layer model, actualWidth is defined as a const. * Use actualWidth to calculate actualHeight. * * @type { double } */ this.actualWidth = undefined; this.actualHeight = undefined; /** * Calculate unitLength for latter layers. * * @type { double } */ this.unitLength = undefined; /** * Set this attribute for latter layer, * for example, padding2d. * * @type { Array } */ this.openFmCenters = [ { x: 0, y: 0, z: 0 } ]; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for GreyscaleInput when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; this.closeable = false; this.layerDimension = 2; this.layerType = "GreyscaleInput"; }
function GreyscaleInput( config ) { // GreyscaleInput inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * GreyscaleInput has two output dimensions: [ width, height ]. * * @type { int } */ this.width = undefined; this.height = undefined; /** * This attribute not for output, for latter layer, * for example, padding2d. * * @type { int } */ this.depth = 1; /** * As GreyscaleInput is the first layer model, actualWidth is defined as a const. * Use actualWidth to calculate actualHeight. * * @type { double } */ this.actualWidth = undefined; this.actualHeight = undefined; /** * Calculate unitLength for latter layers. * * @type { double } */ this.unitLength = undefined; /** * Set this attribute for latter layer, * for example, padding2d. * * @type { Array } */ this.openFmCenters = [ { x: 0, y: 0, z: 0 } ]; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * False means that user need to add value for GreyscaleInput when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = false; this.closeable = false; this.layerDimension = 2; this.layerType = "GreyscaleInput"; }
JavaScript
function Reshape3d( config ) { // "Reshape3d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * Certain 3d shape the input will be reshape into. * For example: [ 7, 7, 32 ] * * @type { Array } */ this.targetShape = undefined; /** * Total Neural number in layer, calculated in assemble period based on input shape. * Set init size to be 1. * * @type { int } */ this.totalSize = 1; this.layerType = "Reshape3d"; }
function Reshape3d( config ) { // "Reshape3d" inherits from abstract layer "NativeLayer3d". NativeLayer3d.call( this, config ); /** * Certain 3d shape the input will be reshape into. * For example: [ 7, 7, 32 ] * * @type { Array } */ this.targetShape = undefined; /** * Total Neural number in layer, calculated in assemble period based on input shape. * Set init size to be 1. * * @type { int } */ this.totalSize = 1; this.layerType = "Reshape3d"; }
JavaScript
function YoloGrid( config ) { // YoloGrid inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * Grid ceil's handlers list. * * @type { Array } */ this.segregationHandlers = []; /** * Callback function, fired when ceil are clicked. * * @type { function } */ this.onCeilClicked = undefined; /** * Output shape: [ widthNum, heightNum ]. * * @type { int } */ this.widthNum = undefined; this.heightNum = undefined; /** * Total grid ceil number. * * @type { int } */ this.totalCeil = undefined; /** * Depth for each grid ceil. * * @type { int } */ this.channelDepth = undefined; /** * Grid ceil's centers when layer is closed. * * @type { Array } */ this.closeResultPos = []; /** * Grid ceil's centers when layer is totally open. * * @type { Array } */ this.openResultPos = []; /** * Sets from a predetermined set of boxes with particular height-width ratios for Yolo Detection. * Stored as an array, for example, * in VOC data set, anchors: [ 1.08, 1.19, 3.42, 4.41, 6.63, 11.38, 9.42, 5.11, 16.62, 10.52 ] * * @type { Array } float */ this.anchors = undefined; /** * The label list configuration. * For example, in VOC data set, label: [ "aeroplane", "bicycle", "bird", "boat", "bottle", * "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", * "pottedplant", "sheep", "sofa", "train", "tvmonitor" ] * * @type { Array } string */ this.classLabelList = undefined; /** * The threshold to constrain the output baseline. * The larger the value, the higher the confidence value of the detected object need. * [Default] 0.5 * * @type { float } */ this.scoreThreshold = 0.5; /** * The toggle to control whether to draw all 5 boxes in each grid. * Usually be used to how how yolo network generate the final detective boxes. * [Default] false, means to draw the final result. * @type { bool } */ this.isDrawFiveBoxes = false; /** * The toggle to control whether to apply non-maximum suppression to the detection rectangles . * [Default] true, means to apply nms. * @type { bool } */ this.isNMS = true; /** * Model's input shape, the shape is the same as model's input layer. * * @type { Array } */ this.modelInputShape = undefined; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * True means that user do not need to add value for YoloGrid value when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = true; this.layerType = "YoloGrid"; }
function YoloGrid( config ) { // YoloGrid inherits from abstract layer "NativeLayer". NativeLayer.call( this, config ); /** * Grid ceil's handlers list. * * @type { Array } */ this.segregationHandlers = []; /** * Callback function, fired when ceil are clicked. * * @type { function } */ this.onCeilClicked = undefined; /** * Output shape: [ widthNum, heightNum ]. * * @type { int } */ this.widthNum = undefined; this.heightNum = undefined; /** * Total grid ceil number. * * @type { int } */ this.totalCeil = undefined; /** * Depth for each grid ceil. * * @type { int } */ this.channelDepth = undefined; /** * Grid ceil's centers when layer is closed. * * @type { Array } */ this.closeResultPos = []; /** * Grid ceil's centers when layer is totally open. * * @type { Array } */ this.openResultPos = []; /** * Sets from a predetermined set of boxes with particular height-width ratios for Yolo Detection. * Stored as an array, for example, * in VOC data set, anchors: [ 1.08, 1.19, 3.42, 4.41, 6.63, 11.38, 9.42, 5.11, 16.62, 10.52 ] * * @type { Array } float */ this.anchors = undefined; /** * The label list configuration. * For example, in VOC data set, label: [ "aeroplane", "bicycle", "bird", "boat", "bottle", * "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", * "pottedplant", "sheep", "sofa", "train", "tvmonitor" ] * * @type { Array } string */ this.classLabelList = undefined; /** * The threshold to constrain the output baseline. * The larger the value, the higher the confidence value of the detected object need. * [Default] 0.5 * * @type { float } */ this.scoreThreshold = 0.5; /** * The toggle to control whether to draw all 5 boxes in each grid. * Usually be used to how how yolo network generate the final detective boxes. * [Default] false, means to draw the final result. * @type { bool } */ this.isDrawFiveBoxes = false; /** * The toggle to control whether to apply non-maximum suppression to the detection rectangles . * [Default] true, means to apply nms. * @type { bool } */ this.isNMS = true; /** * Model's input shape, the shape is the same as model's input layer. * * @type { Array } */ this.modelInputShape = undefined; /** * Label to define whether layer need an "output value" from backend model (tfjs, keras, or tf). * True means that user do not need to add value for YoloGrid value when they are preprocessing multi-output for the model. * * @type { boolean } */ this.autoOutputDetect = true; this.layerType = "YoloGrid"; }
JavaScript
function NativeLayer( config ) { // NativeLayer inherits from abstract layer "Layer" Layer.call( this, config ); /** * Hold handler for line group. * * @type { Object } */ this.lineGroupHandler = undefined; /** * Identify whether layer is a merged layer or not. * If it's a NativeLayer, "isMerged" is always false. * * @type {boolean} */ this.isMerged = false; }
function NativeLayer( config ) { // NativeLayer inherits from abstract layer "Layer" Layer.call( this, config ); /** * Hold handler for line group. * * @type { Object } */ this.lineGroupHandler = undefined; /** * Identify whether layer is a merged layer or not. * If it's a NativeLayer, "isMerged" is always false. * * @type {boolean} */ this.isMerged = false; }
JavaScript
function onScroll() { // unique tick id ++ticks; // viewport rectangle var top = jWindow.scrollTop(), left = jWindow.scrollLeft(), right = left + jWindow.width(), bottom = top + jWindow.height(); // determine which elements are in view // + 60 accounts for fixed nav var intersections = findElements(top+offset.top + 60, right+offset.right, bottom+offset.bottom, left+offset.left); $.each(intersections, function(i, element) { var lastTick = element.data('scrollSpy:ticks'); if (typeof lastTick != 'number') { // entered into view element.triggerHandler('scrollSpy:enter'); } // update tick id element.data('scrollSpy:ticks', ticks); }); // determine which elements are no longer in view $.each(elementsInView, function(i, element) { var lastTick = element.data('scrollSpy:ticks'); if (typeof lastTick == 'number' && lastTick !== ticks) { // exited from view element.triggerHandler('scrollSpy:exit'); element.data('scrollSpy:ticks', null); } }); // remember elements in view for next tick elementsInView = intersections; }
function onScroll() { // unique tick id ++ticks; // viewport rectangle var top = jWindow.scrollTop(), left = jWindow.scrollLeft(), right = left + jWindow.width(), bottom = top + jWindow.height(); // determine which elements are in view // + 60 accounts for fixed nav var intersections = findElements(top+offset.top + 60, right+offset.right, bottom+offset.bottom, left+offset.left); $.each(intersections, function(i, element) { var lastTick = element.data('scrollSpy:ticks'); if (typeof lastTick != 'number') { // entered into view element.triggerHandler('scrollSpy:enter'); } // update tick id element.data('scrollSpy:ticks', ticks); }); // determine which elements are no longer in view $.each(elementsInView, function(i, element) { var lastTick = element.data('scrollSpy:ticks'); if (typeof lastTick == 'number' && lastTick !== ticks) { // exited from view element.triggerHandler('scrollSpy:exit'); element.data('scrollSpy:ticks', null); } }); // remember elements in view for next tick elementsInView = intersections; }
JavaScript
function propagateErrors(endEarly, errors) { return endEarly ? null : function (err) { errors.push(err); return err.value; }; }
function propagateErrors(endEarly, errors) { return endEarly ? null : function (err) { errors.push(err); return err.value; }; }
JavaScript
createCallablePromise(abortCallback = null) { let promise, resolve, reject promise = new Promise(function(_resolve, _reject) { resolve = _resolve reject = _reject }) promise.resolve = function(result) { resolve(result) } promise.reject = function(result) { reject(result) } return promise }
createCallablePromise(abortCallback = null) { let promise, resolve, reject promise = new Promise(function(_resolve, _reject) { resolve = _resolve reject = _reject }) promise.resolve = function(result) { resolve(result) } promise.reject = function(result) { reject(result) } return promise }
JavaScript
function scaleVoxels(image, image_min, image_max, valid_range, debug) { /* var new_abuf = new ArrayBuffer(image.array.length * Float32Array.BYTES_PER_ELEMENT); var new_data = new Float32Array(new_abuf); */ // 1D array to store the voxel data, // not initialized yet because it depends on the hdf5 type. var new_abuf = null; var new_data = null; // we could simply use image.type, but written types are easier to read... switch (getTypeMatchMinc(image.type)) { case 'int8': new_abuf = new ArrayBuffer(image.array.length * Int8Array.BYTES_PER_ELEMENT); new_data = new Int8Array(new_abuf); break; case 'int16': new_abuf = new ArrayBuffer(image.array.length * Int16Array.BYTES_PER_ELEMENT); new_data = new Int16Array(new_abuf); break; case 'int32': new_abuf = new ArrayBuffer(image.array.length * Int32Array.BYTES_PER_ELEMENT); new_data = new Int32Array(new_abuf); break; case 'float32': new_abuf = new ArrayBuffer(image.array.length * Float32Array.BYTES_PER_ELEMENT); new_data = new Float32Array(new_abuf); break; case 'float64': new_abuf = new ArrayBuffer(image.array.length * Float64Array.BYTES_PER_ELEMENT); new_data = new Float64Array(new_abuf); break; case 'uint8': new_abuf = new ArrayBuffer(image.array.length * Uint8Array.BYTES_PER_ELEMENT); new_data = new Uint8Array(new_abuf); break; case 'uint16': new_abuf = new ArrayBuffer(image.array.length * Uint16Array.BYTES_PER_ELEMENT); new_data = new Uint16Array(new_abuf); break; case 'uint32': new_abuf = new ArrayBuffer(image.array.length * Uint32Array.BYTES_PER_ELEMENT); new_data = new Uint32Array(new_abuf); break; default: var error_message = "Unsupported data type: " + header.datatype; console.log({ message: error_message } ); //BrainBrowser.events.triggerEvent("error", { message: error_message } ); throw new Error(error_message); } var n_slice_dims = image.dims.length - image_min.dims.length; if (n_slice_dims < 1) { throw new Error("Too few slice dimensions: " + image.dims.length + " " + image_min.dims.length); } var n_slice_elements = 1; var i; for (i = image_min.dims.length; i < image.dims.length; i += 1) { n_slice_elements *= image.dims[i]; } if (debug) { console.log(n_slice_elements + " voxels in slice."); } var s = 0; var c = 0; var x = -Number.MAX_VALUE; var n = Number.MAX_VALUE; var im = image.array; var im_max = image_max.array; var im_min = image_min.array; if (debug) { console.log("valid range is " + valid_range[0] + " to " + valid_range[1]); } var vrange; var rrange; var vmin = valid_range[0]; var rmin; var j; var v; var is_float = typeIsFloat(image.type); for (i = 0; i < image_min.array.length; i += 1) { if (debug) { console.log(i + " " + im_min[i] + " " + im_max[i] + " " + im[i * n_slice_elements]); } if (is_float) { /* For floating-point volumes there is no scaling to be performed. * We do scan the data and make sure voxels are within the valid * range, and collect our statistics. */ for (j = 0; j < n_slice_elements; j += 1) { v = im[c]; if (v < valid_range[0] || v > valid_range[1]) { new_data[c] = 0.0; } else { new_data[c] = v; s += v; if (v > x) { x = v; } if (v < n) { n = v; } } c += 1; } } else { /* For integer volumes we have to scale each slice according to image-min, * image-max, and valid_range. */ vrange = (valid_range[1] - valid_range[0]); rrange = (im_max[i] - im_min[i]); rmin = im_min[i]; /* console.log(n_slice_elements); console.log(vrange); console.log(rrange); console.log(rmin); console.log("-----------------"); */ for (j = 0; j < n_slice_elements; j += 1) { // v normalization to avoid "flickering". // v is scaled to the range [0, im_max[i]] // (possibly uint16 if the original per-slice min-max was not scaled up/down) v = (im[c] - vmin) / vrange * rrange + rmin; // we scale up/down to match the type of the target array v = v / im_max[i] * valid_range[1]; new_data[c] = v; s += v; c += 1; if (v > x) { x = v; } if (v < n) { n = v; } } } } if (debug) { console.log("Min: " + n); console.log("Max: " + x); console.log("Sum: " + s); console.log("Mean: " + s / c); } return new_abuf; }
function scaleVoxels(image, image_min, image_max, valid_range, debug) { /* var new_abuf = new ArrayBuffer(image.array.length * Float32Array.BYTES_PER_ELEMENT); var new_data = new Float32Array(new_abuf); */ // 1D array to store the voxel data, // not initialized yet because it depends on the hdf5 type. var new_abuf = null; var new_data = null; // we could simply use image.type, but written types are easier to read... switch (getTypeMatchMinc(image.type)) { case 'int8': new_abuf = new ArrayBuffer(image.array.length * Int8Array.BYTES_PER_ELEMENT); new_data = new Int8Array(new_abuf); break; case 'int16': new_abuf = new ArrayBuffer(image.array.length * Int16Array.BYTES_PER_ELEMENT); new_data = new Int16Array(new_abuf); break; case 'int32': new_abuf = new ArrayBuffer(image.array.length * Int32Array.BYTES_PER_ELEMENT); new_data = new Int32Array(new_abuf); break; case 'float32': new_abuf = new ArrayBuffer(image.array.length * Float32Array.BYTES_PER_ELEMENT); new_data = new Float32Array(new_abuf); break; case 'float64': new_abuf = new ArrayBuffer(image.array.length * Float64Array.BYTES_PER_ELEMENT); new_data = new Float64Array(new_abuf); break; case 'uint8': new_abuf = new ArrayBuffer(image.array.length * Uint8Array.BYTES_PER_ELEMENT); new_data = new Uint8Array(new_abuf); break; case 'uint16': new_abuf = new ArrayBuffer(image.array.length * Uint16Array.BYTES_PER_ELEMENT); new_data = new Uint16Array(new_abuf); break; case 'uint32': new_abuf = new ArrayBuffer(image.array.length * Uint32Array.BYTES_PER_ELEMENT); new_data = new Uint32Array(new_abuf); break; default: var error_message = "Unsupported data type: " + header.datatype; console.log({ message: error_message } ); //BrainBrowser.events.triggerEvent("error", { message: error_message } ); throw new Error(error_message); } var n_slice_dims = image.dims.length - image_min.dims.length; if (n_slice_dims < 1) { throw new Error("Too few slice dimensions: " + image.dims.length + " " + image_min.dims.length); } var n_slice_elements = 1; var i; for (i = image_min.dims.length; i < image.dims.length; i += 1) { n_slice_elements *= image.dims[i]; } if (debug) { console.log(n_slice_elements + " voxels in slice."); } var s = 0; var c = 0; var x = -Number.MAX_VALUE; var n = Number.MAX_VALUE; var im = image.array; var im_max = image_max.array; var im_min = image_min.array; if (debug) { console.log("valid range is " + valid_range[0] + " to " + valid_range[1]); } var vrange; var rrange; var vmin = valid_range[0]; var rmin; var j; var v; var is_float = typeIsFloat(image.type); for (i = 0; i < image_min.array.length; i += 1) { if (debug) { console.log(i + " " + im_min[i] + " " + im_max[i] + " " + im[i * n_slice_elements]); } if (is_float) { /* For floating-point volumes there is no scaling to be performed. * We do scan the data and make sure voxels are within the valid * range, and collect our statistics. */ for (j = 0; j < n_slice_elements; j += 1) { v = im[c]; if (v < valid_range[0] || v > valid_range[1]) { new_data[c] = 0.0; } else { new_data[c] = v; s += v; if (v > x) { x = v; } if (v < n) { n = v; } } c += 1; } } else { /* For integer volumes we have to scale each slice according to image-min, * image-max, and valid_range. */ vrange = (valid_range[1] - valid_range[0]); rrange = (im_max[i] - im_min[i]); rmin = im_min[i]; /* console.log(n_slice_elements); console.log(vrange); console.log(rrange); console.log(rmin); console.log("-----------------"); */ for (j = 0; j < n_slice_elements; j += 1) { // v normalization to avoid "flickering". // v is scaled to the range [0, im_max[i]] // (possibly uint16 if the original per-slice min-max was not scaled up/down) v = (im[c] - vmin) / vrange * rrange + rmin; // we scale up/down to match the type of the target array v = v / im_max[i] * valid_range[1]; new_data[c] = v; s += v; c += 1; if (v > x) { x = v; } if (v < n) { n = v; } } } } if (debug) { console.log("Min: " + n); console.log("Max: " + x); console.log("Sum: " + s); console.log("Mean: " + s / c); } return new_abuf; }
JavaScript
function loadChildren(n) { n.loaded = true; childrenMap[n.type].forEach(function (childCollection) { $.ajax({ url: n.links[childCollection], success: function (collection) { n[childCollection] = collection.Items.map(function (item) { return new node(item.Name, childCollection, item.Links, n.div); }) }, error: function (xhr) { console.log(xhr.responseText); }, beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', 'Basic xxx'); } }) }); }
function loadChildren(n) { n.loaded = true; childrenMap[n.type].forEach(function (childCollection) { $.ajax({ url: n.links[childCollection], success: function (collection) { n[childCollection] = collection.Items.map(function (item) { return new node(item.Name, childCollection, item.Links, n.div); }) }, error: function (xhr) { console.log(xhr.responseText); }, beforeSend: function (xhr) { xhr.setRequestHeader('Authorization', 'Basic xxx'); } }) }); }
JavaScript
function init() { inquirer.prompt(questions) .then(function(data) { writeToFile("README.md", data) //replace data with readmeText }); }
function init() { inquirer.prompt(questions) .then(function(data) { writeToFile("README.md", data) //replace data with readmeText }); }
JavaScript
function renderLicenseBadge(data) { //pass in license choice ---DID THIS IN THE CALL //grab badge and return //if statement returning license agreement if (data === "MIT" ) { return "[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT);" } else if (data === "Mozilla" ) { return "[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)" } else if (data === "IBM") { return "[![License: IPL 1.0](https://img.shields.io/badge/License-IPL%201.0-blue.svg)](https://opensource.org/licenses/IPL-1.0)" } else { return "" } }
function renderLicenseBadge(data) { //pass in license choice ---DID THIS IN THE CALL //grab badge and return //if statement returning license agreement if (data === "MIT" ) { return "[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT);" } else if (data === "Mozilla" ) { return "[![License: MPL 2.0](https://img.shields.io/badge/License-MPL%202.0-brightgreen.svg)](https://opensource.org/licenses/MPL-2.0)" } else if (data === "IBM") { return "[![License: IPL 1.0](https://img.shields.io/badge/License-IPL%201.0-blue.svg)](https://opensource.org/licenses/IPL-1.0)" } else { return "" } }
JavaScript
function renderLicenseLink(data) { if (data === "MIT" ) { return "https://opensource.org/licenses/MIT" } else if (data === "Mozilla" ) { return "https://www.mozilla.org/en-US/MPL/2.0/" } else if (data === "IBM") { return "https://opensource.org/licenses/IPL-1.0" } else { return "" } }
function renderLicenseLink(data) { if (data === "MIT" ) { return "https://opensource.org/licenses/MIT" } else if (data === "Mozilla" ) { return "https://www.mozilla.org/en-US/MPL/2.0/" } else if (data === "IBM") { return "https://opensource.org/licenses/IPL-1.0" } else { return "" } }
JavaScript
function renderLicenseSection(data) { let licenseLink = renderLicenseLink(data); if (data === "MIT" ) { return `This project uses [the MIT License](${licenseLink})` } else if (data === "Mozilla" ) { return `This project uses [Mozilla Public License 2.0](${licenseLink})` } else if (data === "IBM") { return `This project uses [IBM Punlic License Version 1.0](${licenseLink})` } else { return "No License data available" } }
function renderLicenseSection(data) { let licenseLink = renderLicenseLink(data); if (data === "MIT" ) { return `This project uses [the MIT License](${licenseLink})` } else if (data === "Mozilla" ) { return `This project uses [Mozilla Public License 2.0](${licenseLink})` } else if (data === "IBM") { return `This project uses [IBM Punlic License Version 1.0](${licenseLink})` } else { return "No License data available" } }
JavaScript
function updateVisibility() { const views = Array.from(widgetInstances.keys()); views.forEach((otherView) => { let visible = false; if (widgetInstances.has(otherView)) { // handle views of the same type // case: not locked to a slice/axis if (lockAxis.value === null || lockSlice.value === null) { if (currentView.value && viewTypeMap.has(currentView.value)) { const viewType = viewTypeMap.get(currentView.value); visible = viewTypeMap.get(otherView) === viewType; } else { visible = false; } } // case: locked to a slice/axis if (lockAxis.value !== null && lockSlice.value !== null) { if (is2DView(otherView)) { const otherAxis = otherView.getAxis(); visible = otherAxis === lockAxis.value && Math.abs(slices.value['xyz'[otherAxis]] - lockSlice.value) < 1e-6; } else { visible = false; } } const viewWidget = widgetInstances.get(otherView); viewWidget.setVisibility(visible); viewWidget.setContextVisibility(visible); renderViewAndWidgets(otherView); } }); }
function updateVisibility() { const views = Array.from(widgetInstances.keys()); views.forEach((otherView) => { let visible = false; if (widgetInstances.has(otherView)) { // handle views of the same type // case: not locked to a slice/axis if (lockAxis.value === null || lockSlice.value === null) { if (currentView.value && viewTypeMap.has(currentView.value)) { const viewType = viewTypeMap.get(currentView.value); visible = viewTypeMap.get(otherView) === viewType; } else { visible = false; } } // case: locked to a slice/axis if (lockAxis.value !== null && lockSlice.value !== null) { if (is2DView(otherView)) { const otherAxis = otherView.getAxis(); visible = otherAxis === lockAxis.value && Math.abs(slices.value['xyz'[otherAxis]] - lockSlice.value) < 1e-6; } else { visible = false; } } const viewWidget = widgetInstances.get(otherView); viewWidget.setVisibility(visible); viewWidget.setContextVisibility(visible); renderViewAndWidgets(otherView); } }); }
JavaScript
addFileTypeAliases(baseType, aliases) { if (baseType.toLowerCase() in this.fileReaders) { aliases.forEach((alias) => { this.typeAliases[alias.toLowerCase()] = baseType; }); } }
addFileTypeAliases(baseType, aliases) { if (baseType.toLowerCase() in this.fileReaders) { aliases.forEach((alias) => { this.typeAliases[alias.toLowerCase()] = baseType; }); } }