Skip to content

Instantly share code, notes, and snippets.

@tmpvar
Forked from Marak/JUP.node.js
Created June 9, 2010 05:24
Show Gist options
  • Save tmpvar/431094 to your computer and use it in GitHub Desktop.
Save tmpvar/431094 to your computer and use it in GitHub Desktop.
(function( window, undefined ) {
var JUP = {};
// Define a local copy of parseDOM JUP
JUP.parseDOM = function(items, ARR){
if(typeof ARR == 'undefined'){
var ARR = [];
}
window.jQuery(items).each(function(i,e){
if(window.jQuery(e).children().length){
JUP.parseDOM(window.jQuery(e).children(), ARR);
}
else{
var arr = [];
arr.push(window.jQuery(e)[0].tagName);
if(window.jQuery(e)[0].attributes.length){
window.jQuery(window.jQuery(e)[0].attributes).each(function(i,e){
var attr = {};
attr[e.name] = e.value;
arr.push(attr);
})
}
if(window.jQuery(e).html().length){
arr.push(window.jQuery(e).html());
}
ARR.push(arr);
}
});
return ARR;
};
window.JUP = window.JUP = JUP;
})(window || exports);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment