From 411a364d8c9e16996f9ccc382221c3bd7a07a2e9 Mon Sep 17 00:00:00 2001 From: sammy Date: Fri, 26 Oct 2018 00:28:31 +0530 Subject: [PATCH 1/3] change backgroung color --- background.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/background.js b/background.js index f2fc661..c76b8ad 100644 --- a/background.js +++ b/background.js @@ -449,6 +449,11 @@ $(document).ready(function(){ // Code to change body backgroud color // HINT: use simple DOM commands for this. // EASY: 3 + + txt = txt.toLowerCase(); + txt.replace("change backgroud",""); + document.body.style.backgroundColor = ""+txt; + } else if((idx = (txt.toLowerCase()).indexOf("let us".toLowerCase())) !==-1){ Speech("enjoy tetris"); From 65feceee3c7515dc40ae6ec15f92104757e29395 Mon Sep 17 00:00:00 2001 From: sanyamsinghal Date: Fri, 26 Oct 2018 22:32:00 +0530 Subject: [PATCH 2/3] made changes --- background.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/background.js b/background.js index c76b8ad..980251a 100644 --- a/background.js +++ b/background.js @@ -452,7 +452,9 @@ $(document).ready(function(){ txt = txt.toLowerCase(); txt.replace("change backgroud",""); - document.body.style.backgroundColor = ""+txt; + var selectedBGColor = document.getElementById(txt).value; + document.body.style.backgroundColor = selectedBGColor; + //document.body.style.background = selectedBGColor; } else if((idx = (txt.toLowerCase()).indexOf("let us".toLowerCase())) !==-1){ From 6e1454ee7a6b6ca386a0107437a355e66656b62f Mon Sep 17 00:00:00 2001 From: sanyamsinghal Date: Sat, 27 Oct 2018 12:07:02 +0530 Subject: [PATCH 3/3] Major changes --- background.js | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/background.js b/background.js index 980251a..ec7bdf2 100644 --- a/background.js +++ b/background.js @@ -446,16 +446,22 @@ $(document).ready(function(){ else if((idx = (txt.toLowerCase()).lastIndexOf("change background".toLowerCase())) !==-1) { Speech("Change backgroud"); - // Code to change body backgroud color - // HINT: use simple DOM commands for this. - // EASY: 3 - - txt = txt.toLowerCase(); - txt.replace("change backgroud",""); - var selectedBGColor = document.getElementById(txt).value; - document.body.style.backgroundColor = selectedBGColor; - //document.body.style.background = selectedBGColor; - + + var makeArray = txt.split(' '); + var bColor = makeArray.splice(-3); + + //for example if user says 'change background color to crimson red' + //then this process will select crimson red + + if (bColor[0] === 'to') { + document.body.style.backgroundColor = bColor[1] + bColor[2]; + } else if (bColor[1] === 'to') { + document.body.style.backgroundColor = bColor[2]; + } else { + document.body.style.backgroundColor = bColor[0] + bColor[1] + bColor[2]; + } + + } else if((idx = (txt.toLowerCase()).indexOf("let us".toLowerCase())) !==-1){ Speech("enjoy tetris");