You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
188 lines
4.1 KiB
188 lines
4.1 KiB
4 years ago
|
var site;
|
||
|
var is_dsgvo = false;
|
||
|
var thirdpartylinks = [];
|
||
|
var os = "win";
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Typical start of a jquery script.
|
||
|
* when the pop up pops up this function fires
|
||
|
*
|
||
|
* */
|
||
|
$(document).ready(async function(){
|
||
|
|
||
|
await browser.runtime.sendMessage({auswertung: "check_if_dsgvo"}).then( response => {
|
||
|
try{
|
||
|
is_dsgvo = response.is_dsgvo;
|
||
|
console.log("Super hat geklappt: "+ is_dsgvo);
|
||
|
thirdpartylinks = JSON.parse(response.third);
|
||
|
} catch(e){
|
||
|
state_cookies();
|
||
|
}
|
||
|
|
||
|
});
|
||
|
|
||
|
os = await browser.runtime.getPlatformInfo();
|
||
|
console.log(os);
|
||
|
|
||
|
/** inits the start of the pop up context**/
|
||
|
first_init(is_dsgvo);
|
||
|
$("#zsf-div").hide();
|
||
|
|
||
|
$("#cookie-tab-button").click(async function(){
|
||
|
state_cookies();
|
||
|
await handleCookies();
|
||
|
});
|
||
|
|
||
|
handleCookies();
|
||
|
|
||
|
$("#privacy-tab-button").click(function(){
|
||
|
state_privacycheck(is_dsgvo);
|
||
|
});
|
||
|
|
||
|
$("#about-tab-button").click(function(){
|
||
|
state_more();
|
||
|
});
|
||
|
|
||
|
|
||
|
$("#auswertenv2").click(function(){
|
||
|
$(".animation-container").show();
|
||
|
$("#auswertenv2").hide();
|
||
|
$("#auswerten-longer").hide();
|
||
|
$("#auswertenv2").removeClass("privacyfade");
|
||
|
$("#p_hint_for_press_privacy").hide();
|
||
|
$("#auswerten-longer").hide();
|
||
|
console.log("Dieser Promise main");
|
||
|
browser.runtime.sendMessage({get: "summary_with_id"}).then(response => {
|
||
|
console.log("try to summarize");
|
||
|
console.log(response.back);
|
||
|
|
||
|
|
||
|
contexts = response.back;
|
||
|
console.log(JSON.parse(contexts));
|
||
|
|
||
|
//let result_list = getSummaryFromServer(JSON.parse(contexts));
|
||
|
let result_list = getSummaryFromServer(contexts);
|
||
|
console.log(result_list);
|
||
|
browser.runtime.sendMessage({auswertung: "summary", set: JSON.stringify(result_list)});
|
||
|
|
||
|
let html_saved = "<div class='mdc-card' class='saved-div'>"+create_short_summary_saved(result_list[0])+"</div>";
|
||
|
let html_third = "<div class='mdc-card' class='saved-div'>"+create_short_summary_third(result_list[1])+"</div>";
|
||
|
|
||
|
|
||
|
let html_cards = html_saved+html_third;
|
||
|
|
||
|
|
||
|
$("#zsf-div").empty();
|
||
|
//$("#zsf-div").append(create_example_summary());
|
||
|
$("#zsf-div").append(html_cards);
|
||
|
$("#zsf-div").show();
|
||
|
$("#auswerten-longer").show();
|
||
|
$("#auswerten-longer").show();
|
||
|
$(".animation-container").hide();
|
||
|
|
||
|
});
|
||
|
});
|
||
|
|
||
|
|
||
|
$("#weiteres").click(function(){
|
||
|
browser.tabs.create({
|
||
|
url:"aboutprivacycheck.html"
|
||
|
});
|
||
|
window.close();
|
||
|
});
|
||
|
|
||
|
$("#auswerten-longer").click(function(){
|
||
|
console.log("creating advanced context");
|
||
|
|
||
|
browser.runtime.sendMessage({createadvanced: "context", set: JSON.stringify(contexts)});
|
||
|
window.close();
|
||
|
});
|
||
|
|
||
|
$("#settings").click(function(){
|
||
|
$("#settings-div").show();
|
||
|
$("#settings-back").show();
|
||
|
state_settings();
|
||
|
});
|
||
|
|
||
|
|
||
|
$("#settings-back").click(function(){
|
||
|
state_more();
|
||
|
});
|
||
|
|
||
|
|
||
|
$("#switch-eng").click(function(){
|
||
|
del_switch_classes();
|
||
|
$(this).addClass("mdc-switch--checked");
|
||
|
});
|
||
|
|
||
|
$("#switch-ger").click(function(){
|
||
|
del_switch_classes();
|
||
|
$(this).addClass("mdc-switch--checked");
|
||
|
});
|
||
|
});
|
||
|
|
||
|
|
||
|
/**
|
||
|
* This function creates a html tag
|
||
|
**/
|
||
|
function createHTMLTag(tagName, value) {
|
||
|
if (tagName === undefined){
|
||
|
return "<br><p> FEHLER </p>"
|
||
|
} else {
|
||
|
return "<"+tagName.toLowerCase()+">"+value+"</"+tagName.toLowerCase()+">";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* This function is getting the url of the active tab
|
||
|
* its not used but can be used in the futere
|
||
|
*/
|
||
|
function getUrl(){
|
||
|
|
||
|
site = ""
|
||
|
|
||
|
Browser.tabs.query({
|
||
|
currentWindow: true,
|
||
|
active: true})
|
||
|
.then((tabs) => {
|
||
|
let tab = tabs[0];
|
||
|
site = tabs.url;
|
||
|
});
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
/* *
|
||
|
* Mandatory
|
||
|
* */
|
||
|
function create_example_summary(){
|
||
|
console.log("Creating Example");
|
||
|
//let example = getExampleSummary();
|
||
|
let example = "";
|
||
|
|
||
|
browser.runtime.sendMessage({auswertung: "summary", set: example});
|
||
|
return example;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* Mandatory
|
||
|
**/
|
||
|
function example(){
|
||
|
setTimeout(function() {
|
||
|
browser.runtime.sendMessage({get: "summary"}).then(response => {
|
||
|
console.log("try to summarize");
|
||
|
console.log(response.back);
|
||
|
//console.log(getContextList(response.back));
|
||
|
|
||
|
$("#zsf-div").empty();
|
||
|
$("#zsf-div").append(create_example_summary());
|
||
|
$("#zsf-div").show();
|
||
|
|
||
|
$(".animation-container").hide();
|
||
|
|
||
|
});
|
||
|
}, 3000);
|
||
|
}
|