Skip to content

Commit

Permalink
ogf r12.1
Browse files Browse the repository at this point in the history
  • Loading branch information
theo-armour committed Oct 17, 2016
1 parent 4e5cb21 commit c1384f5
Show file tree
Hide file tree
Showing 45 changed files with 4,823 additions and 799 deletions.
34 changes: 33 additions & 1 deletion core4/0-cor-core4/cor-core4-r1.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@

// reset what needs resetting

COR.nearby = [];
// COR.nearby = [];
COR.placards = [];

keys = Object.keys( COR.defaults );
Expand All @@ -423,3 +423,35 @@
xhr.send( null );

}

// http://stackoverflow.com/questions/1669190/javascript-min-max-array-values

COR.arrayMin = function( arr ) {

var len = arr.length, min = Infinity;

while ( len-- ) {

if ( arr[ len ] < min) { min = arr[ len ]; }

}

return min;

};


COR.arrayMax = function( arr ) {

var len = arr.length, max = -Infinity;

while ( len-- ) {

if (arr[len] > max) { max = arr[len]; }

}

return max;

};

3 changes: 3 additions & 0 deletions core4/0-def-defaults4/def-defaults4-r1.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
'</small></div>';
*/




DEF.objectName = 'defaults';

DEF.repo = 'terrain3';
Expand Down
226 changes: 226 additions & 0 deletions core4/0-sel-select4/sel-select4-r1-00.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,226 @@
// Copyright &copy; 2016 Jaanga authors. MIT License

var SEL = {};


/*
SEL.folders = [
'elevations-airports-01',
'elevations-data-04',
'elevations-data-family+friends',
'elevations-data-oakland-gran-fondo',
'elevations-data-path-json',
'elevations-data-tgif',
'test'
];
SEL.defaultFolder = 1;
// more visible in HTML
// add user and branch
SEL.urlAPITreeContents = 'https://api.github.com/repos/jaanga/terrain3/git/trees/gh-pages?recursive=1';
// SEL.defaultFile = '../../elevations/elevations-data-04/san-francisco_10_163_394_3_3_450_450_.json';
SEL.defaultFile; // if no default, select a random file
SEL.searchInFolder = 'elevations-data-04/';
SEL.searchInFolder = SEL.folders[ SEL.defaultFolder ];
SEL.extension = '.json';
// SEL.urlBase = '../../elevations-data/';
SEL.urlBase = 'https://jaanga.github.io/terrain3/elevations-data/';
*/


SEL.getMenuDetailsSelectFile = function() {

var menuDetailsSelectFile =

'<details id=SELdetailsSelectFile >' +

'<summary id=SELmenuSummary ><h3>Select file to view</h3></summary>' +

'<small id=SELmenuSummaryTagline >Select or open a file to view in 3D</small>' +

'<p id=SELpFolder >' +
'<select id=SELselFolder onchange=SEL.searchInFolder=this.value;SEL.getFiles(); ></select>' +
'</p>' +

'<p>' +
'<select id=SELselFiles onchange=SEL.getJSONFileXHR(SEL.urlBase+SEL.searchInFolder+"/"+this.value); size=12 style=width:100% ></select>' +
'</p>' +

'<p><input type=file id=SELinpFile onchange=SEL.getJSONFileReader(this); /></p>' + b +

'</details>' +

'';

return menuDetailsSelectFile;

}


SEL.getFolders = function() {

for ( var i = 0; i < SEL.folders.length; i++ ) {

SELselFolder[ i ] = new Option( SEL.folders[ i ] );

}

SELselFolder.selectedIndex = SEL.defaultFolder;

}


SEL.getGitHubAPITreeContents = function() {

var xhr, response, files, file;

SEL.getFolders();

xhr = new XMLHttpRequest();
xhr.open( 'GET', SEL.urlAPITreeContents, true );
xhr.onload = onLoadGitHubTreeContents;
xhr.send( null );

function onLoadGitHubTreeContents() {

SEL.response = JSON.parse( xhr.response );
SEL.extension = SEL.extension || '.json';
SEL.getFiles();

}

}


SEL.getFiles = function() {

SEL.files = [];
SELselFiles.innerHTML = ''

for ( var i = 0; i < SEL.response.tree.length; i++ ) {

file = SEL.response.tree[ i ].path;

if ( !file.includes( SEL.searchInFolder ) ) { continue; }
if ( !file.includes( SEL.extension ) ) { continue; }

file = file.split( '\/' ).pop();

SEL.files.push( file );

SELselFiles[ SELselFiles.length ] = new Option( file, file );

}

SEL.onGitHubTreeLoad();

}


SEL.onGitHubTreeLoad = function() {

// remember that COR.place may have been created by an iframe parent or previous window

var file;

if ( COR.place === undefined ) {

SELselFiles.selectedIndex = Math.floor( Math.random() * SELselFiles.length );

file = SEL.defaultFile ? SEL.defaultFile : SEL.urlBase + SEL.searchInFolder + '/' + SELselFiles.value;

SELselFiles.selectedIndex = SEL.defaultFile ? -1 : SELselFiles.selectedIndex;

SEL.getJSONFileXHR( file );

} else {

SELselFiles.selectedIndex = -1;

}

}


// Gather data when using the default

SEL.getJSONFileXHR = function( fName ) {

console.time( 'timer0' );

var xhr;

xhr = new XMLHttpRequest();
xhr.open( 'GET', fName, true );
xhr.onload = function callbackXHR() {

// SEL.fileJSON = JSON.parse( xhr.responseText );
COR.place = JSON.parse( xhr.responseText );

COR.fileName = fName.split( '/' ).pop();

location.hash = 'file=' + fName;

COR.onLoadJSONFile();

};

xhr.send( null );

}



// gather the data using file open dialog

SEL.getJSONFileReader = function( files ) {

console.time( 'timer0' );

var reader;

reader = new FileReader();
reader.onload = function( event ) {

// SEL.fileJSON = JSON.parse( reader.result );
COR.place = JSON.parse( reader.result );

// TERoutVertical.value = TERinpVertical.value = COR.place.verticalScale;

COR.fileName = files.files[ 0 ].name;

COR.onLoadJSONFile();

};

reader.readAsText( files.files[ 0 ] );

}



/*
// more visible and editable when it's in the HTML file
COR.onLoadJSONFile = function() {
COR.getPlaceDefaults();
console.log( 'file loaded', SEL.fileName );
}
*/


7 changes: 3 additions & 4 deletions core4/0-sel-select4/sel-select4-r1.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,18 @@

b;

SELdetailsSelectFile.setAttribute( 'open', 'open' );

if ( window.self !== window.top ) { hamburger.style.left = '0px'; }

SEL.getGitHubAPITreeContents();

SELdetailsSelectFile.setAttribute('open', 'open');


}


//

COR.onLoadJSONFile = function() {
SEL.onLoadJSONFile = function() {

COR.getPlaceDefaults();

Expand Down
Loading

0 comments on commit c1384f5

Please sign in to comment.