-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
Showing
12 changed files
with
400 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.