Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Run this against a content type page to get the HTML for the columns!
- els = array of elements
- type = ["li"|"td"|"th"]
- */
- function create(el, type) {
- for (var i=10;i<el.length;i++) {
- var fieldname, displayname, outputHTML;
- /* Drag the field name out of the relevant URL, then decode it */
- fieldname = el[i].querySelector("a").getAttribute("href");
- fieldname = fieldname.substring(fieldname.indexOf('Field=')+6,fieldname.indexOf('&Fid'));
- fieldname = decodeURIComponent(fieldname);
- if (Number(fieldname.charAt(0)) > 0) {
- fieldname = "_x003" + fieldname.charAt(0) + "_" + fieldname.substring(1);
- }
- /* Drag a friendly title straight off the page */
- displayname = el[i].innerText;
- /* Now build the HTML */
- switch (type) {
- case "li":
- outputHTML = '<li><h3>' + displayname + '</h3><p><xsl:value-of disable-output-escaping="yes" select="@' + fieldname + '" /></p></li>';
- break;
- case "th":
- outputHTML = '<th class="type2" hidden="hidden">' + displayname + '</th>';
- break;
- case "td":
- outputHTML = '<td class="type2" hidden="hidden"><xsl:value-of disable-output-escaping="yes" select="@' + fieldname + '" /></td>';
- break;
- case "fieldname":
- outputHTML = '<FieldRef Name="' + fieldname + '" />';
- break;
- default:
- console.log('Type must be "li", "td", "th" or "fieldname".');
- break;
- }
- console.log(outputHTML);
- }
- }
- var els = document.querySelectorAll("#columnstable tr[class] td:first-of-type");
- create(els,"li");
- create(els,"th");
- create(els,"td");
- create(els,"fieldname");
Add Comment
Please, Sign In to add comment