narrow window conf

This commit is contained in:
q
2017-05-31 22:50:11 +03:00
parent 9200eb36c7
commit 20542265af
2 changed files with 7 additions and 2 deletions

View File

@@ -1,5 +1,6 @@
config.source="example_links.txt"; config.source="example_links.txt";
config.columns=3; config.columns=3;
config.narrow=500; // less than N pixels window results in single column
config.title="MDLinks"; config.title="MDLinks";
config.favicon=null; // link to favicon config.favicon=null; // link to favicon
config.css=null; // link to style file config.css=null; // link to style file

View File

@@ -57,6 +57,9 @@ function init() {
hitList=search_hits(document.getElementById("filter").value); hitList=search_hits(document.getElementById("filter").value);
print_results(hitList); print_results(hitList);
} }
function narrow_window() {
return window.innerWidth < config.narrow;
}
String.prototype.capitalizeFirstLetter = function() { String.prototype.capitalizeFirstLetter = function() {
return this.charAt(0).toUpperCase() + this.slice(1); return this.charAt(0).toUpperCase() + this.slice(1);
} }
@@ -134,7 +137,7 @@ function print_results(hitList) {
var cat=0; var cat=0;
for (c=0; c<linkList.length; c++) { for (c=0; c<linkList.length; c++) {
if ( linkList[c].substring(0,2) == "# " ) { if ( linkList[c].substring(0,2) == "# " ) {
if (cat%config.columns==0) { tbody.innerHTML+="<tr>"; } if (cat%config.columns==0 || narrow_window()) { tbody.innerHTML+="<tr>"; }
var td=document.createElement("td"); var td=document.createElement("td");
td.innerHTML+=make_head(linkList[c]); td.innerHTML+=make_head(linkList[c]);
tbody.appendChild(td); tbody.appendChild(td);
@@ -206,7 +209,8 @@ var config = {
search:true, // include search bar search:true, // include search bar
columns:4, // number of columns for link table columns:4, // number of columns for link table
style:null, // file to load css from style:null, // file to load css from
favicon:null // link to favicon file favicon:null, // link to favicon file
narrow:600 // pixel width that is narrow screen = single column table
}; };
</script> </script>