diff --git a/.gitignore b/.gitignore index 7da7500..6197e58 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,5 @@ Temporary Items .apdisk bower_components +js/actions.js +js/actions.js diff --git a/css/style.css b/css/style.css index 5cf8636..439f045 100644 --- a/css/style.css +++ b/css/style.css @@ -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; } \ No newline at end of file diff --git a/js/actions.js b/js/actions.js deleted file mode 100644 index 9d097c8..0000000 --- a/js/actions.js +++ /dev/null @@ -1,15 +0,0 @@ -$(function(){ - $('.save-btn').click(save()); - $('.load-btn').click(load()); -}); - -var save = function() { - console.log('Hello'); - localStorage.scrollY = window.pageYOffset; - -}; - - var load = function() { - window.scroll(0, localStorage.scrollY); - console.log('Boo'); -}; \ No newline at end of file diff --git a/js/popup.js b/js/popup.js index 5bf3e6a..80c78ce 100644 --- a/js/popup.js +++ b/js/popup.js @@ -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); + }) +} diff --git a/manifest.json b/manifest.json index 6a9d2fc..25a2614 100644 --- a/manifest.json +++ b/manifest.json @@ -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;" } diff --git a/popup.html b/popup.html index b6c9d90..4e0f266 100644 --- a/popup.html +++ b/popup.html @@ -2,13 +2,15 @@ - - - - -

Search Content

-
- + + +

Search In History

+
+ +
+
+
some text
- + +