2018-10-09 08:14:50 +02:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
(function(){
|
|
|
|
"use strict";
|
|
|
|
|
2019-04-09 08:29:52 +02:00
|
|
|
const extension = require("../lib/extension");
|
2019-04-08 00:02:29 +02:00
|
|
|
const settings = require("../lib/settings");
|
2019-05-02 00:30:30 +02:00
|
|
|
require("../lib/theme").init("sanitize");
|
2019-03-12 22:24:23 +01:00
|
|
|
const sanitationRules = require("./sanitationRules");
|
2018-10-09 08:14:50 +02:00
|
|
|
|
|
|
|
var title = document.createElement("h1");
|
|
|
|
title.className = "title";
|
2019-04-09 08:29:52 +02:00
|
|
|
title.textContent = extension.getTranslation("sanitation_title");
|
2018-10-09 08:14:50 +02:00
|
|
|
document.body.appendChild(title);
|
|
|
|
|
|
|
|
var description = document.createElement("div");
|
|
|
|
description.className = "description";
|
2019-04-09 08:29:52 +02:00
|
|
|
description.textContent = extension.getTranslation("sanitation_description");
|
2018-10-09 08:14:50 +02:00
|
|
|
document.body.appendChild(description);
|
|
|
|
|
|
|
|
settings.onloaded(function(){
|
|
|
|
const list = document.createElement("ul");
|
|
|
|
sanitationRules.ruleset.forEach(function(ruleset){
|
|
|
|
const rulesetContainer = document.createElement("li");
|
2019-04-09 08:29:52 +02:00
|
|
|
rulesetContainer.textContent = extension.getTranslation("sanitation_ruleset." + ruleset.name);
|
2018-10-09 08:14:50 +02:00
|
|
|
|
|
|
|
const rulesetErrors = document.createElement("ul");
|
|
|
|
let anyComplaint = false;
|
|
|
|
ruleset.check(function({message, severity, resolutions}){
|
|
|
|
anyComplaint = true;
|
|
|
|
const li = document.createElement("li");
|
|
|
|
li.className = "complaint " + severity;
|
|
|
|
li.textContent = message;
|
|
|
|
|
|
|
|
const buttons = document.createElement("span");
|
|
|
|
buttons.className = "resolutions";
|
|
|
|
resolutions.forEach(function(resolution){
|
|
|
|
const button = document.createElement("button");
|
|
|
|
button.textContent = resolution.label;
|
|
|
|
button.addEventListener("click", function(){
|
|
|
|
resolution.callback();
|
|
|
|
window.location.reload();
|
|
|
|
});
|
|
|
|
buttons.appendChild(button);
|
|
|
|
});
|
|
|
|
li.appendChild(buttons);
|
|
|
|
rulesetErrors.appendChild(li);
|
|
|
|
});
|
|
|
|
if (!anyComplaint){
|
|
|
|
const noComplaints = document.createElement("li");
|
|
|
|
noComplaints.className = "noComplaints";
|
2019-04-09 08:29:52 +02:00
|
|
|
noComplaints.textContent = extension.getTranslation("sanitation_nothingToComplain");
|
2018-10-09 08:14:50 +02:00
|
|
|
rulesetErrors.appendChild(noComplaints);
|
|
|
|
}
|
|
|
|
rulesetContainer.appendChild(rulesetErrors);
|
|
|
|
list.appendChild(rulesetContainer);
|
|
|
|
});
|
|
|
|
document.body.appendChild(list);
|
|
|
|
});
|
|
|
|
}());
|