Skip to content

Commit

Permalink
1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
reticivis-net committed Jul 24, 2020
1 parent 4d2271c commit be5c855
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 48 deletions.
10 changes: 6 additions & 4 deletions evergreen_newtab/changelog.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<h3>Changelog v1.2</h3>
<h3>Changelog v1.3</h3>
<h4>Features</h4>
<ul>
<li>New option to change from the default icon set (Adam Whitcroft's Climacons) to FontAwesome icons.</li>
<li>Option to download current background.</li>
<li>Warning to save unsaved changes.</li>
<li>Hourly weather view changed from pagination to scrolling.</li>
<li>Added some icons to the weather popup.</li>
<li>Added extra current weather info such as the wind speed.</li>
<li>Made text fields (google search & in settings) dark.</li>
<li>Removed reliance on my web server for handling offline backgrounds.</li>
</ul>
30 changes: 29 additions & 1 deletion evergreen_newtab/evergreen.css
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ a.popper:focus {
font-size: 100%;
}

.weatherpopover *, .weatherh3 * {
.weatherblock * {
vertical-align: middle;
}

Expand All @@ -207,4 +207,32 @@ a.popper:focus {

.btn-circle svg {
vertical-align: -.125em;
}

.whourlycontent {
overflow-x: scroll;
width: 500px;
display: block;
white-space: nowrap;
scrollbar-color: dark;
margin-bottom: 5px;
}

::-webkit-scrollbar {
background-color: #202324;
color: #aba499;
height: 15px;
}

::-webkit-scrollbar-thumb {
background-color: #454a4d;
}

::-webkit-scrollbar-track, ::-webkit-scrollbar-thumb {
border-radius: 15px !important;
}

.form-control, .form-control:focus {
background: var(--secondary);
color: #ccc;
}
80 changes: 38 additions & 42 deletions evergreen_newtab/evergreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ var promotional = false; // use the same BG for promotionial purposes
var development = false; // enables debug prints

var version = chrome.runtime.getManifest().version;

var weatherpage = 0;
debugp("Evergreen in development mode");

function debugp(string) {
Expand Down Expand Up @@ -57,9 +55,18 @@ function httpGetAsync(theUrl, callback) {
xmlHttp.send(null);
}

/*
function followredirects(url, callback) {
var theUrl = `https://reticivis.net/follow-redirect.php?url=${encodeURIComponent(url)}`;
httpGetAsync(theUrl, callback);
}*/
function followredirects(url, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function () {
callback(this.responseURL); //cant fucking believe i was using a web server to do this for like a year
}
xhr.open('HEAD', url, true);
xhr.send();
}

function datetime() {
Expand Down Expand Up @@ -148,6 +155,13 @@ function tunit(temp) { //for general use to have one function for every temperat
return Math.round(temp);
}

function sunit(speed) { // cleaner to define it here
if (tempunit === "c") {
speed = speed * 1.609344;
}
return Math.round(speed);
}

function climacon(prop) {
if (iconset === "climacons") {
var climacons = {
Expand Down Expand Up @@ -200,22 +214,25 @@ function weather(response, showafter = false) {
chrome.storage.local.set({
"weather": response
});
debugp(`Weather page ${weatherpage}`);
var temp = response.currently.temperature;
$(".wdaily").html(response.daily.summary);
$(".whourly").html(response.hourly.summary);
$(".wdaily").html("<i class=\"fas fa-calendar-week\"></i> " + response.daily.summary);
$(".whourly").html("<i class=\"fas fa-calendar-day\"></i> " + response.hourly.summary);
if (response.minutely) { // not all regions have minutely
$(".wminutely").html(response.minutely.summary);
$(".wminutely").html("<i class=\"fas fa-clock\"></i> " + response.minutely.summary);
} else {
$(".wminutely").html(response.currently.summary);
$(".wminutely").html("<i class=\"fas fa-clock\"></i> " + response.currently.summary);
}
$(".whourlycontent").html("");
$(".wdailycontent").html("");
$(".walerts").html("");
$("#weatherimage").html(`${climacon(response.currently.icon)}`);
response.hourly.data.slice(weatherpage * 7, 7 + weatherpage * 7).forEach(function (hour, i) {
// weatherpage * 7, 7 + weatherpage * 7
let todaydate = new Date().getDate();
let nextday = false;
response.hourly.data.slice().forEach(function (hour, i) {
var paginationtime = "";
if (weatherpage > 0) {
if (new Date(hour.time * 1000).getDate() !== todaydate || nextday) {
nextday = true;
paginationtime = "<p class=\"pfix\">" + dayofepoch(hour.time) + " " + localeHourString(hour.time) + "</p>";
}
$(".whourlycontent").append(`
Expand All @@ -228,13 +245,7 @@ function weather(response, showafter = false) {
</div>
`);
});
if (weatherpage > 0) {
$(".whourlycontent").append("<a class=\"btn btn-sm btn-primary btn-circle weather-pagination-left\"><i class=\"fas fa-chevron-left\"></i></a>");
}
if (weatherpage < 6) {
$(".whourlycontent").append("<a class=\"btn btn-sm btn-primary btn-circle weather-pagination-right\"><i class=\"fas fa-chevron-right\"></i></a>");
}
response.daily.data.slice(0, 7).forEach(function (day, i) {
response.daily.data.slice().forEach(function (day, i) {
var accum = "";
if (day.precipAccumulation) {
accum = day.precipAccumulation;
Expand All @@ -256,6 +267,13 @@ function weather(response, showafter = false) {
</div>
`);
});
var cur = response.currently;
$(".wminutelycontent").html(`
<h5 class="pfix"><i class="fas fa-thermometer-half"></i> Feels like: ${tunit(cur.apparentTemperature)}°</h5>
<h5 class="pfix"><i class="fas fa-sun"></i> UV Index: ${cur.uvIndex}</h5>
<h5 class="pfix"><i class="fas fa-wind"></i> Wind Speed: ${sunit(cur.windSpeed)} ${tempunit == "c" ? "km/h" : "mph"}</h5>
<h5 class="pfix"><i class="fas fa-tint"></i> Humidity: ${cur.humidity * 100}%</h5>
`);

if (response.alerts) {
response.alerts.forEach(function (alert, i) {
Expand Down Expand Up @@ -288,32 +306,9 @@ function weather(response, showafter = false) {
title: function () {
return $($(this).find(".ttcontent")[0]).html();
},
trigger: "hover"
});
//weather pagination
$(".weather-pagination-left").on('click', function (event) {
event.stopPropagation();
event.stopImmediatePropagation();
if (weatherpage > 0) {
weatherpage = weatherpage - 1;
$(".popover").css("transition-duration", "0");
chrome.storage.local.get(["weather"], function (resp) {
weather(resp["weather"], true);
});
}
});
$(".weather-pagination-right").on('click', function (event) {
event.stopPropagation();
event.stopImmediatePropagation();

if (weatherpage < 6) {
weatherpage = weatherpage + 1;
$(".popover").css("transition-duration", "0");
chrome.storage.local.get(["weather"], function (resp) {

weather(resp["weather"], true);
});
}
trigger: "hover",
placement: "top",
boundary: "window"
});
});
$("#weatherpopover").on("hidden.bs.popover", function () {
Expand Down Expand Up @@ -443,6 +438,7 @@ function backgroundhandler() {
if (!promotional) {
debugp("changing BG...");
followredirects(`https://source.unsplash.com/${window.screen.width}x${window.screen.height}/?${searchtags}`, function (response) {
console.log(response);
debugp("redirect followed");
preloadImage(response, function () {
$(".bg").css("background-image", `url(${response})`);
Expand Down
2 changes: 1 addition & 1 deletion evergreen_newtab/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Evergreen New Tab",
"short_name": "Evergreen",
"description": "A beautiful and minimalistic new tab extension for Chrome",
"version": "1.2",
"version": "1.3",
"permissions": [
"storage",
"geolocation"
Expand Down
1 change: 1 addition & 0 deletions evergreen_newtab/newtab.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ <h5><span class="whourly">${response.hourly.summary}</span></h5>
<span class="whourlycontent">
</span>
<h5 class="pfix"><span class="wminutely">${response.minutely.summary}</span></h5>
<span class="wminutelycontent"></span>
<span class="walerts"></span>
</div>

Expand Down

0 comments on commit be5c855

Please sign in to comment.