Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Farben der #jumpToQuestionNrX in default.css definieren #48

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Merge remote-tracking branch 'origin/stable-v0.6-BMBF-PTF' into featu…
…re-v0.6-define-colors-for-jumptotable-in-css

# Conflicts:
#	system/general.js
  • Loading branch information
lrusch committed Aug 1, 2021
commit 5865fcd99f4495a11c31a6853dfa7a6bc69f8758
107 changes: 53 additions & 54 deletions system/general.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@ var activeQuestion=0; //aktuell angezeigte Frage (output.js)
function fnReadCsv(csvFile,fnCallback)
{
// http://michaelsoriano.com/working-with-jquerys-ajax-promises-and-deferred-objects/
$.ajax({
type: "GET",
$.ajax({
type: "GET",
url: csvFile,
dataType: "text",
dataType: "text",
contentType: "application/x-www-form-urlencoded",
error: function(objXML, textStatus, errorThrown) {
console.log("Mat-O-Wahl ERROR - Reading CSV-file \n Code - objXML-Status: "+objXML.status+" \n Code - textStatus: "+textStatus+" \n Code - errorThrown: "+errorThrown+" \n Name and folder of CSV-file should be: "+csvFile+" \n\nPossible solutions: Check for capital letters? OR check the extension of the file (csv / xls / xlsx)? OR is the file in the wrong folder? OR are you working on a local machine :( instead of a server? See documentation on www.mat-o-wahl.de");
console.log("Mat-O-Wahl ERROR - Reading CSV-file \n Code - objXML-Status: "+objXML.status+" \n Code - textStatus: "+textStatus+" \n Code - errorThrown: "+errorThrown+" \n Name and folder of CSV-file should be: "+csvFile+" \n\nPossible solutions: Check for capital letters? OR check the extension of the file (csv / xls / xlsx)? OR is the file in the wrong folder? OR are you working on a local machine :( instead of a server? See documentation on www.mat-o-wahl.de");
// document.getElementById("descriptionAddonTop").innerHTML("nanu. Da ist etwas schief gegangen.")
$("#descriptionExplanation").css("color","red").css("font-size", "150%")
text = "<p>Nanu? Da ist etwas schief gegangen. Einige Dateien konnten nicht geladen werden. <br /> Sind Sie ein Besucher der Seite? Dann geben Sie bitte dem Administrator der Webseite Bescheid. <br /> Sind Sie der Administrator? Dann schauen Sie bitte in die Browser-Konsole.</p>"
Expand All @@ -45,13 +45,13 @@ function fnReadCsv(csvFile,fnCallback)
}
})
.done(function(data) {
// console.log('success', data)
// console.log('success', data)
console.log("Mat-o-Wahl load: "+csvFile);
fnCallback(data);
})
.fail(function(xhr) {
console.log('Mat-O-Wahl file error - ', xhr);
});
console.log('Mat-O-Wahl file error - ', xhr);
});
}


Expand All @@ -61,14 +61,14 @@ function fnShowQuestions(csvData)
// Einlesen der Fragen ...
// fnSplitLines(csvData,1);
fnTransformCsvToArray(csvData,1)

// ... und Anzeigen
var questionNumber = -1;

// v.0.6 - deaktiviert, da nun am Anfang ein Willkommensbildschirm erscheint.
// neu: fnHideWelcomeMessage()
// fnShowQuestionNumber(questionNumber);
}
}



Expand All @@ -87,12 +87,12 @@ function fnReadPositions(csvData)
function fnEvaluation()
{

// Abstimmungsknöpfe u.a. entfernen
// Abstimmungsknöpfe u.a. entfernen
$("#sectionDescription").empty().hide();
$("#sectionShowQuestions").empty().hide();
$("#sectionVotingButtons").empty().hide();
$("#sectionVotingButtons").empty().hide();
$("#sectionNavigation").empty().hide();

$("#keepStats").hide();

// Anzahl der Fragen bestimmen, da Positions-Array ein Vielfaches aus Fragen * Parteien enthält.
Expand All @@ -110,7 +110,7 @@ function fnEvaluation()
// for (i = 0; i <= (arPartyFiles.length-1); i++)
for (i = 0; i <= (intParties-1); i++)
{
arResults.push(0); // Array mit leeren Werten füllen
arResults.push(0); // Array mit leeren Werten füllen
}

// Vergleichen der Positionen (= Fragen x Parteien)
Expand All @@ -124,13 +124,13 @@ function fnEvaluation()
}

// Frage wurde nicht uebersprungen per SKIP (99) oder GEHE ZUR NAECHSTEN FRAGE (-)
if ( (arPersonalPositions[modulo] < 99) )
if ( (arPersonalPositions[modulo] < 99) )
{
var faktor=1; // Faktor ist 1 normal und 2, wenn Frage doppelt gewertet werden soll
if(arVotingDouble[modulo])
{faktor=2;}

// Bei Uebereinstimmung der persönlichen Meinung (1,0,-1) mit Partei-Antwort (1,0-1), den Zaehler (Anzahl Übereinstimmungen) um eins erhoehen
// Bei Uebereinstimmung der persönlichen Meinung (1,0,-1) mit Partei-Antwort (1,0-1), den Zaehler (Anzahl Übereinstimmungen) um eins erhoehen
if (arPartyPositions[i] == arPersonalPositions[modulo])
{
positionsMatch+=faktor;
Expand All @@ -148,7 +148,7 @@ function fnEvaluation()
} // end: for numberOfQuestions


/*
/*
// Wenn Nutzer eingewilligt hat ...
if ( $("#keepStatsCheckbox").prop("checked")==1)
{
Expand All @@ -174,19 +174,18 @@ function fnSendResults(arResults, arPersonalPositions)
{
// Korrektur der Parteiposition (-1,0,1) mit den Informationen aus der doppelten Wertung (-2,-1,0,1,2)
// Marius Nisslmueller, Bad Honnef, Juni 2020
// Bedingung für übersprungene Frage hinzugefügt
arPersonalPositionsForStats = arPersonalPositions.slice(); // Damit arPersonalPositions nicht verändert wird
for(let i=0; i<arPersonalPositionsForStats.length; i++){
if(arVotingDouble[i]){
arPersonalPositionsForStats[i] *= 2;
if(arVotingDouble[i] && arPersonalPositionsForStats[i] < 99){
arPersonalPositionsForStats[i] *= 2;
}
}


var strResults = arResults.join(",");
// var strPersonalPositions = arPersonalPositions.join(",");
var strPersonalPositions = arPersonalPositionsForStats.join(",");

$.get(statsServer, { mowpersonal: strPersonalPositions, mowparties: strResults } );

console.log("Mat-O-Wahl. Daten gesendet an Server: "+statsServer+" - mowpersonal: "+strPersonalPositions+" - mowparties: "+strResults+"")
Expand All @@ -198,7 +197,7 @@ function fnPercentage(value,max)
{
var percent = value * 100 / max;
percent = Math.round(percent);
return percent;
return percent;
}

// v.0.3 NEU
Expand All @@ -207,15 +206,15 @@ function fnTransformCsvToArray(csvData,modus)
{
// benutzt externe jquery-csv-Bibliothek
arZeilen = $.csv.toArrays(csvData, {separator: ""+separator+""});

// console.log(arZeilen.length+ " Part "+intParties+" quest: "+intQuestions )


// Number of lines per party for MODULO-Operation on the ANSWERS-file
// There are five (5) lines with information on the party + "intQuestions" lines + an empty line
// Example "Obsthausen"/"Fruitville" = 5 + 6 + 1 = 12
// Example "Springfield" = 5 + 15 + 1 = 21
var numberOfLines = 6 + intQuestions
var numberOfLines = 6 + intQuestions

if (modus == 1) // Fragen / Questions
{ lastLine = intQuestions}
Expand All @@ -226,10 +225,10 @@ function fnTransformCsvToArray(csvData,modus)
// for(i = 0; i <= arZeilen.length-1; i++)
for(i = 0; i <= lastLine-1; i++)
{
// console.log("i: "+i+" m: "+modus+" val0: "+arZeilen[i][0]+" val1: "+arZeilen[i][1] )
// console.log("i: "+i+" m: "+modus+" val0: "+arZeilen[i][0]+" val1: "+arZeilen[i][1] )
valueOne = arZeilen[i][0];
valueTwo = arZeilen[i][1];

// FRAGEN in globales Array schreiben (z.B. aus FRAGEN.CSV)
if (modus == 1)
{
Expand All @@ -244,28 +243,28 @@ function fnTransformCsvToArray(csvData,modus)
modulo = i % numberOfLines;

if ( (modulo == 0) && (valueTwo != "undefined") )
{
{
// Parteinamen - kurz
arPartyNamesShort.push(valueTwo)
}
else if ( (modulo == 1) && (valueTwo != "undefined") )
{
{
// Parteinamen - lang
arPartyNamesLong.push(valueTwo)
}
else if ( (modulo == 2) && (valueTwo != "undefined") )
{
{
// Beschreibung der Partei (optional)
arPartyDescription.push(valueTwo)
// console.log("i: "+i+ " value: "+valueTwo)
}
else if ( (modulo == 3) && (valueTwo != "undefined") )
{
{
// Webseite der Partei
arPartyInternet.push(valueTwo)
}
else if ( (modulo == 4) && (valueTwo != "undefined") )
{
{
// Logo der Partei
arPartyLogosImg.push(valueTwo)
}
Expand All @@ -275,11 +274,11 @@ function fnTransformCsvToArray(csvData,modus)
arPartyPositions.push(valueOne); // -1,0,1
arPartyOpinions.push(valueTwo); // Erklärung zur Zahl
}
else
else
{
// nothing to do. Just empty lines in the CSV-file
}
} // end: if-else modus == 1
} // end: if-else modus == 1
} // end: for

} // end: function
Expand Down Expand Up @@ -345,27 +344,27 @@ function fnTransformPositionToText(position)
}
}
return positionText;

}

// Gibt ein Bild/CSS-Klasse für den Balken in der Auswertung entsprechend der Prozentzahl Uebereinstimmung zurück
function fnBarImage(percent)
{
// bis v.0.3 mit PNG-Bildern, danach mit farblicher Bootstrap-Progressbar

if (percent <= 33) {
// var barImage = "contra_px.png";
var barImage = "bg-danger";
if (percent <= 33) {
// var barImage = "contra_px.png";
var barImage = "bg-danger";
}
else if (percent <= 66) {
// var barImage = "neutral_px.png";
var barImage = "bg-warning";
else if (percent <= 66) {
// var barImage = "neutral_px.png";
var barImage = "bg-warning";
}
else {
// var barImage = "pro_px.png";
var barImage = "bg-success";
else {
// var barImage = "pro_px.png";
var barImage = "bg-success";
}

return barImage;
}

Expand All @@ -374,16 +373,16 @@ function fnBarImage(percent)
function fnToggleSelfPosition(i)
{
arPersonalPositions[i]--;
if (arPersonalPositions[i]==-2)
if (arPersonalPositions[i]==-2)
{arPersonalPositions[i]=99}
if (arPersonalPositions[i]==98)
if (arPersonalPositions[i]==98)
{arPersonalPositions[i]=1}
// var positionImage = fnTransformPositionToImage(arPersonalPositions[i]);
var positionButton = fnTransformPositionToButton(arPersonalPositions[i]);
var positionIcon = fnTransformPositionToIcon(arPersonalPositions[i]);
// var positionColor = fnTransformPositionToColor(arPersonalPositions[i]);
var positionText = fnTransformPositionToText(arPersonalPositions[i]);

// $("#selfPosition"+i).attr("src", "img/"+positionImage);
$(".selfPosition"+i).removeClass("btn-danger btn-warning btn-success btn-default").addClass(positionButton);
$(".selfPosition"+i).html(positionIcon);
Expand Down Expand Up @@ -424,12 +423,12 @@ function fnFadeIn(el, time, modus) {
// Default FadeIn / FadeOut-Time
if (!time) {time = 500;}

// Loading CSS
// Loading CSS
el.style.animation = "myFadeIn "+time+"ms 1"
el.style.opacity = 1;

if (modus == 1) {
el.style.display = ""
el.style.display = ""
el.style.visibility = ""
}
}
Expand All @@ -441,15 +440,15 @@ function fnFadeOut(el, time, modus) {
// Default FadeIn / FadeOut-Time
if (!time) {time = 500;}

// Loading CSS
// Loading CSS
el.style.animation = "myFadeOut "+time+"ms 1"
el.style.opacity = 0;

// hide element from DOM AFTER opacity is set to 0 (setTimeout)
if (modus == 1) {
window.setTimeout(function() {
el.style.display = "none"
el.style.visibility = "hidden"
}, (time-50));
el.style.display = "none"
el.style.visibility = "hidden"
}, (time-50));
}
}
You are viewing a condensed version of this merge commit. You can view the full changes here.