diff --git a/client/bundle-es5.js b/client/bundle-es5.js index e1302af678f1bec7b540b3ea70c4ae97d6e879e9..1b348db0d609338e89c1d3b9ae04f76157e062e4 100644 --- a/client/bundle-es5.js +++ b/client/bundle-es5.js @@ -11,12 +11,49 @@ /******/__webpack_require__.c=installedModules;/******/// __webpack_public_path__ /******/__webpack_require__.p="";/******/// Load entry module and return exports /******/return __webpack_require__(0);/******/})(/************************************************************************//******/[/* 0 *//***/function(module,exports,__webpack_require__){"use strict";// main.js -var util=__webpack_require__(1);var LoadingPopup=__webpack_require__(3);var PubSub=__webpack_require__(4);var Router=__webpack_require__(5);var MaterialMod=__webpack_require__(6);var SearchModule=__webpack_require__(29);var UserGuidance=__webpack_require__(30);var contentElement=document.getElementById("content");var titleElement=document.querySelector('title');var Breadcrumb=function(){function Breadcrumb(){_classCallCheck(this,Breadcrumb);this.element=document.querySelector('#breadcrumb-placeholder');this.element.innerHTML="\n\t <span class=\"goto-page Search\">Search</span>\n\t <span class=\"goto-page Results\"> > <span>Results</span></span>\n\t <span class=\"goto-page Overview\"> > <span>Overview</span></span>\n\t <span class=\"Details\"> > <span>Details</span></span>\n\t ";this.resultsSel=this.element.querySelector('.Results');this.overviewSel=this.element.querySelector('.Overview');this.detailsSel=this.element.querySelector('.Details');// Events -this.element.querySelector('.Search').addEventListener("click",function(e){util.setBrowserHashPath('search');});this.resultsSel.addEventListener("click",function(e){util.setBrowserHashPath('search/results');});this.overviewSel.addEventListener('click',function(){util.setBrowserHashPath('material',util.materialId);});}_createClass(Breadcrumb,[{key:"setState",value:function setState(appModule,param){if(appModule==='search'){this.overviewSel.style.display='none';this.detailsSel.style.display='none';this.resultsSel.style.display='inline';if(param==='results')this.element.style.visibility='visible';else this.element.style.visibility='hidden';}else if(appModule==='material'){this.element.style.visibility='visible';this.overviewSel.style.display='inline';this.resultsSel.style.display=util.searchResults?'inline':'none';if(param===undefined){// Overview page +var util=__webpack_require__(1);var LoadingPopup=__webpack_require__(3);var FlaggingFormPopup=__webpack_require__(34);var PubSub=__webpack_require__(4);var Router=__webpack_require__(5);var MaterialMod=__webpack_require__(6);var SearchModule=__webpack_require__(29);var UserGuidance=__webpack_require__(30);var DataStore=__webpack_require__(2);var contentElement=document.getElementById("content");var titleElement=document.querySelector('title');/*** User authentication **/var userNameElement=document.querySelector('#user-name');var logoutButton=document.querySelector('#logout-button');// When the app loads, it checks if the user is authenticated +var oReq=util.authServerReq('saml/user/',function(e){var jsonData=void 0;try{jsonData=JSON.parse(oReq.responseText);//JSON.parse(response); // +}catch(e){console.log('../saml/user/ json response bad format',e);}if(jsonData.status==='Authenticated'){userNameElement.innerHTML=jsonData.user.username;document.querySelector('#guest-user').style.display='none';document.querySelector('#auth-user').style.display='inline';util.setAuthRequestHeader(jsonData.user.username,jsonData.token.data);//flaggingTab.style.visibility = 'visible'; +}});// Logout +logoutButton.addEventListener("click",function(e){util.authServerReq('saml/logout/',function(e){});//console.log('Logging out ',userNameElement.innerHTML); +userNameElement.innerHTML='';document.querySelector('#guest-user').style.display='inline';document.querySelector('#auth-user').style.display='none';util.setAuthRequestHeader();//flaggingTab.style.visibility = 'hidden'; +});/* An exception is launched, so this code after the response arrives is not executed + oReq1.addEventListener("load", e => { + console.log('Logging out ',userNameElement.innerHTML); + //location.reload(true); + userNameElement.innerHTML = ''; + document.querySelector('#guest-user').style.display = 'inline'; + document.querySelector('#auth-user').style.display = 'none'; + util.setAuthRequestHeader(); + }); + *//*** Popup code + + let loginButton = document.querySelector('#login-button'); + let params = `width=400,height=600,left=600,top=100`; + loginButton.addEventListener( "click", e => { + let loginWindow; + // I think it's a blocking call + loginWindow = window.open('http://enc-testing-nomad.esc.rzg.mpg.de/v1.0/saml/', 'Login', params); + console.log("loginWindow", loginWindow); + loginWindow.addEventListener("focus", function(event) { + console.log("focus", loginWindow, loginWindow.document); + }); + + loginWindow.addEventListener("unload", function(event) { + console.log("unload", loginWindow, loginWindow.document.firstChild); + //loginWindow.close(); + }); + //location.reload(true); + }); + *//*************************/var flaggingTab=document.getElementById('calc-flagging-tab');var top=(window.innerHeight-flaggingTab.getBoundingClientRect().height)/2;flaggingTab.style.top=top+'px';//calcFlaggingTab.style.visibility = 'visible'; +flaggingTab.addEventListener('click',function(e){FlaggingFormPopup.show();});/**************************/var Breadcrumb=function(){function Breadcrumb(){_classCallCheck(this,Breadcrumb);this.element=document.querySelector('#breadcrumb-placeholder');this.element.innerHTML="\n\t <span class=\"goto-page Search\">Search</span>\n\t <span class=\"goto-page Results\"> > <span>Results</span></span>\n\t <span class=\"goto-page Overview\"> > <span>Overview</span></span>\n\t <span class=\"Details\">\n\t > \n\t <select class=\"details-dropdown\" >\n\t <option value=\"structure\">Structure Details</option>\n\t <option value=\"electronicstruct\">Electronic structure Details</option>\n\t <option value=\"methodology\">Methodology Details</option>\n\t <option value=\"thermalprops\">Thermal Properties Details</option>\n\t <!-- elasticconst-->\n\t </select>\n\t </span>\n\t ";this.resultsSel=this.element.querySelector('.Results');this.overviewSel=this.element.querySelector('.Overview');this.detailsSel=this.element.querySelector('.Details');this.detailsDropDown=this.element.querySelector('.details-dropdown');// Events +this.element.querySelector('.Search').addEventListener("click",function(e){util.setBrowserHashPath('search');});this.resultsSel.addEventListener("click",function(e){util.setBrowserHashPath('search/results');});this.overviewSel.addEventListener('click',function(){util.setBrowserHashPath('material',util.materialId);});this.detailsDropDown.addEventListener('change',function(e){util.setBrowserHashPath('material',DataStore.getMaterialData().id+'/'+e.target.value);});var self=this;function adjustDropdownOptions(){//console.log('FAOCUS'); +var esOption=self.detailsDropDown.querySelector('option[value="electronicstruct"]');if(!DataStore.hasElecStructureData)self.detailsDropDown.removeChild(esOption);var thOption=self.detailsDropDown.querySelector('option[value="thermalprops"]');if(!DataStore.hasThermalData)self.detailsDropDown.removeChild(thOption);// Remove because we want it's executed once +self.detailsDropDown.removeEventListener('focus',adjustDropdownOptions);}this.detailsDropDown.addEventListener('focus',adjustDropdownOptions);}_createClass(Breadcrumb,[{key:"setState",value:function setState(appModule,param){if(appModule==='search'){this.overviewSel.style.display='none';this.detailsSel.style.display='none';this.resultsSel.style.display='inline';if(param==='results')this.element.style.visibility='visible';else this.element.style.visibility='hidden';}else if(appModule==='material'){this.element.style.visibility='visible';this.overviewSel.style.display='inline';this.resultsSel.style.display=util.searchResults?'inline':'none';if(param===undefined){// Overview page this.detailsSel.style.display='none';}else{// Details page -this.detailsSel.style.display='inline';switch(param){case'structure':this.detailsSel.lastChild.innerHTML='Structure Details';break;case'electronicstruct':this.detailsSel.lastChild.innerHTML='Electronic Structure Details';break;case'methodology':this.detailsSel.lastChild.innerHTML='Methodology Details';break;case'thermalprops':this.detailsSel.lastChild.innerHTML='Thermal Properties Details';break;case'elasticconst':this.detailsSel.lastChild.innerHTML='Elastic Constants Details';}}}this.setBoldLabel(appModule,param);}// setState -},{key:"setBoldLabel",value:function setBoldLabel(appModule,param){var currentPage=this.element.querySelector('.current-page');if(currentPage!==null)currentPage.className='';if(param==='results')this.resultsSel.lastChild.className='current-page';else appModule==='material';if(param===undefined)this.overviewSel.lastChild.className='current-page';else this.detailsSel.lastChild.className='current-page';}}]);return Breadcrumb;}();// class Breadcrumb -var breadcrumb=new Breadcrumb();var searchMod=void 0;var MaterialModule=void 0;var materialModDOM=void 0;var currentModule=void 0;// current module DOM being shown +this.detailsSel.style.display='inline';this.detailsDropDown.value=param;}}}// setState +}]);return Breadcrumb;}();// class Breadcrumb +/*****************************/var breadcrumb=new Breadcrumb();var searchMod=void 0;var MaterialModule=void 0;var materialModDOM=void 0;var currentModule=void 0;// current module DOM being shown function showModuleDOM(module){if(currentModule)contentElement.removeChild(currentModule);currentModule=module;contentElement.appendChild(currentModule);}/****** App level events *************/PubSub.subscribe('show-material',function(data){console.log('Handling event show-material: '+data.id+' view: '+data.view);//titleElement.innerHTML = 'NOMAD Encyclopedia - Material '+data.id; breadcrumb.setState('material',data.view);if(typeof materialModDOM==='undefined'){MaterialModule=new MaterialMod();materialModDOM=MaterialModule.element;}MaterialModule.setMaterialView(data);showModuleDOM(materialModDOM);// In case the app comes from the search module through the url (back button) UserGuidance.show(false);});PubSub.subscribe('show-search',function(search){console.log('Handling event show-search: '+search);titleElement.innerHTML='NOMAD Encyclopedia - Search';breadcrumb.setState('search',search);if(search===undefined){searchMod.showSearchPage();LoadingPopup.hide();// In case it comes from the result page @@ -24,7 +61,7 @@ UserGuidance.show(false);});PubSub.subscribe('show-search',function(search){cons if(document.location.hash==='')document.location+="#/search";Router.route();/***/},/* 1 *//***/function(module,exports,__webpack_require__){"use strict";var DataStore=__webpack_require__(2);//let LoadingPopup = require('./LoadingPopup.js'); // global state vars var materialId=null;var searchResults=false;var IMAGE_DIR='img/';var API_HOST='http://enc-testing-nomad.esc.rzg.mpg.de/';if(document.location.href.indexOf('nomad-coe.eu')>0)API_HOST='https://encyclopedia-api.nomad-coe.eu/';//HOST= 'http://localhost:8080/'; -console.log('API host: ',API_HOST);var API_BASE_URL=API_HOST+'v1.0/';var AUTH_REQUEST_HEADER_VALUE='Basic '+btoa('eyJhbGciOiJIUzI1NiIsImlhdCI6MTQ5MjA3MDI5MCwiZXhwIjoxNTIzNjI3ODkwfQ.ey'+'JpZCI6ImVuY2d1aSJ9.oXYwGrLHRxdvKRal1NaAJJ5tCVTDupB5SjAGTtJVDKU:');// Mockup URLs +console.log('API host: ',API_HOST);var API_BASE_URL=API_HOST+'v1.0/';var AUTH_REQUEST_HEADER_GUEST_USER='Basic '+btoa('eyJhbGciOiJIUzI1NiIsImlhdCI6MTQ5MjA3MDI5MCwiZXhwIjoxNTIzNjI3ODkwfQ.ey'+'JpZCI6ImVuY2d1aSJ9.oXYwGrLHRxdvKRal1NaAJJ5tCVTDupB5SjAGTtJVDKU:');// Mockup URLs //const FERMI_SURFACE_URL= HOST+'files/fermi/'+ //'fed3fa9fbc68aa6c5e51845396889666ca37bb2e626e1da53.x3d'; var BAND_STRUCT_EXAMPLE_URL=API_BASE_URL+'materials/108541/calculations/290737';var MAT_VIEW={'structure':'structure','electronicstruct':'electronicstruct','methodology':'methodology','thermalprops':'thermalprops','elasticconst':'elasticconst'};var ELEMENTS=['H','He','Li','Be','B','C','N','O','F','Ne','Na','Mg','Al','Si',// Si = 14 @@ -36,12 +73,18 @@ var BAND_STRUCT_EXAMPLE_URL=API_BASE_URL+'materials/108541/calculations/290737'; 'Tl','Pb','Bi','Po','At','Rn','Fr','Ra','Ac','Th','Pa','U','Np',// Np = 93 'Pu','Am','Cm','Bk','Cf','Es','Fm','Md','No','Lr','Rf','Ha','Sg',// sg = 106 'Ns','Hs','Mt','Ds','Rg','Cn','Nh','Fl','Mc','Lv','Ts','Og'// Mt = 109 -];function serverReq(url,callback){var oReq=new XMLHttpRequest();oReq.addEventListener("load",callback);oReq.open("GET",url);oReq.setRequestHeader('Authorization',AUTH_REQUEST_HEADER_VALUE);oReq.send();return oReq;}function serverReqPOST(url,data,callback){var oReq=new XMLHttpRequest();oReq.addEventListener('load',callback);oReq.open('POST',url);oReq.setRequestHeader('Content-Type','application/json');oReq.setRequestHeader('Authorization',AUTH_REQUEST_HEADER_VALUE);oReq.send(data);return oReq;}function getSubscriptedFormula(formula){var finalFormula='';// 'elementCode' : number +];var authRequestHeaderValue=AUTH_REQUEST_HEADER_GUEST_USER;//console.log('user: ANONYMOUS authRequestHeader: ',authRequestHeaderValue); +function authServerReq(url,callback){var oReq=new XMLHttpRequest();oReq.addEventListener("load",callback);oReq.open("GET",API_BASE_URL+url);oReq.send();return oReq;}function setAuthRequestHeader(user,value){if(value===undefined){// default value +authRequestHeaderValue=AUTH_REQUEST_HEADER_GUEST_USER;//console.log('user: ANONYMOUS authRequestHeader: ',authRequestHeaderValue); +}else{authRequestHeaderValue='Basic '+btoa(value+':');//console.log('user',user,'authRequestHeader: ',authRequestHeaderValue); +}}function serverReq(url,callback){var oReq=new XMLHttpRequest();oReq.addEventListener("load",callback);oReq.open("GET",url);//console.log('authRequestHeaderValue: ',authRequestHeaderValue); +oReq.setRequestHeader('Authorization',authRequestHeaderValue);oReq.send();return oReq;}function serverReqPOST(url,data,callback){var oReq=new XMLHttpRequest();oReq.addEventListener('load',callback);oReq.open('POST',url);oReq.setRequestHeader('Content-Type','application/json');//console.log('authRequestHeaderValue: ',authRequestHeaderValue); +oReq.setRequestHeader('Authorization',authRequestHeaderValue);oReq.send(data);return oReq;}function getSubscriptedFormula(formula){var finalFormula='';// 'elementCode' : number for(var i=0;i<formula.length;i++){if(formula.charCodeAt(i)>=47&&formula.charCodeAt(i)<58)finalFormula+='<sub>'+formula[i]+'</sub>';else finalFormula+=formula[i];//console.log(formula.charCodeAt(i) + " "+finalFormula); }return finalFormula;}function getSearchURL(){return API_BASE_URL+'materials';}function getSuggestionURL(quantity){return API_BASE_URL+'suggestions?property='+quantity;}function getMaterialURL(matId){return API_BASE_URL+'materials/'+matId;//'/materials/matid'; // }function getMaterialCalcURL(matId,calcId){var property=arguments.length<=2||arguments[2]===undefined?'':arguments[2];var propertyString=property===''?'':'?property='+property;return API_BASE_URL+'materials/'+matId+'/calculations/'+calcId+propertyString;}function getMaterialXsURL(what,matId){return API_BASE_URL+'materials/'+matId+'/'+what+'?pagination=off';//page=1&per_page=5000';//'/materials/calculations';// }function getCalcEnergiesURL(matId,calcId){return API_BASE_URL+'materials/'+matId+'/calculations/'+calcId+'/energies';//'/materials/calculations';// -}// Launch an app event +}function getFlaggingURL(){return API_BASE_URL+'flagme';}// Launch an app event function setBrowserHashPath(modulePath,finalPath){if(typeof finalPath==='undefined')document.location='#/'+modulePath;else document.location='#/'+modulePath+'/'+finalPath;}function loadLib(url){var script=document.createElement('script');script.setAttribute('type','text/javascript');script.setAttribute('src',url);document.getElementsByTagName('head')[0].appendChild(script);}function getNumberArray(string){var sArray=string.substring(1,string.length-1).split(',');var fArray=[];for(var i=0;i<sArray.length;i++){fArray.push(parseFloat(sArray[i]));}//console.log('getNumberArray.SPLIT: '+fArray); return fArray;}function getCellDataForViewer(matData){var cellData={};cellData.normalizedCell=[getNumberArray(matData.cell.a),getNumberArray(matData.cell.b),getNumberArray(matData.cell.c)];cellData.periodicity=JSON.parse(matData.periodicity);cellData.labels=[];cellData.positions=[];for(var i=0;i<matData.elements.length;i++){cellData.labels.push(matData.elements[i].label);cellData.positions.push(getNumberArray(matData.elements[i].position));}return cellData;}function J2eV(energy){var result=energy/1.602176565e-19;if(result<0.01)return result.toFixed(6);else return result.toFixed(3);}function eV2J(energy){return energy*1.602176565e-19;}/* function getBandGapStatsValue(calcs){ @@ -88,7 +131,7 @@ exp=exp<0?0:exp;return[stepArray,exp];}/* //console.log('TEMPORARY PATCH is2DSystem:', DataStore.getMaterialData()); return DataStore.getMaterialData().system_type === '2D'; } - */module.exports={searchResults:searchResults,materialId:materialId,AUTH_REQUEST_HEADER_VALUE:AUTH_REQUEST_HEADER_VALUE,MAT_VIEW:MAT_VIEW,IMAGE_DIR:IMAGE_DIR,ELEMENTS:ELEMENTS,serverReq:serverReq,serverReqPOST:serverReqPOST,getSearchURL:getSearchURL,getSuggestionURL:getSuggestionURL,getMaterialURL:getMaterialURL,getMaterialCalcURL:getMaterialCalcURL,getMaterialXsURL:getMaterialXsURL,getCalcEnergiesURL:getCalcEnergiesURL,setBrowserHashPath:setBrowserHashPath,loadLib:loadLib,getNumberArray:getNumberArray,getCellDataForViewer:getCellDataForViewer,//FERMI_SURFACE_URL: FERMI_SURFACE_URL, + */module.exports={searchResults:searchResults,materialId:materialId,MAT_VIEW:MAT_VIEW,IMAGE_DIR:IMAGE_DIR,ELEMENTS:ELEMENTS,setAuthRequestHeader:setAuthRequestHeader,authServerReq:authServerReq,serverReq:serverReq,serverReqPOST:serverReqPOST,getSearchURL:getSearchURL,getSuggestionURL:getSuggestionURL,getMaterialURL:getMaterialURL,getMaterialCalcURL:getMaterialCalcURL,getMaterialXsURL:getMaterialXsURL,getCalcEnergiesURL:getCalcEnergiesURL,getFlaggingURL:getFlaggingURL,setBrowserHashPath:setBrowserHashPath,loadLib:loadLib,getNumberArray:getNumberArray,getCellDataForViewer:getCellDataForViewer,//FERMI_SURFACE_URL: FERMI_SURFACE_URL, BAND_STRUCT_EXAMPLE_URL:BAND_STRUCT_EXAMPLE_URL,J2eV:J2eV,eV2J:eV2J,//getBandGapStatsValue: getBandGapStatsValue, m2Angstrom:m2Angstrom,getLatticeAnglesValues:getLatticeAnglesValues,rad2degree:rad2degree,m3ToAngstrom3:m3ToAngstrom3,getQuantityStatsMap:getQuantityStatsMap,toAngstromMinus3:toAngstromMinus3,getMaterialTitle:getMaterialTitle,getMinMaxHTML:getMinMaxHTML,getSubscriptedFormula:getSubscriptedFormula,getAverage:getAverage,generateDiagramSteps:generateDiagramSteps};},/* 2 *//***/function(module,exports){var materialData=void 0;function setMaterialData(dataFromAPI){materialData=dataFromAPI;}function getMaterialData(){return materialData;}var calcs=void 0;var calcMap=new Map();function setCalculations(calcsFromAPI){calcs=calcsFromAPI;for(var i=0;i<calcs.length;i++){calcMap.set(calcs[i].id,calcs[i]);}}function getCalculations(){return calcs;}function getCalc(calcId){return calcMap.get(calcId);}var groups=void 0;function processCalcGroups(groupsFromAPI){var methodCalcsMap=new Map();groupsFromAPI.forEach(function(group,i){if(group.group_type!=='method'){var calcsMins=void 0;if(methodCalcsMap.has(group.method_hash)){calcsMins=methodCalcsMap.get(group.method_hash);}else{calcsMins={'ids':[],'minEnergies':[]};methodCalcsMap.set(group.method_hash,calcsMins);}calcsMins.ids.push(group.representative_calculation_id);calcsMins.minEnergies.push(group.energy_minimum);}});//console.log('methodCalcsMap', methodCalcsMap); var methodRepresentativeMap=new Map();methodCalcsMap.forEach(function(calcsData,methodHash){var minVal=Math.min.apply(null,calcsData.minEnergies);var index=calcsData.minEnergies.indexOf(minVal);methodRepresentativeMap.set(methodHash,calcsData.ids[index]);});//console.log('methodRepresentativeMap', methodRepresentativeMap); @@ -102,8 +145,23 @@ if(codeNameTrimed!=='VASP'&&codeNameTrimed!=='FHI-aims'&&groupData.calcs.has(cal });return thereIs;}function getGroupLeafId(calcId){var leafId=null;groups.forEach(function(groupData,groupId){//console.log('isInAnyGroup', calcId, groupData.calcs); if(groupData.calcs.has(calcId))leafId=groupId;//return true; });//console.log('getGroupLeafId', leafId); -return leafId;}// EXPORTS -module.exports={setMaterialData:setMaterialData,getMaterialData:getMaterialData,getCalculations:getCalculations,getCalc:getCalc,setCalculations:setCalculations,getGroups:getGroups,setGroups:setGroups,isGroup:isGroup,getGroupType:getGroupType,getCalcReprIntId:getCalcReprIntId,isInAnyGroup:isInAnyGroup,isInAnyNotDisabledGroup:isInAnyNotDisabledGroup,getGroupLeafId:getGroupLeafId};/***/},/* 3 *//***/function(module,exports,__webpack_require__){"use strict";var util=__webpack_require__(1);var loadingPopup=document.querySelector('#loading-popup');function show(){var ttRect=loadingPopup.getBoundingClientRect();var leftPos=(window.innerWidth-ttRect.width)/2;var topPos=(window.innerHeight-ttRect.height)/2;loadingPopup.style.left=leftPos+'px';loadingPopup.style.top=topPos-100+'px';loadingPopup.style.visibility='visible';}function hide(){loadingPopup.style.visibility='hidden';}// EXPORTS +return leafId;}var hasThermalData=void 0,hasElecStructureData=void 0;/* + function hasThermalData(bool){ + hasThermalData = bool; + } + + function setHasThermalData(bool){ + hasThermalData = bool; + } + + function hasElecStructureData(bool){ + hasThermalData = bool; + } + + function setHasElecStructureData(bool){ + hasElecStructureData = bool; + }*/// EXPORTS +module.exports={setMaterialData:setMaterialData,getMaterialData:getMaterialData,getCalculations:getCalculations,getCalc:getCalc,setCalculations:setCalculations,getGroups:getGroups,setGroups:setGroups,isGroup:isGroup,getGroupType:getGroupType,getCalcReprIntId:getCalcReprIntId,isInAnyGroup:isInAnyGroup,isInAnyNotDisabledGroup:isInAnyNotDisabledGroup,getGroupLeafId:getGroupLeafId,hasThermalData:hasThermalData,hasElecStructureData:hasElecStructureData};/***/},/* 3 *//***/function(module,exports,__webpack_require__){"use strict";var util=__webpack_require__(1);var loadingPopup=document.querySelector('#loading-popup');function show(){var ttRect=loadingPopup.getBoundingClientRect();var leftPos=(window.innerWidth-ttRect.width)/2;var topPos=(window.innerHeight-ttRect.height)/2;loadingPopup.style.left=leftPos+'px';loadingPopup.style.top=topPos-100+'px';loadingPopup.style.visibility='visible';}function hide(){loadingPopup.style.visibility='hidden';}// EXPORTS module.exports={show:show,hide:hide};/***/},/* 4 *//***/function(module,exports){"use strict";var messages=new Map();// = {}; var lastUid=-1;/** * subscribe( message, func ) -> String @@ -141,7 +199,7 @@ if(materialData!==null){// Case: landing at e. structure details page this.structureViewer.load(util.getCellDataForViewer(materialData));this.structureViewer.setMaterialId(materialData.id);}}else this.structureViewer.changeHostElement(hostElement);}},{key:"_setDetailView",value:function _setDetailView(view){var _this=this;// console.log('FFFFF _setDetailView: '+view); if(view===util.MAT_VIEW.structure){this.currentDetailView=this.structureDetails;this.navTree.showCalcsGraphDataAvalability(false);this.navTree.setHeight(250);this.navTree.setMarkedLeafIfNoneMarked(null);// Set the first leaf marked }else if(view===util.MAT_VIEW.electronicstruct){this.currentDetailView=this.electronicStructDetails;this.navTree.showCalcsGraphDataAvalability(true);this.navTree.setHeight(400);this.navTree.setMarkedLeafIfNoneMarked(markedTreeLeafs.eStruct);}else if(view===util.MAT_VIEW.methodology){// Methodology -this.currentDetailView=this.methodologyDetails;this.navTree.showCalcsGraphDataAvalability(false);this.navTree.setHeight(600);this.navTree.setMarkedLeafIfNoneMarked(null);}else if(view===util.MAT_VIEW.thermalProps){// Thermal properties +this.currentDetailView=this.methodologyDetails;this.navTree.showCalcsGraphDataAvalability(false);this.navTree.setHeight(600);this.navTree.setMarkedLeafIfNoneMarked(null);}else if(view===util.MAT_VIEW.thermalprops){// Thermal properties this.currentDetailView=this.thermalDetails;this.navTree.showCalcsGraphDataAvalability(true);this.navTree.setHeight(600);this.navTree.setMarkedLeafIfNoneMarked(markedTreeLeafs.thermalProps);}/* else{ // Elastic constants this.currentDetailView = this.elasticDetails; @@ -154,7 +212,7 @@ this.currentDetailView.attachNavTree(this.navTree);this.currentDetailView.update document.querySelector('title').innerHTML='NOMAD Encyclopedia - '+util.getMaterialTitle(materialData,false);_this2.overview.setMaterialData();_this2.structureDetails.setMaterialData();_this2.electronicStructDetails.setMaterialData();_this2.methodologyDetails.setMaterialData();_this2.thermalDetails.setMaterialData();_this2.elasticDetails.setMaterialData();//console.log("MATDATA LOADED: "); if(_this2.structureViewer!==null)_this2.structureViewer.load(util.getCellDataForViewer(materialData));util.serverReq(util.getMaterialXsURL('calculations',matId),function(e4){DataStore.setCalculations(JSON.parse(e4.target.response).results);util.serverReq(util.getMaterialXsURL('groups',matId),function(e5){DataStore.setGroups(JSON.parse(e5.target.response).groups);var name=materialData.material_name===null?materialData.formula:materialData.material_name;_this2.navTree.build(name);_this2.overview.setCalcsData(markedTreeLeafs);_this2.navTree.selectAll();//console.log('MaterialMod - thermalPropsDetailsTreeLeaf: ', markedTreeLeafs.thermalProps); _this2._setView(view);_this2.overview.element.style.visibility='visible';LoadingPopup.hide();});});});});}else{// Error - First request -}});}}]);return MaterialMod;}();var StructureViewerWrapper=function(){function StructureViewerWrapper(hostElement){var _this3=this;_classCallCheck(this,StructureViewerWrapper);this.hostElement=hostElement;this.viewer=new StructureViewer(hostElement);this.legendElement=document.createElement('div');this.legendElement.setAttribute('class','element-labels');this.legendElement.setAttribute('style','position: absolute; bottom: 50px; right: 0');this.hostElement.appendChild(this.legendElement);this.footerElement=document.createElement('div');this.footerElement.setAttribute('class','structure-viewer-legend');this.hostElement.appendChild(this.footerElement);this.footerElement.innerHTML="\n\n\t <div style=\"float: left; padding-right: 10px\" >\n\t <input type=\"checkbox\" class=\"show-axis\" checked> Show axis\n\t </div>\n\n\t <div style=\"float: left; padding-right: 20px\" >\n\t <input type=\"checkbox\" class=\"show-bonds\" checked> Show bonds\n\t </div>\n\n\t <div class=\"vr-download\" style=\"float: right\"> </div>\n\n\t <div style=\"float: right; padding-right: 20px\" >\n\t <button class=\"view-reset\"> RESET</button>\n\t </div>\n\n\n\t <div style=\"clear: both;\"></div>\n\t ";var axisCheckbox=this.footerElement.querySelector('.show-axis');axisCheckbox.addEventListener('click',function(e){_this3.viewer.toggleLatticeParameters(axisCheckbox.checked);});var bondsCheckbox=this.footerElement.querySelector('.show-bonds');bondsCheckbox.addEventListener('click',function(e){_this3.viewer.toggleBonds(bondsCheckbox.checked);});this.labelsContainer=this.hostElement.querySelector('.element-labels');this.vrLinksContainer=this.footerElement.querySelector('.vr-download');this.vrDropDown=new DropDown();this.vrLinksContainer.appendChild(this.vrDropDown.element);var resetButton=this.hostElement.querySelector('.view-reset');resetButton.addEventListener('click',function(e){_this3.viewer.reset();});}_createClass(StructureViewerWrapper,[{key:"load",value:function load(data){this.viewer.load(data);this.createElementLegend();}},{key:"setMaterialId",value:function setMaterialId(id){this.vrDropDown.setMaterialId(id);}},{key:"changeHostElement",value:function changeHostElement(hostElement){if(this.hostElement!==hostElement){this.hostElement.removeChild(this.legendElement);this.hostElement.removeChild(this.footerElement);this.hostElement=hostElement;this.viewer.changeHostElement(hostElement);this.hostElement.appendChild(this.legendElement);this.hostElement.appendChild(this.footerElement);}}},{key:"createElementLegend",value:function createElementLegend(){// Empty the old legend +}});}}]);return MaterialMod;}();var StructureViewerWrapper=function(){function StructureViewerWrapper(hostElement){var _this3=this;_classCallCheck(this,StructureViewerWrapper);this.hostElement=hostElement;this.viewer=new StructureViewer(hostElement);this.legendElement=document.createElement('div');this.legendElement.setAttribute('class','element-labels');this.legendElement.setAttribute('style','position: absolute; bottom: 50px; right: 0');this.hostElement.appendChild(this.legendElement);this.footerElement=document.createElement('div');this.footerElement.setAttribute('class','structure-viewer-legend');this.hostElement.appendChild(this.footerElement);this.footerElement.innerHTML="\n\n\t <div style=\"float: left; padding-right: 12px\" >\n\t <input type=\"checkbox\" class=\"show-axis\" checked> Show axis\n\t </div>\n\n\t <div style=\"float: left; padding-right: 18px\" >\n\t <input type=\"checkbox\" class=\"show-bonds\" checked> Show bonds\n\t </div>\n\n\t <div style=\"float: left; position:relative;\" >\n\t <img class=\"view-reset\" style=\"cursor: pointer;\" height=\"18px\"\n\t src=\""+util.IMAGE_DIR+"reset.svg\" />\n\t <div class=\"view-reset-tooltip\" > Set original view </div>\n\t </div>\n\n\t<!--\n\t <div class=\"view-reset-tooltip\" style=\"float: left; display: none; font-size: 0.8em;\" >\n\t Set original <br> view\n\t </div>\n\t -->\n\n\t <div class=\"vr-download\" style=\"float: right\"> </div>\n\n\t <div style=\"clear: both;\"></div>\n\t ";var axisCheckbox=this.footerElement.querySelector('.show-axis');axisCheckbox.addEventListener('click',function(e){_this3.viewer.toggleLatticeParameters(axisCheckbox.checked);});var bondsCheckbox=this.footerElement.querySelector('.show-bonds');bondsCheckbox.addEventListener('click',function(e){_this3.viewer.toggleBonds(bondsCheckbox.checked);});this.labelsContainer=this.hostElement.querySelector('.element-labels');this.vrLinksContainer=this.footerElement.querySelector('.vr-download');this.vrDropDown=new DropDown();this.vrLinksContainer.appendChild(this.vrDropDown.element);var resetButton=this.hostElement.querySelector('.view-reset');resetButton.addEventListener('click',function(e){return _this3.viewer.reset();});resetButton.addEventListener('mouseover',function(e){_this3.hostElement.querySelector('.view-reset-tooltip').style.display='block';});resetButton.addEventListener('mouseout',function(e){_this3.hostElement.querySelector('.view-reset-tooltip').style.display='none';});}_createClass(StructureViewerWrapper,[{key:"load",value:function load(data){this.viewer.load(data);this.createElementLegend();}},{key:"setMaterialId",value:function setMaterialId(id){this.vrDropDown.setMaterialId(id);}},{key:"changeHostElement",value:function changeHostElement(hostElement){if(this.hostElement!==hostElement){this.hostElement.removeChild(this.legendElement);this.hostElement.removeChild(this.footerElement);this.hostElement=hostElement;this.viewer.changeHostElement(hostElement);this.hostElement.appendChild(this.legendElement);this.hostElement.appendChild(this.footerElement);}}},{key:"createElementLegend",value:function createElementLegend(){// Empty the old legend this.labelsContainer.innerHTML='';var elements=this.viewer.elements;// Create a list of elements var elementArray=[];for(var property in elements){if(elements.hasOwnProperty(property))elementArray.push([property,elements[property][0],elements[property][1]]);}// Sort by name elementArray.sort(function(a,b){if(a[0]<b[0])return-1;if(a[0]>b[0])return 1;return 0;});var svgElement=document.createElementNS("http://www.w3.org/2000/svg","svg");svgElement.setAttribute("width",50);svgElement.setAttribute("height",elementArray.length*25);this.labelsContainer.appendChild(svgElement);for(var i=0;i<elementArray.length;++i){var elementName=elementArray[i][0];//let elementColor = "#" + elementArray[i][1].toString(16); Lauri's bugfixing feb-2017 @@ -283,8 +341,8 @@ if(calcWithHeat===null&&calcs[i].has_thermal_properties)calcWithHeat=calcs[i];}v else if(DataStore.isInAnyNotDisabledGroup(tempCalcId)){markedTreeLeafs.eStruct=DataStore.getGroupLeafId(tempCalcId);}else markedTreeLeafs.eStruct=+tempCalcId;if(calcWithHeat===null)markedTreeLeafs.thermalProps=null;else if(DataStore.isInAnyNotDisabledGroup(calcWithHeat.id)){markedTreeLeafs.thermalProps=DataStore.getGroupLeafId(calcWithHeat.id);}else markedTreeLeafs.thermalProps=+calcWithHeat.id;//console.log('Overview - thermalPropsDetailsTreeLeaf: ', markedTreeLeafs.thermalProps); //this.band_gap.innerHTML= util.getBandGapStatsValue(calcs); var functionalHTML='';functionalMap.forEach(function(number,functional){functionalHTML+='<span info-sys-data="functional-type.value:'+functional+'">'+number+' '+functional+'</span> <br> ';});this.functional.innerHTML=functionalHTML;InfoSys.addToInfoSystem(this.functional);var codeHTML='';codeMap.forEach(function(number,codeName){codeHTML+='<span info-sys-data="code-name.value:'+codeName+'">'+number+' '+codeName+'</span> <br> ';//codeHTML+= number+' '+codeName+' <br> '; -});this.code.innerHTML=codeHTML;InfoSys.addToInfoSystem(this.code);if(calcWithBS===null&&calcWithDOS===null)document.getElementById('e-structure-ov').style.display='none';else{document.getElementById('e-structure-ov').style.display='block';if(this.bandPlotter===null){this.bandPlotter=new BSPlotter();this.bandPlotter.attach(document.getElementById('band-plotter'),undefined,316);}if(this.dosPlotter===null){this.dosPlotter=new DOSPlotter({left:40,right:16,top:0,bottom:30});this.dosPlotter.attach(document.getElementById('dos-plotter'),undefined,317);}if(calcWithBS===null){this.bandPlotter.setNoData();this.bsCalcIdBox.innerHTML='';}else{var url=util.getMaterialCalcURL(calcWithBS.material,calcWithBS.id,'band_structure');LoadingPopup.show();util.serverReq(url,function(e){if(e.target.status===200){var bandStructData=JSON.parse(e.target.response).band_structure;_this8.bandPlotter.setBandStructureData(bandStructData);_this8.bsCalcIdBox.innerHTML='From calculation <b>'+calcWithBS.id+'</b><br><span style="font-size: 0.8em">('+calcWithBS.functional_type+' - '+calcWithBS.code_name+')</span>';if(bandStructData.segments[0].band_energies.length===2)_this8.spinLegend.style.display='block';}LoadingPopup.hide();});}if(calcWithDOS===null){this.dosPlotter.setNoData();this.dosCalcIdBox.innerHTML='';}else{var _url=util.getMaterialCalcURL(calcWithDOS.material,calcWithDOS.id,'dos');LoadingPopup.show();util.serverReq(_url,function(e){if(e.target.status===200){var dosData=JSON.parse(e.target.response).dos;_this8.dosPlotter.setPoints(dosData);//paintPointsLine(dosData); -_this8.dosCalcIdBox.innerHTML='From calculation <b>'+calcWithDOS.id+'</b><br><span style="font-size: 0.8em">('+calcWithDOS.functional_type+' - '+calcWithDOS.code_name+')</span>';if(dosData.dos_values.length===2)_this8.spinLegend.style.display='block';}LoadingPopup.hide();});}}if(calcWithHeat===null)document.getElementById('thermal-props-ov').style.display='none';else{document.getElementById('thermal-props-ov').style.display='block';if(this.heatPlotter===null){this.heatPlotter=new HeatCapPlotter();this.heatPlotter.attach(document.getElementById('heat-plotter'),undefined,317);}if(calcWithHeat===null){this.heatPlotter.setNoData();this.heatCalcIdBox.innerHTML='';}else{var _url2=util.getMaterialCalcURL(calcWithHeat.material,calcWithHeat.id,'specific_heat_cv');LoadingPopup.show();util.serverReq(_url2,function(e){if(e.target.status===200){var heatData=JSON.parse(e.target.response).specific_heat_cv;//console.log(heatData); +});this.code.innerHTML=codeHTML;InfoSys.addToInfoSystem(this.code);if(calcWithBS===null&&calcWithDOS===null){document.getElementById('e-structure-ov').style.display='none';DataStore.hasElecStructureData=false;}else{document.getElementById('e-structure-ov').style.display='block';DataStore.hasElecStructureData=true;if(this.bandPlotter===null){this.bandPlotter=new BSPlotter();this.bandPlotter.attach(document.getElementById('band-plotter'),undefined,316);}if(this.dosPlotter===null){this.dosPlotter=new DOSPlotter({left:40,right:16,top:0,bottom:30});this.dosPlotter.attach(document.getElementById('dos-plotter'),undefined,317);}if(calcWithBS===null){this.bandPlotter.setNoData();this.bsCalcIdBox.innerHTML='';}else{var url=util.getMaterialCalcURL(calcWithBS.material,calcWithBS.id,'band_structure');LoadingPopup.show();util.serverReq(url,function(e){if(e.target.status===200){var bandStructData=JSON.parse(e.target.response).band_structure;_this8.bandPlotter.setBandStructureData(bandStructData);_this8.bsCalcIdBox.innerHTML='From calculation <b>'+calcWithBS.id+'</b><br><span style="font-size: 0.8em">('+calcWithBS.functional_type+' - '+calcWithBS.code_name+')</span>';if(bandStructData.segments[0].band_energies.length===2)_this8.spinLegend.style.display='block';}LoadingPopup.hide();});}if(calcWithDOS===null){this.dosPlotter.setNoData();this.dosCalcIdBox.innerHTML='';}else{var _url=util.getMaterialCalcURL(calcWithDOS.material,calcWithDOS.id,'dos');LoadingPopup.show();util.serverReq(_url,function(e){if(e.target.status===200){var dosData=JSON.parse(e.target.response).dos;_this8.dosPlotter.setPoints(dosData);//paintPointsLine(dosData); +_this8.dosCalcIdBox.innerHTML='From calculation <b>'+calcWithDOS.id+'</b><br><span style="font-size: 0.8em">('+calcWithDOS.functional_type+' - '+calcWithDOS.code_name+')</span>';if(dosData.dos_values.length===2)_this8.spinLegend.style.display='block';}LoadingPopup.hide();});}}if(calcWithHeat===null){document.getElementById('thermal-props-ov').style.display='none';DataStore.hasThermalData=false;}else{document.getElementById('thermal-props-ov').style.display='block';DataStore.hasThermalData=true;if(this.heatPlotter===null){this.heatPlotter=new HeatCapPlotter();this.heatPlotter.attach(document.getElementById('heat-plotter'),undefined,317);}if(calcWithHeat===null){this.heatPlotter.setNoData();this.heatCalcIdBox.innerHTML='';}else{var _url2=util.getMaterialCalcURL(calcWithHeat.material,calcWithHeat.id,'specific_heat_cv');LoadingPopup.show();util.serverReq(_url2,function(e){if(e.target.status===200){var heatData=JSON.parse(e.target.response).specific_heat_cv;//console.log(heatData); _this8.heatPlotter.setData(heatData);_this8.heatCalcIdBox.innerHTML='From calculation <b>'+calcWithHeat.id+'</b>'+'</b> <span style="font-size: 0.8em">('+calcWithHeat.functional_type+' - '+calcWithHeat.code_name+')</span>';}LoadingPopup.hide();});}}}// setCalcsData function }]);return Overview;}();// EXPORTS module.exports=Overview;/***/},/* 10 *//***/function(module,exports,__webpack_require__){"use strict";var util=__webpack_require__(1);var SwitchComponent=__webpack_require__(11);var INFOSYS_FILE_PATH='infosys.json';var tooltip=document.querySelector('#info-tooltip');var tooltipContent=document.querySelector('#tooltip-content');var elements=[];var timerSet=null;var on=false;var data=null;function clearCurrentTimeoutAnSetANew(){if(timerSet!==null)window.clearTimeout(timerSet);timerSet=window.setTimeout(function(t){return tooltip.style.display='none';},1000);}var switchComponent=new SwitchComponent(util.IMAGE_DIR+'switch');document.querySelector('#info-sys-switch-box').appendChild(switchComponent.element);switchComponent.setListener(function(off){on=!off;if(off){elements.forEach(function(element){element.removeEventListener('mouseover',mouseOver);element.className='';});}else{if(data===null)util.serverReq(INFOSYS_FILE_PATH,function(e){return data=JSON.parse(e.target.response);});elements.forEach(enableTooltip);}tooltip.addEventListener('mouseover',function(e){window.clearTimeout(timerSet);});tooltip.addEventListener('mouseout',function(e){clearCurrentTimeoutAnSetANew();});});function addToInfoSystem(baseElement){var infosysLabels=baseElement.querySelectorAll('span[info-sys-data]');for(var i=0;i<infosysLabels.length;++i){elements.push(infosysLabels[i]);}//if (on) infosysLabels.forEach(enableTooltip); @@ -890,4 +948,7 @@ _this59.addPropertiesListener(propsMap);_this59.addButton.disabled=true;});var p var propsMap=new Map();if(tabString==='structure'){this.addPropsFromTextFields(propsMap,['space-group'],reset);this.addPropsFromDropdownList(propsMap,['structure-type'],reset);this.addPropsFromCheckboxes(propsMap,['system-type','crystal-system'],reset);this.addMassDensityProps(propsMap,reset);}else if(tabString==='results'){this.addBandgapProps(propsMap,reset);this.addPropsFromCheckboxes(propsMap,['has-band-structure','has-dos','has-fermi-surface','has-thermal-properties'],reset);}else if(tabString==='method'){this.addPropsFromCheckboxes(propsMap,['functional-type','basis-set-type'],reset);this.addPropsFromDropdownList(propsMap,['code-name'],reset);}//else if (this.tabSelected.className === 'contributors-tab'){ //this.addPropsFromTextFields(propsMap,['contributors']);} return propsMap;}},{key:"addPropsFromTextFields",value:function addPropsFromTextFields(propsMap,propsArray,reset){var _this60=this;propsArray.forEach(function(propName){var field=_this60.element.querySelector('.'+propName+'-field');if(field.value!==''){propsMap.set(propName,[field.value]);if(reset)field.value='';}});}},{key:"addPropsFromCheckboxes",value:function addPropsFromCheckboxes(propsMap,propsArray,reset){var _this61=this;propsArray.forEach(function(propName){var checkboxes=_this61.element.querySelectorAll('.'+propName+'-field');var value=[];for(var i=0;i<checkboxes.length;i++){if(checkboxes[i].checked){value.push(checkboxes[i].value);if(reset)checkboxes[i].checked=false;}}if(value.length>0)propsMap.set(propName,value);});}},{key:"addPropsFromDropdownList",value:function addPropsFromDropdownList(propsMap,propsArray,reset){var _this62=this;propsArray.forEach(function(propName){var field=_this62.element.querySelector('.'+propName+'-field');var value=field.options[field.selectedIndex].value;if(value.length>2)propsMap.set(propName,[value]);if(reset)field.selectedIndex=0;});}},{key:"addBandgapProps",value:function addBandgapProps(propsMap,reset){var minField=document.querySelector('.band-gap-min-field');var maxField=document.querySelector('.band-gap-max-field');var fieldName='band-gap';var label='Band Gap';if(minField.value!==''){label=minField.value+' < '+label;fieldName+=':'+minField.value;if(reset)minField.value='';}if(maxField.value!==''){label+=' < '+maxField.value;fieldName+=':'+maxField.value;if(reset)maxField.value='';}if(label!=='Band Gap'){var val=document.querySelector('input[name="band-gap-type"]:checked').value;if(val==='d')fieldName+=':True';else if(val==='i')fieldName+=':False';propsMap.set(fieldName,[label+' '+val]);}}},{key:"addMassDensityProps",value:function addMassDensityProps(propsMap,reset){var minField=document.querySelector('.mass-density-min-field');var maxField=document.querySelector('.mass-density-max-field');var fieldName='mass-density';var label='Mass Density';if(minField.value!==''){label=minField.value+' < '+label;fieldName+=':'+minField.value;if(reset)minField.value='';}if(maxField.value!==''){label+=' < '+maxField.value;fieldName+=':'+maxField.value;if(reset)maxField.value='';}if(label!=='Mass Density')propsMap.set(fieldName,[label]);}},{key:"setAddPropertiesListener",value:function setAddPropertiesListener(listener){this.addPropertiesListener=listener;}}]);return PropertiesBox;}();// EXPORTS -module.exports=PropertiesBox;/***/}/******/]); +module.exports=PropertiesBox;/***/},/* 34 *//***/function(module,exports,__webpack_require__){"use strict";var util=__webpack_require__(1);var flaggingFormPopup=document.querySelector('#flagging-form-popup');var sectionField=flaggingFormPopup.querySelector('#flagging-section');var subsectionField=flaggingFormPopup.querySelector('#flagging-subsection');var closeButton=flaggingFormPopup.querySelector('img');var validationMsg=flaggingFormPopup.querySelector('#form-validation-msg');var sendButton=flaggingFormPopup.querySelector('button');function show(){var ttRect=flaggingFormPopup.getBoundingClientRect();var leftPos=(window.innerWidth-ttRect.width)/2;var topPos=(window.innerHeight-ttRect.height)/2;flaggingFormPopup.style.left=leftPos+'px';flaggingFormPopup.style.top=topPos-100+'px';flaggingFormPopup.style.visibility='visible';}function hide(){flaggingFormPopup.style.visibility='hidden';// reset UI +sectionField.selectedIndex=0;subsectionField.selectedIndex=0;flaggingFormPopup.querySelector('textarea').value='';validationMsg.innerHTML='';}closeButton.addEventListener('click',function(e){hide();});sendButton.addEventListener('click',function(e){var sectionChosen=sectionField.options[sectionField.selectedIndex];var subsectionChosen=subsectionField.options[subsectionField.selectedIndex];if(sectionChosen.value===''||subsectionField.value==='')validationMsg.innerHTML='The section and subsection fields must be set';else{validationMsg.innerHTML='Sending report...';var textareaText=flaggingFormPopup.querySelector('textarea').value;var queryJson="{\n\t \"title\": \"GUI user flagging: "+sectionChosen.text+" section / "+subsectionChosen.text+"\",\n\t \"description\":\""+textareaText+"\"}";//console.log('queryJson',queryJson); +util.serverReqPOST(util.getFlaggingURL(),queryJson,function(e){if(e.target.status===200)hide();});}});// EXPORTS +module.exports={show:show,hide:hide};/***/}/******/]); diff --git a/client/bundle.js b/client/bundle.js index 42915c9edf9d858cbcdbccf12dfed326c7e6d25e..d6044c4abcca5964d5d8c444e2ca50c8e91e0610 100644 --- a/client/bundle.js +++ b/client/bundle.js @@ -79,7 +79,7 @@ document.querySelector('#auth-user').style.display = 'inline'; util.setAuthRequestHeader(jsonData.user.username, jsonData.token.data); - flaggingTab.style.visibility = 'visible'; + //flaggingTab.style.visibility = 'visible'; } }); @@ -93,7 +93,7 @@ document.querySelector('#auth-user').style.display = 'none'; util.setAuthRequestHeader(); - flaggingTab.style.visibility = 'hidden'; + //flaggingTab.style.visibility = 'hidden'; }); /* An exception is launched, so this code after the response arrives is not executed @@ -155,17 +155,20 @@ <span class="goto-page Results"> > <span>Results</span></span> <span class="goto-page Overview"> > <span>Overview</span></span> <span class="Details"> - > <span class="details-label">Details</span> - <span class="details-dropdown"></span> + > + <select class="details-dropdown" > + <option value="structure">Structure Details</option> + <option value="electronicstruct">Electronic structure Details</option> + <option value="methodology">Methodology Details</option> + <option value="thermalprops">Thermal Properties Details</option> + <!-- elasticconst--> + </select> </span> `; this.resultsSel = this.element.querySelector('.Results'); this.overviewSel = this.element.querySelector('.Overview'); this.detailsSel = this.element.querySelector('.Details'); - this.detailsLabel = this.element.querySelector('.details-label'); - this.detailsDropDown = new DropDown(); - this.element.querySelector('.details-dropdown') - .appendChild(this.detailsDropDown.element); + this.detailsDropDown = this.element.querySelector('.details-dropdown'); // Events this.element.querySelector('.Search').addEventListener( "click", e => { @@ -178,13 +181,30 @@ this.overviewSel.addEventListener('click', () => { util.setBrowserHashPath('material', util.materialId); }); + + this.detailsDropDown.addEventListener('change', e => { + util.setBrowserHashPath('material', + DataStore.getMaterialData().id+'/'+e.target.value); + }); + + let self = this; + function adjustDropdownOptions() { + //console.log('FAOCUS'); + let esOption = self.detailsDropDown.querySelector('option[value="electronicstruct"]'); + if (!DataStore.hasElecStructureData) self.detailsDropDown.removeChild(esOption); + + let thOption = self.detailsDropDown.querySelector('option[value="thermalprops"]'); + if (!DataStore.hasThermalData) self.detailsDropDown.removeChild(thOption); + // Remove because we want it's executed once + self.detailsDropDown.removeEventListener('focus', adjustDropdownOptions); + } + + this.detailsDropDown.addEventListener('focus', adjustDropdownOptions); } setState(appModule, param){ - this.detailsDropDown.closePanel(); - if (appModule === 'search'){ this.overviewSel.style.display = 'none'; this.detailsSel.style.display = 'none'; @@ -202,113 +222,14 @@ } else{ // Details page this.detailsSel.style.display = 'inline'; - this.detailsDropDown.setDetailsPage(param); - switch(param){ - case 'structure': - this.detailsLabel.innerHTML = 'Structure Details'; - break; - case 'electronicstruct': - this.detailsLabel.innerHTML = 'Electronic Structure Details'; - break; - case 'methodology': - this.detailsLabel.innerHTML = 'Methodology Details'; - break; - case 'thermalprops': - this.detailsLabel.innerHTML = 'Thermal Properties Details'; - break; - case 'elasticconst': - this.detailsLabel.innerHTML = 'Elastic Constants Details'; - } + this.detailsDropDown.value = param; } } - - this.setBoldLabel(appModule, param); - } // setState - setBoldLabel(appModule, param){ - let currentPage = this.element.querySelector('.current-page'); - if (currentPage !== null) currentPage.className = ''; - - if (param === 'results') this.resultsSel.lastChild.className = 'current-page'; - else (appModule === 'material') - if (param === undefined) this.overviewSel.lastChild.className = 'current-page'; - else this.detailsLabel.className = 'current-page'; - } - } // class Breadcrumb - - class DropDown{ - - constructor(){ - this.materialId; - this.folded = true; - this.element = document.createElement('span'); - this.element.style.position = 'absolute'; - this.element.innerHTML+=` - <img height="16px" style="cursor: pointer; padding: 0 6px;" src="${util.IMAGE_DIR}folded.png" /> - <div class="details-sel-panel" - style="position: relative; display: none"> - <div class="structure-dropdown">Structure Details</div> - <div class="electronicstruct-dropdown">Electronic Structure Details</div> - <div class="methodology-dropdown">Methodology Details</div> - <div class="thermalprops-dropdown">Thermal Properties Details</div> - </div> - `; - - this.foldingPanel = this.element.querySelector('.details-sel-panel'); - this.foldBtn = this.element.querySelector('img'); - - this.foldBtn.addEventListener('click', e => { - this.folded = !this.folded; - this.foldBtn.src = (this.folded ? util.IMAGE_DIR+'folded.png' : - util.IMAGE_DIR+'unfolded.png'); - this.foldingPanel.style.display = (this.folded ? 'none' : 'block'); - - // Visible if this material has this data type (and if it's not the current) - this.foldingPanel.querySelector('.electronicstruct-dropdown'). - style.display = (DataStore.hasElecStructureData ? 'block' : 'none'); - this.foldingPanel.querySelector('.thermalprops-dropdown'). - style.display = (DataStore.hasThermalData ? 'block' : 'none'); - // Always visible (if it's not the current) - this.foldingPanel.querySelector('.structure-dropdown'). - style.display = 'block'; - this.foldingPanel.querySelector('.methodology-dropdown'). - style.display = 'block'; - // The current details page link is hidden - this.foldingPanel.querySelector('.'+this.detailsPage+'-dropdown'). - style.display = 'none'; - }); - - this.foldingPanel.addEventListener('click', e => { - let classString = e.target.className; - let det = classString.substring(0,classString.indexOf('-dropdown')); - util.setBrowserHashPath('material', DataStore.getMaterialData().id+'/'+det); - - this.closePanel(); - - - /*dropdownElements.forEach( element => { - let det = element.className.substring(0,element.className.indexOf('-dropdown')); - if (det === ) - });*/ - }); - } - - - setDetailsPage(page){ - this.detailsPage = page; - } - - closePanel(){ - this.foldingPanel.style.display = 'none'; - this.foldBtn.src = util.IMAGE_DIR+'folded.png'; - this.folded = true; - } - - } - + /*****************************/ let breadcrumb = new Breadcrumb(); diff --git a/client/css/styles.css b/client/css/styles.css index 5f3edef954cccb981974a55488ae3ca933f639b0..84bd3c6808facbe9cb4acb48e4e98c511742adb9 100644 --- a/client/css/styles.css +++ b/client/css/styles.css @@ -154,6 +154,18 @@ div#second-header{ padding: 16px 0;} #breadcrumb-placeholder{ font-style: normal; } + +.details-dropdown{ + background: transparent; + border: solid 1px #DDD; + font-size: 1em; + font-weight: bold; + color: #777; + + padding: 2px 6px; +} + + .goto-search, .goto-results, .goto-overview, .goto-page{ cursor: pointer; } diff --git a/client/index.html b/client/index.html index c34a7e43ff5285450234d0c413f166cba3fca31d..ce4567900f58f29c20a838876e98ed979d80318a 100644 --- a/client/index.html +++ b/client/index.html @@ -35,17 +35,19 @@ <div id="tooltip-content" ></div> </div> - <div id="loading-popup" style="position:absolute; visibility: hidden"> + <div id="loading-popup" style="position:absolute; + visibility: hidden"> <img src="img/loading_animation.gif" width="40px" style="margin-bottom: -6px" /> Loading </div> <div id="calc-flagging-tab" - style="position:absolute;"> + style="position:absolute;visibility: hidden"> Report error </div> - <div id="flagging-form-popup" style="position:absolute;visibility: hidden"> + <div id="flagging-form-popup" style="position:absolute; + visibility: hidden"> <div> Error reporting <img src="img/cross.svg" height="16px" style="float: right; cursor: pointer" /> @@ -146,6 +148,6 @@ <!-- <script type='text/javascript' src='http://www.x3dom.org/download/x3dom.js'> </script>--> - <script type="text/javascript" src="bundle.js" charset="utf-8"></script> + <script type="text/javascript" src="bundle-es5.js" charset="utf-8"></script> </body> </html> diff --git a/client/src/main.js b/client/src/main.js index 8e2f609c3ac14bc76b8d0d6b686c74f64bdfa35f..4fd46279153e617877fac5d210790725e860ece9 100644 --- a/client/src/main.js +++ b/client/src/main.js @@ -33,7 +33,7 @@ let oReq = util.authServerReq('saml/user/', e => { document.querySelector('#auth-user').style.display = 'inline'; util.setAuthRequestHeader(jsonData.user.username, jsonData.token.data); - flaggingTab.style.visibility = 'visible'; + //flaggingTab.style.visibility = 'visible'; } }); @@ -47,7 +47,7 @@ logoutButton.addEventListener( "click", e => { document.querySelector('#auth-user').style.display = 'none'; util.setAuthRequestHeader(); - flaggingTab.style.visibility = 'hidden'; + //flaggingTab.style.visibility = 'hidden'; }); /* An exception is launched, so this code after the response arrives is not executed @@ -109,17 +109,20 @@ class Breadcrumb { <span class="goto-page Results"> > <span>Results</span></span> <span class="goto-page Overview"> > <span>Overview</span></span> <span class="Details"> - > <span class="details-label">Details</span> - <span class="details-dropdown"></span> + > + <select class="details-dropdown" > + <option value="structure">Structure Details</option> + <option value="electronicstruct">Electronic structure Details</option> + <option value="methodology">Methodology Details</option> + <option value="thermalprops">Thermal Properties Details</option> + <!-- elasticconst--> + </select> </span> `; this.resultsSel = this.element.querySelector('.Results'); this.overviewSel = this.element.querySelector('.Overview'); this.detailsSel = this.element.querySelector('.Details'); - this.detailsLabel = this.element.querySelector('.details-label'); - this.detailsDropDown = new DropDown(); - this.element.querySelector('.details-dropdown') - .appendChild(this.detailsDropDown.element); + this.detailsDropDown = this.element.querySelector('.details-dropdown'); // Events this.element.querySelector('.Search').addEventListener( "click", e => { @@ -132,13 +135,30 @@ class Breadcrumb { this.overviewSel.addEventListener('click', () => { util.setBrowserHashPath('material', util.materialId); }); + + this.detailsDropDown.addEventListener('change', e => { + util.setBrowserHashPath('material', + DataStore.getMaterialData().id+'/'+e.target.value); + }); + + let self = this; + function adjustDropdownOptions() { + //console.log('FAOCUS'); + let esOption = self.detailsDropDown.querySelector('option[value="electronicstruct"]'); + if (!DataStore.hasElecStructureData) self.detailsDropDown.removeChild(esOption); + + let thOption = self.detailsDropDown.querySelector('option[value="thermalprops"]'); + if (!DataStore.hasThermalData) self.detailsDropDown.removeChild(thOption); + // Remove because we want it's executed once + self.detailsDropDown.removeEventListener('focus', adjustDropdownOptions); + } + + this.detailsDropDown.addEventListener('focus', adjustDropdownOptions); } setState(appModule, param){ - this.detailsDropDown.closePanel(); - if (appModule === 'search'){ this.overviewSel.style.display = 'none'; this.detailsSel.style.display = 'none'; @@ -156,113 +176,14 @@ class Breadcrumb { } else{ // Details page this.detailsSel.style.display = 'inline'; - this.detailsDropDown.setDetailsPage(param); - switch(param){ - case 'structure': - this.detailsLabel.innerHTML = 'Structure Details'; - break; - case 'electronicstruct': - this.detailsLabel.innerHTML = 'Electronic Structure Details'; - break; - case 'methodology': - this.detailsLabel.innerHTML = 'Methodology Details'; - break; - case 'thermalprops': - this.detailsLabel.innerHTML = 'Thermal Properties Details'; - break; - case 'elasticconst': - this.detailsLabel.innerHTML = 'Elastic Constants Details'; - } + this.detailsDropDown.value = param; } } - - this.setBoldLabel(appModule, param); - } // setState - setBoldLabel(appModule, param){ - let currentPage = this.element.querySelector('.current-page'); - if (currentPage !== null) currentPage.className = ''; - - if (param === 'results') this.resultsSel.lastChild.className = 'current-page'; - else (appModule === 'material') - if (param === undefined) this.overviewSel.lastChild.className = 'current-page'; - else this.detailsLabel.className = 'current-page'; - } - } // class Breadcrumb - -class DropDown{ - - constructor(){ - this.materialId; - this.folded = true; - this.element = document.createElement('span'); - this.element.style.position = 'absolute'; - this.element.innerHTML+=` - <img height="16px" style="cursor: pointer; padding: 0 6px;" src="${util.IMAGE_DIR}folded.png" /> - <div class="details-sel-panel" - style="position: relative; display: none"> - <div class="structure-dropdown">Structure Details</div> - <div class="electronicstruct-dropdown">Electronic Structure Details</div> - <div class="methodology-dropdown">Methodology Details</div> - <div class="thermalprops-dropdown">Thermal Properties Details</div> - </div> - `; - - this.foldingPanel = this.element.querySelector('.details-sel-panel'); - this.foldBtn = this.element.querySelector('img'); - - this.foldBtn.addEventListener('click', e => { - this.folded = !this.folded; - this.foldBtn.src = (this.folded ? util.IMAGE_DIR+'folded.png' : - util.IMAGE_DIR+'unfolded.png'); - this.foldingPanel.style.display = (this.folded ? 'none' : 'block'); - - // Visible if this material has this data type (and if it's not the current) - this.foldingPanel.querySelector('.electronicstruct-dropdown'). - style.display = (DataStore.hasElecStructureData ? 'block' : 'none'); - this.foldingPanel.querySelector('.thermalprops-dropdown'). - style.display = (DataStore.hasThermalData ? 'block' : 'none'); - // Always visible (if it's not the current) - this.foldingPanel.querySelector('.structure-dropdown'). - style.display = 'block'; - this.foldingPanel.querySelector('.methodology-dropdown'). - style.display = 'block'; - // The current details page link is hidden - this.foldingPanel.querySelector('.'+this.detailsPage+'-dropdown'). - style.display = 'none'; - }); - - this.foldingPanel.addEventListener('click', e => { - let classString = e.target.className; - let det = classString.substring(0,classString.indexOf('-dropdown')); - util.setBrowserHashPath('material', DataStore.getMaterialData().id+'/'+det); - - this.closePanel(); - - - /*dropdownElements.forEach( element => { - let det = element.className.substring(0,element.className.indexOf('-dropdown')); - if (det === ) - });*/ - }); - } - - - setDetailsPage(page){ - this.detailsPage = page; - } - - closePanel(){ - this.foldingPanel.style.display = 'none'; - this.foldBtn.src = util.IMAGE_DIR+'folded.png'; - this.folded = true; - } - -} - +/*****************************/ let breadcrumb = new Breadcrumb();