Skip to content

Instantly share code, notes, and snippets.

@codewizard13
Created November 4, 2015 22:24
Show Gist options
  • Save codewizard13/ea49fc4a0da8e9510c05 to your computer and use it in GitHub Desktop.
Save codewizard13/ea49fc4a0da8e9510c05 to your computer and use it in GitHub Desktop.
var arrTabGroups = JSON.parse(localStorage.state)
var strOut = '';
for (var i=0; i<arrTabGroups.tabGroups.length; ++i) {
var outTabGroup = '';
// has label?
// doesn't work ...
//var label = arrTabGroups.tabGroups[i].label != "" ? arrTabGroups.tabGroups[i].label : "--- no label --";
// this one works! if label not undefined ...
var label = typeof arrTabGroups.tabGroups[i].label != 'undefined' ? arrTabGroups.tabGroups[i].label : "--- NO LABEL: Tab Group # [" + i + "] --";
//console.log("LABEL " + i + ": " + label);
/*
foreach tabGroup
*/
// If there is a label, print the label, otherwise print '--------'
//var bHasLabel = typeof arrTabGroups.tabGroups[i].label != 'undefined' ? true : false;
var labelText = "<h2 style='background-color:orange; border:solid black 2px; border-radius: 15px;padding: 10px;'>";
labelText += label;
labelText += "</h2>";
console.log(labelText);
// make unordered list of all links under here
var linkList = "<ul style='list-style: none'>";
// loop through all links ...
var linksCount = arrTabGroups.tabGroups[i].tabsMeta.length;
console.log("linksCount = " + linksCount);
for (var j=0; j<linksCount; ++j) {
console.log('Link object: ' + j);
console.log('ID: ' + arrTabGroups.tabGroups[i].tabsMeta[j].id);
console.log('TITLE: ' + arrTabGroups.tabGroups[i].tabsMeta[j].title);
console.log('URL: ' + arrTabGroups.tabGroups[i].tabsMeta[j].url);
var id = arrTabGroups.tabGroups[i].tabsMeta[j].id;
var title = arrTabGroups.tabGroups[i].tabsMeta[j].title;
var url = arrTabGroups.tabGroups[i].tabsMeta[j].url;
var currentLink = "<li>" + id + " <a href='" + url + "' target='_blank' >" +
title + "</a></li>";
linkList += currentLink;
}
// console.log(formatted link data)
linkList += "</ul>";
// BUILD OUT HTML STRING:
outTabGroup += labelText + linkList + "<hr />";
strOut += outTabGroup;
}
//var win = window.open('http://stackoverflow.com/', '_blank');
/*
var win = window.open("", "Title", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=yes, width=780, height=200, top="+(screen.height-400)+", left="+(screen.width-840));
win.document.body.innerHTML = "HTML";
*/
var win = window.open("", "APPLES");
win.document.body.innerHTML = strOut;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment