[x3d-public] Swiss Army Knife of DOM selection (used with X3DJSONLD) suggestions welcome
John Carlson
yottzumm at gmail.com
Tue Mar 5 00:20:55 PST 2019
classes.log(this.nodeUtil(selector, true)+" = function(selector, node, field, value) {");
classes.log(" if (typeof selector === 'undefined') {");
classes.log(" selector = '';");
classes.log(" } else {");
classes.log(" selector = selector+' ';");
classes.log(" }");
classes.log(" selector = selector+\"[DEF='\"+node+\"']\";");
classes.log(" var element = document.querySelector(selector);");
classes.log(" if (element === null) {");
classes.log(" console.error('unDEFed node', node, selector);");
classes.log(" } else if (arguments.length > 3) {");
classes.log(" try {");
classes.log(" if (typeof element.setFieldValue === 'function') {");
classes.log(" element.setFieldValue(field, value);");
classes.log(" } else {");
classes.log(" element.setAttribute(field, value);");
classes.log(" }");
classes.log(" } catch (e) {");
classes.log(" console.log(e);");
classes.log(" }");
classes.log(" return element;");
classes.log(" } else if (arguments.length > 2) {");
classes.log(" if (typeof element.getFieldValue === 'function') {");
classes.log(" value = element.getFieldValue(field);");
classes.log(" } else {");
classes.log(" value = element.getAttribute(field);");
classes.log(" }");
classes.log(" // console.log('get', node, '.', field,'=',value);");
classes.log(" return value;");
classes.log(" } else if (arguments.length > 0) {");
classes.log(" return $(selector)[0];");
classes.log(" } else {");
classes.log(" return;");
classes.log(" }");
classes.log("};");
Sent from Mail for Windows 10
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://web3d.org/pipermail/x3d-public_web3d.org/attachments/20190305/5af7b521/attachment.html>
More information about the x3d-public
mailing list