/*******************************************************************************

    
    Cloud Firewall - a browser extension/addon that allows users to block connections 
    to sites, pages and web resources (images, videos, etc) hosted in major cloud services
    if the user wishes to do so.
    Copyright (C) 2019 Niklas Poslovski
    Copyright (C) 2019 Gokulakrishna Sudharsan
    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.

    Home: https://notabug.org/nipos/cloud-firewall
*/

var PopupApp = window.PopupApp || {};

var languages = ['de', 'en'];
var helplink;
var privacylink;

if(languages.includes(browser.i18n.getUILanguage())){
  helplink = 'help.' + browser.i18n.getUILanguage() + '.html';
  privacylink = 'privacy.' + browser.i18n.getUILanguage() + '.html';
} else {
  helplink = 'help.en.html';
  privacylink = 'privacy.en.html';
}

$(document).ready(function() {
$("#settingsbutton").click(function() {
PopupApp.openUrl(chrome.extension.getURL("settings.html"));
});
$("#helpButton").click(function() {
PopupApp.openUrl(chrome.extension.getURL(helplink));
});
$("#rulesbutton").click(function() {
PopupApp.openUrl(chrome.extension.getURL("rules.html"));
});
$("#resetRule").click(function() {
PopupApp.resetToggles();
});
$("#switchgoogle").click(function() {
PopupApp.toggle("google");
});
$("#switchamazon").click(function() {
PopupApp.toggle("amazon");
});
$("#switchfacebook").click(function() {
PopupApp.toggle("facebook");
});
$("#switchapple").click(function() {
PopupApp.toggle("apple");
});
$("#switchmicrosoft").click(function() {
PopupApp.toggle("microsoft");
});
$("#switchcloudflare").click(function() {
PopupApp.toggle("cloudflare");
});
$("#blockAllButton").click(function() {
PopupApp.toggleAll(true);
});
$("#allowAllButton").click(function() {
PopupApp.toggleAll(false);
});
$("#addToExcludes").click(function() {
PopupApp.addToExcludes();
});
$("#removeFromExcludes").click(function() {
PopupApp.removeFromExcludes();
});
$("#showInPopup").click(function() {
PopupApp.copyToClipboard("popup");
});
$("#copyToClipboardJSON").click(function() {
PopupApp.copyToClipboard("json");
});
$("#copyToClipboardYAML").click(function() {
PopupApp.copyToClipboard("yaml");
});
$("#copyToClipboardTOML").click(function() {
PopupApp.copyToClipboard("toml");
});
$("#copyToClipboardCSON").click(function() {
PopupApp.copyToClipboard("cson");
});
$("#copyToClipboardPlain").click(function() {
PopupApp.copyToClipboard("plain");
});
});
