grout-js
Version:
A small module for reading rock grouting files
2 lines (1 loc) • 1.71 kB
JavaScript
var grout=function(t){"use strict";var e={Project:"",Tunnel:"",PegNo:"",ScreenNo:""},o=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"}},r=function(){function t(t){void 0===t&&(t="Driftslogg"),this.operatingLogs=[],this.operatingLogKey=t,this.metadata=e}return t.prototype.init=function(t){var e=this.parse(t);return this.setDocument(e),this.setMetadata(),this.getOperatingLogs()},t.prototype.parse=function(t){return(new DOMParser).parseFromString(t,"text/xml")},t.prototype.setDocument=function(t){this.document=t},t.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))}))},t.prototype.getNodeByTagName=function(t,e){return t.getElementsByTagName(e)[0].firstChild.textContent},t.prototype.getMetadata=function(t){return this.metadata[t]},t.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},t.prototype.getOperatingLog=function(t){var e=this,r=new o;return Object.values(r).forEach((function(o){e.getProperty(t,o)})),r},t.prototype.getProperty=function(t,e){e.value;var o=e.key;Object.assign(e,{value:this.getPropertyValue(t,o)})},t.prototype.getPropertyValue=function(t,e){return t.getElementsByTagName(e)[0].firstChild.textContent},t}();return t.Grout=r,t.add=function(t,e){return t+e},Object.defineProperty(t,"__esModule",{value:!0}),t}({});