Merge branch 'master' of github.com:felixfoertsch/mahlowat
This commit is contained in:
@@ -11,7 +11,7 @@ body {
|
||||
}
|
||||
|
||||
#thesesbox{
|
||||
min-height: 250px;
|
||||
min-height: 150px;
|
||||
}
|
||||
.button-wrapper .btn {
|
||||
margin-bottom: 10px;
|
||||
@@ -37,4 +37,8 @@ body {
|
||||
.pagination > .active.pagination-no > a {
|
||||
background-color: #ff4136;
|
||||
border-color: #00CC66;
|
||||
}
|
||||
|
||||
.m-t-5 {
|
||||
margin-top: 5px;
|
||||
}
|
||||
386
mahlowat.php
386
mahlowat.php
@@ -4,119 +4,119 @@ include 'includes/elements.php';
|
||||
//include 'includes/theses.php';
|
||||
$data_content = file_get_contents("config/data.json");
|
||||
if(!$data_content){
|
||||
echo "ERROR READING CONFIG";
|
||||
echo "ERROR READING CONFIG";
|
||||
} else {
|
||||
$data = json_decode($data_content, true);
|
||||
if($data == NULL){
|
||||
echo "ERROR PARSING CONFIG";
|
||||
}
|
||||
$data = json_decode($data_content, true);
|
||||
if($data == NULL){
|
||||
echo "ERROR PARSING CONFIG";
|
||||
}
|
||||
//$theses = get_theses_array();
|
||||
$theses = $data['theses'];
|
||||
$theses_count = sizeof($theses);
|
||||
$ans = Array();
|
||||
$emph = Array();
|
||||
$answerstring = '';
|
||||
$warning = false;
|
||||
$count = 'undefined';
|
||||
if(isset($_POST['count'])){
|
||||
$count = $_POST['count'];
|
||||
}
|
||||
if(isset($_POST['ans'])){
|
||||
$answerstring = $_POST['ans'];
|
||||
$retval = result_from_string($answerstring, $theses_count);
|
||||
$ans = $retval[0];
|
||||
$emph = $retval[1];
|
||||
} elseif(isset($_GET['ans'])){
|
||||
$answerstring = $_GET['ans'];
|
||||
$retval = result_from_string($answerstring, $theses_count);
|
||||
$ans = $retval[0];
|
||||
$emph = $retval[1];
|
||||
} else {
|
||||
$warning = true;
|
||||
for($i = 0; $i < $theses_count; $i++){
|
||||
$ans[$i] = 'skip';
|
||||
$emph[$i] = 1;
|
||||
}
|
||||
}
|
||||
$theses = $data['theses'];
|
||||
$theses_count = sizeof($theses);
|
||||
$ans = Array();
|
||||
$emph = Array();
|
||||
$answerstring = '';
|
||||
$warning = false;
|
||||
$count = 'undefined';
|
||||
if(isset($_POST['count'])){
|
||||
$count = $_POST['count'];
|
||||
}
|
||||
if(isset($_POST['ans'])){
|
||||
$answerstring = $_POST['ans'];
|
||||
$retval = result_from_string($answerstring, $theses_count);
|
||||
$ans = $retval[0];
|
||||
$emph = $retval[1];
|
||||
} elseif(isset($_GET['ans'])){
|
||||
$answerstring = $_GET['ans'];
|
||||
$retval = result_from_string($answerstring, $theses_count);
|
||||
$ans = $retval[0];
|
||||
$emph = $retval[1];
|
||||
} else {
|
||||
$warning = true;
|
||||
for($i = 0; $i < $theses_count; $i++){
|
||||
$ans[$i] = 'skip';
|
||||
$emph[$i] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>EUromat - Der Bundestagswahl-Helfer zum Thema Europa</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta content="Mahlowat">
|
||||
<link href="css/jef.min.css" rel="stylesheet" media="screen">
|
||||
<link rel="stylesheet" href="css/font-awesome.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<script src="js/jquery-2.0.2.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<script src="js/mahlowat.js"></script>
|
||||
|
||||
<div id="savemodal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">Statistik</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Erlaubst du, dass dein Aufruf für die Statistik gezählt wird?<br>
|
||||
Falls du Nein auswählst, bist du lediglich als Logeintrag auf dem Server verewigt.<br>
|
||||
<small><a href="faq.php#log" target="_blank">Ich will aber gar keinen Logeintrag!</a></small>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" onclick="callResult(false)" style="width: 100px;"><i class="fa fa-times fa-lg"></i> Nein</button>
|
||||
<button type="button" class="btn btn-primary" onclick="callResult(true)" style="width: 100px;"><i class="fa fa-check fa-lg"></i> Ja</button>
|
||||
</div>
|
||||
<head>
|
||||
<title>EUromat - Der Bundestagswahl-Helfer zum Thema Europa</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<meta content="Mahlowat">
|
||||
<link href="css/jef.min.css" rel="stylesheet" media="screen">
|
||||
<link rel="stylesheet" href="css/font-awesome.min.css">
|
||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||
</head>
|
||||
<body>
|
||||
<script src="js/jquery-2.0.2.min.js"></script>
|
||||
<script src="js/bootstrap.min.js"></script>
|
||||
<script src="js/mahlowat.js"></script>
|
||||
|
||||
<div id="savemodal" class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-sm">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
|
||||
<h4 class="modal-title" id="myModalLabel">Statistik</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
Erlaubst du, dass dein Aufruf für die Statistik gezählt wird?<br>
|
||||
Falls du Nein auswählst, bist du lediglich als Logeintrag auf dem Server verewigt.<br>
|
||||
<small><a href="faq.php#log" target="_blank">Ich will aber gar keinen Logeintrag!</a></small>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" onclick="callResult(false)" style="width: 100px;"><i class="fa fa-times fa-lg"></i> Nein</button>
|
||||
<button type="button" class="btn btn-primary" onclick="callResult(true)" style="width: 100px;"><i class="fa fa-check fa-lg"></i> Ja</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<?php print_pagination($theses_count); ?>
|
||||
<?php print_thesesbox($theses); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<?php print_pagination($theses_count); ?>
|
||||
<?php print_thesesbox($theses); ?>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<p class='text-center'>
|
||||
<button id="weight" type="button" class="btn btn-default" data-toggle="button">These doppelt gewichten</button>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1 m-t-5">
|
||||
<button id="weight" type="button" class="btn btn-default btn-block" data-toggle="button">These doppelt gewichten</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-10 col-md-offset-1 button-wrapper">
|
||||
|
||||
<div class="col-xs-6 col-sm-3">
|
||||
<button id='no' type='submit' class='btn btn-danger btn-block' name='no' onclick="nextThesis('c')">
|
||||
<i class="fa fa-thumbs-down fa-lg"></i> Ablehnung
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6 col-sm-3">
|
||||
<button id='neutral' type='submit' class='btn btn-warning btn-block' name='neutral' onclick="nextThesis('b')">
|
||||
<i class="fa fa-asterisk fa-lg"></i> Neutral
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6 col-sm-3">
|
||||
<button id='yes' type='submit' class='btn btn-success btn-block' name='yes' onclick="nextThesis('a')">
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1 m-t-5">
|
||||
<button id='yes' type='submit' class='btn btn-success btn-block' name='yes' onclick="nextThesis('a')">
|
||||
<i class="fa fa-thumbs-up fa-lg"></i> Zustimmung
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="col-xs-6 col-sm-3">
|
||||
<button id='skip' type='submit' class='btn btn-default btn-block' name='skip' onclick="nextThesis('d')">
|
||||
Überspringen <i class="fa fa-step-forward fa-lg"></i></button>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1 m-t-5">
|
||||
<button id='neutral' type='submit' class='btn btn-warning btn-block' name='neutral' onclick="nextThesis('b')">
|
||||
<i class="fa fa-asterisk fa-lg"></i> Neutral
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1 m-t-5">
|
||||
<button id='no' type='submit' class='btn btn-danger btn-block' name='no' onclick="nextThesis('c')">
|
||||
<i class="fa fa-thumbs-down fa-lg"></i> Ablehnung
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4 col-md-offset-4 col-sm-6 col-sm-offset-3 col-xs-10 col-xs-offset-1 m-t-5">
|
||||
<button id='skip' type='submit' class='btn btn-default btn-block' name='skip' onclick="nextThesis('d')">
|
||||
Überspringen <i class="fa fa-step-forward fa-lg"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-10 col-md-offset-1">
|
||||
<div class="text-right">
|
||||
@@ -127,93 +127,93 @@ $emph[$i] = 1;
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
var resultArray;
|
||||
var activeThesis = 0;
|
||||
var answerstring = '<?php echo $answerstring; ?>';
|
||||
$(function(){
|
||||
$('.tt').tooltip();
|
||||
$('.explic').hide();
|
||||
$('#weight').click(function(){
|
||||
$('#weight').toggleClass('btn-default');
|
||||
$('#weight').toggleClass('btn-info');
|
||||
if($('#weight').text() == 'These doppelt gewichten'){
|
||||
$('#weight').text('These wird doppelt gewichtet');
|
||||
} else {
|
||||
$('#weight').text('These doppelt gewichten');
|
||||
}
|
||||
});
|
||||
$('.explanationbutton').click(function(event){
|
||||
event.preventDefault();
|
||||
$('.explic').toggle(200);
|
||||
});
|
||||
thesesboxes = $('.singlethesis');
|
||||
pagination = $('#navigation li');
|
||||
resultArray = resultStringToArray(answerstring, thesesboxes.length);
|
||||
setPaginationColors(resultArray);
|
||||
var resultArray;
|
||||
var activeThesis = 0;
|
||||
var answerstring = '<?php echo $answerstring; ?>';
|
||||
$(function(){
|
||||
$('.tt').tooltip();
|
||||
$('.explic').hide();
|
||||
$('#weight').click(function(){
|
||||
$('#weight').toggleClass('btn-default');
|
||||
$('#weight').toggleClass('btn-info');
|
||||
if($('#weight').text() == 'These doppelt gewichten'){
|
||||
$('#weight').text('These wird doppelt gewichtet');
|
||||
} else {
|
||||
$('#weight').text('These doppelt gewichten');
|
||||
}
|
||||
});
|
||||
$('.explanationbutton').click(function(event){
|
||||
event.preventDefault();
|
||||
$('.explic').toggle(200);
|
||||
});
|
||||
thesesboxes = $('.singlethesis');
|
||||
pagination = $('#navigation li');
|
||||
resultArray = resultStringToArray(answerstring, thesesboxes.length);
|
||||
setPaginationColors(resultArray);
|
||||
// Remove the # from the hash, as different browsers may or may not include it
|
||||
var hash = location.hash.replace('#','');
|
||||
if(hash != '' && jQuery.isNumeric(hash)){
|
||||
// Show the hash if it's set
|
||||
loadThesis(hash);
|
||||
} else {
|
||||
} else {
|
||||
loadThesis(activeThesis+1);
|
||||
}
|
||||
});
|
||||
function gotoResultPage(result){
|
||||
count = '<?php echo $count; ?>';
|
||||
if(count != 'true' && count != 'false'){
|
||||
$('#savemodal').modal('show');
|
||||
} else if(count == 'true') {
|
||||
callResult(true);
|
||||
} else {
|
||||
callResult(false);
|
||||
}
|
||||
}
|
||||
function gotoFAQPage(evt, result){
|
||||
callPage(evt, 'faq.php?from=mahlowat.php'+window.location.hash, array2str(result), '<?php echo $count; ?>');
|
||||
}
|
||||
function callResult(count){
|
||||
ans = array2str(resultArray);
|
||||
if(count){
|
||||
url = "count.php?ans=" + ans;
|
||||
jQuery.get(url,function( data ) {
|
||||
callPage(null, 'result.php', ans, 'true');
|
||||
});
|
||||
} else {
|
||||
jQuery.get("count.php?false",function( data ) {
|
||||
callPage(null, 'result.php', ans, 'false');
|
||||
});
|
||||
}
|
||||
}
|
||||
function nextThesis(selection){
|
||||
multiply = false;
|
||||
if($('#weight').hasClass('active')){
|
||||
multiply = true;
|
||||
}
|
||||
resultArray[activeThesis] = result2letter(selection, multiply);
|
||||
pagination.eq(activeThesis).removeClass('pagination-yes pagination-neutral pagination-no');
|
||||
pagination.eq(activeThesis).addClass(letter2paginationclass(selection));
|
||||
if(activeThesis+1 < thesesboxes.length){
|
||||
loadThesis(activeThesis+2);
|
||||
} else {
|
||||
}
|
||||
});
|
||||
function gotoResultPage(result){
|
||||
count = '<?php echo $count; ?>';
|
||||
if(count != 'true' && count != 'false'){
|
||||
$('#savemodal').modal('show');
|
||||
} else if(count == 'true') {
|
||||
callResult(true);
|
||||
} else {
|
||||
callResult(false);
|
||||
}
|
||||
}
|
||||
function gotoFAQPage(evt, result){
|
||||
callPage(evt, 'faq.php?from=mahlowat.php'+window.location.hash, array2str(result), '<?php echo $count; ?>');
|
||||
}
|
||||
function callResult(count){
|
||||
ans = array2str(resultArray);
|
||||
if(count){
|
||||
url = "count.php?ans=" + ans;
|
||||
jQuery.get(url,function( data ) {
|
||||
callPage(null, 'result.php', ans, 'true');
|
||||
});
|
||||
} else {
|
||||
jQuery.get("count.php?false",function( data ) {
|
||||
callPage(null, 'result.php', ans, 'false');
|
||||
});
|
||||
}
|
||||
}
|
||||
function nextThesis(selection){
|
||||
multiply = false;
|
||||
if($('#weight').hasClass('active')){
|
||||
multiply = true;
|
||||
}
|
||||
resultArray[activeThesis] = result2letter(selection, multiply);
|
||||
pagination.eq(activeThesis).removeClass('pagination-yes pagination-neutral pagination-no');
|
||||
pagination.eq(activeThesis).addClass(letter2paginationclass(selection));
|
||||
if(activeThesis+1 < thesesboxes.length){
|
||||
loadThesis(activeThesis+2);
|
||||
} else {
|
||||
// call result page
|
||||
gotoResultPage(resultArray);
|
||||
}
|
||||
}
|
||||
function loadThesis(number){
|
||||
if(number > thesesboxes.length){
|
||||
}
|
||||
}
|
||||
function loadThesis(number){
|
||||
if(number > thesesboxes.length){
|
||||
number = 1;
|
||||
}
|
||||
activeThesis = number-1;
|
||||
thesesboxes.hide();
|
||||
pagination.removeClass('active');
|
||||
setClasses(resultArray[activeThesis]);
|
||||
thesesboxes.eq(number-1).show();
|
||||
pagination.eq(number-1).addClass('active');
|
||||
location.hash = number;
|
||||
}
|
||||
function letter2paginationclass(letter){
|
||||
switch(letter){
|
||||
}
|
||||
activeThesis = number-1;
|
||||
thesesboxes.hide();
|
||||
pagination.removeClass('active');
|
||||
setClasses(resultArray[activeThesis]);
|
||||
thesesboxes.eq(number-1).show();
|
||||
pagination.eq(number-1).addClass('active');
|
||||
location.hash = number;
|
||||
}
|
||||
function letter2paginationclass(letter){
|
||||
switch(letter){
|
||||
case 'a':
|
||||
case 'e':
|
||||
return 'pagination-yes';
|
||||
@@ -230,22 +230,22 @@ $emph[$i] = 1;
|
||||
case 'h':
|
||||
return '';
|
||||
break;
|
||||
}
|
||||
}
|
||||
function setClasses(code){
|
||||
$('.explic').hide();
|
||||
if(code < 'e'){
|
||||
}
|
||||
}
|
||||
function setClasses(code){
|
||||
$('.explic').hide();
|
||||
if(code < 'e'){
|
||||
$('#weight').removeClass('btn-info');
|
||||
$('#weight').addClass('btn-default');
|
||||
$('#weight').removeClass('active');
|
||||
$('#weight').text('These doppelt gewichten');
|
||||
} else {
|
||||
} else {
|
||||
$('#weight').addClass('btn-info');
|
||||
$('#weight').removeClass('btn-default');
|
||||
$('#weight').addClass('active');
|
||||
$('#weight').text('These wird doppelt gewichtet');
|
||||
}
|
||||
switch (code){
|
||||
}
|
||||
switch (code){
|
||||
case 'a':
|
||||
case 'e':
|
||||
$('#yes').addClass('btn-success');
|
||||
@@ -270,13 +270,13 @@ $emph[$i] = 1;
|
||||
$('#neutral').addClass('btn-warning');
|
||||
$('#no').addClass('btn-danger');
|
||||
break;
|
||||
}
|
||||
}
|
||||
function setPaginationColors(array){
|
||||
for(i = 0; i < array.length; i++){
|
||||
}
|
||||
}
|
||||
function setPaginationColors(array){
|
||||
for(i = 0; i < array.length; i++){
|
||||
pagination.eq(i).addClass(letter2paginationclass(array[i]));
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user