Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a new web page for dictionary #21

Merged
merged 7 commits into from
Nov 18, 2018
Merged
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
Binary file removed extension/icons/a_img.png
Binary file not shown.
Binary file added extension/icons/articles.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 extension/icons/dictionary.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 34 additions & 22 deletions extension/js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,7 @@ chrome.contextMenus.onClicked.addListener( function(clickData,$scope){
var text = clickData.selectionText;

//Search for meaning in the google
if(clickData.menuItemId == "meaning" && text)
{
if(clickData.menuItemId == "meaning" && text){
var googleUrl = "https://www.google.com/search?safe=active&q=define+" + fixedEncodeURI(clickData.selectionText);
var search = {
"url": googleUrl,
Expand Down Expand Up @@ -139,8 +138,7 @@ chrome.contextMenus.onClicked.addListener( function(clickData,$scope){
}

//Translate the selected text
if (clickData.menuItemId == "translation" && text )
{
if (clickData.menuItemId == "translation" && text ){
var googleUrl = "https://translate.google.com/#auto/en/" + fixedEncodeURI(clickData.selectionText);
var search = {
"url": googleUrl,
Expand All @@ -154,14 +152,12 @@ chrome.contextMenus.onClicked.addListener( function(clickData,$scope){
}

//Pronounce the selected text
if(clickData.menuItemId == "speak" && text)
{
if(clickData.menuItemId == "speak" && text){
chrome.tts.speak(clickData.selectionText, {'lang': 'en-US','rate': 0.7});
}

//Search the selected text in quora
if(clickData.menuItemId == "quora" && text)
{
if(clickData.menuItemId == "quora" && text){
var quoraUrl = "https://www.quora.com/search?q=" + fixedEncodeURI(clickData.selectionText)
var quoraSearch ={
"url":quoraUrl,
Expand All @@ -176,8 +172,7 @@ chrome.contextMenus.onClicked.addListener( function(clickData,$scope){
}

//Search the selected text in wikipedia
if(clickData.menuItemId == "wiki" && text)
{
if(clickData.menuItemId == "wiki" && text){
var wikiUrl = "https://en.wikipedia.org/wiki/" + fixedEncodeURI(clickData.selectionText)
var wikiSearch ={
"url":wikiUrl,
Expand All @@ -192,8 +187,7 @@ chrome.contextMenus.onClicked.addListener( function(clickData,$scope){
}

//Search the selected text in stackoverflow
if(clickData.menuItemId == "stack" && text)
{
if(clickData.menuItemId == "stack" && text){
var stackUrl = "https://stackoverflow.com/search?q=" + fixedEncodeURI(clickData.selectionText);
var stack = {
"url": stackUrl,
Expand All @@ -208,8 +202,7 @@ chrome.contextMenus.onClicked.addListener( function(clickData,$scope){
}

//Searches for the images
if(clickData.menuItemId == "images" && text)
{
if(clickData.menuItemId == "images" && text){
var imageUrl = "https://www.google.co.in/search?tbm=isch&sa=1&ei=4k3pW7TyNIrQvgSZn56wBA&btnG=Search&q="+ fixedEncodeURI(text)
var image = {
"url": imageUrl,
Expand All @@ -223,8 +216,7 @@ chrome.contextMenus.onClicked.addListener( function(clickData,$scope){
}

//Searches for the news
if(clickData.menuItemId == "news" && text)
{
if(clickData.menuItemId == "news" && text){
var newsUrl = "https://news.google.com/search?q="+ fixedEncodeURI(text)
var news = {
"url": newsUrl,
Expand All @@ -238,8 +230,7 @@ chrome.contextMenus.onClicked.addListener( function(clickData,$scope){
}

//Searches video for the selected text in youtube
if(clickData.menuItemId == "youtube" && text)
{
if(clickData.menuItemId == "youtube" && text){
var videosUrl = "https://www.youtube.com/results?search_query="+ fixedEncodeURI(text)
var videos ={
"url":videosUrl,
Expand All @@ -253,8 +244,7 @@ chrome.contextMenus.onClicked.addListener( function(clickData,$scope){
}

//Searches for the product in amazon
if(clickData.menuItemId == "amazon" && text)
{
if(clickData.menuItemId == "amazon" && text){
var amazonUrl = "https://www.amazon.in/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords="+ fixedEncodeURI(text)
var amazon ={
"url":amazonUrl,
Expand Down Expand Up @@ -340,8 +330,30 @@ chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
}
else if (!(request.savedArticles in allSavedArticles)){
console.log('NORMAL CASES')
details.savedArticlesCodeZero.savedArticles.push(request.savedArticles);
chrome.storage.local.set({'savedArticlesCodeZero':details.savedArticlesCodeZero})
console.log(request.savedArticles)
console.log(allSavedArticles)
let len = allSavedArticles.length;
let i =0;
let j= 0;
for(i=0;i<len;i++){
console.log(i)
console.log(request.savedArticles.URL)
console.log(allSavedArticles[i].URL)
if(request.savedArticles.URL === allSavedArticles[i].URL && i == len-1){
j=10;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

j =10; for what??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To have a check whether the loop is terminated at i = allSavedArticles.length, it is an extra condition. j=10, the value is specified only for a check, any value can be specified.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try using boolean expression for the same. Boolean is made for the purpose.

break;
}
if(request.savedArticles.URL === allSavedArticles[i].URL){
break;
}
}
if(j != 10){
if(i-1 == (allSavedArticles.length)-1){
console.log("hii")
details.savedArticlesCodeZero.savedArticles.push(request.savedArticles);
chrome.storage.local.set({'savedArticlesCodeZero':details.savedArticlesCodeZero})
}
}
}
})
}
Expand Down
2 changes: 1 addition & 1 deletion extension/templates/articles.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@ <h3>Article View</h3> <p><i>Below are the list of articles you have come across
</div>
</div>
</div>

<footer style="text-align:center;padding:20px;background-color:rgb(23, 57, 131);color:white;font-weight:bold;">Designed by Team CodeZero @HackaBIT, BIT Mesra</footer>
</body>
</html>
37 changes: 37 additions & 0 deletions extension/templates/dictionary.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<!DOCTYPE <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Dictionary</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="../styles/bootstrap.min.css" />

<script src="../js/options.js"></script>
</head>

<style>
h3{
font-weight: bolder;
font-size:35px;
color:brown;
}


</style>
<body>

<div style="margin:1% 3% 3% 3%;">
<div class="container-fluid">
<div class="row">
<h3>Dictionary View</h3> <p><i>Searched meanings below</i></p>
<br>
<div class="col-md-4" style="border:1px black solid;height:200px;border-radius: 10px;overflow-y:auto">
<div id="word_view" style="overflow-y:auto"></div>
</div>
</div>
</div>
</div>
<footer style="text-align:center;padding:20px;background-color:rgb(23, 57, 131);color:white;font-weight:bold;">Designed by Team CodeZero @HackaBIT, BIT Mesra</footer>
</body>
</html>
4 changes: 3 additions & 1 deletion extension/templates/front_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@
<body>
<h4 class="text-center" style="background-color:rgb(23, 57, 131);color: floralwhite;line-height: 30px; margin:0px !important; "><strong>PRODUCTIFY</strong><br></h4>
<div class="container">
<a href= "articles.html" target="_blank"><img src="../icons/a_img.png" alt="Saved Articles" style="height:25px;right:40px;position:absolute;"></a>

<a href= "dictionary.html" target="_blank"><img src="../icons/dictionary.png" alt="Saved Articles" style="height:25px;right:70px;position:absolute;"></a>
<a href= "articles.html" target="_blank"><img src="../icons/articles.png" alt="Saved Articles" style="height:25px;right:40px;position:absolute;"></a>
<a href="options.html" target="_blank"><img src="../icons/settings.png" alt="Settings page" style="height:25px;right:10px;position:absolute;"></a>
<div class="col-md-12 ">
<h5>Your Productivity Score: <span id="thiss"></span> </h5>
Expand Down
10 changes: 5 additions & 5 deletions extension/templates/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,17 +97,17 @@ <h3>Article View</h3> <p><i>Below are the list of articles you have come across
</div>

</div>
</div> -->
<br>
<hr>
<div class="row">
</div>
<br>
<hr>
<div class="row">
<h3>Dictionary View</h3> <p><i>Searched meanings below</i></p>
<br>
<div class="col-md-4" style="border:1px black solid;height:200px;border-radius: 10px;overflow-y:auto">
<div id="word_view" style="overflow-y:auto"></div>
</div>
</div>
<br>
<br> -->
</div>
</div>
<footer style="text-align:center;padding:20px;background-color:rgb(23, 57, 131);color:white;font-weight:bold;">Designed by Team CodeZero @HackaBIT, BIT Mesra</footer>
Expand Down