language
stringclasses
6 values
original_string
stringlengths
25
887k
text
stringlengths
25
887k
JavaScript
function collapse(id) { var coll = document.getElementById("collapsible" + id); var nameButton = document.getElementById('showName' + id); var content = coll.nextElementSibling; var deleteButtonCollapse = document.getElementById("deleteNeumeButton" + id); var collapseAllButton = document.getElementById("buttonCollapseAll"); // cookie used on collapsible element to save if a neume is collapsed // if it is then collapse it when the page is reloaded $.cookie(id, "true"); // change the contents of the nameButton to have the correct arrow direction var inner = nameButton.innerHTML; var splitInner = inner.split('>'); nameButton.innerHTML = '<i class=\"fa fa-caret-right fa-lg\"></i>' + splitInner[splitInner.length - 1]; // hide the contents of the neume content.style.display = "none"; deleteButtonCollapse.style.display = "none"; collapseAllButton.value = Number(collapseAllButton.value) + 1; }
function collapse(id) { var coll = document.getElementById("collapsible" + id); var nameButton = document.getElementById('showName' + id); var content = coll.nextElementSibling; var deleteButtonCollapse = document.getElementById("deleteNeumeButton" + id); var collapseAllButton = document.getElementById("buttonCollapseAll"); // cookie used on collapsible element to save if a neume is collapsed // if it is then collapse it when the page is reloaded $.cookie(id, "true"); // change the contents of the nameButton to have the correct arrow direction var inner = nameButton.innerHTML; var splitInner = inner.split('>'); nameButton.innerHTML = '<i class=\"fa fa-caret-right fa-lg\"></i>' + splitInner[splitInner.length - 1]; // hide the contents of the neume content.style.display = "none"; deleteButtonCollapse.style.display = "none"; collapseAllButton.value = Number(collapseAllButton.value) + 1; }
JavaScript
async function init () { let displayContents = document.getElementById('displayContents'); if (displayContents !== null) { let panelBlock = document.createElement('div'); panelBlock.classList.add('panel-block'); let pNotif = document.createElement('p'); pNotif.textContent = 'MEI Status: '; let span = document.createElement('span'); span.id = 'validation_status'; span.textContent = 'unknown'; pNotif.appendChild(span); panelBlock.appendChild(pNotif); displayContents.appendChild(panelBlock); statusField = document.getElementById('validation_status'); worker = new Worker(); worker.onmessage = updateUI; } }
async function init () { let displayContents = document.getElementById('displayContents'); if (displayContents !== null) { let panelBlock = document.createElement('div'); panelBlock.classList.add('panel-block'); let pNotif = document.createElement('p'); pNotif.textContent = 'MEI Status: '; let span = document.createElement('span'); span.id = 'validation_status'; span.textContent = 'unknown'; pNotif.appendChild(span); panelBlock.appendChild(pNotif); displayContents.appendChild(panelBlock); statusField = document.getElementById('validation_status'); worker = new Worker(); worker.onmessage = updateUI; } }
JavaScript
async function sendForValidation (meiData) { if (statusField === undefined) { return; } if (schema === undefined) { schema = await schemaPromise; } statusField.textContent = 'checking...'; statusField.style = 'color:gray'; worker.postMessage({ mei: meiData, schema: schema.default }); }
async function sendForValidation (meiData) { if (statusField === undefined) { return; } if (schema === undefined) { schema = await schemaPromise; } statusField.textContent = 'checking...'; statusField.style = 'color:gray'; worker.postMessage({ mei: meiData, schema: schema.default }); }
JavaScript
function updateUI (message) { let errors = message.data; if (errors === null) { statusField.textContent = 'VALID'; statusField.style = 'color:green'; for (let child of statusField.children) { statusField.deleteChild(child); } } else { let log = ''; errors.forEach(line => { log += line + '\n'; }); statusField.textContent = ''; statusField.style = 'color:red'; let link = document.createElement('a'); link.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(log)); link.setAttribute('download', 'validation.log'); link.textContent = 'INVALID'; statusField.appendChild(link); } }
function updateUI (message) { let errors = message.data; if (errors === null) { statusField.textContent = 'VALID'; statusField.style = 'color:green'; for (let child of statusField.children) { statusField.deleteChild(child); } } else { let log = ''; errors.forEach(line => { log += line + '\n'; }); statusField.textContent = ''; statusField.style = 'color:red'; let link = document.createElement('a'); link.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(log)); link.setAttribute('download', 'validation.log'); link.textContent = 'INVALID'; statusField.appendChild(link); } }
JavaScript
function Neume(name, dragAndDrop, folio, description, classificationLabel, meiSnippet) { // Note: Don't worry about 'this' yet. You'll understand it later. Follow along for now. this.name = name this.dragAndDrop = dragAndDrop this.folio = folio this.description = description this.classificationLabel = classificationLabel this.meiSnippet = meiSnippet this.sayName = function() { console.log(`I am ${name} ${dragAndDrop}`) } }
function Neume(name, dragAndDrop, folio, description, classificationLabel, meiSnippet) { // Note: Don't worry about 'this' yet. You'll understand it later. Follow along for now. this.name = name this.dragAndDrop = dragAndDrop this.folio = folio this.description = description this.classificationLabel = classificationLabel this.meiSnippet = meiSnippet this.sayName = function() { console.log(`I am ${name} ${dragAndDrop}`) } }
JavaScript
function CSVToArray(strData, strDelimiter) { strData = strData.trim(); // Check to see if the delimiter is defined. If not, // then default to comma. strDelimiter = (strDelimiter || ","); // Create a regular expression to parse the CSV values. var objPattern = new RegExp(( // Delimiters. "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" + // Quoted fields. "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" + // Standard fields. "([^\"\\" + strDelimiter + "\\r\\n]*))"), "gi"); // Create an array to hold our data. Give the array // a default empty first row. var arrData = [ [] ]; // Create an array to hold our individual pattern // matching groups. var arrMatches = null; // Keep looping over the regular expression matches // until we can no longer find a match. while (arrMatches = objPattern.exec(strData)) { // Get the delimiter that was found. var strMatchedDelimiter = arrMatches[1]; // Check to see if the given delimiter has a length // (is not the start of string) and if it matches // field delimiter. If id does not, then we know // that this delimiter is a row delimiter. if (strMatchedDelimiter.length && (strMatchedDelimiter != strDelimiter)) { // Since we have reached a new row of data, // add an empty row to our data array. arrData.push([]); } // Now that we have our delimiter out of the way, // let's check to see which kind of value we // captured (quoted or unquoted). if (arrMatches[2]) { // We found a quoted value. When we capture // this value, unescape any double quotes. var strMatchedValue = arrMatches[2].replace( new RegExp("\"\"", "g"), "\""); } else { // We found a non-quoted value. var strMatchedValue = arrMatches[3]; } // Now that we have our value string, let's add // it to the data array. arrData[arrData.length - 1].push(strMatchedValue); } // Return the parsed data. return (arrData); }
function CSVToArray(strData, strDelimiter) { strData = strData.trim(); // Check to see if the delimiter is defined. If not, // then default to comma. strDelimiter = (strDelimiter || ","); // Create a regular expression to parse the CSV values. var objPattern = new RegExp(( // Delimiters. "(\\" + strDelimiter + "|\\r?\\n|\\r|^)" + // Quoted fields. "(?:\"([^\"]*(?:\"\"[^\"]*)*)\"|" + // Standard fields. "([^\"\\" + strDelimiter + "\\r\\n]*))"), "gi"); // Create an array to hold our data. Give the array // a default empty first row. var arrData = [ [] ]; // Create an array to hold our individual pattern // matching groups. var arrMatches = null; // Keep looping over the regular expression matches // until we can no longer find a match. while (arrMatches = objPattern.exec(strData)) { // Get the delimiter that was found. var strMatchedDelimiter = arrMatches[1]; // Check to see if the given delimiter has a length // (is not the start of string) and if it matches // field delimiter. If id does not, then we know // that this delimiter is a row delimiter. if (strMatchedDelimiter.length && (strMatchedDelimiter != strDelimiter)) { // Since we have reached a new row of data, // add an empty row to our data array. arrData.push([]); } // Now that we have our delimiter out of the way, // let's check to see which kind of value we // captured (quoted or unquoted). if (arrMatches[2]) { // We found a quoted value. When we capture // this value, unescape any double quotes. var strMatchedValue = arrMatches[2].replace( new RegExp("\"\"", "g"), "\""); } else { // We found a non-quoted value. var strMatchedValue = arrMatches[3]; } // Now that we have our value string, let's add // it to the data array. arrData[arrData.length - 1].push(strMatchedValue); } // Return the parsed data. return (arrData); }
JavaScript
createWalls() { // create floor and ceiling sprites for(let x = 0; x < 20; x++) { let w1 = new Sprite('/content/spritesheet.png'); w1.collision = new Rectangle(32, 32); w1.frame = new Frame(7 * 32, 1 * 32, 32, 32); w1.x = -320 + (x * 32) + 16; w1.y = 240 - 16; this.walls.push(w1); this.addChild(w1); let w2 = new Sprite('/content/spritesheet.png'); w2.collision = new Rectangle(32, 32); w2.frame = new Frame(7 * 32, 1 * 32, 32, 32); w2.x = -320 + (x * 32) + 16; w2.y = -240 + 16; this.walls.push(w2); this.addChild(w2); } // create walls for(let y = 0; y < 14; y++) { let w1 = new Sprite('/content/spritesheet.png'); w1.collision = new Rectangle(32, 32); w1.frame = new Frame(7 * 32, 1 * 32, 32, 32); w1.x = -320 + 16; w1.y = -240 + (y * 32) + 16; this.walls.push(w1); this.addChild(w1); let w2 = new Sprite('/content/spritesheet.png'); w2.collision = new Rectangle(32, 32); w2.frame = new Frame(7 * 32, 1 * 32, 32, 32); w2.x = 320 - 16; w2.y = -240 + (y * 32) + 16; this.walls.push(w2); this.addChild(w2); } }
createWalls() { // create floor and ceiling sprites for(let x = 0; x < 20; x++) { let w1 = new Sprite('/content/spritesheet.png'); w1.collision = new Rectangle(32, 32); w1.frame = new Frame(7 * 32, 1 * 32, 32, 32); w1.x = -320 + (x * 32) + 16; w1.y = 240 - 16; this.walls.push(w1); this.addChild(w1); let w2 = new Sprite('/content/spritesheet.png'); w2.collision = new Rectangle(32, 32); w2.frame = new Frame(7 * 32, 1 * 32, 32, 32); w2.x = -320 + (x * 32) + 16; w2.y = -240 + 16; this.walls.push(w2); this.addChild(w2); } // create walls for(let y = 0; y < 14; y++) { let w1 = new Sprite('/content/spritesheet.png'); w1.collision = new Rectangle(32, 32); w1.frame = new Frame(7 * 32, 1 * 32, 32, 32); w1.x = -320 + 16; w1.y = -240 + (y * 32) + 16; this.walls.push(w1); this.addChild(w1); let w2 = new Sprite('/content/spritesheet.png'); w2.collision = new Rectangle(32, 32); w2.frame = new Frame(7 * 32, 1 * 32, 32, 32); w2.x = 320 - 16; w2.y = -240 + (y * 32) + 16; this.walls.push(w2); this.addChild(w2); } }
JavaScript
createBalls() { // make some things to collide for(let i = 0; i < 25; i++) { let s = new Sprite('/content/frostflake.png'); s.position.x = MathUtil.randomInRange(-200, 200); s.position.y = MathUtil.randomInRange(-200, 200); s.velocity.x = MathUtil.randomInRange(-300, 300); s.velocity.y = MathUtil.randomInRange(-300, 300); this.balls.push(s); this.addChild(s); } }
createBalls() { // make some things to collide for(let i = 0; i < 25; i++) { let s = new Sprite('/content/frostflake.png'); s.position.x = MathUtil.randomInRange(-200, 200); s.position.y = MathUtil.randomInRange(-200, 200); s.velocity.x = MathUtil.randomInRange(-300, 300); s.velocity.y = MathUtil.randomInRange(-300, 300); this.balls.push(s); this.addChild(s); } }
JavaScript
handleChange() { const addFile = (uid, result) => { this.addFile(uid, result); } if (this.uploadInput.files.length === 0) return; // step1: get the choosed file from the input element. let originalFile = this.uploadInput.files[0]; // type is File {name: "test.jpg", lastModified: 1622528580998, ...} this.uploadInput.value = ''; // step2: add the file to the fileList in state let uid = genUniqueId(); let reader = new FileReader(); reader.readAsDataURL(originalFile); reader.onload = function() { // Since in this function, here cannot call addFile of the ChueasyUploader class, // I define the function addFile inside the handleChange function. // The 'this' is 'reader', so using 'reader.result' is OK as well. addFile(uid, this.result); }; // step3: handle something before upload let beforeUploadPromise = this.handleBeforeUpload(originalFile); beforeUploadPromise.then((handledFile) => { // step4: handle upload this.handleUpload(uid, handledFile); }) }
handleChange() { const addFile = (uid, result) => { this.addFile(uid, result); } if (this.uploadInput.files.length === 0) return; // step1: get the choosed file from the input element. let originalFile = this.uploadInput.files[0]; // type is File {name: "test.jpg", lastModified: 1622528580998, ...} this.uploadInput.value = ''; // step2: add the file to the fileList in state let uid = genUniqueId(); let reader = new FileReader(); reader.readAsDataURL(originalFile); reader.onload = function() { // Since in this function, here cannot call addFile of the ChueasyUploader class, // I define the function addFile inside the handleChange function. // The 'this' is 'reader', so using 'reader.result' is OK as well. addFile(uid, this.result); }; // step3: handle something before upload let beforeUploadPromise = this.handleBeforeUpload(originalFile); beforeUploadPromise.then((handledFile) => { // step4: handle upload this.handleUpload(uid, handledFile); }) }
JavaScript
function register() { if (arguments.length == 1) { registerAll(arguments[0]); } else if (arguments.length == 2) { registerModule(arguments[0], arguments[1]); } }
function register() { if (arguments.length == 1) { registerAll(arguments[0]); } else if (arguments.length == 2) { registerModule(arguments[0], arguments[1]); } }
JavaScript
function mapAlign (value) { return value == 'left' && 'align-left' || value == 'right' && 'align-right' || value == 'start' && (this.rtl ? 'align-right' : 'align-left') || value == 'end' && (this.rtl ? 'align-left' : 'align-right') || ''; }
function mapAlign (value) { return value == 'left' && 'align-left' || value == 'right' && 'align-right' || value == 'start' && (this.rtl ? 'align-right' : 'align-left') || value == 'end' && (this.rtl ? 'align-left' : 'align-right') || ''; }
JavaScript
function mapShowing (showing) { return (showing === true || showing === false) && 'show' || showing == 'spotlight' && 'show-on-spotlight' || showing == 'hover' && 'show-on-hover' || ''; }
function mapShowing (showing) { return (showing === true || showing === false) && 'show' || showing == 'spotlight' && 'show-on-spotlight' || showing == 'hover' && 'show-on-hover' || ''; }
JavaScript
function forwardPropertyChange (was, is, prop) { var target = this.$[this.overlayTarget]; if (target) { // Special handling for overlayComponents to ensure the component ownership is correct if (prop == 'overlayComponents') { is = updateOwnership(is, this.getInstanceOwner()); } target.set(prop, is); } }
function forwardPropertyChange (was, is, prop) { var target = this.$[this.overlayTarget]; if (target) { // Special handling for overlayComponents to ensure the component ownership is correct if (prop == 'overlayComponents') { is = updateOwnership(is, this.getInstanceOwner()); } target.set(prop, is); } }
JavaScript
function updateOwnership (components, owner) { var control, i; if (components) { for (i = components.length - 1; i >= 0; --i) { control = components[i]; control.owner = control.owner || owner; } } return components; }
function updateOwnership (components, owner) { var control, i; if (components) { for (i = components.length - 1; i >= 0; --i) { control = components[i]; control.owner = control.owner || owner; } } return components; }
JavaScript
function withProcessQueue(f) { const queue = []; let running = false; return (notebook) => __awaiter(this, void 0, void 0, function* () { queue.push(notebook); if (!running) { running = true; while (queue.length) { const next = queue.shift(); yield f(next); } running = false; } }); }
function withProcessQueue(f) { const queue = []; let running = false; return (notebook) => __awaiter(this, void 0, void 0, function* () { queue.push(notebook); if (!running) { running = true; while (queue.length) { const next = queue.shift(); yield f(next); } running = false; } }); }
JavaScript
function initMap() { document.addEventListener( 'sfmaploaded', checkGeo ); document.addEventListener( 'filtersapplied', filterMarkers ); document.addEventListener( 'spacesloaded', maybeSetupMap ); document.addEventListener( 'sfmaploaded', maybeSetupMap ); spacefinder.map = new google.maps.Map(document.getElementById('map'), { center: spacefinder.currentLoc, zoom: spacefinder.startZoom, mapTypeId: google.maps.MapTypeId.ROADMAP, }); google.maps.event.addListenerOnce( spacefinder.map, 'tilesloaded', () => { spacefinder.mapLoaded = true; document.dispatchEvent( new Event( 'sfmaploaded' ) ); }); }
function initMap() { document.addEventListener( 'sfmaploaded', checkGeo ); document.addEventListener( 'filtersapplied', filterMarkers ); document.addEventListener( 'spacesloaded', maybeSetupMap ); document.addEventListener( 'sfmaploaded', maybeSetupMap ); spacefinder.map = new google.maps.Map(document.getElementById('map'), { center: spacefinder.currentLoc, zoom: spacefinder.startZoom, mapTypeId: google.maps.MapTypeId.ROADMAP, }); google.maps.event.addListenerOnce( spacefinder.map, 'tilesloaded', () => { spacefinder.mapLoaded = true; document.dispatchEvent( new Event( 'sfmaploaded' ) ); }); }
JavaScript
function maybeSetupMap() { if ( spacefinder.mapLoaded && spacefinder.spacesLoaded ) { spacefinder.mapBounds = new google.maps.LatLngBounds(); spacefinder.infoWindow = new google.maps.InfoWindow({ maxWidth: 350 }); /* add each spoace to the map using a marker */ for ( let i = 0; i < spacefinder.spaces.length; i++ ) { if ( spacefinder.spaces[i].lat && spacefinder.spaces[i].lng ) { var spacePosition = new google.maps.LatLng( spacefinder.spaces[i].lat, spacefinder.spaces[i].lng ); spacefinder.spaces[i].marker = new google.maps.Marker({ position: spacePosition, map: spacefinder.map, title: spacefinder.spaces[i].title, optimized: false, icon: { path: google.maps.SymbolPath.CIRCLE,//'M0-30.5c-5.7,0-10.2,4.6-10.2,10.2C-10.2-14.6,0,0,0,0s10.2-14.6,10.2-20.2C10.2-25.9,5.7-30.5,0-30.5z M0-17.7c-1.6,0-3-1.3-3-3s1.3-3,3-3s3,1.3,3,3S1.6-17.7,0-17.7z', fillColor: "#c70000", strokeColor: "#910000", fillOpacity: 1, scale: 8, strokeWeight: 4 } }); spacefinder.spaces[i].marker.infoContent = getSpaceInfoWindowContent( spacefinder.spaces[i] ); google.maps.event.addListener( spacefinder.spaces[i].marker, 'click', function (e) { spacefinder.infoWindow.setContent( spacefinder.spaces[i].marker.infoContent ); spacefinder.infoWindow.open( spacefinder.map, spacefinder.spaces[i].marker ); selectSpace(spacefinder.spaces[i].id, 'map'); }); spacefinder.mapBounds.extend( spacePosition ); } } google.maps.event.addListener(spacefinder.infoWindow,'closeclick',function(){ deselectSpaces(false); }); fitAllBounds( spacefinder.mapBounds ); document.dispatchEvent( new Event( 'sfmapready' ) ); } }
function maybeSetupMap() { if ( spacefinder.mapLoaded && spacefinder.spacesLoaded ) { spacefinder.mapBounds = new google.maps.LatLngBounds(); spacefinder.infoWindow = new google.maps.InfoWindow({ maxWidth: 350 }); /* add each spoace to the map using a marker */ for ( let i = 0; i < spacefinder.spaces.length; i++ ) { if ( spacefinder.spaces[i].lat && spacefinder.spaces[i].lng ) { var spacePosition = new google.maps.LatLng( spacefinder.spaces[i].lat, spacefinder.spaces[i].lng ); spacefinder.spaces[i].marker = new google.maps.Marker({ position: spacePosition, map: spacefinder.map, title: spacefinder.spaces[i].title, optimized: false, icon: { path: google.maps.SymbolPath.CIRCLE,//'M0-30.5c-5.7,0-10.2,4.6-10.2,10.2C-10.2-14.6,0,0,0,0s10.2-14.6,10.2-20.2C10.2-25.9,5.7-30.5,0-30.5z M0-17.7c-1.6,0-3-1.3-3-3s1.3-3,3-3s3,1.3,3,3S1.6-17.7,0-17.7z', fillColor: "#c70000", strokeColor: "#910000", fillOpacity: 1, scale: 8, strokeWeight: 4 } }); spacefinder.spaces[i].marker.infoContent = getSpaceInfoWindowContent( spacefinder.spaces[i] ); google.maps.event.addListener( spacefinder.spaces[i].marker, 'click', function (e) { spacefinder.infoWindow.setContent( spacefinder.spaces[i].marker.infoContent ); spacefinder.infoWindow.open( spacefinder.map, spacefinder.spaces[i].marker ); selectSpace(spacefinder.spaces[i].id, 'map'); }); spacefinder.mapBounds.extend( spacePosition ); } } google.maps.event.addListener(spacefinder.infoWindow,'closeclick',function(){ deselectSpaces(false); }); fitAllBounds( spacefinder.mapBounds ); document.dispatchEvent( new Event( 'sfmapready' ) ); } }
JavaScript
function fitAllBounds(b) { // Get north east and south west markers bounds coordinates var ne = b.getNorthEast(); var sw = b.getSouthWest(); // Get the current map bounds var mapBounds = spacefinder.map.getBounds(); // Check if map bounds contains both north east and south west points if (mapBounds.contains(ne) && mapBounds.contains(sw)) { // Everything fits return; } else { var mapZoom = spacefinder.map.getZoom(); if (mapZoom > 0) { // Zoom out spacefinder.map.setZoom(mapZoom - 1); // Try again fitAllBounds(b); } } }
function fitAllBounds(b) { // Get north east and south west markers bounds coordinates var ne = b.getNorthEast(); var sw = b.getSouthWest(); // Get the current map bounds var mapBounds = spacefinder.map.getBounds(); // Check if map bounds contains both north east and south west points if (mapBounds.contains(ne) && mapBounds.contains(sw)) { // Everything fits return; } else { var mapZoom = spacefinder.map.getZoom(); if (mapZoom > 0) { // Zoom out spacefinder.map.setZoom(mapZoom - 1); // Try again fitAllBounds(b); } } }
JavaScript
function zoomMapToSpace( space ) { let newCenter = new google.maps.LatLng( space.lat, space.lng ); spacefinder.map.panTo( newCenter ); spacefinder.map.setZoom(18); spacefinder.infoWindow.setContent( getSpaceInfoWindowContent( space ) ); spacefinder.infoWindow.open( spacefinder.map, space.marker ); }
function zoomMapToSpace( space ) { let newCenter = new google.maps.LatLng( space.lat, space.lng ); spacefinder.map.panTo( newCenter ); spacefinder.map.setZoom(18); spacefinder.infoWindow.setContent( getSpaceInfoWindowContent( space ) ); spacefinder.infoWindow.open( spacefinder.map, space.marker ); }
JavaScript
function filterMarkers() { document.querySelectorAll('.list-space').forEach( el => { let space = getSpaceById( el.getAttribute('data-id') ); if ( el.classList.contains('hidden') ) { space.marker.setMap( null ); } else { space.marker.setMap( spacefinder.map ); } }); }
function filterMarkers() { document.querySelectorAll('.list-space').forEach( el => { let space = getSpaceById( el.getAttribute('data-id') ); if ( el.classList.contains('hidden') ) { space.marker.setMap( null ); } else { space.marker.setMap( spacefinder.map ); } }); }
JavaScript
function toggleGeolocation( enable ) { if ( enable ) { document.querySelectorAll( '.geo-button' ).forEach( e => e.disabled = false ); } else { document.querySelectorAll( '.geo-button' ).forEach( e => e.disabled = true ); } }
function toggleGeolocation( enable ) { if ( enable ) { document.querySelectorAll( '.geo-button' ).forEach( e => e.disabled = false ); } else { document.querySelectorAll( '.geo-button' ).forEach( e => e.disabled = true ); } }
JavaScript
function activateGeolocation( activate ) { if ( activate ) { document.querySelectorAll( '.geo-button' ).forEach( e => { e.classList.add('active'); e.setAttribute('aria-label','Stop using my location') e.setAttribute('title','Stop using my location') }); document.addEventListener( 'userlocationchanged', movePersonMarker ); document.dispatchEvent(new CustomEvent('sfanalytics', { detail: { type: 'geostart' } })); } else { document.querySelectorAll( '.geo-button' ).forEach( e => { e.classList.remove('active'); e.setAttribute('aria-label','Use my location') e.setAttribute('title','Use my location') }); document.removeEventListener( 'userlocationchanged', movePersonMarker ); /* remove sorting indicator from all buttons */ document.getElementById( 'sortdistance' ).setAttribute('data-sortdir', ''); document.dispatchEvent(new CustomEvent('sfanalytics', { detail: { type: 'geoend' } })); } updateDistances(); activateSort( activate, 'distance' ); }
function activateGeolocation( activate ) { if ( activate ) { document.querySelectorAll( '.geo-button' ).forEach( e => { e.classList.add('active'); e.setAttribute('aria-label','Stop using my location') e.setAttribute('title','Stop using my location') }); document.addEventListener( 'userlocationchanged', movePersonMarker ); document.dispatchEvent(new CustomEvent('sfanalytics', { detail: { type: 'geostart' } })); } else { document.querySelectorAll( '.geo-button' ).forEach( e => { e.classList.remove('active'); e.setAttribute('aria-label','Use my location') e.setAttribute('title','Use my location') }); document.removeEventListener( 'userlocationchanged', movePersonMarker ); /* remove sorting indicator from all buttons */ document.getElementById( 'sortdistance' ).setAttribute('data-sortdir', ''); document.dispatchEvent(new CustomEvent('sfanalytics', { detail: { type: 'geoend' } })); } updateDistances(); activateSort( activate, 'distance' ); }
JavaScript
function movePersonMarker() { /* move person marker */ if ( spacefinder.personMarker ) { spacefinder.personMarker.setPosition( spacefinder.personLoc ); } /* update distances to each space */ updateDistances(); /* see if the spaces are sorted by distance */ let btn = document.querySelector('#sortdistance[data-sortdir$="sc"'); if ( btn !== null ) { /* determine direction from current attribute value */ let sortdir = document.getElementById('sortdistance').getAttribute('data-sortdir'); let dir = ( sortdir == 'desc' ) ? false: true; /* re-sort spaces */ sortSpaces( 'sortdistance', dir ); } /* centre the map on the person */ spacefinder.map.setCenter( spacefinder.personLoc ); }
function movePersonMarker() { /* move person marker */ if ( spacefinder.personMarker ) { spacefinder.personMarker.setPosition( spacefinder.personLoc ); } /* update distances to each space */ updateDistances(); /* see if the spaces are sorted by distance */ let btn = document.querySelector('#sortdistance[data-sortdir$="sc"'); if ( btn !== null ) { /* determine direction from current attribute value */ let sortdir = document.getElementById('sortdistance').getAttribute('data-sortdir'); let dir = ( sortdir == 'desc' ) ? false: true; /* re-sort spaces */ sortSpaces( 'sortdistance', dir ); } /* centre the map on the person */ spacefinder.map.setCenter( spacefinder.personLoc ); }
JavaScript
function geolocationEnabled() { const btn = document.querySelector( '.geo-button' ); if ( btn !== null ) { return btn.disabled == false; } return false; }
function geolocationEnabled() { const btn = document.querySelector( '.geo-button' ); if ( btn !== null ) { return btn.disabled == false; } return false; }
JavaScript
function checkGeo() { /* first see if geolocation is available on the device */ checkGeoAvailable(); /* check to see if it is enabled to determine initial button states */ checkGeoPermissions(); }
function checkGeo() { /* first see if geolocation is available on the device */ checkGeoAvailable(); /* check to see if it is enabled to determine initial button states */ checkGeoPermissions(); }
JavaScript
function checkGeoPermissions() { /* check for permissions query */ if ( 'permissions' in navigator && navigator.permissions.query ) { /* query geolocation permissions */ navigator.permissions.query( { name: 'geolocation' } ).then( result => { /* save permission state (denied, granted or prompt) */ spacefinder.permission = result.state; if ( 'denied' == result.state ) { toggleGeolocation( false ); } else { toggleGeolocation( true ); } result.onchange = function() { spacefinder.permission = result.state; if ( 'denied' == result.state ) { toggleGeolocation( false ); } else { toggleGeolocation( true ); } } }).catch(error => { toggleGeolocation( false ); }); } }
function checkGeoPermissions() { /* check for permissions query */ if ( 'permissions' in navigator && navigator.permissions.query ) { /* query geolocation permissions */ navigator.permissions.query( { name: 'geolocation' } ).then( result => { /* save permission state (denied, granted or prompt) */ spacefinder.permission = result.state; if ( 'denied' == result.state ) { toggleGeolocation( false ); } else { toggleGeolocation( true ); } result.onchange = function() { spacefinder.permission = result.state; if ( 'denied' == result.state ) { toggleGeolocation( false ); } else { toggleGeolocation( true ); } } }).catch(error => { toggleGeolocation( false ); }); } }
JavaScript
function checkGeoAvailable() { if ( 'geolocation' in navigator ) { /* make button for map to let user activate geolocation */ const locationButton = document.createElement( 'button' ); locationButton.innerHTML = ''; locationButton.classList.add('geo-button'); locationButton.classList.add('icon-my-location'); locationButton.setAttribute('aria-label', 'Use my location'); locationButton.setAttribute('title', 'Use my location'); spacefinder.map.controls[google.maps.ControlPosition.RIGHT_TOP].push(locationButton); /* add listener to buttons to toggle geolocation */ document.addEventListener('click', e => { if ( e.target.matches('.geo-button') ) { if ( ! geolocationEnabled() ) { return; } if ( geolocationActive() ) { /* disable geolocation */ forgetUserPosition() } else { /* get the current position */ getUserPosition(); } } }); } else { activateGeolocation( false ); toggleGeolocation( false ); } }
function checkGeoAvailable() { if ( 'geolocation' in navigator ) { /* make button for map to let user activate geolocation */ const locationButton = document.createElement( 'button' ); locationButton.innerHTML = ''; locationButton.classList.add('geo-button'); locationButton.classList.add('icon-my-location'); locationButton.setAttribute('aria-label', 'Use my location'); locationButton.setAttribute('title', 'Use my location'); spacefinder.map.controls[google.maps.ControlPosition.RIGHT_TOP].push(locationButton); /* add listener to buttons to toggle geolocation */ document.addEventListener('click', e => { if ( e.target.matches('.geo-button') ) { if ( ! geolocationEnabled() ) { return; } if ( geolocationActive() ) { /* disable geolocation */ forgetUserPosition() } else { /* get the current position */ getUserPosition(); } } }); } else { activateGeolocation( false ); toggleGeolocation( false ); } }
JavaScript
function forgetUserPosition() { /* stop watching user position */ navigator.geolocation.clearWatch( spacefinder.watchID ); /* remove person marker from map */ spacefinder.personMarker.setMap(null); /* make location buttons inactive */ activateGeolocation( false ); /* re-centre map */ spacefinder.map.setCenter( spacefinder.currentLoc ); }
function forgetUserPosition() { /* stop watching user position */ navigator.geolocation.clearWatch( spacefinder.watchID ); /* remove person marker from map */ spacefinder.personMarker.setMap(null); /* make location buttons inactive */ activateGeolocation( false ); /* re-centre map */ spacefinder.map.setCenter( spacefinder.currentLoc ); }
JavaScript
function updateDistances() { if ( geolocationActive() ) { spacefinder.spaces.forEach( (space, index) => { spacefinder.spaces[index].distancefromcentre = haversine_distance( spacefinder.personLoc, { lat: space.lat, lng: space.lng } ); document.querySelector('[data-id="' + space.id + '"]').setAttribute('data-sortdistance', spacefinder.spaces[index].distancefromcentre ); }); } else { let spacenodes = document.querySelectorAll('.list-space'); if ( spacenodes !== null ) { spacenodes.forEach( el => el.setAttribute('data-sortdistance', '') ); } } }
function updateDistances() { if ( geolocationActive() ) { spacefinder.spaces.forEach( (space, index) => { spacefinder.spaces[index].distancefromcentre = haversine_distance( spacefinder.personLoc, { lat: space.lat, lng: space.lng } ); document.querySelector('[data-id="' + space.id + '"]').setAttribute('data-sortdistance', spacefinder.spaces[index].distancefromcentre ); }); } else { let spacenodes = document.querySelectorAll('.list-space'); if ( spacenodes !== null ) { spacenodes.forEach( el => el.setAttribute('data-sortdistance', '') ); } } }
JavaScript
function* singlesGenerator(ns) { let i = 0 while (i < ns.length) yield ns[i] }
function* singlesGenerator(ns) { let i = 0 while (i < ns.length) yield ns[i] }
JavaScript
function NullorUndefinedException(message) { this.message = message; this.name = "NullorUndefinedException"; this.toString = function () { return this.name + ": " + this.message; }; }
function NullorUndefinedException(message) { this.message = message; this.name = "NullorUndefinedException"; this.toString = function () { return this.name + ": " + this.message; }; }
JavaScript
createABActivity (body) { return new Promise((resolve, reject) => { this.sdk.apis.abactivity.createABActivity({}, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target createABActivity - ' + err) reject(err) }) }) }
createABActivity (body) { return new Promise((resolve, reject) => { this.sdk.apis.abactivity.createABActivity({}, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target createABActivity - ' + err) reject(err) }) }) }
JavaScript
createXTActivity (body) { return new Promise((resolve, reject) => { this.sdk.apis.xtactivity.createXTActivity({}, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target createXTActivity - ' + err) reject(err) }) }) }
createXTActivity (body) { return new Promise((resolve, reject) => { this.sdk.apis.xtactivity.createXTActivity({}, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target createXTActivity - ' + err) reject(err) }) }) }
JavaScript
updateABActivity (id, body) { var params = {} params.id = id return new Promise((resolve, reject) => { this.sdk.apis.abactivity.updateABActivity(params, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target updateABActivity - ' + err) reject(err) }) }) }
updateABActivity (id, body) { var params = {} params.id = id return new Promise((resolve, reject) => { this.sdk.apis.abactivity.updateABActivity(params, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target updateABActivity - ' + err) reject(err) }) }) }
JavaScript
updateXTActivity (id, body) { var params = {} params.id = id return new Promise((resolve, reject) => { this.sdk.apis.xtactivity.updateXTActivity(params, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target updateXTActivity - ' + err) reject(err) }) }) }
updateXTActivity (id, body) { var params = {} params.id = id return new Promise((resolve, reject) => { this.sdk.apis.xtactivity.updateXTActivity(params, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target updateXTActivity - ' + err) reject(err) }) }) }
JavaScript
deleteABActivity (id) { var params = {} params.id = id return new Promise((resolve, reject) => { this.sdk.apis.abactivity.deleteABActivity(params, this.__createRequest({})) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target deleteABActivity - ' + err) reject(err) }) }) }
deleteABActivity (id) { var params = {} params.id = id return new Promise((resolve, reject) => { this.sdk.apis.abactivity.deleteABActivity(params, this.__createRequest({})) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target deleteABActivity - ' + err) reject(err) }) }) }
JavaScript
deleteXTActivity (id) { var params = {} params.id = id return new Promise((resolve, reject) => { this.sdk.apis.xtactivity.deleteXTActivity(params, this.__createRequest({})) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target deleteXTActivity - ' + err) reject(err) }) }) }
deleteXTActivity (id) { var params = {} params.id = id return new Promise((resolve, reject) => { this.sdk.apis.xtactivity.deleteXTActivity(params, this.__createRequest({})) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target deleteXTActivity - ' + err) reject(err) }) }) }
JavaScript
createOffer (body) { return new Promise((resolve, reject) => { this.sdk.apis.offers.createOffer({}, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target createOffer - ' + err) reject(err) }) }) }
createOffer (body) { return new Promise((resolve, reject) => { this.sdk.apis.offers.createOffer({}, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target createOffer - ' + err) reject(err) }) }) }
JavaScript
createAudience (body) { return new Promise((resolve, reject) => { this.sdk.apis.audiences.createAudience({}, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target createAudience - ' + err) reject(err) }) }) }
createAudience (body) { return new Promise((resolve, reject) => { this.sdk.apis.audiences.createAudience({}, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target createAudience - ' + err) reject(err) }) }) }
JavaScript
updateAudience (id, body) { var params = {} params.id = id return new Promise((resolve, reject) => { this.sdk.apis.audience.updateAudience(params, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target updateAudience - ' + err) reject(err) }) }) }
updateAudience (id, body) { var params = {} params.id = id return new Promise((resolve, reject) => { this.sdk.apis.audience.updateAudience(params, this.__createRequest(body)) .then(response => { resolve(response.body) }) .catch(err => { console.log('Error while calling Adobe Target updateAudience - ' + err) reject(err) }) }) }
JavaScript
dataConfig(data, noConvert) { const shouldConvert = noConvert !== true; if (shouldConvert) { this.extendConfig(this.dataConvert(DatabaseEvent.isMine(data) ? data.Data : data)); } this.modifySelection(); }
dataConfig(data, noConvert) { const shouldConvert = noConvert !== true; if (shouldConvert) { this.extendConfig(this.dataConvert(DatabaseEvent.isMine(data) ? data.Data : data)); } this.modifySelection(); }
JavaScript
transition() { const orginArgs = core.toArray(arguments), isFromBoard = DatabaseEvent.is1stMine(orginArgs), args = isFromBoard ? orginArgs[0].Args : orginArgs; let config; if (isFromBoard) { config = args && args.length > 0 && args[0] !== undefined ? args[0] : {}; } else { config = orginArgs.length > 1 ? orginArgs.shift() : {}; if (orginArgs.length > 0 && orginArgs[0] !== undefined) { this.data.apply(this, orginArgs); } } let transition = this.Selection.transition(); transition = core.callInner(transition, config); return this.renderSelection(transition); }
transition() { const orginArgs = core.toArray(arguments), isFromBoard = DatabaseEvent.is1stMine(orginArgs), args = isFromBoard ? orginArgs[0].Args : orginArgs; let config; if (isFromBoard) { config = args && args.length > 0 && args[0] !== undefined ? args[0] : {}; } else { config = orginArgs.length > 1 ? orginArgs.shift() : {}; if (orginArgs.length > 0 && orginArgs[0] !== undefined) { this.data.apply(this, orginArgs); } } let transition = this.Selection.transition(); transition = core.callInner(transition, config); return this.renderSelection(transition); }
JavaScript
function PlotWidget(Plot) { // Public methods this.render = PlotWidget_render; this.disable = PlotWidget_disable; this.enable = PlotWidget_enable; this.show = PlotWidget_show; this.hide = PlotWidget_hide; // // this.getSelectedIndex = PlotWidget_getSelectedIndex; this.getValue = PlotWidget_getValue; this.getValues = PlotWidget_getValues; this.setCallback = PlotWidget_setCallback; // // this.setValue = PlotWidget_setValue; // // this.setValueByIndex = PlotWidget_setValueByIndex; // Event handlers this.mouseDown = PlotWidget_mouseDown; this.mouseMove = PlotWidget_mouseMove; this.mouseUp = PlotWidget_mouseUp; // Private methods this.resizeSelection = PlotWidget_resizeSelection; this.EventPosX = PlotWidget_EventPosX; this.EventPosY = PlotWidget_EventPosY; this.ObjPosX = PlotWidget_ObjPosX; this.ObjPosY = PlotWidget_ObjPosY; this.pixelToUserX = PlotWidget_pixelToUserX; this.pixelToUserY = PlotWidget_pixelToUserY; this.showSelectionDiv = PlotWidget_showSelectionDiv; // Initialization /** * Plot object with information about the location of a plot within an image * These pixel values describe the location of the plot relative the to the * image origin. (All other pixel values are relative to the browser origin.) */ this.Plot = Plot; // TODO: deal with reversed axes this.Plot.pix_right = this.Plot.pix_left + this.Plot.pix_width; this.Plot.pix_bottom = this.Plot.pix_top + this.Plot.pix_height; this.Plot.val_right = this.Plot.val_left + this.Plot.val_width; this.Plot.val_bottom = this.Plot.val_top - this.Plot.val_height; /** * Information about the location of the plot image within the page */ this.img_pix_top = null; this.img_pix_left = null; this.plot_pix_top = null; this.plot_pix_left = null; this.plot_pix_right = null; this.plot_pix_bottom = null; /** * Information about the location of mouse clicks within the page */ this.mouseDown_pix_X = null; this.mouseDown_pix_Y = null; this.mouseUp_pix_X = null; this.mouseUp_pix_Y = null; /** * User selected region in pixel and plot axis coordinates. */ this.userDrag_pix_top = null; this.userDrag_pix_left = null; this.userDrag_pix_width = null; this.userDrag_pix_height = null; this.userDrag_val_Xlo = null; this.userDrag_val_Xhi = null; this.userDrag_val_Ylo = null; this.userDrag_val_Yhi = null; /** * User selected point in pixel plot axis coordinates. */ this.userClick_pix_X = null; this.userClick_pix_Y = null; this.userClick_val_X = null; this.userClick_val_Y = null; /** * Wheter the user mouse button is currently depressed. */ this.mouseActive = 0; /** * Wheter the mouse has been moved while active. */ this.mouseDrag = 0; /** * Selection box style. * NOTE: Style Could be in a stylesheet but why require an additional file? */ /* Jon's favorites this.selectionBorderWidth = '2px'; this.selectionBorderStyle = 'dotted'; this.selectionBorderColor = '#FFF'; this.selectionBackgroundColor = 'transparent'; this.selectionOpacity = 0.0; */ this.selectionBorderWidth = '1px'; this.selectionBorderStyle = 'solid'; this.selectionBorderColor = 'black'; this.selectionBackgroundColor = 'yellow'; this.selectionOpacity = 0.5; /** * Number of digits to retain after the decimal point. */ this.decimal_digits = 1; /** * ID string identifying this widget. */ this.widgetType = 'PlotWidget'; /** * Specifies the type of region selection ['horizontal' | 'vertical' | 'region'] */ this.type = 0; /** * Specifies whether this widget is currently disabled. */ this.disabled = 0; /** * Specifies whether this widget is currently visible. */ this.visible = 0; /** * Callback function attached to the onChange event. */ this.callback = null; }
function PlotWidget(Plot) { // Public methods this.render = PlotWidget_render; this.disable = PlotWidget_disable; this.enable = PlotWidget_enable; this.show = PlotWidget_show; this.hide = PlotWidget_hide; // // this.getSelectedIndex = PlotWidget_getSelectedIndex; this.getValue = PlotWidget_getValue; this.getValues = PlotWidget_getValues; this.setCallback = PlotWidget_setCallback; // // this.setValue = PlotWidget_setValue; // // this.setValueByIndex = PlotWidget_setValueByIndex; // Event handlers this.mouseDown = PlotWidget_mouseDown; this.mouseMove = PlotWidget_mouseMove; this.mouseUp = PlotWidget_mouseUp; // Private methods this.resizeSelection = PlotWidget_resizeSelection; this.EventPosX = PlotWidget_EventPosX; this.EventPosY = PlotWidget_EventPosY; this.ObjPosX = PlotWidget_ObjPosX; this.ObjPosY = PlotWidget_ObjPosY; this.pixelToUserX = PlotWidget_pixelToUserX; this.pixelToUserY = PlotWidget_pixelToUserY; this.showSelectionDiv = PlotWidget_showSelectionDiv; // Initialization /** * Plot object with information about the location of a plot within an image * These pixel values describe the location of the plot relative the to the * image origin. (All other pixel values are relative to the browser origin.) */ this.Plot = Plot; // TODO: deal with reversed axes this.Plot.pix_right = this.Plot.pix_left + this.Plot.pix_width; this.Plot.pix_bottom = this.Plot.pix_top + this.Plot.pix_height; this.Plot.val_right = this.Plot.val_left + this.Plot.val_width; this.Plot.val_bottom = this.Plot.val_top - this.Plot.val_height; /** * Information about the location of the plot image within the page */ this.img_pix_top = null; this.img_pix_left = null; this.plot_pix_top = null; this.plot_pix_left = null; this.plot_pix_right = null; this.plot_pix_bottom = null; /** * Information about the location of mouse clicks within the page */ this.mouseDown_pix_X = null; this.mouseDown_pix_Y = null; this.mouseUp_pix_X = null; this.mouseUp_pix_Y = null; /** * User selected region in pixel and plot axis coordinates. */ this.userDrag_pix_top = null; this.userDrag_pix_left = null; this.userDrag_pix_width = null; this.userDrag_pix_height = null; this.userDrag_val_Xlo = null; this.userDrag_val_Xhi = null; this.userDrag_val_Ylo = null; this.userDrag_val_Yhi = null; /** * User selected point in pixel plot axis coordinates. */ this.userClick_pix_X = null; this.userClick_pix_Y = null; this.userClick_val_X = null; this.userClick_val_Y = null; /** * Wheter the user mouse button is currently depressed. */ this.mouseActive = 0; /** * Wheter the mouse has been moved while active. */ this.mouseDrag = 0; /** * Selection box style. * NOTE: Style Could be in a stylesheet but why require an additional file? */ /* Jon's favorites this.selectionBorderWidth = '2px'; this.selectionBorderStyle = 'dotted'; this.selectionBorderColor = '#FFF'; this.selectionBackgroundColor = 'transparent'; this.selectionOpacity = 0.0; */ this.selectionBorderWidth = '1px'; this.selectionBorderStyle = 'solid'; this.selectionBorderColor = 'black'; this.selectionBackgroundColor = 'yellow'; this.selectionOpacity = 0.5; /** * Number of digits to retain after the decimal point. */ this.decimal_digits = 1; /** * ID string identifying this widget. */ this.widgetType = 'PlotWidget'; /** * Specifies the type of region selection ['horizontal' | 'vertical' | 'region'] */ this.type = 0; /** * Specifies whether this widget is currently disabled. */ this.disabled = 0; /** * Specifies whether this widget is currently visible. */ this.visible = 0; /** * Callback function attached to the onChange event. */ this.callback = null; }
JavaScript
function PlotWidget_render(element_id,type) { this.element_id = element_id; if (type) { this.type = type; } var node = document.getElementById(this.element_id); var children = node.childNodes; var num_children = children.length; // Remove any children of this widget // NOTE: Start removing children from the end. Otherwise, what was // NOTE: children[1] becomes children[0] when children[0] is removed. for (var i=num_children-1; i>=0; i--) { var child = children[i]; if (child) { node.removeChild(child); } } // Create and populate the PlotWidget object var id_text = this.element_id + '_PlotContainer'; var Container = document.createElement('div'); Container.setAttribute('id',id_text); node.appendChild(Container); var id_text = this.element_id + '_PlotImage'; var Img = document.createElement('img'); Img.setAttribute('id',id_text); Img.setAttribute('src',this.Plot.src); Img.onmousedown = PlotWidget_mouseDown; Img.onmousemove = PlotWidget_mouseMove; Img.onmouseup = PlotWidget_mouseUp; Img.ondrag = "return false;" Img.GALLERYIMG = "no"; // IE document.ondragstart = function(e) { return false; } // //Img.onmouseout = PlotWidget_mouseUp; Container.appendChild(Img); // Now that the <img> has been appended it should have a position. // Store that position globally so we don't have to recalculate it. // TODO: What if someone scrolls the page? this.img_pix_top = this.ObjPosY(Img); this.img_pix_left = this.ObjPosX(Img); this.plot_pix_top = this.img_pix_top + this.Plot.pix_top; this.plot_pix_left = this.img_pix_left + this.Plot.pix_left; this.plot_pix_right = this.plot_pix_left + this.Plot.pix_width; this.plot_pix_bottom = this.plot_pix_top + this.Plot.pix_height; // Create the transparent DIV to prevent mouse moves from triggering // the browser 'copy image' behavior. This DIV should cover the // entire image. var id_text = this.element_id + '_TransparentDiv'; var TransparentDiv = document.createElement('div'); TransparentDiv.setAttribute('id',id_text); TransparentDiv.style.position = 'absolute'; TransparentDiv.style.backgroundColor = 'transparent'; TransparentDiv.style.visibility = 'visible'; TransparentDiv.onmousedown = PlotWidget_mouseDown; TransparentDiv.onmousemove = PlotWidget_mouseMove; TransparentDiv.onmouseup = PlotWidget_mouseUp; // //TransparentDiv.onmouseout = PlotWidget_mouseUp; Container.appendChild(TransparentDiv); var top = this.img_pix_top + 'px'; var left = this.img_pix_left + 'px'; // NOTE: The bottom and right borders need not be the same height as the top and left. // NOTE: But we don't have access to the image width and height at this point so this // NOTE: this is about as good as we can do. var width = this.Plot.pix_left + this.Plot.pix_width + this.Plot.pix_left + 'px'; var height = this.Plot.pix_top + this.Plot.pix_height + this.Plot.pix_top + 'px'; TransparentDiv.style.top = top; TransparentDiv.style.left = left; TransparentDiv.style.width = width; TransparentDiv.style.height = height; // Create the dotted-outline Div for user selection var id_text = this.element_id + '_SelectionDiv'; var SelectionDiv = document.createElement('div'); SelectionDiv.setAttribute('id',id_text); SelectionDiv.style.position = 'absolute'; var border_style = this.selectionBorderWidth + ' ' + this.selectionBorderStyle + ' ' + this.selectionBorderColor; SelectionDiv.style.border = border_style; SelectionDiv.style.backgroundColor = this.selectionBackgroundColor; SelectionDiv.style.opacity = this.selectionOpacity; SelectionDiv.style.filter = 'alpha(opacity='+this.selectionOpacity*100+')'; SelectionDiv.style.visibility = 'hidden'; SelectionDiv.onmousedown = PlotWidget_mouseDown; SelectionDiv.onmousemove = PlotWidget_mouseMove; SelectionDiv.onmouseup = PlotWidget_mouseUp; Container.appendChild(SelectionDiv); var border_width = Number(this.selectionBorderWidth.replace(/px/,'')); var top = this.img_pix_top + this.Plot.pix_top + 'px'; var left = this.img_pix_left + this.Plot.pix_left + 'px'; var width = "0px";// this.Plot.pix_width - border_width - 1 + 'px'; var height = "0px";//this.Plot.pix_height - border_width + 'px'; SelectionDiv.style.top = top; SelectionDiv.style.left = left; SelectionDiv.style.width = width; SelectionDiv.style.height = height; // Create the dark screen Div for disabling var id_text = this.element_id + '_DisableDiv'; var DisableDiv = document.createElement('div'); DisableDiv.setAttribute('id',id_text); DisableDiv.style.position = 'absolute'; DisableDiv.style.backgroundColor = '#000'; DisableDiv.style.opacity = 0.6; DisableDiv.style.visibility = 'hidden'; Container.appendChild(DisableDiv); var top = Math.abs(this.img_pix_top + this.Plot.pix_top) + 'px'; var left = Math.abs(this.img_pix_left + this.Plot.pix_left) + 'px'; var width = Math.abs(this.Plot.pix_width - 2 * border_width) + 'px'; var height = Math.abs(this.Plot.pix_height - 2 * border_width) + 'px'; DisableDiv.style.top = top; DisableDiv.style.left = left; DisableDiv.style.width = width; DisableDiv.style.height = height; // Store the pointers to various DOM elements inside the PlotWidget object this.Img = Img; this.TransparentDiv = TransparentDiv; this.SelectionDiv = SelectionDiv; this.DisableDiv = DisableDiv; // Store the pointer to PlotWidget inside the Img DOM element so that // Plotwidget methods and attributes can be accessed by the event listener. this.Img.widget = this; this.TransparentDiv.widget = this; this.SelectionDiv.widget = this; this.DisableDiv.widget = this; this.disabled = 0; this.visible = 1; }
function PlotWidget_render(element_id,type) { this.element_id = element_id; if (type) { this.type = type; } var node = document.getElementById(this.element_id); var children = node.childNodes; var num_children = children.length; // Remove any children of this widget // NOTE: Start removing children from the end. Otherwise, what was // NOTE: children[1] becomes children[0] when children[0] is removed. for (var i=num_children-1; i>=0; i--) { var child = children[i]; if (child) { node.removeChild(child); } } // Create and populate the PlotWidget object var id_text = this.element_id + '_PlotContainer'; var Container = document.createElement('div'); Container.setAttribute('id',id_text); node.appendChild(Container); var id_text = this.element_id + '_PlotImage'; var Img = document.createElement('img'); Img.setAttribute('id',id_text); Img.setAttribute('src',this.Plot.src); Img.onmousedown = PlotWidget_mouseDown; Img.onmousemove = PlotWidget_mouseMove; Img.onmouseup = PlotWidget_mouseUp; Img.ondrag = "return false;" Img.GALLERYIMG = "no"; // IE document.ondragstart = function(e) { return false; } // //Img.onmouseout = PlotWidget_mouseUp; Container.appendChild(Img); // Now that the <img> has been appended it should have a position. // Store that position globally so we don't have to recalculate it. // TODO: What if someone scrolls the page? this.img_pix_top = this.ObjPosY(Img); this.img_pix_left = this.ObjPosX(Img); this.plot_pix_top = this.img_pix_top + this.Plot.pix_top; this.plot_pix_left = this.img_pix_left + this.Plot.pix_left; this.plot_pix_right = this.plot_pix_left + this.Plot.pix_width; this.plot_pix_bottom = this.plot_pix_top + this.Plot.pix_height; // Create the transparent DIV to prevent mouse moves from triggering // the browser 'copy image' behavior. This DIV should cover the // entire image. var id_text = this.element_id + '_TransparentDiv'; var TransparentDiv = document.createElement('div'); TransparentDiv.setAttribute('id',id_text); TransparentDiv.style.position = 'absolute'; TransparentDiv.style.backgroundColor = 'transparent'; TransparentDiv.style.visibility = 'visible'; TransparentDiv.onmousedown = PlotWidget_mouseDown; TransparentDiv.onmousemove = PlotWidget_mouseMove; TransparentDiv.onmouseup = PlotWidget_mouseUp; // //TransparentDiv.onmouseout = PlotWidget_mouseUp; Container.appendChild(TransparentDiv); var top = this.img_pix_top + 'px'; var left = this.img_pix_left + 'px'; // NOTE: The bottom and right borders need not be the same height as the top and left. // NOTE: But we don't have access to the image width and height at this point so this // NOTE: this is about as good as we can do. var width = this.Plot.pix_left + this.Plot.pix_width + this.Plot.pix_left + 'px'; var height = this.Plot.pix_top + this.Plot.pix_height + this.Plot.pix_top + 'px'; TransparentDiv.style.top = top; TransparentDiv.style.left = left; TransparentDiv.style.width = width; TransparentDiv.style.height = height; // Create the dotted-outline Div for user selection var id_text = this.element_id + '_SelectionDiv'; var SelectionDiv = document.createElement('div'); SelectionDiv.setAttribute('id',id_text); SelectionDiv.style.position = 'absolute'; var border_style = this.selectionBorderWidth + ' ' + this.selectionBorderStyle + ' ' + this.selectionBorderColor; SelectionDiv.style.border = border_style; SelectionDiv.style.backgroundColor = this.selectionBackgroundColor; SelectionDiv.style.opacity = this.selectionOpacity; SelectionDiv.style.filter = 'alpha(opacity='+this.selectionOpacity*100+')'; SelectionDiv.style.visibility = 'hidden'; SelectionDiv.onmousedown = PlotWidget_mouseDown; SelectionDiv.onmousemove = PlotWidget_mouseMove; SelectionDiv.onmouseup = PlotWidget_mouseUp; Container.appendChild(SelectionDiv); var border_width = Number(this.selectionBorderWidth.replace(/px/,'')); var top = this.img_pix_top + this.Plot.pix_top + 'px'; var left = this.img_pix_left + this.Plot.pix_left + 'px'; var width = "0px";// this.Plot.pix_width - border_width - 1 + 'px'; var height = "0px";//this.Plot.pix_height - border_width + 'px'; SelectionDiv.style.top = top; SelectionDiv.style.left = left; SelectionDiv.style.width = width; SelectionDiv.style.height = height; // Create the dark screen Div for disabling var id_text = this.element_id + '_DisableDiv'; var DisableDiv = document.createElement('div'); DisableDiv.setAttribute('id',id_text); DisableDiv.style.position = 'absolute'; DisableDiv.style.backgroundColor = '#000'; DisableDiv.style.opacity = 0.6; DisableDiv.style.visibility = 'hidden'; Container.appendChild(DisableDiv); var top = Math.abs(this.img_pix_top + this.Plot.pix_top) + 'px'; var left = Math.abs(this.img_pix_left + this.Plot.pix_left) + 'px'; var width = Math.abs(this.Plot.pix_width - 2 * border_width) + 'px'; var height = Math.abs(this.Plot.pix_height - 2 * border_width) + 'px'; DisableDiv.style.top = top; DisableDiv.style.left = left; DisableDiv.style.width = width; DisableDiv.style.height = height; // Store the pointers to various DOM elements inside the PlotWidget object this.Img = Img; this.TransparentDiv = TransparentDiv; this.SelectionDiv = SelectionDiv; this.DisableDiv = DisableDiv; // Store the pointer to PlotWidget inside the Img DOM element so that // Plotwidget methods and attributes can be accessed by the event listener. this.Img.widget = this; this.TransparentDiv.widget = this; this.SelectionDiv.widget = this; this.DisableDiv.widget = this; this.disabled = 0; this.visible = 1; }
JavaScript
function PlotWidget_show() { var node = document.getElementById(this.element_id); node.style.visibility = 'visible'; // TODO: Show all child nodes. this.visible = 1; }
function PlotWidget_show() { var node = document.getElementById(this.element_id); node.style.visibility = 'visible'; // TODO: Show all child nodes. this.visible = 1; }
JavaScript
function PlotWidget_showSelectionDiv() { var id_text = this.element_id + '_SelectionDiv'; var SelectionDiv = document.getElementById(id_text); SelectionDiv.style.visibility = 'visible'; }
function PlotWidget_showSelectionDiv() { var id_text = this.element_id + '_SelectionDiv'; var SelectionDiv = document.getElementById(id_text); SelectionDiv.style.visibility = 'visible'; }
JavaScript
function PlotWidget_hide() { var node = document.getElementById(this.element_id); node.style.visibility = 'hidden'; // TODO: Hide all child nodes. this.visible = 0; }
function PlotWidget_hide() { var node = document.getElementById(this.element_id); node.style.visibility = 'hidden'; // TODO: Hide all child nodes. this.visible = 0; }
JavaScript
function PlotWidget_mouseDown(e) { if (!e) e = window.event; // IE event model if(e.preventDefault) { e.preventDefault(); } else if (event.stopPropagation) event.stopPropagation(); // DOM Level 2 else event.cancelBubble = true; // Cross-browser discovery of the event target // By Stuart Landridge in "DHTML Utopia ..." var target; if (window.event && window.event.srcElement) { target = window.event.srcElement; } else if (e && e.target) { target = e.target; } else { alert('PlotWidget ERROR:\n> mouseDown: This browser does not support standard javascript events.'); return; } var PW = target.widget; PW.SelectionDiv.style.width = "0px"; PW.SelectionDiv.style.height = "0px"; var pos_X = PW.EventPosX(e); var pos_Y = PW.EventPosY(e); if (pos_X > PW.plot_pix_left) { if (pos_X < PW.plot_pix_right) { PW.mouseDown_pix_X = pos_X; } else { PW.mouseDown_pix_X = PW.plot_pix_right; } } else { PW.mouseDown_pix_X = PW.plot_pix_left; } if (pos_Y > PW.plot_pix_top) { if (pos_Y < PW.plot_pix_bottom) { PW.mouseDown_pix_Y = pos_Y; } else { PW.mouseDown_pix_Y = PW.plot_pix_bottom; } } else { PW.mouseDown_pix_Y = PW.plot_pix_top; } PW.mouseActive = 1; PW.mouseDrag = 0; }
function PlotWidget_mouseDown(e) { if (!e) e = window.event; // IE event model if(e.preventDefault) { e.preventDefault(); } else if (event.stopPropagation) event.stopPropagation(); // DOM Level 2 else event.cancelBubble = true; // Cross-browser discovery of the event target // By Stuart Landridge in "DHTML Utopia ..." var target; if (window.event && window.event.srcElement) { target = window.event.srcElement; } else if (e && e.target) { target = e.target; } else { alert('PlotWidget ERROR:\n> mouseDown: This browser does not support standard javascript events.'); return; } var PW = target.widget; PW.SelectionDiv.style.width = "0px"; PW.SelectionDiv.style.height = "0px"; var pos_X = PW.EventPosX(e); var pos_Y = PW.EventPosY(e); if (pos_X > PW.plot_pix_left) { if (pos_X < PW.plot_pix_right) { PW.mouseDown_pix_X = pos_X; } else { PW.mouseDown_pix_X = PW.plot_pix_right; } } else { PW.mouseDown_pix_X = PW.plot_pix_left; } if (pos_Y > PW.plot_pix_top) { if (pos_Y < PW.plot_pix_bottom) { PW.mouseDown_pix_Y = pos_Y; } else { PW.mouseDown_pix_Y = PW.plot_pix_bottom; } } else { PW.mouseDown_pix_Y = PW.plot_pix_top; } PW.mouseActive = 1; PW.mouseDrag = 0; }
JavaScript
function PlotWidget_mouseMove(e) { if (!e) e = window.event; // IE event model if(e.preventDefault) { e.preventDefault(); } else if (event.stopPropagation) event.stopPropagation(); // DOM Level 2 else event.cancelBubble = true; // Cross-browser discovery of the event target // By Stuart Landridge in "DHTML Utopia ..." var target; if (window.event && window.event.srcElement) { target = window.event.srcElement; } else if (e && e.target) { target = e.target; } else { alert('PlotWidget ERROR:\n> mouseDown: This browser does not support standard javascript events.'); return; } var PW = target.widget; if (PW.mouseActive) { var pos_X = PW.EventPosX(e); var pos_Y = PW.EventPosY(e); // Keep pos_X and pos_Y inside the plot boundaries. if (pos_X > PW.plot_pix_left) { if (pos_X > PW.plot_pix_right) { pos_X = PW.plot_pix_right; } } else { pos_X = PW.plot_pix_left; } if (pos_Y > PW.plot_pix_top) { if (pos_Y > PW.plot_pix_bottom) { pos_Y = PW.plot_pix_bottom; } } else { pos_Y = PW.plot_pix_top; } // Now resize the Selection DIV PW.resizeSelection(pos_X,pos_Y); PW.mouseDrag = 1; PW.showSelectionDiv(); } }
function PlotWidget_mouseMove(e) { if (!e) e = window.event; // IE event model if(e.preventDefault) { e.preventDefault(); } else if (event.stopPropagation) event.stopPropagation(); // DOM Level 2 else event.cancelBubble = true; // Cross-browser discovery of the event target // By Stuart Landridge in "DHTML Utopia ..." var target; if (window.event && window.event.srcElement) { target = window.event.srcElement; } else if (e && e.target) { target = e.target; } else { alert('PlotWidget ERROR:\n> mouseDown: This browser does not support standard javascript events.'); return; } var PW = target.widget; if (PW.mouseActive) { var pos_X = PW.EventPosX(e); var pos_Y = PW.EventPosY(e); // Keep pos_X and pos_Y inside the plot boundaries. if (pos_X > PW.plot_pix_left) { if (pos_X > PW.plot_pix_right) { pos_X = PW.plot_pix_right; } } else { pos_X = PW.plot_pix_left; } if (pos_Y > PW.plot_pix_top) { if (pos_Y > PW.plot_pix_bottom) { pos_Y = PW.plot_pix_bottom; } } else { pos_Y = PW.plot_pix_top; } // Now resize the Selection DIV PW.resizeSelection(pos_X,pos_Y); PW.mouseDrag = 1; PW.showSelectionDiv(); } }
JavaScript
function PlotWidget_mouseUp(e) { if (!e) e = window.event; // IE event model if(e.preventDefault) { e.preventDefault(); } else if (event.stopPropagation) event.stopPropagation(); // DOM Level 2 else event.cancelBubble = true; // Cross-browser discovery of the event target // By Stuart Landridge in "DHTML Utopia ..." var target; if (window.event && window.event.srcElement) { target = window.event.srcElement; } else if (e && e.target) { target = e.target; } else { alert('PlotWidget ERROR:\n> mouseDown: This browser does not support standard javascript events.'); return; } var PW = target.widget; PW.mouseActive = 0; PW.mouseUp_pix_X = PW.EventPosX(e); PW.mouseUp_pix_Y = PW.EventPosY(e); if (PW.mouseDrag) { PW.userDrag_val_Xlo = PW.pixelToUserX(PW.userDrag_pix_left); PW.userDrag_val_Xhi = PW.pixelToUserX(PW.userDrag_pix_left + PW.userDrag_pix_width); PW.userDrag_val_Yhi = PW.pixelToUserY(PW.userDrag_pix_top); PW.userDrag_val_Ylo = PW.pixelToUserY(PW.userDrag_pix_top + PW.userDrag_pix_height); } else { PW.userClick_val_X = PW.pixelToUserX(PW.mouseDown_pix_X); PW.userClick_val_Y = PW.pixelToUserY(PW.mouseDown_pix_Y); } // Call the callback function if it is defined. if (PW.callback) { PW.callback(PW); } }
function PlotWidget_mouseUp(e) { if (!e) e = window.event; // IE event model if(e.preventDefault) { e.preventDefault(); } else if (event.stopPropagation) event.stopPropagation(); // DOM Level 2 else event.cancelBubble = true; // Cross-browser discovery of the event target // By Stuart Landridge in "DHTML Utopia ..." var target; if (window.event && window.event.srcElement) { target = window.event.srcElement; } else if (e && e.target) { target = e.target; } else { alert('PlotWidget ERROR:\n> mouseDown: This browser does not support standard javascript events.'); return; } var PW = target.widget; PW.mouseActive = 0; PW.mouseUp_pix_X = PW.EventPosX(e); PW.mouseUp_pix_Y = PW.EventPosY(e); if (PW.mouseDrag) { PW.userDrag_val_Xlo = PW.pixelToUserX(PW.userDrag_pix_left); PW.userDrag_val_Xhi = PW.pixelToUserX(PW.userDrag_pix_left + PW.userDrag_pix_width); PW.userDrag_val_Yhi = PW.pixelToUserY(PW.userDrag_pix_top); PW.userDrag_val_Ylo = PW.pixelToUserY(PW.userDrag_pix_top + PW.userDrag_pix_height); } else { PW.userClick_val_X = PW.pixelToUserX(PW.mouseDown_pix_X); PW.userClick_val_Y = PW.pixelToUserY(PW.mouseDown_pix_Y); } // Call the callback function if it is defined. if (PW.callback) { PW.callback(PW); } }
JavaScript
function PlotWidget_resizeSelection(x,y) { this.userDrag_pix_top = Math.min(y,this.mouseDown_pix_Y); this.userDrag_pix_left = Math.min(x,this.mouseDown_pix_X); this.userDrag_pix_width = Math.abs(x - this.mouseDown_pix_X); this.userDrag_pix_height = Math.abs(y - this.mouseDown_pix_Y); var border_width = Number(this.selectionBorderWidth.replace(/px/,'')); var top = this.userDrag_pix_top + 'px'; var left = this.userDrag_pix_left + 'px'; var width = Math.abs(this.userDrag_pix_width - border_width - 1) + 'px'; var height = Math.abs(this.userDrag_pix_height - border_width) + 'px'; this.SelectionDiv.style.top = top; this.SelectionDiv.style.left = left; this.SelectionDiv.style.width = width; this.SelectionDiv.style.height = height; }
function PlotWidget_resizeSelection(x,y) { this.userDrag_pix_top = Math.min(y,this.mouseDown_pix_Y); this.userDrag_pix_left = Math.min(x,this.mouseDown_pix_X); this.userDrag_pix_width = Math.abs(x - this.mouseDown_pix_X); this.userDrag_pix_height = Math.abs(y - this.mouseDown_pix_Y); var border_width = Number(this.selectionBorderWidth.replace(/px/,'')); var top = this.userDrag_pix_top + 'px'; var left = this.userDrag_pix_left + 'px'; var width = Math.abs(this.userDrag_pix_width - border_width - 1) + 'px'; var height = Math.abs(this.userDrag_pix_height - border_width) + 'px'; this.SelectionDiv.style.top = top; this.SelectionDiv.style.left = left; this.SelectionDiv.style.width = width; this.SelectionDiv.style.height = height; }
JavaScript
function PlotWidget_EventPosX(e) { if(e.preventDefault) { e.preventDefault(); } else if (event.stopPropagation) event.stopPropagation(); // DOM Level 2 else event.cancelBubble = true; var pix_x; if (e.pageX) { pix_x = e.pageX; } else if (e.clientX) { pix_x = e.clientX; // NOTE: This is supposed to be an isIE test. User browser sniffing if this doesn't work. if (document.documentElement.scrollLeft != 0) { pix_x += document.documentElement.scrollLeft; } } return pix_x; }
function PlotWidget_EventPosX(e) { if(e.preventDefault) { e.preventDefault(); } else if (event.stopPropagation) event.stopPropagation(); // DOM Level 2 else event.cancelBubble = true; var pix_x; if (e.pageX) { pix_x = e.pageX; } else if (e.clientX) { pix_x = e.clientX; // NOTE: This is supposed to be an isIE test. User browser sniffing if this doesn't work. if (document.documentElement.scrollLeft != 0) { pix_x += document.documentElement.scrollLeft; } } return pix_x; }
JavaScript
function PlotWidget_EventPosY(e) { if(e.preventDefault) { e.preventDefault(); } else if (event.stopPropagation) event.stopPropagation(); // DOM Level 2 else event.cancelBubble = true; var pix_y; if (e.pageY) { pix_y = e.pageY; } else if (e.clientY) { pix_y = e.clientY; // NOTE: This is supposed to be an isIE test. User browser sniffing if this doesn't work. if (document.documentElement.scrollTop != 0) { pix_y += document.documentElement.scrollTop; } } return pix_y; }
function PlotWidget_EventPosY(e) { if(e.preventDefault) { e.preventDefault(); } else if (event.stopPropagation) event.stopPropagation(); // DOM Level 2 else event.cancelBubble = true; var pix_y; if (e.pageY) { pix_y = e.pageY; } else if (e.clientY) { pix_y = e.clientY; // NOTE: This is supposed to be an isIE test. User browser sniffing if this doesn't work. if (document.documentElement.scrollTop != 0) { pix_y += document.documentElement.scrollTop; } } return pix_y; }
JavaScript
function PlotWidget_ObjPosX(obj) { var pix_x = 0; if (obj.offsetParent) { do { pix_x += obj.offsetLeft; } while (obj = obj.offsetParent); } else if (obj.x) { pix_x += obj.x; } return pix_x; }
function PlotWidget_ObjPosX(obj) { var pix_x = 0; if (obj.offsetParent) { do { pix_x += obj.offsetLeft; } while (obj = obj.offsetParent); } else if (obj.x) { pix_x += obj.x; } return pix_x; }
JavaScript
function PlotWidget_ObjPosY(obj) { var pix_y = 0; if (obj.offsetParent) { do { pix_y += obj.offsetTop; } while (obj = obj.offsetParent); } else if (obj.y) { pix_y += obj.y; } return pix_y; }
function PlotWidget_ObjPosY(obj) { var pix_y = 0; if (obj.offsetParent) { do { pix_y += obj.offsetTop; } while (obj = obj.offsetParent); } else if (obj.y) { pix_y += obj.y; } return pix_y; }
JavaScript
function PlotWidget_pixelToUserX(pix_x) { // TODO: deal with reversed axes var plot_relative_pix_x = pix_x - this.plot_pix_left; var units_per_pixel = this.Plot.val_width / this.Plot.pix_width; var val_x = this.Plot.val_left + (plot_relative_pix_x * units_per_pixel); var str_x = String(val_x) var val_x_trimmed = str_x; if (str_x.indexOf('.') > -1) { val_x_trimmed = str_x.substr(0,str_x.indexOf('.') + 1 + this.decimal_digits); } else { val_x_trimmed += '.'; for (i=0;i<this.decimal_digits;i++) { val_x_trimmed += '0'; } } return Number(val_x_trimmed); }
function PlotWidget_pixelToUserX(pix_x) { // TODO: deal with reversed axes var plot_relative_pix_x = pix_x - this.plot_pix_left; var units_per_pixel = this.Plot.val_width / this.Plot.pix_width; var val_x = this.Plot.val_left + (plot_relative_pix_x * units_per_pixel); var str_x = String(val_x) var val_x_trimmed = str_x; if (str_x.indexOf('.') > -1) { val_x_trimmed = str_x.substr(0,str_x.indexOf('.') + 1 + this.decimal_digits); } else { val_x_trimmed += '.'; for (i=0;i<this.decimal_digits;i++) { val_x_trimmed += '0'; } } return Number(val_x_trimmed); }
JavaScript
function PlotWidget_pixelToUserY(pix_y) { // TODO: deal with reversed axes var units_per_pixel = this.Plot.val_height / this.Plot.pix_height; // NOTE: y pixels start at the top and go down but coordinates start at the bottom and go up var plot_relative_pix_y_from_bottom = this.plot_pix_top + this.Plot.pix_height - pix_y; var val_y = this.Plot.val_bottom + (plot_relative_pix_y_from_bottom * units_per_pixel); var str_y = String(val_y) var val_y_trimmed = str_y; if (str_y.indexOf('.') > -1) { val_y_trimmed = str_y.substr(0,str_y.indexOf('.') + 1 + this.decimal_digits); } else { val_y_trimmed += '.'; for (i=0;i<this.decimal_digits;i++) { val_y_trimmed += '0'; } } return Number(val_y_trimmed); }
function PlotWidget_pixelToUserY(pix_y) { // TODO: deal with reversed axes var units_per_pixel = this.Plot.val_height / this.Plot.pix_height; // NOTE: y pixels start at the top and go down but coordinates start at the bottom and go up var plot_relative_pix_y_from_bottom = this.plot_pix_top + this.Plot.pix_height - pix_y; var val_y = this.Plot.val_bottom + (plot_relative_pix_y_from_bottom * units_per_pixel); var str_y = String(val_y) var val_y_trimmed = str_y; if (str_y.indexOf('.') > -1) { val_y_trimmed = str_y.substr(0,str_y.indexOf('.') + 1 + this.decimal_digits); } else { val_y_trimmed += '.'; for (i=0;i<this.decimal_digits;i++) { val_y_trimmed += '0'; } } return Number(val_y_trimmed); }
JavaScript
function LASRequest(xml) { if (!xml) xml = '<?xml version=\"1.0\"?><lasRequest href=\"file:las.xml\"><link match=\"/lasdata/operations/shade\"/><args><link match=\"/lasdata/datasets/coads_climatology_cdf/variables/airt\"></link><region><range type=\"x\" low=\"-180.0\" high=\"180.0\"/><range type=\"y\" low=\"-89.5\" high=\"89.5\"/><point type=\"t\" v=\"15-Jan\"/></region></args></lasRequest>'; /** * Internal DOM representation of the LASRequest as returned by * the XMLDoc() method defined in xmldom.js. * @private * @type XMLDoc */ this.DOM = new XMLDoc(xml,_LASReq_parseError); var operationNode = this.DOM.selectNode("/link"); /* * Initialize additional nodes for <properties><ferret> and * <properties><product_server> if they are not described by * the incoming XML. */ if (!this.DOM.selectNode('/properties')) { var newNode = this.DOM.createXMLNode('<properties></properties>'); this.DOM = this.DOM.insertNodeAfter(operationNode,newNode); } // Add methods to this object this.getOperation = LASReq_getOperation; this.setOperation = LASReq_setOperation; this.addPropertyGroup = LASReq_addPropertyGroup; this.removePropertyGroup = LASReq_removePropertyGroup; this.getProperty = LASReq_getProperty; this.setProperty = LASReq_setProperty; this.addProperty = LASReq_addProperty; this.removeProperty = LASReq_removeProperty; this.getVariable = LASReq_getVariable; this.setVariable = LASReq_setVariable; this.addVariable = LASReq_addVariable; this.removeVariable = LASReq_removeVariable; this.removeVariables = LASReq_removeVariables; this.replaceVariable = LASReq_replaceVariable; this.getDataset = LASReq_getDataset; // NOTE: The current XML representation of Constraints makes it difficult to identify constraints // NOTE: or to return useful stringified versions of them. The getConstraint(), setConstraint() // NOTE: and removeConstraint() methods will not be implemented at this time. //this.getConstraint ?? //this.setconstraint ?? this.addTextConstraint = LASReq_addTextConstraint; this.addVariableConstraint = LASReq_addVariableConstraint; //this.removeConstraint = LASReq_removeConstraints ?? this.removeConstraints = LASReq_removeConstraints; this.getTextConstraints = LASReq_getTextConstraints; this.getVariableConstraints = LASReq_getVariableConstraints; // NOTE: Do we need to support a get/setAnalysis(dataset,variable) method? this.setAnalysis = LASReq_setAnalysis; this.getAnalysis = LASReq_getAnalysis; this.removeAnalysis = LASReq_removeAnalysis; this.addRegion = LASReq_addRegion; this.removeRegion = LASReq_removeRegion; this.getRangeLo = LASReq_getRangeLo; this.getRangeHi = LASReq_getRangeHi; this.getAxisType = LASReq_getAxisType; this.setRange = LASReq_setRange; this.addRange = LASReq_addRange; this.removeRange = LASReq_removeRange; this.getXMLText = LASReq_getXMLText; this.getVariableNode = LASReq_getVariableNode; this.getVariableNodeByIndex = LASReq_getVariableNodeByIndex; }
function LASRequest(xml) { if (!xml) xml = '<?xml version=\"1.0\"?><lasRequest href=\"file:las.xml\"><link match=\"/lasdata/operations/shade\"/><args><link match=\"/lasdata/datasets/coads_climatology_cdf/variables/airt\"></link><region><range type=\"x\" low=\"-180.0\" high=\"180.0\"/><range type=\"y\" low=\"-89.5\" high=\"89.5\"/><point type=\"t\" v=\"15-Jan\"/></region></args></lasRequest>'; /** * Internal DOM representation of the LASRequest as returned by * the XMLDoc() method defined in xmldom.js. * @private * @type XMLDoc */ this.DOM = new XMLDoc(xml,_LASReq_parseError); var operationNode = this.DOM.selectNode("/link"); /* * Initialize additional nodes for <properties><ferret> and * <properties><product_server> if they are not described by * the incoming XML. */ if (!this.DOM.selectNode('/properties')) { var newNode = this.DOM.createXMLNode('<properties></properties>'); this.DOM = this.DOM.insertNodeAfter(operationNode,newNode); } // Add methods to this object this.getOperation = LASReq_getOperation; this.setOperation = LASReq_setOperation; this.addPropertyGroup = LASReq_addPropertyGroup; this.removePropertyGroup = LASReq_removePropertyGroup; this.getProperty = LASReq_getProperty; this.setProperty = LASReq_setProperty; this.addProperty = LASReq_addProperty; this.removeProperty = LASReq_removeProperty; this.getVariable = LASReq_getVariable; this.setVariable = LASReq_setVariable; this.addVariable = LASReq_addVariable; this.removeVariable = LASReq_removeVariable; this.removeVariables = LASReq_removeVariables; this.replaceVariable = LASReq_replaceVariable; this.getDataset = LASReq_getDataset; // NOTE: The current XML representation of Constraints makes it difficult to identify constraints // NOTE: or to return useful stringified versions of them. The getConstraint(), setConstraint() // NOTE: and removeConstraint() methods will not be implemented at this time. //this.getConstraint ?? //this.setconstraint ?? this.addTextConstraint = LASReq_addTextConstraint; this.addVariableConstraint = LASReq_addVariableConstraint; //this.removeConstraint = LASReq_removeConstraints ?? this.removeConstraints = LASReq_removeConstraints; this.getTextConstraints = LASReq_getTextConstraints; this.getVariableConstraints = LASReq_getVariableConstraints; // NOTE: Do we need to support a get/setAnalysis(dataset,variable) method? this.setAnalysis = LASReq_setAnalysis; this.getAnalysis = LASReq_getAnalysis; this.removeAnalysis = LASReq_removeAnalysis; this.addRegion = LASReq_addRegion; this.removeRegion = LASReq_removeRegion; this.getRangeLo = LASReq_getRangeLo; this.getRangeHi = LASReq_getRangeHi; this.getAxisType = LASReq_getAxisType; this.setRange = LASReq_setRange; this.addRange = LASReq_addRange; this.removeRange = LASReq_removeRange; this.getXMLText = LASReq_getXMLText; this.getVariableNode = LASReq_getVariableNode; this.getVariableNodeByIndex = LASReq_getVariableNodeByIndex; }
JavaScript
function LASReq_getOperation(style) { var operationNode = this.DOM.selectNode("/link"); var matchString = new String(operationNode.getAttribute("match")); var pieces = matchString.split('/'); var operation = ""; if (style == 'LAS6') { /* /lasdata/operations/operation_name */ operation = pieces[3]; } else { /* /lasdata/operations/operation[@ID='operation_name'] */ var operationIDString = new String(pieces[3]); var subpieces = operationIDString.split("'"); operation = subpieces[1]; if (!operation) { operation = this.getOperation('LAS6'); } } return operation; }
function LASReq_getOperation(style) { var operationNode = this.DOM.selectNode("/link"); var matchString = new String(operationNode.getAttribute("match")); var pieces = matchString.split('/'); var operation = ""; if (style == 'LAS6') { /* /lasdata/operations/operation_name */ operation = pieces[3]; } else { /* /lasdata/operations/operation[@ID='operation_name'] */ var operationIDString = new String(pieces[3]); var subpieces = operationIDString.split("'"); operation = subpieces[1]; if (!operation) { operation = this.getOperation('LAS6'); } } return operation; }
JavaScript
function LASReq_getProperty(group,property) { var nodePath = '/properties/' + group + '/' + property; var propertyNode = this.DOM.selectNode(nodePath); if (propertyNode) { return this.DOM.selectNodeText(nodePath); } else { return null; } }
function LASReq_getProperty(group,property) { var nodePath = '/properties/' + group + '/' + property; var propertyNode = this.DOM.selectNode(nodePath); if (propertyNode) { return this.DOM.selectNodeText(nodePath); } else { return null; } }
JavaScript
function LASReq_setProperty(group,property,value) { var nodePath = '/properties/' + group + '/' + property; var propertyNode = this.DOM.selectNode(nodePath); if (propertyNode) { this.DOM = this.DOM.replaceNodeContents(propertyNode,value); } else { this.addProperty(group,property,value); } }
function LASReq_setProperty(group,property,value) { var nodePath = '/properties/' + group + '/' + property; var propertyNode = this.DOM.selectNode(nodePath); if (propertyNode) { this.DOM = this.DOM.replaceNodeContents(propertyNode,value); } else { this.addProperty(group,property,value); } }
JavaScript
function LASReq_addVariable(dataset,variable) { var nodeXML = '<link match=\"/lasdata/datasets/' + dataset + '/variables/' + variable + '\"></link>'; var newNode = this.DOM.createXMLNode(nodeXML); var argsNode = this.DOM.selectNode("/args"); var childNodes = argsNode.getElements(); if ( childNodes.length == 0 ) { this.DOM = this.DOM.insertNodeInto(argsNode,newNode); } else { var lastIndex = childNodes.length - 1; var lastChildNode = childNodes[lastIndex]; this.DOM = this.DOM.insertNodeAfter(lastChildNode,newNode); } }
function LASReq_addVariable(dataset,variable) { var nodeXML = '<link match=\"/lasdata/datasets/' + dataset + '/variables/' + variable + '\"></link>'; var newNode = this.DOM.createXMLNode(nodeXML); var argsNode = this.DOM.selectNode("/args"); var childNodes = argsNode.getElements(); if ( childNodes.length == 0 ) { this.DOM = this.DOM.insertNodeInto(argsNode,newNode); } else { var lastIndex = childNodes.length - 1; var lastChildNode = childNodes[lastIndex]; this.DOM = this.DOM.insertNodeAfter(lastChildNode,newNode); } }
JavaScript
function LASReq_removeVariables() { var argsNode = this.DOM.selectNode("/args"); var variableNodes = argsNode.getElements('link'); for (i=0;i<variableNodes.length;i++) { this.DOM = this.DOM.removeNodeFromTree(variableNodes[i]); } }
function LASReq_removeVariables() { var argsNode = this.DOM.selectNode("/args"); var variableNodes = argsNode.getElements('link'); for (i=0;i<variableNodes.length;i++) { this.DOM = this.DOM.removeNodeFromTree(variableNodes[i]); } }
JavaScript
function LASReq_addTextConstraint(variable,operator,value, id) { var argsNode = this.DOM.selectNode("/args"); var nodeXML = '<constraint id=\"'+id+'\"type=\"text\"><v>' + variable + '</v><v>' + operator + '</v><v>' + value + '</v></constraint>'; var newNode = this.DOM.createXMLNode(nodeXML); this.DOM = this.DOM.insertNodeInto(argsNode,newNode); }
function LASReq_addTextConstraint(variable,operator,value, id) { var argsNode = this.DOM.selectNode("/args"); var nodeXML = '<constraint id=\"'+id+'\"type=\"text\"><v>' + variable + '</v><v>' + operator + '</v><v>' + value + '</v></constraint>'; var newNode = this.DOM.createXMLNode(nodeXML); this.DOM = this.DOM.insertNodeInto(argsNode,newNode); }
JavaScript
function LASReq_addVariableConstraint(dataset,variable,operator,value, id) { var argsNode = this.DOM.selectNode("/args"); var linkXML = '<link match=\"/lasdata/datasets/' + dataset + '/variables/' + variable + '\"/>'; var nodeXML = '<constraint id=\"'+ id + '\" type=\"variable\" op=\"' + operator + '\">' + linkXML + '<v>' + value + '</v></constraint>'; var newNode = this.DOM.createXMLNode(nodeXML); this.DOM = this.DOM.insertNodeInto(argsNode,newNode); }
function LASReq_addVariableConstraint(dataset,variable,operator,value, id) { var argsNode = this.DOM.selectNode("/args"); var linkXML = '<link match=\"/lasdata/datasets/' + dataset + '/variables/' + variable + '\"/>'; var nodeXML = '<constraint id=\"'+ id + '\" type=\"variable\" op=\"' + operator + '\">' + linkXML + '<v>' + value + '</v></constraint>'; var newNode = this.DOM.createXMLNode(nodeXML); this.DOM = this.DOM.insertNodeInto(argsNode,newNode); }
JavaScript
function LASReq_removeConstraints() { var argsNode = this.DOM.selectNode("/args"); var constraintNodes = argsNode.getElements('constraint'); for (i=0;i<constraintNodes.length;i++) { this.DOM = this.DOM.removeNodeFromTree(constraintNodes[i]); } }
function LASReq_removeConstraints() { var argsNode = this.DOM.selectNode("/args"); var constraintNodes = argsNode.getElements('constraint'); for (i=0;i<constraintNodes.length;i++) { this.DOM = this.DOM.removeNodeFromTree(constraintNodes[i]); } }
JavaScript
function LASReq_setAnalysis(index,A) { var variableNode = this.getVariableNodeByIndex(index); var nodeXML = '<analysis label=\"' + A.label + '\"></analysis>'; var AnalysisNode = this.DOM.createXMLNode(nodeXML); for (i=0;i<A.axis.length;i++) { var nodeXML = '<axis type=\"' + A.axis[i].type + '\" lo=\"' + A.axis[i].lo + '\" hi=\"' + A.axis[i].hi + '\" op=\"' + A.axis[i].op + '\"/>'; var AxisNode = this.DOM.createXMLNode(nodeXML); AnalysisNode.addElement(AxisNode); } this.DOM = this.DOM.insertNodeInto(variableNode,AnalysisNode); }
function LASReq_setAnalysis(index,A) { var variableNode = this.getVariableNodeByIndex(index); var nodeXML = '<analysis label=\"' + A.label + '\"></analysis>'; var AnalysisNode = this.DOM.createXMLNode(nodeXML); for (i=0;i<A.axis.length;i++) { var nodeXML = '<axis type=\"' + A.axis[i].type + '\" lo=\"' + A.axis[i].lo + '\" hi=\"' + A.axis[i].hi + '\" op=\"' + A.axis[i].op + '\"/>'; var AxisNode = this.DOM.createXMLNode(nodeXML); AnalysisNode.addElement(AxisNode); } this.DOM = this.DOM.insertNodeInto(variableNode,AnalysisNode); }
JavaScript
function LASReq_removeAnalysis(index) { var variableNode = this.getVariableNodeByIndex(index); var analysisNodes = variableNode.getElements('analysis'); for (i=0;i<analysisNodes.length;i++) { this.DOM = this.DOM.removeNodeFromTree(analysisNodes[i]); } }
function LASReq_removeAnalysis(index) { var variableNode = this.getVariableNodeByIndex(index); var analysisNodes = variableNode.getElements('analysis'); for (i=0;i<analysisNodes.length;i++) { this.DOM = this.DOM.removeNodeFromTree(analysisNodes[i]); } }
JavaScript
function LASReq_addRegion() { var nodeXML = '<region></region>'; var newNode = this.DOM.createXMLNode(nodeXML); var argsNode = this.DOM.selectNode("/args"); var childNodes = argsNode.getElements(); if ( childNodes.length == 0 ) { this.DOM = this.DOM.insertNodeInto(argsNode,newNode); } else { var lastIndex = childNodes.length - 1; var lastChildNode = childNodes[lastIndex]; this.DOM = this.DOM.insertNodeAfter(lastChildNode,newNode); } }
function LASReq_addRegion() { var nodeXML = '<region></region>'; var newNode = this.DOM.createXMLNode(nodeXML); var argsNode = this.DOM.selectNode("/args"); var childNodes = argsNode.getElements(); if ( childNodes.length == 0 ) { this.DOM = this.DOM.insertNodeInto(argsNode,newNode); } else { var lastIndex = childNodes.length - 1; var lastChildNode = childNodes[lastIndex]; this.DOM = this.DOM.insertNodeAfter(lastChildNode,newNode); } }
JavaScript
function LASReq_removeRegion(region_ID) { var index = (region_ID) ? region_ID : 0; var argsNode = this.DOM.selectNode("/args"); var regionNodes = argsNode.getElements('region'); if (regionNodes.length > index) { this.DOM = this.DOM.removeNodeFromTree(regionNodes[index]); } }
function LASReq_removeRegion(region_ID) { var index = (region_ID) ? region_ID : 0; var argsNode = this.DOM.selectNode("/args"); var regionNodes = argsNode.getElements('region'); if (regionNodes.length > index) { this.DOM = this.DOM.removeNodeFromTree(regionNodes[index]); } }
JavaScript
function LASReq_addRange(xyzt,lo,hi,region_ID) { var index = (region_ID) ? region_ID : 0; var regionNode = this.DOM.selectNode('/args/region[' + index + ']'); if (!regionNode) { this.addRegion(); } var nodeXML = ''; if (hi != null && (hi != lo)) { nodeXML = '<range type=\"' + xyzt + '\" low=\"' + lo + '\" high=\"' + hi + '\"/>'; } else { nodeXML = '<point type=\"' + xyzt + '\" v=\"' + lo + '\"/>'; } var newNode = this.DOM.createXMLNode(nodeXML); regionNode = this.DOM.selectNode('/args/region[' + index + ']'); this.DOM = this.DOM.insertNodeInto(regionNode,newNode); }
function LASReq_addRange(xyzt,lo,hi,region_ID) { var index = (region_ID) ? region_ID : 0; var regionNode = this.DOM.selectNode('/args/region[' + index + ']'); if (!regionNode) { this.addRegion(); } var nodeXML = ''; if (hi != null && (hi != lo)) { nodeXML = '<range type=\"' + xyzt + '\" low=\"' + lo + '\" high=\"' + hi + '\"/>'; } else { nodeXML = '<point type=\"' + xyzt + '\" v=\"' + lo + '\"/>'; } var newNode = this.DOM.createXMLNode(nodeXML); regionNode = this.DOM.selectNode('/args/region[' + index + ']'); this.DOM = this.DOM.insertNodeInto(regionNode,newNode); }
JavaScript
function LASReq_getVariableNode(dataset,variable) { var argsNode = this.DOM.selectNode("/args"); var variableNodes = argsNode.getElements('link'); for (i=0;i<variableNodes.length;i++) { matchString = new String(variableNodes[i].getAttribute("match")); var pieces = matchString.split('/'); if (pieces[5] == variable) { return variableNodes[i]; } } }
function LASReq_getVariableNode(dataset,variable) { var argsNode = this.DOM.selectNode("/args"); var variableNodes = argsNode.getElements('link'); for (i=0;i<variableNodes.length;i++) { matchString = new String(variableNodes[i].getAttribute("match")); var pieces = matchString.split('/'); if (pieces[5] == variable) { return variableNodes[i]; } } }
JavaScript
function LASReq_getVariableNodeByIndex(index) { var argsNode = this.DOM.selectNode("/args"); var variableNodes = argsNode.getElements('link'); if (variableNodes[index]) { return variableNodes[index]; } else { return null; } }
function LASReq_getVariableNodeByIndex(index) { var argsNode = this.DOM.selectNode("/args"); var variableNodes = argsNode.getElements('link'); if (variableNodes[index]) { return variableNodes[index]; } else { return null; } }
JavaScript
function LASGetOperationsResponse(JSONObject) { this.response = JSONObject; if(!this.response) return false; // Add methods to this object this.getAllOperations = LASGetOperationsResponse_getAllOperations; this.getOperationCount = LASGetOperationsResponse_getOperationCount; this.getOperation = LASGetOperationsResponse_getOperation; this.getOperationID = LASGetOperationsResponse_getOperationID; this.getOperationByID = LASGetOperationsResponse_getOperationByID; this.getOperationName = LASGetOperationsResponse_getOperationName; this.getOperationsByView = LASGetOperationsResponse_getOperationsByView; this.getOperationsByType = LASGetOperationsResponse_getOperationsByType; this.getOperationTypes = LASGetOperationsResponse_getOperationTypes; this.getAllOperationTypes = LASGetOperationsResponse_getAllOperationTypes; this.getAllIntervals = LASGetOperationsResponse_getAllIntervals; this.getOperationIntervals = LASGetOperationsResponse_getOperationIntervals; this.hasInterval = LASGetOperationsResponse_hasInterval; }
function LASGetOperationsResponse(JSONObject) { this.response = JSONObject; if(!this.response) return false; // Add methods to this object this.getAllOperations = LASGetOperationsResponse_getAllOperations; this.getOperationCount = LASGetOperationsResponse_getOperationCount; this.getOperation = LASGetOperationsResponse_getOperation; this.getOperationID = LASGetOperationsResponse_getOperationID; this.getOperationByID = LASGetOperationsResponse_getOperationByID; this.getOperationName = LASGetOperationsResponse_getOperationName; this.getOperationsByView = LASGetOperationsResponse_getOperationsByView; this.getOperationsByType = LASGetOperationsResponse_getOperationsByType; this.getOperationTypes = LASGetOperationsResponse_getOperationTypes; this.getAllOperationTypes = LASGetOperationsResponse_getAllOperationTypes; this.getAllIntervals = LASGetOperationsResponse_getAllIntervals; this.getOperationIntervals = LASGetOperationsResponse_getOperationIntervals; this.hasInterval = LASGetOperationsResponse_hasInterval; }
JavaScript
function LASGetOperationsResponse_getAllOperations() { if(this.response.operations.operation) return this.response.operations.operation; else return null; }
function LASGetOperationsResponse_getAllOperations() { if(this.response.operations.operation) return this.response.operations.operation; else return null; }
JavaScript
function LASGetOperationsResponse_getOperation(i) { if(i>=0&&i<this.getOperationCount()) return this.getAllOperations()[i]; else return null; }
function LASGetOperationsResponse_getOperation(i) { if(i>=0&&i<this.getOperationCount()) return this.getAllOperations()[i]; else return null; }
JavaScript
function LASGetOperationsResponse_getOperationID(i) { if(this.getOperation(i)) { return this.getOperation(i).ID; } else return null; }
function LASGetOperationsResponse_getOperationID(i) { if(this.getOperation(i)) { return this.getOperation(i).ID; } else return null; }
JavaScript
function LASGetOperationsResponse_getOperationByID(id) { for(var i=0;i<this.getOperationCount();i++) { if(this.getOperation(i).ID == id) return this.getOperation(i); } return null; }
function LASGetOperationsResponse_getOperationByID(id) { for(var i=0;i<this.getOperationCount();i++) { if(this.getOperation(i).ID == id) return this.getOperation(i); } return null; }
JavaScript
function LASGetOperationsResponse_getOperationName(i) { if(this.getOperation(i)) { return this.getOperation(i).name } else return null; }
function LASGetOperationsResponse_getOperationName(i) { if(this.getOperation(i)) { return this.getOperation(i).name } else return null; }
JavaScript
function LASContentCell() { // Add methods to this object this.render = LASContentCell_render; this.display = LASContentCell_display; }
function LASContentCell() { // Add methods to this object this.render = LASContentCell_render; this.display = LASContentCell_display; }
JavaScript
function LASContentCell_render(element_id,type) { this.element_id = element_id; if (type) { this.type = type; } var node = document.getElementById(this.element_id); var children = node.childNodes; var num_children = children.length; // Remove any children of element_id // NOTE: Start removing children from the end. Otherwise, what was // NOTE: children[1] becomes children[0] when children[0] is removed. for (var i=num_children-1; i>=0; i--) { var child = children[i]; if (child) { node.removeChild(child); } } // Create the table that will contain the content var id_text; var CC_table = document.createElement('table'); id_text = this.element_id + '_table'; CC_table.setAttribute('id',id_text); CC_table.setAttribute('border',2); node.appendChild(CC_table); var CC_tbody = document.createElement('tbody'); id_text = this.element_id + '_tbody'; CC_tbody.setAttribute('id',id_text); CC_table.appendChild(CC_tbody); var CC_tr = document.createElement('tr'); id_text = this.element_id + '_tr'; CC_tr.setAttribute('id',id_text); CC_tbody.appendChild(CC_tr); var CC_td = document.createElement('td'); id_text = this.element_id + '_td'; CC_td.setAttribute('id',id_text); CC_tr.appendChild(CC_td); // Now that the table is in place, the sendLASRequest() method will // be in charge of sending the request and appending the appropriate // DOM elements based on the LASResponse. }
function LASContentCell_render(element_id,type) { this.element_id = element_id; if (type) { this.type = type; } var node = document.getElementById(this.element_id); var children = node.childNodes; var num_children = children.length; // Remove any children of element_id // NOTE: Start removing children from the end. Otherwise, what was // NOTE: children[1] becomes children[0] when children[0] is removed. for (var i=num_children-1; i>=0; i--) { var child = children[i]; if (child) { node.removeChild(child); } } // Create the table that will contain the content var id_text; var CC_table = document.createElement('table'); id_text = this.element_id + '_table'; CC_table.setAttribute('id',id_text); CC_table.setAttribute('border',2); node.appendChild(CC_table); var CC_tbody = document.createElement('tbody'); id_text = this.element_id + '_tbody'; CC_tbody.setAttribute('id',id_text); CC_table.appendChild(CC_tbody); var CC_tr = document.createElement('tr'); id_text = this.element_id + '_tr'; CC_tr.setAttribute('id',id_text); CC_tbody.appendChild(CC_tr); var CC_td = document.createElement('td'); id_text = this.element_id + '_td'; CC_td.setAttribute('id',id_text); CC_tr.appendChild(CC_td); // Now that the table is in place, the sendLASRequest() method will // be in charge of sending the request and appending the appropriate // DOM elements based on the LASResponse. }
JavaScript
function LASContentCell_display(LASResponse,result_type) { // TODO: Should we use 'type' or 'ID' for this switch in the code? // Default behavior is to plot the image found in the LASResponse. if (!result_type) { result_type = 'plot_image'; } var cell_id = this.element_id + '_td'; var node = document.getElementById(cell_id); var children = node.childNodes; var num_children = children.length; // Remove any children of cell_id // NOTE: Start removing children from the end. Otherwise, what was // NOTE: children[1] becomes children[0] when children[0] is removed. for (var i=num_children-1; i>=0; i--) { var child = children[i]; if (child) { node.removeChild(child); } } // Check for errors first // if (LASResponse.isError()) { // result_type = 'error'; // } // Add the appropriate Elements to display the Result switch (result_type) { case 'full_error': var CC_div = document.createElement('div'); CC_div.setAttribute('class','CCell_las_message'); node.appendChild(CC_div); var text = LASResponse.getResult('las_message').content; var textNode = document.createTextNode(text); CC_div.appendChild(textNode); CC_div = document.createElement('div'); CC_div.setAttribute('class','CCell_text'); node.appendChild(CC_div); var text = LASResponse.getResult('exception_message').content; var sub_header = 'exception message is ' + text.length + ' characters long. The first 200 are:' var textNode = document.createTextNode(sub_header); CC_div.appendChild(textNode); CC_div = document.createElement('div'); CC_div.setAttribute('class','CCell_exception_message'); node.appendChild(CC_div); var sub_text = text.slice(0,200) + ' ...'; var textNode = document.createTextNode(sub_text); CC_div.appendChild(textNode); break; case 'las_message': var CC_div = document.createElement('div'); CC_div.setAttribute('class','CCell_las_message'); node.appendChild(CC_div); var text = LASResponse.getResult('las_message').content; var textNode = document.createTextNode(text); CC_div.appendChild(textNode); CC_div = document.createElement('div'); CC_div.setAttribute('class','CCell_error_link'); node.appendChild(CC_div); var error_link = document.createElement('a'); error_link.href = LASResponse.getResult('debug').url; textNode = document.createTextNode('More details about this error.'); error_link.appendChild(textNode); CC_div.appendChild(error_link); break; case 'plot_image': var CC_anchor = document.createElement('a'); CC_anchor.setAttribute('target','_blank'); if (LASResponse.large_img_url) { CC_anchor.href = LASResponse.large_img_url; } node.appendChild(CC_anchor); var CC_img = document.createElement('img'); CC_img.setAttribute('src',LASResponse.getImageURL()); CC_anchor.appendChild(CC_img); break; } }
function LASContentCell_display(LASResponse,result_type) { // TODO: Should we use 'type' or 'ID' for this switch in the code? // Default behavior is to plot the image found in the LASResponse. if (!result_type) { result_type = 'plot_image'; } var cell_id = this.element_id + '_td'; var node = document.getElementById(cell_id); var children = node.childNodes; var num_children = children.length; // Remove any children of cell_id // NOTE: Start removing children from the end. Otherwise, what was // NOTE: children[1] becomes children[0] when children[0] is removed. for (var i=num_children-1; i>=0; i--) { var child = children[i]; if (child) { node.removeChild(child); } } // Check for errors first // if (LASResponse.isError()) { // result_type = 'error'; // } // Add the appropriate Elements to display the Result switch (result_type) { case 'full_error': var CC_div = document.createElement('div'); CC_div.setAttribute('class','CCell_las_message'); node.appendChild(CC_div); var text = LASResponse.getResult('las_message').content; var textNode = document.createTextNode(text); CC_div.appendChild(textNode); CC_div = document.createElement('div'); CC_div.setAttribute('class','CCell_text'); node.appendChild(CC_div); var text = LASResponse.getResult('exception_message').content; var sub_header = 'exception message is ' + text.length + ' characters long. The first 200 are:' var textNode = document.createTextNode(sub_header); CC_div.appendChild(textNode); CC_div = document.createElement('div'); CC_div.setAttribute('class','CCell_exception_message'); node.appendChild(CC_div); var sub_text = text.slice(0,200) + ' ...'; var textNode = document.createTextNode(sub_text); CC_div.appendChild(textNode); break; case 'las_message': var CC_div = document.createElement('div'); CC_div.setAttribute('class','CCell_las_message'); node.appendChild(CC_div); var text = LASResponse.getResult('las_message').content; var textNode = document.createTextNode(text); CC_div.appendChild(textNode); CC_div = document.createElement('div'); CC_div.setAttribute('class','CCell_error_link'); node.appendChild(CC_div); var error_link = document.createElement('a'); error_link.href = LASResponse.getResult('debug').url; textNode = document.createTextNode('More details about this error.'); error_link.appendChild(textNode); CC_div.appendChild(error_link); break; case 'plot_image': var CC_anchor = document.createElement('a'); CC_anchor.setAttribute('target','_blank'); if (LASResponse.large_img_url) { CC_anchor.href = LASResponse.large_img_url; } node.appendChild(CC_anchor); var CC_img = document.createElement('img'); CC_img.setAttribute('src',LASResponse.getImageURL()); CC_anchor.appendChild(CC_img); break; } }
JavaScript
function LASSlideSorter(form,init_object) { /* * The LASSlideSorter object must be attached to the document * so that it is available to the 'LASSlideSorter_cellWidgetChoice' event * handler which is a function of the document and not of * the LASSlideSorter object. */ document.LSS = this; // Internal Constants // Public functions this.render = LASSlideSorter_render; this.createCellWidgets = LASSlideSorter_createCellWidgets; this.createGlobalWidgets = LASSlideSorter_createGlobalWidgets; this.createGlobalRadios = LASSlideSorter_createGlobalRadios; this.loadAllImages = LASSlideSorter_loadAllImages; this.loadContentCell = LASSlideSorter_loadContentCell; this.getCellAA = LASSlideSorter_getCellAA; this.switchMode = LASSlideSorter_switchMode; // Internal functions // Callback functions (when a Widget event is triggered) document.globalWidgetChoice = LASSlideSorter_globalWidgetChoice; document.cellWidgetChoice = LASSlideSorter_cellWidgetChoice; // Event handlers document.radioChoice = LASSlideSorter_radioChoice; document.imgComplete = LASSlideSorter_imgComplete; // Initialization (default settings for rows, cols and chosenMenuName) this.form = form; this.InitObject = init_object; this.numRows = 2; this.numCols = 2; this.chosenMenuName = 't'; this.anomalyMode = 0; this.Widgets = new Object(); }
function LASSlideSorter(form,init_object) { /* * The LASSlideSorter object must be attached to the document * so that it is available to the 'LASSlideSorter_cellWidgetChoice' event * handler which is a function of the document and not of * the LASSlideSorter object. */ document.LSS = this; // Internal Constants // Public functions this.render = LASSlideSorter_render; this.createCellWidgets = LASSlideSorter_createCellWidgets; this.createGlobalWidgets = LASSlideSorter_createGlobalWidgets; this.createGlobalRadios = LASSlideSorter_createGlobalRadios; this.loadAllImages = LASSlideSorter_loadAllImages; this.loadContentCell = LASSlideSorter_loadContentCell; this.getCellAA = LASSlideSorter_getCellAA; this.switchMode = LASSlideSorter_switchMode; // Internal functions // Callback functions (when a Widget event is triggered) document.globalWidgetChoice = LASSlideSorter_globalWidgetChoice; document.cellWidgetChoice = LASSlideSorter_cellWidgetChoice; // Event handlers document.radioChoice = LASSlideSorter_radioChoice; document.imgComplete = LASSlideSorter_imgComplete; // Initialization (default settings for rows, cols and chosenMenuName) this.form = form; this.InitObject = init_object; this.numRows = 2; this.numCols = 2; this.chosenMenuName = 't'; this.anomalyMode = 0; this.Widgets = new Object(); }
JavaScript
function LASSlideSorter_createGlobalRadios() { // NOTE: Radio buttons are handled directly by the LASSlideSorter. // NOTE: There is no 'widget interface' abstraction layer. var i = 1; var num_radios = 0; for (var menuName in this.InitObject) { // NOTE: json.js breaks for loops by adding the toJSONString() method. // NOTE: See: http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ if (typeof this.InitObject[menuName] !== 'function') { var radioButton_id = 'basicRadioButton' + i; var titleCell_id = 'basicTitleCell' + i; var Menu = this.InitObject[menuName]; var RadioButton = document.getElementById(radioButton_id); var TitleCell = document.getElementById(titleCell_id); // TODO: Is this a robust way of changing the title? if (TitleCell.firstchild) { if (menuName == this.chosenMenuName) { TitleCell.firstChild.nodeValue = 'Compare ' + Menu.title; } else { TitleCell.firstChild.nodeValue = Menu.title; } } else { var textNode = document.createTextNode(Menu.title); if (menuName == this.chosenMenuName) { var textNode = document.createTextNode('Compare ' + Menu.title); } TitleCell.appendChild(textNode); } RadioButton.value = menuName; RadioButton.onclick = document.radioChoice; RadioButton.LSS = this; if (menuName == this.chosenMenuName) { RadioButton.checked = true; first = 0; TitleCell.style.fontWeight = "bold"; TitleCell.style.color = "#D33"; } i++; num_radios++; } } // NOTE: Remove global widgets if there is only one. It would be disabled // NOTE: anyway as it is the one replicated in the imageCells. if (num_radios == 1) { var RadioButton = document.getElementById('basicRadioButton1'); RadioButton.style.display = 'none'; // document.getElementById('LSS_controlRow').style.display = 'none'; } }
function LASSlideSorter_createGlobalRadios() { // NOTE: Radio buttons are handled directly by the LASSlideSorter. // NOTE: There is no 'widget interface' abstraction layer. var i = 1; var num_radios = 0; for (var menuName in this.InitObject) { // NOTE: json.js breaks for loops by adding the toJSONString() method. // NOTE: See: http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ if (typeof this.InitObject[menuName] !== 'function') { var radioButton_id = 'basicRadioButton' + i; var titleCell_id = 'basicTitleCell' + i; var Menu = this.InitObject[menuName]; var RadioButton = document.getElementById(radioButton_id); var TitleCell = document.getElementById(titleCell_id); // TODO: Is this a robust way of changing the title? if (TitleCell.firstchild) { if (menuName == this.chosenMenuName) { TitleCell.firstChild.nodeValue = 'Compare ' + Menu.title; } else { TitleCell.firstChild.nodeValue = Menu.title; } } else { var textNode = document.createTextNode(Menu.title); if (menuName == this.chosenMenuName) { var textNode = document.createTextNode('Compare ' + Menu.title); } TitleCell.appendChild(textNode); } RadioButton.value = menuName; RadioButton.onclick = document.radioChoice; RadioButton.LSS = this; if (menuName == this.chosenMenuName) { RadioButton.checked = true; first = 0; TitleCell.style.fontWeight = "bold"; TitleCell.style.color = "#D33"; } i++; num_radios++; } } // NOTE: Remove global widgets if there is only one. It would be disabled // NOTE: anyway as it is the one replicated in the imageCells. if (num_radios == 1) { var RadioButton = document.getElementById('basicRadioButton1'); RadioButton.style.display = 'none'; // document.getElementById('LSS_controlRow').style.display = 'none'; } }
JavaScript
function LASSlideSorter_createGlobalWidgets() { var i = 1; for (var menuName in this.InitObject) { // NOTE: json.js breaks for loops by adding the toJSONString() method. // NOTE: See: http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ if (typeof this.InitObject[menuName] !== 'function') { var basicWidgetCell_id = "basicWidgetCell" + i; var Widget; var Menu = this.InitObject[menuName]; // TODO: The javascript components are very close to having a uniform // TODO: 'interface'. When that happens then the only things inside the // TODO: statement should be the 'new ~Widget' lines. Everything about // TODO: rendering, setting initial values, etc can be moved outside the block. switch (Menu.type) { case 'latitudeWidget': if (Menu.data.delta) { Widget = new LatitudeWidget(Menu.data.lo, Menu.data.hi, Menu.data.delta); } else { Widget = new LatitudeWidget(Menu.data.lo, Menu.data.hi); } Widget.render(basicWidgetCell_id); Widget.setCallback(document.globalWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'longitudeWidget': if (Menu.data.delta) { Widget = new LongitudeWidget(Menu.data.lo, Menu.data.hi, Menu.data.delta); } else { Widget = new LongitudeWidget(Menu.data.lo, Menu.data.hi); } Widget.render(basicWidgetCell_id); Widget.setCallback(document.globalWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'menuWidget': Widget = new MenuWidget(Menu.data); Widget.render(basicWidgetCell_id); Widget.setCallback(document.globalWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'dateWidget': if(Menu.render_format.indexOf('T') > 0){ if(Menu.data.tUnits == 'hour'){ Widget = new DateWidget( Menu.data.lo, Menu.data.hi, 60*(Menu.data.tDelta)); } if(Menu.data.tUnits == 'minute'){ Widget = new DateWidget( Menu.data.lo, Menu.data.hi, Menu.data.tDelta); } }else{ Widget = new DateWidget(Menu.data.lo, Menu.data.hi); } //Widget = new DateWidget(Menu.data.lo, Menu.data.hi); if (Menu.render_format) { Widget.render(basicWidgetCell_id,Menu.render_format); } else { Widget.render(basicWidgetCell_id,"MY"); } Widget.setCallback(document.globalWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; } if (menuName == this.chosenMenuName) { Widget.disable() }; this.Widgets[basicWidgetCell_id] = Widget; i++; } } }
function LASSlideSorter_createGlobalWidgets() { var i = 1; for (var menuName in this.InitObject) { // NOTE: json.js breaks for loops by adding the toJSONString() method. // NOTE: See: http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ if (typeof this.InitObject[menuName] !== 'function') { var basicWidgetCell_id = "basicWidgetCell" + i; var Widget; var Menu = this.InitObject[menuName]; // TODO: The javascript components are very close to having a uniform // TODO: 'interface'. When that happens then the only things inside the // TODO: statement should be the 'new ~Widget' lines. Everything about // TODO: rendering, setting initial values, etc can be moved outside the block. switch (Menu.type) { case 'latitudeWidget': if (Menu.data.delta) { Widget = new LatitudeWidget(Menu.data.lo, Menu.data.hi, Menu.data.delta); } else { Widget = new LatitudeWidget(Menu.data.lo, Menu.data.hi); } Widget.render(basicWidgetCell_id); Widget.setCallback(document.globalWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'longitudeWidget': if (Menu.data.delta) { Widget = new LongitudeWidget(Menu.data.lo, Menu.data.hi, Menu.data.delta); } else { Widget = new LongitudeWidget(Menu.data.lo, Menu.data.hi); } Widget.render(basicWidgetCell_id); Widget.setCallback(document.globalWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'menuWidget': Widget = new MenuWidget(Menu.data); Widget.render(basicWidgetCell_id); Widget.setCallback(document.globalWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'dateWidget': if(Menu.render_format.indexOf('T') > 0){ if(Menu.data.tUnits == 'hour'){ Widget = new DateWidget( Menu.data.lo, Menu.data.hi, 60*(Menu.data.tDelta)); } if(Menu.data.tUnits == 'minute'){ Widget = new DateWidget( Menu.data.lo, Menu.data.hi, Menu.data.tDelta); } }else{ Widget = new DateWidget(Menu.data.lo, Menu.data.hi); } //Widget = new DateWidget(Menu.data.lo, Menu.data.hi); if (Menu.render_format) { Widget.render(basicWidgetCell_id,Menu.render_format); } else { Widget.render(basicWidgetCell_id,"MY"); } Widget.setCallback(document.globalWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; } if (menuName == this.chosenMenuName) { Widget.disable() }; this.Widgets[basicWidgetCell_id] = Widget; i++; } } }
JavaScript
function LASSlideSorter_createCellWidgets(chosenMenuName) { var index = 0; for (var i=0; i<this.numRows; i++) { for (var j=0; j<this.numCols; j++) { var inum = i+1; var jnum = j+1; var widget_id = "widgetCell" + inum + jnum; var Widget; var Menu = this.InitObject[chosenMenuName]; switch (Menu.type) { case 'latitudeWidget': if (Menu.data.delta) { Widget = new LatitudeWidget(Menu.data.lo, Menu.data.hi, Menu.data.delta); } else { Widget = new LatitudeWidget(Menu.data.lo, Menu.data.hi); } Widget.render(widget_id); Widget.setCallback(document.cellWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'longitudeWidget': if (Menu.data.delta) { Widget = new LongitudeWidget(Menu.data.lo, Menu.data.hi, Menu.data.delta); } else { Widget = new LongitudeWidget(Menu.data.lo, Menu.data.hi); } Widget.render(widget_id); Widget.setCallback(document.cellWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'menuWidget': Widget = new MenuWidget(Menu.data); Widget.render(widget_id); Widget.setCallback(document.cellWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'dateWidget': if(Menu.render_format.indexOf('T') > 0){ if(Menu.data.tUnits == 'hour'){ Widget = new DateWidget( Menu.data.lo, Menu.data.hi, 60*(Menu.data.tDelta)); } if(Menu.data.tUnits == 'minute'){ Widget = new DateWidget( Menu.data.lo, Menu.data.hi, Menu.data.tDelta); } }else{ Widget = new DateWidget(Menu.data.lo, Menu.data.hi); } //Widget = new DateWidget(Menu.data.lo, Menu.data.hi); if (Menu.render_format) { Widget.render(widget_id,Menu.render_format); } else { Widget.render(widget_id,"MY"); } Widget.setCallback(document.cellWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; } this.Widgets[widget_id] = Widget; index++; } } }
function LASSlideSorter_createCellWidgets(chosenMenuName) { var index = 0; for (var i=0; i<this.numRows; i++) { for (var j=0; j<this.numCols; j++) { var inum = i+1; var jnum = j+1; var widget_id = "widgetCell" + inum + jnum; var Widget; var Menu = this.InitObject[chosenMenuName]; switch (Menu.type) { case 'latitudeWidget': if (Menu.data.delta) { Widget = new LatitudeWidget(Menu.data.lo, Menu.data.hi, Menu.data.delta); } else { Widget = new LatitudeWidget(Menu.data.lo, Menu.data.hi); } Widget.render(widget_id); Widget.setCallback(document.cellWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'longitudeWidget': if (Menu.data.delta) { Widget = new LongitudeWidget(Menu.data.lo, Menu.data.hi, Menu.data.delta); } else { Widget = new LongitudeWidget(Menu.data.lo, Menu.data.hi); } Widget.render(widget_id); Widget.setCallback(document.cellWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'menuWidget': Widget = new MenuWidget(Menu.data); Widget.render(widget_id); Widget.setCallback(document.cellWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; case 'dateWidget': if(Menu.render_format.indexOf('T') > 0){ if(Menu.data.tUnits == 'hour'){ Widget = new DateWidget( Menu.data.lo, Menu.data.hi, 60*(Menu.data.tDelta)); } if(Menu.data.tUnits == 'minute'){ Widget = new DateWidget( Menu.data.lo, Menu.data.hi, Menu.data.tDelta); } }else{ Widget = new DateWidget(Menu.data.lo, Menu.data.hi); } //Widget = new DateWidget(Menu.data.lo, Menu.data.hi); if (Menu.render_format) { Widget.render(widget_id,Menu.render_format); } else { Widget.render(widget_id,"MY"); } Widget.setCallback(document.cellWidgetChoice); if (Menu.initial_value) { Widget.setValue(Menu.initial_value); } break; } this.Widgets[widget_id] = Widget; index++; } } }
JavaScript
function LASSlideSorter_loadAllImages() { for (var i=1; i<=this.numRows; i++) { for (var j=1; j<=this.numCols; j++) { this.loadContentCell(i,j); } } }
function LASSlideSorter_loadAllImages() { for (var i=1; i<=this.numRows; i++) { for (var j=1; j<=this.numCols; j++) { this.loadContentCell(i,j); } } }
JavaScript
function LASSlideSorter_loadContentCell(row,col) { // Modify the background color until the image is loaded // TODO: Clean up ugly parentNode.parentNode... stuff // TODO: use style sheet properties instead of hardcoding the color var aGifID = "aGif" + row + col; var aGif = document.getElementById(aGifID); var a1 = aGif.parentNode.parentNode.parentNode.parentNode.parentNode; var a2 = aGif.parentNode.parentNode.parentNode.parentNode; var a3 = aGif.parentNode.parentNode.parentNode; if (this.anomalyMode == 0) { a1.className = a1.className.replace(/regularBackground/,'downloadingBackground'); a2.className = a2.className.replace(/regularBackground/,'downloadingBackground'); a3.className = a3.className.replace(/regularBackground/,'downloadingBackground'); } else { a1.className = a1.className.replace(/anomalyBackground/,'downloadingBackground'); a2.className = a2.className.replace(/anomalyBackground/,'downloadingBackground'); a3.className = a3.className.replace(/anomalyBackground/,'downloadingBackground'); } aGif.style.visibility = 'visible'; // Create an Associative Array that will consist of name:value pairs var AA = new Object; AA["row"] = row; AA["col"] = col; AA.anomalyMode = this.anomalyMode; // Get the values from the enabled Global Widgets var i = 1; for (var menuName in this.InitObject) { // NOTE: json.js breaks for loops by adding the toJSONString() method. // NOTE: See: http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ if (typeof this.InitObject[menuName] !== 'function') { var widget_id = "basicWidgetCell" + i; var Widget = this.Widgets[widget_id]; if (!Widget.disabled) { AA[menuName] = Widget.getValue(); } i++; } } // TODO: Need to figure out how to add the current 'view' to AA. // Now get the values from the Cell Widgets // Pass the Associative Array to the user defined createLASRequest() // Use the returned LASRequest to create a URL // Use sarissa.js to send an AJAX request to the server var widget_id = "widgetCell" + row + col; var Widget = this.Widgets[widget_id]; AA[this.chosenMenuName] = Widget.getValue(); var Request = createLASRequest(AA); // TODO: The Request prefix needs accessor methods that allow you // TODO: to specify the type of Request you are sending // TODO: - ProductServer.do // TODO: - GetDatasets.do // TODO: - GetVariables.do // TODO: - GetGrids.do // TODO: - etc. // TODO: and in what format the response should come back // TODO: - xml // TODO: - json // TODO: - html // TODO: - etc. Request.setProperty('las','output_type','json'); var prefix = Request.prefix; var url = prefix + escape(Request.getXMLText()); // 2) Send LAS Request URL using Sarissa methods // Register handleLASResponse(...) as callback routine // Set 'output_type' back to normal (nothing) Request.setProperty('las','output_type',''); var xmlhttp = new XMLHttpRequest(); xmlhttp.open('GET', url, true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { handleLASResponse(xmlhttp.responseText,row,col,Request); } } xmlhttp.send(null); }
function LASSlideSorter_loadContentCell(row,col) { // Modify the background color until the image is loaded // TODO: Clean up ugly parentNode.parentNode... stuff // TODO: use style sheet properties instead of hardcoding the color var aGifID = "aGif" + row + col; var aGif = document.getElementById(aGifID); var a1 = aGif.parentNode.parentNode.parentNode.parentNode.parentNode; var a2 = aGif.parentNode.parentNode.parentNode.parentNode; var a3 = aGif.parentNode.parentNode.parentNode; if (this.anomalyMode == 0) { a1.className = a1.className.replace(/regularBackground/,'downloadingBackground'); a2.className = a2.className.replace(/regularBackground/,'downloadingBackground'); a3.className = a3.className.replace(/regularBackground/,'downloadingBackground'); } else { a1.className = a1.className.replace(/anomalyBackground/,'downloadingBackground'); a2.className = a2.className.replace(/anomalyBackground/,'downloadingBackground'); a3.className = a3.className.replace(/anomalyBackground/,'downloadingBackground'); } aGif.style.visibility = 'visible'; // Create an Associative Array that will consist of name:value pairs var AA = new Object; AA["row"] = row; AA["col"] = col; AA.anomalyMode = this.anomalyMode; // Get the values from the enabled Global Widgets var i = 1; for (var menuName in this.InitObject) { // NOTE: json.js breaks for loops by adding the toJSONString() method. // NOTE: See: http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ if (typeof this.InitObject[menuName] !== 'function') { var widget_id = "basicWidgetCell" + i; var Widget = this.Widgets[widget_id]; if (!Widget.disabled) { AA[menuName] = Widget.getValue(); } i++; } } // TODO: Need to figure out how to add the current 'view' to AA. // Now get the values from the Cell Widgets // Pass the Associative Array to the user defined createLASRequest() // Use the returned LASRequest to create a URL // Use sarissa.js to send an AJAX request to the server var widget_id = "widgetCell" + row + col; var Widget = this.Widgets[widget_id]; AA[this.chosenMenuName] = Widget.getValue(); var Request = createLASRequest(AA); // TODO: The Request prefix needs accessor methods that allow you // TODO: to specify the type of Request you are sending // TODO: - ProductServer.do // TODO: - GetDatasets.do // TODO: - GetVariables.do // TODO: - GetGrids.do // TODO: - etc. // TODO: and in what format the response should come back // TODO: - xml // TODO: - json // TODO: - html // TODO: - etc. Request.setProperty('las','output_type','json'); var prefix = Request.prefix; var url = prefix + escape(Request.getXMLText()); // 2) Send LAS Request URL using Sarissa methods // Register handleLASResponse(...) as callback routine // Set 'output_type' back to normal (nothing) Request.setProperty('las','output_type',''); var xmlhttp = new XMLHttpRequest(); xmlhttp.open('GET', url, true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4) { handleLASResponse(xmlhttp.responseText,row,col,Request); } } xmlhttp.send(null); }
JavaScript
function LASSlideSorter_getCellAA(row,col) { // See the loadContentCell method for more explanation var AA = new Object; AA["row"] = row; AA["col"] = col; AA.anomalyMode = this.anomalyMode; var i = 1; for (var menuName in this.InitObject) { // NOTE: json.js breaks for loops by adding the toJSONString() method. // NOTE: See: http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ if (typeof this.InitObject[menuName] !== 'function') { var widget_id = "basicWidgetCell" + i; var Widget = this.Widgets[widget_id]; if (!Widget.disabled) { AA[menuName] = Widget.getValue(); } i++; } } var widget_id = "widgetCell" + row + col; var Widget = this.Widgets[widget_id]; AA[this.chosenMenuName] = Widget.getValue(); return AA; }
function LASSlideSorter_getCellAA(row,col) { // See the loadContentCell method for more explanation var AA = new Object; AA["row"] = row; AA["col"] = col; AA.anomalyMode = this.anomalyMode; var i = 1; for (var menuName in this.InitObject) { // NOTE: json.js breaks for loops by adding the toJSONString() method. // NOTE: See: http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ if (typeof this.InitObject[menuName] !== 'function') { var widget_id = "basicWidgetCell" + i; var Widget = this.Widgets[widget_id]; if (!Widget.disabled) { AA[menuName] = Widget.getValue(); } i++; } } var widget_id = "widgetCell" + row + col; var Widget = this.Widgets[widget_id]; AA[this.chosenMenuName] = Widget.getValue(); return AA; }
JavaScript
function LASSlideSorter_switchMode(mode) { if (mode == 0) { // Switch things back to 'Regular mode' this.anomalyMode = 0; var table = document.getElementById('LSS_controlTable'); table.className = table.className.replace(/anomalyBackground/, 'regularBackground'); var cell = document.getElementById('LSS_modeCell'); cell.className = cell.className.replace(/regularBackground/, 'anomalyBackground'); var anchor = document.getElementById('LSS_modeAnchor'); anchor.setAttribute('href','javascript: LSS.switchMode(1)'); anchor.firstChild.nodeValue = 'to Anomaly mode'; for (var i=1; i<=this.numRows; i++) { for (var j=1; j<=this.numCols; j++) { if (i != 1 || j != 1) { var id_text = 'LSS_imageCell' + i + j; var imageCell = document.getElementById(id_text); var tables = imageCell.getElementsByTagName('table') for (var k=0; k<tables.length; k++) { var table = tables[k]; if (table.className) { table.className = table.className.replace(/anomalyBackground/, 'regularBackground'); } } var cells = imageCell.getElementsByTagName('td') for (var k=0; k<cells.length; k++) { var cell = cells[k]; if (cell.className) { cell.className = cell.className.replace(/anomalyBackground/, 'regularBackground'); } } } } } } else { // Switch things to 'Anomaly mode' this.anomalyMode = 1; var table = document.getElementById('LSS_controlTable'); table.className = table.className.replace(/regularBackground/, 'anomalyBackground'); var cell = document.getElementById('LSS_modeCell'); cell.className = cell.className.replace(/anomalyBackground/, 'regularBackground'); var anchor = document.getElementById('LSS_modeAnchor'); anchor.setAttribute('href','javascript: LSS.switchMode(0)'); anchor.firstChild.nodeValue = 'to Regular mode'; for (var i=1; i<=this.numRows; i++) { for (var j=1; j<=this.numCols; j++) { if (i != 1 || j != 1) { var id_text = 'LSS_imageCell' + i + j; var imageCell = document.getElementById(id_text); var tables = imageCell.getElementsByTagName('table') for (var k=0; k<tables.length; k++) { var table = tables[k]; if (table.className) { table.className = table.className.replace(/regularBackground/, 'anomalyBackground'); } } var cells = imageCell.getElementsByTagName('td') for (var k=0; k<cells.length; k++) { var cell = cells[k]; if (cell.className) { cell.className = cell.className.replace(/regularBackground/, 'anomalyBackground'); } } } } } } this.loadAllImages(); }
function LASSlideSorter_switchMode(mode) { if (mode == 0) { // Switch things back to 'Regular mode' this.anomalyMode = 0; var table = document.getElementById('LSS_controlTable'); table.className = table.className.replace(/anomalyBackground/, 'regularBackground'); var cell = document.getElementById('LSS_modeCell'); cell.className = cell.className.replace(/regularBackground/, 'anomalyBackground'); var anchor = document.getElementById('LSS_modeAnchor'); anchor.setAttribute('href','javascript: LSS.switchMode(1)'); anchor.firstChild.nodeValue = 'to Anomaly mode'; for (var i=1; i<=this.numRows; i++) { for (var j=1; j<=this.numCols; j++) { if (i != 1 || j != 1) { var id_text = 'LSS_imageCell' + i + j; var imageCell = document.getElementById(id_text); var tables = imageCell.getElementsByTagName('table') for (var k=0; k<tables.length; k++) { var table = tables[k]; if (table.className) { table.className = table.className.replace(/anomalyBackground/, 'regularBackground'); } } var cells = imageCell.getElementsByTagName('td') for (var k=0; k<cells.length; k++) { var cell = cells[k]; if (cell.className) { cell.className = cell.className.replace(/anomalyBackground/, 'regularBackground'); } } } } } } else { // Switch things to 'Anomaly mode' this.anomalyMode = 1; var table = document.getElementById('LSS_controlTable'); table.className = table.className.replace(/regularBackground/, 'anomalyBackground'); var cell = document.getElementById('LSS_modeCell'); cell.className = cell.className.replace(/anomalyBackground/, 'regularBackground'); var anchor = document.getElementById('LSS_modeAnchor'); anchor.setAttribute('href','javascript: LSS.switchMode(0)'); anchor.firstChild.nodeValue = 'to Regular mode'; for (var i=1; i<=this.numRows; i++) { for (var j=1; j<=this.numCols; j++) { if (i != 1 || j != 1) { var id_text = 'LSS_imageCell' + i + j; var imageCell = document.getElementById(id_text); var tables = imageCell.getElementsByTagName('table') for (var k=0; k<tables.length; k++) { var table = tables[k]; if (table.className) { table.className = table.className.replace(/regularBackground/, 'anomalyBackground'); } } var cells = imageCell.getElementsByTagName('td') for (var k=0; k<cells.length; k++) { var cell = cells[k]; if (cell.className) { cell.className = cell.className.replace(/regularBackground/, 'anomalyBackground'); } } } } } } this.loadAllImages(); }
JavaScript
function LASSlideSorter_imgComplete(e) { // Cross-browser discovery of the event target // By Stuart Landridge in "DHTML Utopia ..." // NOTE: 'load' events require 'e.currentTarget' instead of 'e.target'. var target; if (window.event && window.event.srcElement) { target = window.event.srcElement; } else if (e && e.currentTarget) { target = e.currentTarget; } else { alert('LASSlideSorter ERROR:\n> selectChange: This browser does not support standard javascript events.'); return; } // TODO: use style sheet properties instead of hardcoding the color var Img = target; var currentBackground = 'regularBackground'; if (this.anomalyMode == 1) { currentBackground = 'anomlyBackground'; } var ContentCell = Img.parentNode.parentNode.parentNode.parentNode.parentNode; ContentCell.className = ContentCell.className.replace(/downloadingBackground/,currentBackground); Img.aGif.style.visibility = 'hidden'; }
function LASSlideSorter_imgComplete(e) { // Cross-browser discovery of the event target // By Stuart Landridge in "DHTML Utopia ..." // NOTE: 'load' events require 'e.currentTarget' instead of 'e.target'. var target; if (window.event && window.event.srcElement) { target = window.event.srcElement; } else if (e && e.currentTarget) { target = e.currentTarget; } else { alert('LASSlideSorter ERROR:\n> selectChange: This browser does not support standard javascript events.'); return; } // TODO: use style sheet properties instead of hardcoding the color var Img = target; var currentBackground = 'regularBackground'; if (this.anomalyMode == 1) { currentBackground = 'anomlyBackground'; } var ContentCell = Img.parentNode.parentNode.parentNode.parentNode.parentNode; ContentCell.className = ContentCell.className.replace(/downloadingBackground/,currentBackground); Img.aGif.style.visibility = 'hidden'; }
JavaScript
function LASSlideSorter_cellWidgetChoice(Widget) { var i = Number(Widget.element_id.charAt(10)); var j = Number(Widget.element_id.charAt(11)); var LSS = document.LSS; if (LSS.anomalyMode == 1 && i == 1 && j == 1) { document.LSS.loadAllImages(); } else { LSS.loadContentCell(i,j); } }
function LASSlideSorter_cellWidgetChoice(Widget) { var i = Number(Widget.element_id.charAt(10)); var j = Number(Widget.element_id.charAt(11)); var LSS = document.LSS; if (LSS.anomalyMode == 1 && i == 1 && j == 1) { document.LSS.loadAllImages(); } else { LSS.loadContentCell(i,j); } }
JavaScript
function LASSlideSorter_radioChoice(e) { // Cross-browser discovery of the event target // By Stuart Landridge in "DHTML Utopia ..." var target; if (window.event && window.event.srcElement) { target = window.event.srcElement; } else if (e && e.target) { target = e.target; } else { alert('LASSlideSorter ERROR:\n> selectChange: This browser does not support standard javascript events.'); return; } var Radio = target; var menuName = Radio.value; var LSS = Radio.LSS; // Create new select objects for each cell LSS.createCellWidgets(menuName); LSS.chosenMenuName = menuName; // Dis/en-able Global selects so that only those // 'orthogonal' to the rows and columns are available. var i = 0; for (var menuName in LSS.InitObject) { // NOTE: json.js breaks for loops by adding the toJSONString() method. // NOTE: See: http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ if (typeof LSS.InitObject[menuName] !== 'function') { var num = i+1; var widget_id = "basicWidgetCell" + num; var title_id = "basicTitleCell" + num; var radio_id = "basicRadioButton" + num; var Widget = LSS.Widgets[widget_id]; var Title = document.getElementById(title_id); var Radio = document.getElementById(radio_id); if (Radio.checked) { Widget.disable(); Title.firstChild.nodeValue = 'Compare ' + LSS.InitObject[menuName].title; Title.style.fontWeight = "bold"; Title.style.color = "#D33"; } else { Widget.enable(); Title.firstChild.nodeValue = LSS.InitObject[menuName].title; Title.style.fontWeight = "normal"; Title.style.color = "#000"; } i++; } } LSS.loadAllImages(); }
function LASSlideSorter_radioChoice(e) { // Cross-browser discovery of the event target // By Stuart Landridge in "DHTML Utopia ..." var target; if (window.event && window.event.srcElement) { target = window.event.srcElement; } else if (e && e.target) { target = e.target; } else { alert('LASSlideSorter ERROR:\n> selectChange: This browser does not support standard javascript events.'); return; } var Radio = target; var menuName = Radio.value; var LSS = Radio.LSS; // Create new select objects for each cell LSS.createCellWidgets(menuName); LSS.chosenMenuName = menuName; // Dis/en-able Global selects so that only those // 'orthogonal' to the rows and columns are available. var i = 0; for (var menuName in LSS.InitObject) { // NOTE: json.js breaks for loops by adding the toJSONString() method. // NOTE: See: http://yuiblog.com/blog/2006/09/26/for-in-intrigue/ if (typeof LSS.InitObject[menuName] !== 'function') { var num = i+1; var widget_id = "basicWidgetCell" + num; var title_id = "basicTitleCell" + num; var radio_id = "basicRadioButton" + num; var Widget = LSS.Widgets[widget_id]; var Title = document.getElementById(title_id); var Radio = document.getElementById(radio_id); if (Radio.checked) { Widget.disable(); Title.firstChild.nodeValue = 'Compare ' + LSS.InitObject[menuName].title; Title.style.fontWeight = "bold"; Title.style.color = "#D33"; } else { Widget.enable(); Title.firstChild.nodeValue = LSS.InitObject[menuName].title; Title.style.fontWeight = "normal"; Title.style.color = "#000"; } i++; } } LSS.loadAllImages(); }
JavaScript
function LASGetViewsResponse(JSONObject) { this.response = JSONObject; if(!this.response) return false; // Add methods to this object this.getAllViews = LASGetViewsResponse_getAllViews; this.getViewCount = LASGetViewsResponse_getViewCount; this.getView = LASGetViewsResponse_getView; this.getViewID = LASGetViewsResponse_getViewID; this.getViewByID = LASGetViewsResponse_getViewByID; this.getViewName = LASGetViewsResponse_getViewName; }
function LASGetViewsResponse(JSONObject) { this.response = JSONObject; if(!this.response) return false; // Add methods to this object this.getAllViews = LASGetViewsResponse_getAllViews; this.getViewCount = LASGetViewsResponse_getViewCount; this.getView = LASGetViewsResponse_getView; this.getViewID = LASGetViewsResponse_getViewID; this.getViewByID = LASGetViewsResponse_getViewByID; this.getViewName = LASGetViewsResponse_getViewName; }
JavaScript
function LASGetViewsResponse_getAllViews() { if(this.response.views.view) return this.response.views.view; else return null; }
function LASGetViewsResponse_getAllViews() { if(this.response.views.view) return this.response.views.view; else return null; }
JavaScript
function LASGetViewsResponse_getViewByID(id) { for(var i=0;i<this.getViewCount();i++) { if(this.getView(i).value == id) return this.getView(i); } return null; }
function LASGetViewsResponse_getViewByID(id) { for(var i=0;i<this.getViewCount();i++) { if(this.getView(i).value == id) return this.getView(i); } return null; }
JavaScript
function LASGetGridResponse(response) { /** * LAS Grid object returned by the getGrid.do request. */ this.response = response; // Add methods to this object this.hasAxis = LASGetGridResponse_hasAxis; this.hasArange = LASGetGridResponse_hasArange; this.hasMenu = LASGetGridResponse_hasMenu; this.hasView = LASGetGridResponse_hasView; this.getAxis = LASGetGridResponse_getAxis; this.getLo = LASGetGridResponse_getLo; this.getHi = LASGetGridResponse_getHi; this.getDelta = LASGetGridResponse_getDelta; this.getSize = LASGetGridResponse_getSize; this.getUnits = LASGetGridResponse_getUnits; this.getID = LASGetGridResponse_getID; this.getMinuteInterval = LASGetGridResponse_getMinuteInterval; this.getDisplayType = LASGetGridResponse_getDisplayType; this.getRenderFormat = LASGetGridResponse_getRenderFormat; this.getMenu = LASGetGridResponse_getMenu; // Check for incomplete LASGetGridResponse. if (response == null) { var error_string = 'getGrid.do returned a null response.'; throw(error_string); } else { if (response.status != 'ok') { var error_string = response.error ? response.error : 'Unknown error in LASGetGridResponse.'; throw(error_string); } } }
function LASGetGridResponse(response) { /** * LAS Grid object returned by the getGrid.do request. */ this.response = response; // Add methods to this object this.hasAxis = LASGetGridResponse_hasAxis; this.hasArange = LASGetGridResponse_hasArange; this.hasMenu = LASGetGridResponse_hasMenu; this.hasView = LASGetGridResponse_hasView; this.getAxis = LASGetGridResponse_getAxis; this.getLo = LASGetGridResponse_getLo; this.getHi = LASGetGridResponse_getHi; this.getDelta = LASGetGridResponse_getDelta; this.getSize = LASGetGridResponse_getSize; this.getUnits = LASGetGridResponse_getUnits; this.getID = LASGetGridResponse_getID; this.getMinuteInterval = LASGetGridResponse_getMinuteInterval; this.getDisplayType = LASGetGridResponse_getDisplayType; this.getRenderFormat = LASGetGridResponse_getRenderFormat; this.getMenu = LASGetGridResponse_getMenu; // Check for incomplete LASGetGridResponse. if (response == null) { var error_string = 'getGrid.do returned a null response.'; throw(error_string); } else { if (response.status != 'ok') { var error_string = response.error ? response.error : 'Unknown error in LASGetGridResponse.'; throw(error_string); } } }
JavaScript
function LASGetGridResponse_getAxis(axis) { var axis_lc = String(axis).toLowerCase(); var value = null; for (var i=0;i<this.response.grid.axis.length; i++) { if(this.response.grid.axis[i].type==axis_lc) value = this.response.grid.axis[i]; } return value; }
function LASGetGridResponse_getAxis(axis) { var axis_lc = String(axis).toLowerCase(); var value = null; for (var i=0;i<this.response.grid.axis.length; i++) { if(this.response.grid.axis[i].type==axis_lc) value = this.response.grid.axis[i]; } return value; }
JavaScript
function LASGetGridResponse_hasAxis(axis) { var axis_lc = String(axis).toLowerCase(); var value = false; if (this.getAxis(axis_lc)) { value = true; } return value; }
function LASGetGridResponse_hasAxis(axis) { var axis_lc = String(axis).toLowerCase(); var value = false; if (this.getAxis(axis_lc)) { value = true; } return value; }
JavaScript
function LASGetGridResponse_hasArange(axis) { var axis_lc = String(axis).toLowerCase(); var value = false; if(this.hasAxis(axis_lc)) { if (this.getAxis(axis_lc).arange) { value = true; } } return value; }
function LASGetGridResponse_hasArange(axis) { var axis_lc = String(axis).toLowerCase(); var value = false; if(this.hasAxis(axis_lc)) { if (this.getAxis(axis_lc).arange) { value = true; } } return value; }