grout-js
Version:
A small module for reading rock grouting files
2 lines (1 loc) • 1.62 kB
JavaScript
var t={Project:"",Tunnel:"",PegNo:"",ScreenNo:""},e=function(){this.logTime={value:"",key:"LogTime"},this.pressure={value:"",key:"Trykk"},this.flow={value:"",key:"Flow"},this.pumpNr={value:"",key:"PumpeNr"},this.hole={value:"",key:"Hull"},this.volume={value:"",key:"Volume"}},o=function(){function o(e){void 0===e&&(e="Driftslogg"),this.operatingLogs=[],this.operatingLogKey=e,this.metadata=t}return o.prototype.init=function(t){var e=this.parse(t);return this.setDocument(e),this.setMetadata(),this.getOperatingLogs()},o.prototype.parse=function(t){return(new DOMParser).parseFromString(t,"text/xml")},o.prototype.setDocument=function(t){this.document=t},o.prototype.setMetadata=function(){var t=this;Object.keys(this.metadata).forEach((function(e){var o;Object.assign(t.metadata,((o={})[e]=t.getNodeByTagName(t.document,e),o))}))},o.prototype.getNodeByTagName=function(t,e){return t.getElementsByTagName(e)[0].firstChild.textContent},o.prototype.getMetadata=function(t){return this.metadata[t]},o.prototype.getOperatingLogs=function(){var t=this;return Array.from(this.document.getElementsByTagName(this.operatingLogKey)).forEach((function(e){var o=t.getOperatingLog(e);t.operatingLogs.push(o)})),this.operatingLogs},o.prototype.getOperatingLog=function(t){var o=this,r=new e;return Object.values(r).forEach((function(e){o.getProperty(t,e)})),r},o.prototype.getProperty=function(t,e){e.value;var o=e.key;Object.assign(e,{value:this.getPropertyValue(t,o)})},o.prototype.getPropertyValue=function(t,e){return t.getElementsByTagName(e)[0].firstChild.textContent},o}(),r=function(t,e){return t+e};export{o as Grout,r as add};