Skip to content

Commit

Permalink
Merge branch 'ft-bookmarks'
Browse files Browse the repository at this point in the history
* ft-bookmarks:
  Bookmarks are enabled by default
  Added Donation link address
  Changed the favicon width/height
  Added styling to remove the bookmark button
  Added logic to remove the bookmark and get the favicon if they don't supply it
  Added text about the icon and button to remove the bookmark
  Added logic to get, set, show, modify bookmarks
  Added more styling rules
  Increased version number
  Added logic to show/hide bookmarks
  Added ability to toggle bookmarks on/off and able to customize them
  Added default images
  • Loading branch information
409H committed Aug 27, 2017
2 parents ebcd776 + 90bf033 commit 560ca6e
Show file tree
Hide file tree
Showing 12 changed files with 400 additions and 40 deletions.
33 changes: 32 additions & 1 deletion css/app.css
Expand Up @@ -37,6 +37,37 @@
#ext-etheraddresslookup-report {
margin-bottom: 20px;
padding: 8px 20px 8px 17px;
margin-left: 10px;
width: 100%;
font-size: 10pt;
}

.ext-etheraddresslookup-center {
text-align: center;
}

#ext-etheraddresslookup-bookmarks {
margin-bottom: 10px;
}

.ext-etheraddresslookup-bookmark_icon {
width: 16px;
height: 16px;
display: inline-block;
}

.ext-etheraddresslookup-bookmark_icon:hover {
opacity: 0.5;
}

.ext-etheraddresslookup-bookmark_icon:nth-child(2n) {
margin-left: 15px;
margin-right: 15px;
}

#ext-etheraddresslookup-bookmark_modify_window {
display: none;
color: #252428;
margin-top: 5%;
padding: 15px 5%;
background: #e4e4e4;
}
65 changes: 65 additions & 0 deletions css/settings.css
@@ -0,0 +1,65 @@
body {
background: #00c2c1;
padding: 50px;
font-family: 'Montserrat', sans-serif;
color: #ffffff;
font-weight: 600;
}

h3 {
font-size: 23pt;
}

.pure-g {
margin-bottom: 5%;
}

.pure-u-1-3 > p {
font-size: 10pt;
font-weight: 500;
color: #b4b4b4;
}

.pure-u-1-3 > p > .label {
font-weight: 700;
}

.pure-u-1-3 {
background: #fff;
color: #000;
border: 3px solid #009c9b;
padding: 15px;
}
.lblbox {
border: 1px solid #eeeeee;
border-radius: 5px;
background: #d4d4d4;
padding: 5px;
margin: 5px;
display: inline-block;
}
.pure-table {
width: 100%;
}

.note {
color: #b4b4b4;
font-style: italic;
font-size: 10pt;
}
#ext-etheraddresslookup-bookmark_modify_remove {
font-size: 85%;
background: rgb(202, 60, 60);
color: #fff;
}

#donate_address {
font-size: 80%;
background: #fffdfd;
padding: 2px;
border: 1px solid #ffe4e4;
color: #009d9c;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
}
Binary file added images/bookmarks/etherchain.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bookmarks/etherscan.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bookmarks/ethplorer.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bookmarks/myetherwallet.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bookmarks/rethereum.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added images/bookmarks/rethtrader.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
173 changes: 173 additions & 0 deletions js/app/toggleBookmarks.js
@@ -0,0 +1,173 @@
//On page load it checks/unchecks the checkbox
(function() {
refreshBookmarksOption();
showBookmarks();

//Check to see if we are on settings.html
if(document.getElementById("ext-etheraddresslookup-show_bookmarks")) {
document.getElementById("ext-etheraddresslookup-show_bookmarks").addEventListener("change", toggleBookmarks);

var objModifyBookmarks = document.getElementsByClassName("ext-etheraddresslookup-bookmarks_modify");
for(var i = 0; i < objModifyBookmarks.length; i++) {
objModifyBookmarks[i].addEventListener("click", showModifyWindow, false);
}
}
})();

//Sets the local storage to remember their match highlight settings
function toggleBookmarks()
{
var objShowBookmarks = document.getElementById("ext-etheraddresslookup-show_bookmarks");
var intShowBookmarks = objShowBookmarks.checked ? 1 : 0;
localStorage.setItem("ext-etheraddresslookup-show_bookmarks", intShowBookmarks);

refreshBookmarksOption();
}

function refreshBookmarksOption()
{
var intShowBookmarks = localStorage.getItem("ext-etheraddresslookup-show_bookmarks");

if(document.getElementById("ext-etheraddresslookup-show_bookmarks")) {
document.getElementById("ext-etheraddresslookup-show_bookmarks").checked = (intShowBookmarks == 1 || intShowBookmarks === null ? true : false);
document.getElementById("ext-etheraddresslookup-show_bookmarks_text").innerText = (intShowBookmarks == 1 || intShowBookmarks === null ? "Enabled" : "Disabled");
}

if(document.getElementById("ext-etheraddresslookup-bookmarks")) {
document.getElementById("ext-etheraddresslookup-bookmarks").style.display = (intShowBookmarks == 1 || intShowBookmarks === null ? "block" : "none");
}
}

/**
* Fetches the bookmarks from LocalStorage (or default)
*/
function getBookmarks()
{
var strBookmarks = localStorage.getItem("ext-etheraddresslookup-bookmarks");
//No bookmarks have been set, set the default ones.
if(strBookmarks === null) {
var arrBookmarks = new Array();
arrBookmarks.push({
"icon": "images/bookmarks/myetherwallet.png",
"url": "https://myetherwallet.com"
});
arrBookmarks.push({
"icon": "images/bookmarks/etherscan.png",
"url": "https://etherscan.io"
});
arrBookmarks.push({
"icon": "images/bookmarks/etherchain.jpg",
"url": "https://etherchain.org"
});
arrBookmarks.push({
"icon": "images/bookmarks/ethplorer.jpg",
"url": "https://ethplorer.io"
});
arrBookmarks.push({
"icon": "images/bookmarks/rethereum.png",
"url": "https://reddit.com/r/ethereum"
});
arrBookmarks.push({
"icon": "images/bookmarks/rethtrader.png",
"url": "https://reddit.com/r/ethtrader"
});
} else {
arrBookmarks = JSON.parse(strBookmarks);
}

return arrBookmarks;
}

/**
* Renders the bookmarks for options.html and settings.html
*/
function showBookmarks()
{
var arrBookmarks = getBookmarks();

//We are on the settings view
if(document.getElementById("ext-etheraddresslookup-bookmarks_table")) {
for (var i = 0; i < arrBookmarks.length; i++) {
var objTable = document.getElementById("ext-etheraddresslookup-bookmarks_table").getElementsByTagName("tbody")[0];
var objRow = objTable.insertRow(objTable.rows.length);

//Show the icon
var objCellIcon = objRow.insertCell(0);
objCellIcon.appendChild(document.createTextNode(""));
if( arrBookmarks[i].icon.length > 0 ) {
objCellIcon.innerHTML = "<img src='" + arrBookmarks[i].icon + "' class=\"ext-etheraddresslookup-bookmark_icon\" />";
}

//Show the link
var objCellLink = objRow.insertCell(1);
objCellLink.appendChild(document.createTextNode(arrBookmarks[i].url));
if( arrBookmarks[i].url.length === 0 ) {
objCellLink.innerHTML = "<span class='note'>Unused bookmark</span>";
}

//Add a modify links
var objCellModify = objRow.insertCell(2);
objCellModify.appendChild(document.createTextNode(""));
objCellModify.innerHTML = "<button class='ext-etheraddresslookup-bookmarks_modify' data-id='"+ i +"'>Modify</button>";
}
}

if(document.getElementById("ext-etheraddresslookup-bookmarks")) {
for (var i = 0; i < arrBookmarks.length; i++) {
if(arrBookmarks[i].icon.length === 0) {
continue;
}
var objLink = document.createElement("span");
objLink.className = 'ext-etheraddresslookup-bookmark_icon';
objLink.innerHTML = "<a href='"+ arrBookmarks[i].url +"' target='_blank'><img src='"+ arrBookmarks[i].icon +"' class=\"ext-etheraddresslookup-bookmark_icon\"></a>";
document.getElementById("ext-etheraddresslookup-bookmarks").appendChild(objLink);
}
}
}

/**
* Shows the modify bookmark window
*/
function showModifyWindow()
{
var intBookmarkId = this.getAttribute("data-id");
var objBookmarks = getBookmarks();
document.getElementById("ext-etheraddresslookup-bookmark_modify_id").value = intBookmarkId;
document.getElementById("ext-etheraddresslookup-bookmark_modify_icon").value = objBookmarks[intBookmarkId].icon;
document.getElementById("ext-etheraddresslookup-bookmark_modify_url").value = objBookmarks[intBookmarkId].url;
document.getElementById("ext-etheraddresslookup-bookmark_modify_form").setAttribute("data-id", intBookmarkId);
document.getElementById("ext-etheraddresslookup-bookmark_modify_form").addEventListener('submit', function(objEvent) {
objEvent.preventDefault();
var intId = document.getElementById("ext-etheraddresslookup-bookmark_modify_id").value;

//See if the icon is blank
var strIconLink = document.getElementById("ext-etheraddresslookup-bookmark_modify_icon").value;
if(document.getElementById("ext-etheraddresslookup-bookmark_modify_icon").value === "") {
strIconLink = "https://www.google.com/s2/favicons?domain="+ document.getElementById("ext-etheraddresslookup-bookmark_modify_url").value;
}

objBookmarks[intId] = {
"icon": strIconLink,
"url": document.getElementById("ext-etheraddresslookup-bookmark_modify_url").value
}

localStorage.setItem("ext-etheraddresslookup-bookmarks", JSON.stringify(objBookmarks));
location.reload();
return false;
}.bind(objBookmarks));

document.getElementById("ext-etheraddresslookup-bookmark_modify_remove").addEventListener('click', function(objEvent) {
objEvent.preventDefault();
var intId = document.getElementById("ext-etheraddresslookup-bookmark_modify_id").value;
objBookmarks[intId] = {
"icon": "",
"url": ""
}

localStorage.setItem("ext-etheraddresslookup-bookmarks", JSON.stringify(objBookmarks));
location.reload();
return false;
}.bind(objBookmarks));

document.getElementById("ext-etheraddresslookup-bookmark_modify_window").style.display = "block";
}
2 changes: 1 addition & 1 deletion manifest.json
Expand Up @@ -4,7 +4,7 @@
"name": "EtherAddressLookup",
"short_name": "EtherAddressLookup",
"description": "Adds links to strings that look like Ethereum addresses to your favorite blockchain explorer.",
"version": "1.5.3",
"version": "1.6",

"browser_action": {
"default_icon": "images/icon.png",
Expand Down

0 comments on commit 560ca6e

Please sign in to comment.