Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion Readme.MD
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,16 @@ Random 48 Laws of Power
=======================
Random48LawsOfPower is a browser (Chrome) new tab extension that shows a random law from the popular 48 Laws of Power Book by Robert Greene

![Random 48 Laws of Power](home.png)
![Random 48 Laws of Power](home.png)


=======================

Additions by Victor Akinwande

30 behaviours that will make you unstoppable

![Medium post by Benjamin P. Hardy](https://medium.com/personal-growth/30-behaviors-that-will-make-you-unstoppable-699b51ce87b3)


Random background image from unsplash.com
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>New Tab - Random 48 Laws of Power</title>
<title>New Tab - Random 48 Laws of Power + 30 tips to becoming unstoppable</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="styles.css" type="text/css" />
</head>
Expand Down
34 changes: 29 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
console.log(data);
var random = Math.floor(Math.random() * 48);
document.getElementById('id').innerHTML = data[random].name;
document.getElementById('law-title').innerHTML = data[random].title;
document.getElementById('law-desc').innerHTML = data[random].desc;
strimg ="#"
try
{


url = "https://api.unsplash.com/photos/random/?client_id=f8c37e9ef128f09611217b491dcb047b5237346a86df3b89c347f1a6722f03da"
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", url, false);
xmlHttp.send(null);

resp = xmlHttp.responseText;

strimg = JSON.parse(resp)["urls"]["regular"]

var body = document.getElementsByTagName('body')[0];
body.style.backgroundImage = 'url(' + strimg + ')';

}
catch(e)
{
console.log("image load failure")
}

var random = Math.floor(Math.random() * 78);

document.getElementById('id').innerHTML = data[random].name;
document.getElementById('law-title').innerHTML = data[random].title;
document.getElementById('law-desc').innerHTML = data[random].desc;

Loading