UNPKG

awv3

Version:
64 lines (55 loc) 1.72 kB
export function errUndefined(text) { throw new Error(text); } export function url(param) { var sPageURL = window.location.search.substring(1), sURLVariables = sPageURL.split('&'); for (var i = 0; i < sURLVariables.length; i++) { var sParameterName = sURLVariables[i].split('='); if (sParameterName[0] == param) { return sParameterName[1]; } } } export function queryDom(item) { if (typeof item === 'string' || item instanceof String) item = document.querySelector(item); return item; } export function setPrefixedValue(elm, prop, value, fallback) { var prefixes = ['-moz-', '-webkit-', '-o-', '-ms-', '-khtml-'], i, v, starting; // Clear elm.style[prop] = ''; starting = elm.style[prop]; // Try raw first try { elm.style[prop] = value; if (elm.style[prop] !== starting) return; } catch (e) {} // Try prefixes for (i = 0; i < prefixes.length; ++i) { v = prefixes[i] + value; try { elm.style[prop] = v; if (elm.style[prop] !== starting) return; } catch (e2) {} } elm.style[prop] = fallback; } export function mergePoints(points) { var mergedPoints = []; points.forEach(function (p) { var isDuplicated = false; var foundDuplicate; mergedPoints.forEach(function (mp) { if (p.meta.id === mp.meta.id && p.meta.position.x === mp.meta.position.x && p.meta.position.y === mp.meta.position.y && p.meta.position.z == mp.meta.position.z) { isDuplicated = true; foundDuplicate = mp; } }); if (isDuplicated) {// TODO: add p.parentId to foundDuplicate.parentId. parentId of points are then arrays } else { mergedPoints.push(p); } }); return mergedPoints; }