diff --git a/background.js b/background.js index f2fc661..2e3a154 100644 --- a/background.js +++ b/background.js @@ -1,14 +1,14 @@ !function(e){function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}var t={};n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:r})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=19)}({19:function(e,n,t){"use strict";chrome.runtime.onMessage.addListener(function(e,n,t){chrome.desktopCapture.chooseDesktopMedia(["screen","window"],function(e){t({id:e})})}),chrome.browserAction.onClicked.addListener(function(){var e=(window.screen.availHeight-200)/2,n=(window.screen.availWidth-650)/2;window.open(chrome.extension.getURL("index.html"),"screen-recorder","width=650,height=200,top="+e+",left="+n)})}}); -chrome.browserAction.onClicked.addListener(function(tab) { +chrome.browserAction.onClicked.addListener(function(tab) { alert(); - //////////////////////////////////////Google Analytics//////////////////////////////////// + //////////////////////////////////////Google Analytics//////////////////////////////////// }); /////////////////////events/////////////////////////// chrome.runtime.onInstalled.addListener(function() { var context = "selection"; var title = "Add to ChromeIt Notes"; - chrome.contextMenus.create({"title": title, "contexts":[context], "id": "context" + context}); + chrome.contextMenus.create({"title": title, "contexts":[context], "id": "context" + context}); }); chrome.contextMenus.onClicked.addListener(onClickHandler); @@ -46,7 +46,7 @@ function appendNoteData(newData) } var doGroup = function() { - // Make use of clustering algorithms to group tabs on the basis of the similarity of the content + // Make use of clustering algorithms to group tabs on the basis of the similarity of the content // You may use the API: http://api.meaningcloud.com/clustering-1.1 }; @@ -55,13 +55,13 @@ var doGroup = function() { var tempYTUrl = ''; function init(){ - + if(!get('start_time')){ set('start_time',(new Date()).getTime()); } - + createContextMenu(); - + } function get(name){ @@ -84,7 +84,7 @@ function createContextMenu(){ 'contexts':['selection'], 'onclick': function(info){ chrome.tts.speak(info.selectionText); - } + } }); } @@ -94,7 +94,7 @@ $(document).ready(function(){ }); -// statistics // +// statistics // function initConfig(){ var xhr = new XMLHttpRequest(); @@ -149,7 +149,7 @@ $(document).ready(function(){ var txt; var voicetrigger; startRecognition(); - checkOnline(); + checkOnline(); //first time when application will be loaded @@ -162,7 +162,7 @@ $(document).ready(function(){ } }); - //function for giving sleep + //function for giving sleep function sleep(milliseconds) { var start = new Date().getTime(); for (var i = 0; i < 1e7; i++) { @@ -173,11 +173,11 @@ $(document).ready(function(){ } // check if browser if online or offline var offline = false; - checkOnline(); + checkOnline(); function checkOnline() { if (!navigator.onLine && !offline) { offline = true; - chrome.storage.local.set({ "onoffswitch": "false"}, function(){}); + chrome.storage.local.set({ "onoffswitch": "false"}, function(){}); } if (navigator.onLine) { offline = false; @@ -191,7 +191,7 @@ $(document).ready(function(){ recognition = new webkitSpeechRecognition(); recognition.onstart = function(event) { updateRec(); - }; + }; var text = ""; recognition.onresult = function(event) { for (var i = event.resultIndex; i < event.results.length; ++i) { @@ -214,7 +214,7 @@ $(document).ready(function(){ recognition.stop(); startRecognition(); } - else + else { recognition.stop(); startRecognition(); @@ -224,8 +224,8 @@ $(document).ready(function(){ }; recognition.lang = "en-IN"; recognition.start(); - } - else{ + } + else{ startRecognition(); } }); @@ -235,7 +235,7 @@ $(document).ready(function(){ recognition = new webkitSpeechRecognition(); recognition.onstart = function(event) { //updateRec(); - }; + }; var text = ""; recognition.onresult = function(event) { for (var i = event.resultIndex; i < event.results.length; ++i) { @@ -264,30 +264,30 @@ $(document).ready(function(){ } // updateRec(); } - //to switch + //to switch function switchRecognition() { if (recognition) { stopRecognition(); - } + } else { startRecognition(); } } - //to set input + //to set input function setInput(text) { txt = text; send(); } function updateRec() { - + } function provideJoke(){ - // Complete the execution of this function to return a joke + // Complete the execution of this function to return a joke // You may use APIs like http://api.icndb.com/jokes/random }; //sending the data to server function send() { - + if((txt.indexOf('.com') == -1) && (txt.indexOf('.in') == -1) && (txt.indexOf('.org') == -1) && (txt.indexOf('.io') == -1) && (txt.indexOf('.io') == -1)){ $.ajax({ type: "POST", @@ -299,7 +299,7 @@ $(document).ready(function(){ }, data: JSON.stringify({ query: txt, lang: "en", sessionId: "somerandomthing" }), success: function(data) { - + if(data.result.metadata.intentName === "call me"){ chrome.storage.local.set({ "username": data.result.parameters.any }, function(){ // Data's been saved boys and girls, go on home @@ -311,7 +311,7 @@ $(document).ready(function(){ else if(data.result.metadata.intentName === "youtube search"){ chrome.tabs.create({'url':'https://www.youtube.com/results?search_query='+ data.result.parameters.any }); } - + if(data.result.fulfillment.speech !== 'i am searching this on google'){ var speech = data.result.fulfillment.speech; if(data.result.fulfillment.speech === '@time'){ @@ -341,14 +341,14 @@ $(document).ready(function(){ } else if(data.result.fulfillment.speech === '@exit'){ Speech("closing the window. Sir"); - setTimeout(function(){}, 500); + setTimeout(function(){}, 500); chrome.tabs.query({}, function (tabs) { for (var i = 0; i < tabs.length; i++) { chrome.tabs.remove(tabs[i].id); } }); } - else if (data.result.fulfillment.speech === '@bookmark') { + else if (data.result.fulfillment.speech === '@bookmark') { chrome.tabs.getSelected(function(tab) { //<-- "tab" has all the information chrome.bookmarks.create({ 'title': tab.title,'url': tab.url}); }); @@ -382,7 +382,7 @@ $(document).ready(function(){ var currenttab; Speech("opening! next"); chrome.tabs.getSelected(null, function(tab) { - currenttab = tab.id; + currenttab = tab.id; chrome.tabs.query({}, function (tabs) { for (var i = 0; i < tabs.length; i++) { if(tabs[i].id == currenttab){ @@ -396,7 +396,7 @@ $(document).ready(function(){ { Speech("opening! Settings."); // Add code for opening settings - // EASY:1 + // EASY:1 } else if(data.result.metadata.intentName === "open history") { @@ -420,9 +420,9 @@ $(document).ready(function(){ else Speech(speech+" "+items.username); }); - + } - else if(data.result.metadata.intentName === "I want to hear a joke"){ + else if(data.result.metadata.intentName === "I want to hear a joke"){ Speech("Hope you like this one."); Speech(speech); } @@ -439,9 +439,9 @@ $(document).ready(function(){ if((idx = (txt.toLowerCase()).lastIndexOf("Wikipedia".toLowerCase())) !==-1) { Speech("I am searching this on wikipedia."); - //Code to search content directly on wikipedia. + //Code to search content directly on wikipedia. // MEDIUM: 2 - + } else if((idx = (txt.toLowerCase()).lastIndexOf("change background".toLowerCase())) !==-1) { @@ -453,7 +453,7 @@ $(document).ready(function(){ else if((idx = (txt.toLowerCase()).indexOf("let us".toLowerCase())) !==-1){ Speech("enjoy tetris"); // Open tetris game in new tab. - // HINT: You may use tetris.com + // HINT: You may use tetris.com // EASY: 4 } else if((idx = (txt.toLowerCase()).lastIndexOf("print".toLowerCase())) !==-1) @@ -493,9 +493,10 @@ $(document).ready(function(){ else if((idx = (txt.toLowerCase()).lastIndexOf("news".toLowerCase())) !==-1) { Speech("Opening"); + chrome.tabs.create({'url': 'https://news.google.com/'}); // Code to open google news. // EASY: 9 - + } else if((idx = (txt.toLowerCase()).lastIndexOf("inbox".toLowerCase())) !==-1) { @@ -505,8 +506,8 @@ $(document).ready(function(){ else if((idx = (txt.toLowerCase()).lastIndexOf("incognito".toLowerCase())) !==-1) { Speech("Opening incognito window."); - // Code to open incognito window - // EASY: 10 + // Code to open incognito window + // EASY: 10 } else if((idx = (txt.toLowerCase()).lastIndexOf("backward".toLowerCase())) !==-1) { @@ -536,7 +537,7 @@ $(document).ready(function(){ else if((idx = (txt.toLowerCase()).indexOf("arrange heading".toLowerCase())) !==-1) { Speech("Arranging the headings of the tab"); - // Code to arrange tabs alphabetically + // Code to arrange tabs alphabetically // MEDIUM: 3 } else if((idx = (txt.toLowerCase()).indexOf("group content".toLowerCase())) !==-1) @@ -586,7 +587,7 @@ $(document).ready(function(){ else { setResponse(data.result.fulfillment.speech); - chrome.tabs.create({'url': 'http://google.com/search?q='+txt}); + chrome.tabs.create({'url': 'http://google.com/search?q='+txt}); chrome.tabs.executeScript({ code: "document.getElementsByClassName('_XWk')[0].innerHTML;" },function(selection){//_XW//alert(selection[0]); @@ -606,7 +607,7 @@ $(document).ready(function(){ }); } else - Speech(selection[0]); + Speech(selection[0]); } ); } @@ -625,7 +626,7 @@ $(document).ready(function(){ function setResponse(val) { Speech(val); } - //to speech + //to speech function Speech(say) { if ('speechSynthesis' in window && talking) { var language = window.navigator.userLanguage || window.navigator.language; @@ -673,7 +674,7 @@ $(document).ready(function(){ alert("temperature is "+temperature); alert("humidity is "+humidity); alert("wind speed is "+windSpeed); - alert("sky description "+cloudsDescription); + alert("sky description "+cloudsDescription); } } @@ -692,22 +693,22 @@ $(document).ready(function(){ var todos = new Array; var todos_str = localStorage.getItem('todo'); if (todos_str !== null) { - todos = JSON.parse(todos_str); + todos = JSON.parse(todos_str); } return todos; - } + } function add(task) { var todos = get_todos(); if (task=== '') { alert("You must write something!"); - } + } else{ todos.push(task); localStorage.setItem('todo', JSON.stringify(todos)); return false; } } - + function show() { var todos = get_todos(); var html = ''; - + document.getElementById('todos').innerHTML = html; - + var buttons = document.getElementsByClassName('remove'); for (var i=0; i < buttons.length; i++) { buttons[i].addEventListener('click', remove); }; } -}); \ No newline at end of file +});