Last active
September 15, 2016 11:25
-
-
Save OrenBochman/ed55f6d0ffb2d44e06b25859a64a2e04 to your computer and use it in GitHub Desktop.
debug data propeties in console
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var result = Object.getOwnPropertyNames(data).filter(/./.test.bind(new RegExp("^g"))); | |
console.table(data,Object.getOwnPropertyNames(data).filter(/./.test.bind(new RegExp("^g")))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var elements = [].slice.call(document.querySelectorAll('*')).filter(function(el) { | |
if (typeof (el.dataset) != "undefined") | |
return Object.keys(el.dataset).length != 0; | |
}); | |
var data = []; //persists data if no var | |
var i = elements.length; | |
while (i--) { | |
var el = JSON.parse(JSON.stringify(elements[i].dataset)); | |
data.push(el); | |
el["gType"] = elements[i].nodeName; | |
} | |
console.table(data); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function() { | |
var generalString = | |
"General--ID:" + {{transactionId}} + | |
",AFF:" + {{transactionAffiliation}} + | |
",TOT:" + {{transactionTotal}} + | |
",TAX:" + {{transactionTax}} + | |
",SHI:" + {{transactionShipping}} + | |
"|"; | |
var productString = ""; | |
var numProducts = {{transactionProducts}}.length; | |
for(var i=0; i<numProducts; i++) { | |
if(i > 0) {productString = productString + "|"}; | |
productString = | |
productString + | |
"P" + (i+1) + | |
"--SKU:" + {{transactionProducts}}[i].sku + | |
",NAM:" + {{transactionProducts}}[i].name + | |
",PRI:" + {{transactionProducts}}[i].price + | |
",QUA:" + {{transactionProducts}}[i].quantity; | |
} | |
return generalString + productString; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var elements = [].slice.call(document.querySelectorAll('*')).filter(function(el) { | |
if (typeof (el.dataset) != "undefined") | |
return Object.keys(el.dataset).length != 0; | |
}); | |
var data = []; | |
var i = elements.length; | |
while (i--) { | |
//var el = Object.getOwnPropertyNames(data).filter(/./.test.bind(new RegExp("^g")))); | |
var el = JSON.parse(JSON.stringify(elements[i].dataset)); | |
var elslice={}; | |
for(prop in el){ | |
if(prop.match(/^g[EALT]/)){ | |
elslice[prop]=el[prop]; | |
} | |
} | |
elslice["gType"] = elements[i].nodeName; | |
data.push(elslice); | |
} | |
console.table(data); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment