Skip to content

Commit

Permalink
Showing a custom icon for each link.
Browse files Browse the repository at this point in the history
An image URL can be specified for each link as fourth
attribute, after a (possibly empty) shortcut.
Showing images for links can be disabled through
'icons.showIcons' configuration parameter.

I also increased block width from '140px' to '160px'
considering spaced possibly required by icons.
  • Loading branch information
grussorusso committed Dec 6, 2015
1 parent 8921620 commit 0534be4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 5 deletions.
Binary file added images/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
-->

Title 1
http://google.com || Google yeah || g
http://google.com || Google yeah || g || images/icon.png
http://deviantart.com || dA || da

Title 2
Expand Down
22 changes: 19 additions & 3 deletions js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ var settings = {

"animation": {
"hideLinks": true
},

"icons": {
"showIcons": true
}
};

Expand Down Expand Up @@ -141,25 +145,37 @@ $(document).ready(function() {
continue;
}

/* Split URL and Title *\
/* Split URL, Title and icon (if any) *\
\*=======================*/
var lineArray = line.split(" || ");
var url = lineArray[0];
var title = lineArray[1];

var icon = "";
if (lineArray[3]) {
icon = lineArray[3];
}

/* Add to shortcuts array *\
\*=========================*/
if(lineArray[2]) {
shortcuts[lineArray[2]] = "'"+url+"'";
}

/* Prepares HTML code for showing icon *\
\*=====================================*/
var iconHtml = '';
if (settings.icons.showIcons && icon) {
iconHtml = '<img src="' + icon + '"/>';
}

/* Add HTML code *\
\*=================*/
if(settings.navigation.newWindow) {
html = html + '<li><a href="' + url + '" target="_blank">' + title + '</a></li>'
html = html + '<li>' + iconHtml + '<a href="' + url + '" target="_blank">' + title + '</a></li>'
}
else {
html = html + '<li><a href="' + url + '">' + title + '</a></li>'
html = html + '<li>' + iconHtml + '<a href="' + url + '">' + title + '</a></li>'
}
}

Expand Down
9 changes: 8 additions & 1 deletion style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ a:hover {
border-left: 1px solid #999; /* Left border of link block */
float: left;
padding: 1em; /* Padding around link block */
width: 140px; /* Link block width */
width: 160px; /* Link block width */
}

h1 {
Expand All @@ -69,6 +69,13 @@ ul li {
padding: 5px;
}

li img {
width: 16px;
border-width: 0;
margin: 5px;
vertical-align: middle;
}

#searches {
position: absolute; /* Position search box */
top: 2em; /* from top edge */
Expand Down

0 comments on commit 0534be4

Please sign in to comment.