Skip to content

Commit

Permalink
fixed#1 should be able to turn it on and off
Browse files Browse the repository at this point in the history
  • Loading branch information
Elabar committed Sep 12, 2019
1 parent 4f2cf7b commit e3ea56f
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
3 changes: 2 additions & 1 deletion background.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ admin.onopen = function(event){

admin.onmessage = function(event){
var data = JSON.parse(event.data)
var notiOn = localStorage.getItem("noti")
if(data.auth == "OK"){
console.log("Joined hub")
console.log("Listening to new message...")
}
if(data.toH == "moliAssist" && data.msg != "JOINED MOLI ASSIST SERVER 023146") {
if(data.toH == "moliAssist" && data.msg != "JOINED MOLI ASSIST SERVER 023146" && (notiOn == "true" || notiOn === null)) {
console.log(data)
var msg = data.FROM + ": " + data.msg;
chrome.tabs.query({
Expand Down
17 changes: 17 additions & 0 deletions helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
document.addEventListener("DOMContentLoaded", function(){
var saved = localStorage.getItem("noti")
if(saved === null){
localStorage.setItem("noti",true)
}else{
if(saved == "true"){
document.getElementById("noti").checked = true
}
}
var checkbox = document.getElementById("noti")
checkbox.addEventListener('click',function (){
var check = document.getElementById("noti").checked
localStorage.setItem("noti",check)
})
})

console.log("loaded")
3 changes: 2 additions & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
},
"permissions" : [
"notifications",
"tabs"
"tabs",
"storage"
]
}
3 changes: 2 additions & 1 deletion popup.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<html>
<head>
<script src="helper.js"></script>
<style>
.switch {
position: relative;
Expand Down Expand Up @@ -71,7 +72,7 @@ <h1>Moli Chat Listener</h1>
<div>
<p style="float: left;margin:0;margin-right:5px">Notification: </p>
<label class="switch">
<input type="checkbox">
<input id="noti" type="checkbox">
<span class="slider round"></span>
</label>
</div>
Expand Down

0 comments on commit e3ea56f

Please sign in to comment.