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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@ Temporary Items
.apdisk

bower_components
js/actions.js
js/actions.js
37 changes: 35 additions & 2 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,39 @@
margin-left: 15px;
}
.cont{
width: 110px;
position: inline;
width: 90%;
position: inline-flex;
}

.window{
width: 200px;
height: 180px;
}

.search-box{
padding: 5px;
margin: 5px;
border-width: thin;
border-color: #57b0b3;
border-radius: 4px;
box-shadow: -2px 1px 5px #888888;
}

.search-box:focus{
box-shadow: inset -2px 1px 5px #888888;
}

body{
background: #485a65;
}
.header {
font-family: cursive;
background: #F0F0F0;
border: 1px solid #CCC;
padding: 14px;
}
.content {
background: #F0F0F0;
border: 1px solid #CCC;
margin: 20px auto;
}
15 changes: 0 additions & 15 deletions js/actions.js

This file was deleted.

99 changes: 39 additions & 60 deletions js/popup.js
Original file line number Diff line number Diff line change
@@ -1,67 +1,46 @@
$(function(){
$('.save-btn').click(save);
$('.load-btn').click(load);
$('.search-btn').click(search);
});

var paint = function() {
chrome.tabs.executeScript({
code:'var prev = document.getElementById(\'page-marker\');'+
'if(prev != null){prev.remove();}'+

'var div = document.createElement(\"div\");'+
'div.style.width = (window.innerWidth * 2/100) +\"px\";'+
'var pointerHeight = ((window.innerHeight / (document.body.scrollHeight / window.innerHeight)) - 9);'+
'div.style.height = (pointerHeight >= 15.5 ? pointerHeight: 15.5) +\"px\";'+
'div.style.background = \"green\";'+

'div.style.position = \"fixed\";'+
'div.style.marginLeft = (window.innerWidth - 18.3 )+\"px\";'+
'div.style.top = window.pageYOffset / window.innerHeight * pointerHeight + 21 +\"px\";'+
'div.id = \"page-marker\";'+
'document.body.appendChild(div);'
});
};

var save = function() {

chrome.tabs.executeScript({
code:'localStorage.setItem(window.location.href,window.pageYOffset);'
});
paint();



};
var search = function(){

var object = {text: ''};
chrome.history.search(object, sendUrls);
// alert('afterSerach');
window.onload = function(){
document.getElementById('search-val').addEventListener('keypress', search, false);
}

var search = function(event){
if(event.keyCode == 13){
chrome.history.search({text: ''}, sendUrls);
}
}

var sendUrls = function(historyItem){
var urls = [];
for(var i = 0; i < historyItem.length; i++){
urls.push(element.url);
}
sendUrls(urls);
}

historyItem.forEach(function(element) {
console.log(element.url);
urls.push(element.url);
});
console.log(urls);
// historyItem.foreach(function(value){
// console.log(value.url);
// });

//console.log('return urls');
var sendUrls = function(urls){

//console.log(historyItem);
// alert(historyItem);
}
var data = {
query: document.getElementById('search-val').value,
urls: urls
}
data = JSON.stringify(data);

console.log('data');
console.log(data);

var load = function() {
chrome.tabs.executeScript({
code: 'window.scroll(0, localStorage.getItem(window.location.href));'
});


};
var myRequest = new Request('http://fathomless-tundra-65369.herokuapp.com/', {method: 'POST', body: data});

fetch(myRequest)
.then(function(response) {
if(response.status == 200){
document.getElementById('output').innerHTML = response.url;
return response;
}
else throw new Error('Something went wrong on api server!');
})
.then(function(response) {
console.debug(response);
})
.catch(function(error) {
console.error(error);
})
}
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"permissions": [
"history"
],
"content_security_policy": "default-src 'self'; connect-src http://127.0.0.1:8080 https://fathomless-tundra-65369.herokuapp.com;"
"content_security_policy": "default-src 'self'; connect-src http://127.0.0.1:8080/ https://fathomless-tundra-65369.herokuapp.com;"
}
18 changes: 10 additions & 8 deletions popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="js/jquery.min.js"></script>
<script src="js/popup.js"></script>
</head>
<body>
<h2>Search Content</h2>
<div class="cont">
<img class="button search-btn" src="img/open2.png"/>
</head>
<body class="window">
<h2 class="header">Search In History</h2>
<div>
<input placeholder="Enter your serach value" type="text" class="search-box" name="search" id="search-val"/>
</div>
<div class="content cont-output">
<div id="output"> some text </div>
</div>
</body>
<script src="js/popup.js"></script>
</body>
</html>