Skip to content

Commit

Permalink
fortune - chrome extension
Browse files Browse the repository at this point in the history
Displays a insightful quote in your chrome tab.
  • Loading branch information
orsenthil authored and senthilkumaran-okta committed May 7, 2016
0 parents commit a431290
Show file tree
Hide file tree
Showing 11 changed files with 152 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.idea/
*.iml
31 changes: 31 additions & 0 deletions assets/css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
@import url(https://fonts.googleapis.com/css?family=Kalam:400,300);

body {
background: white
}

section {
background: #e2e2e2;
color: #000000;
border-radius: 2em;
padding: 1em;
position: absolute;
top: 50%;
left: 50%;
margin-right: -50%;
transform: translate(-50%, -50%);
width:600px;
max-width:650px;
font-size:160%;
}

.fortune {
}

.quote {
font-family: 'Kalam', cursive;
}

.author {
font-size: smaller;
}
Binary file added assets/img/icon128.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/icon16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/icon256.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/img/icon48.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions assets/js/handlebar.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions assets/js/jquery.js

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions assets/js/quotes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
var getRandomFortune = function () {
var fortuneDiv = ".fortune";
var quotesUrl = "http://quotes-1271.appspot.com/json";
var defaultQuote = "There are far, far better things ahead than any we leave behind.";
var defaultAuthor = "C.S.Lewis";

var getQuote = function() {
var quotes = $("#quotes").html();
var template = Handlebars.compile(quotes);

$.get(quotesUrl, function(response) {
if (response) {
$(fortuneDiv).append(template(response));
}
}).fail(function(_) {
$(fortuneDiv).append(template({quote:defaultQuote, author:defaultAuthor}))
});
};

return {
init: function () {
getQuote();
}
};
};

$(function () {
var fortune = new getRandomFortune();
fortune.init();
});
27 changes: 27 additions & 0 deletions fortune.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="assets/css/style.css">
<link href="assets/img/icon16.png" rel="icon" sizes="16x16" type="image/png">
<title></title>
</head>

<body>

<div class="fortune">
<script id="quotes" type="text/x-handlebars-template">
<section>
<p class="quote">{{quote}}</p>
<p class="quote author" align="right">{{author}}</p>
</section>
</script>
</div>


<script src="assets/js/jquery.js"></script>
<script src="assets/js/handlebar.js"></script>
<script src="assets/js/quotes.js"></script>

</body>
</html>
29 changes: 29 additions & 0 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"manifest_version" : 2,
"name" : "fortune",
"short_name": "fortune",
"description": "insightful quote every time you open a new tab.",
"version" : "0.1.0",
"permissions": [
"tabs",
"webNavigation",
"*://quotes-1271.appspot.com/*",
"http://quotes-1271.appspot.com/json",
"https://fonts.googleapis.com/*"
],
"icons": {
"16" : "assets/img/icon16.png",
"48" : "assets/img/icon48.png",
"128": "assets/img/icon128.png"
},
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"homepage_url": "http://www.xtoinfinity.com/posts/fortune.html",
"chrome_url_overrides": {
"newtab": "fortune.html"
},
"browser_action": {
"default_title": "",
"default_icon": "assets/img/icon256.png"
}
}

0 comments on commit a431290

Please sign in to comment.