votes werden jetzt eingefärbt <3

This commit is contained in:
Nael 2014-01-21 21:42:14 +01:00
parent 93f3f3a310
commit 42b0799004
21 changed files with 285 additions and 66 deletions

View File

@ -16,5 +16,10 @@ class api_uvote extends \SYSTEM\API\api_login {
public static function call_img($cat, $id){
return \SYSTEM\IMG\img::get($cat, $id);
}
}
public static function call_vote_action_submit($poll_ID) {
return votes::vote_submit($poll_ID);
}
}

View File

@ -22,6 +22,18 @@ class votes {
return $result;
}
public static function getUserPollData($poll_ID){
if (!\SYSTEM\SECURITY\Security::isLoggedIn()){
return NULL;}
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
$res = $con->prepare( 'selVoteByGrp',
'SELECT * FROM `uvote_data` WHERE `user_ID` = ? AND poll_ID = ?;',
array(\SYSTEM\SECURITY\Security::getUser()->id,$poll_ID));
$result = $res->next();
return $result['choice'];
}
public static function get_barsperusers($poll_ID,$return_as_json = true){
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
//count
@ -95,6 +107,9 @@ class votes {
array($poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $vote));
return JsonResult::ok();
}
public static function open_vote($poll_ID){
new \SYSTEM\LOG\INFO($poll_ID);

View File

@ -3,13 +3,17 @@ class default_bulletin extends SYSTEM\PAGE\Page {
private $poll_ID = NULL;
public function __construct($poll_ID) {
$this->poll_ID=$poll_ID;
}
private function js(){
return '<script src="'.SYSTEM\WEBPATH(new PPAGE(),'default_bulletin/js/vote.js').'"></script>';
}
public function html(){
$vars['poll_ID'] = $this->poll_ID;
$vars['js'] = $this->js();
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
$vars = array_merge($vars,votes::get_voteinfo($this->poll_ID));

View File

@ -1,27 +0,0 @@
$('#btnvote_yes').click(function () {
alert("1");
vote_click($(this).attr('poll_ID'),1);
alert("2");
});
$('#btnvote_no').click(function () {
vote_click($(this).attr('poll_ID'),2);
});
$('#btnvote_off').click(function () {
vote_click($(this).attr('poll_ID'),3);
});
function vote_click (poll_ID, vote) {
$.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + '&vote=' + vote, function(data) {
var items = [];
if(data.status == true){
alert("sucess");
} else {
alert(data.result.message);
alert("abc")
}
});
}

View File

@ -3,6 +3,18 @@ body {
padding-bottom: 40px;
}
/*#list {
/*.list {
border: 2px solid #ccc;
}*/
}*/
.pro{
background: lightgreen;
}
.contra{
background: lightcoral;
}
.ent{
background: lightgray;
}

View File

@ -17,12 +17,30 @@ class default_page extends SYSTEM\PAGE\Page {
private function css(){
return '<link href="'.SYSTEM\WEBPATH(new PPAGE(),'default_page\css\default_page.css').'" rel="stylesheet">';}
private static function tablerow_class($choice){
switch($choice){
case 1:
return 'pro';
case 2:
return 'contra';
case 3:
return 'ent';
default:
return '';
}
}
public function generate_votelist(){
$result = "";
$votes = votes::getAllVotesOfGroup(1);
$votes = votes::getAllVotesOfGroup(1);
foreach($votes as $vote){
$vars = array('vote_title' => $vote['title'], 'vote_text' => $vote['text'], 'vote_init' => $vote['initiative'], 'poll_ID' => $vote['ID'], 'time_end' => $vote['time_end']);
$vars = array( 'vote_title' => $vote['title'],
'vote_text' => $vote['text'],
'vote_init' => $vote['initiative'],
'vote_class' => $this->tablerow_class(votes::getUserPollData($vote['ID'])),
'poll_ID' => $vote['ID'],
'time_end' => $vote['time_end']);
$result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote.tpl'), $vars);
}
new \SYSTEM\LOG\INFO("generated votelist successfully");

View File

@ -8,20 +8,11 @@ $(document).ready(function() {
});*/
$('.btn_vote').click(function () {
//vote_click($(this).attr('poll_ID'));
open_vote($(this).attr('poll_ID'));
$('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID'));
open_vote($(this).attr('poll_ID'));
});
$('.btnvote_yes').click(function () {
alert("1");
vote_click($(this).attr('poll_ID'),1);
alert("2");
});
$('.btnvote_no').click(function () {
vote_click($(this).attr('poll_ID'),2);
});
$('.btnvote_off').click(function () {
vote_click($(this).attr('poll_ID'),3);
});
/*$('.btn_openvoteinfo').click(function () {
if($("#openvoteinfo"+$(this).attr('poll_ID')).is(':visible')){
@ -101,6 +92,7 @@ function load_user_main_tab(action){
}
}
function account_create(inputEmail, inputPassword){
$.get('./api.php?call=account&action=create&username=' + NULL + '&password_sha=' + password + '&email=' + email + '&locale=deDE', function (data) {
dataTmp = data;
@ -138,16 +130,25 @@ function vote_click (poll_ID, vote) {
$.getJSON('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + '&vote=' + vote, function(data) {
var items = [];
if(data.status == true){
alert("sucess");
alert("success");
} else {
alert(data.result.message);
alert("abc")
}
});
}
function open_vote (poll_ID) {
$('#list').load('./api.php?call=vote&action=open_vote&poll_ID=' + poll_ID);
$('#list').load('./api.php?call=vote&action=open_vote&poll_ID=' + poll_ID, function(){
$('.btnvote_yes').click(function () {
vote_click($(this).attr('poll_ID'),1);
});
$('.btnvote_no').click(function () {
vote_click($(this).attr('poll_ID'),2);
});
$('.btnvote_off').click(function () {
vote_click($(this).attr('poll_ID'),3);
});
});
}
function loadAjaxContent(url) {

View File

@ -1,9 +0,0 @@
$(function(){
$('.countdown').countdown({
date: "June 7, 2087 15:03:26",
render: function(data) {
$(this.el).text(this.leadingZeros(data.years, 4) + "j " + this.leadingZeros(data.days, 3) + "t " + this.leadingZeros(data.hours, 2) + "s " + this.leadingZeros(data.min, 2) + "m " + this.leadingZeros(data.sec, 2) + "s");
$(this.el).parent().children('.countdownbar').width('70%');
}
});
});

View File

@ -21,9 +21,9 @@
<body style="">
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<div class="navbar navbar-inverse navbar-fixed-top" style="width: 100%">
<div class="navbar-inner" style="width: 100%">
<div class="container" style="width: 100%">
<button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
@ -45,12 +45,12 @@
</div>
</div>
</div>
<div class="container" id="site-content-wrapper" style="margin-top: 0;">
<div class="container" style="margin-top: 0; clear: both;">
<div id="site-content" style="padding: 0; margin: 0;">
<div id="list" style="border: 2px solid #ccc; position: fixed; padding: 0px; width: 800px; top: 50px; bottom: 50px; overflow-y: scroll; float: left;">
<div id="list" style="border: 2px solid #ccc; position: fixed; padding: 0px; width: 850px; top: 50px; left: 20px; bottom: 50px; overflow-y: scroll;">
${votelist}
</div>
<div id="user_main" style="right: 0px; position: fixed; padding: 0px; padding-right: 10px; width: 35%; top: 50px; bottom: 50px; overflow-y: scroll;">
<div id="user_main" style="right: 0px; position: fixed; padding: 0px; right: 70px; width: 35%; top: 50px; bottom: 50px;">
</div>
</div>

View File

@ -1,4 +1,4 @@
<div style="padding: 5px; background: #f1f1f1; margin-bottom: 8px;">
<div class="${vote_class}" style="padding: 5px; margin-bottom: 8px;">
<div class="row" style="width: 100%; margin: 0; margin-top: 5px; margin-bottom: 8px;">
<div class="span6">
<h4>${vote_title}</h4>
@ -22,4 +22,5 @@
<div class="span5" id="openvoteinfo${poll_ID}" style="margin: 0; display: none; width: 100%; margin-top: 15px;">
</div>
</div>

View File

@ -82,6 +82,5 @@
</tbody>
</table>
<button class="btn btn-primary" type="submit"><i class="icon-ok icon-white"></i> ${register}</button>
<button class="btn btn-primary" type="reset" id="btn_user_registration_cancel"><i class="icon-remove icon-white"></i> ${cancel}</button>
</div>
</form>

View File

@ -9,6 +9,8 @@ class page_uvote extends \SYSTEM\API\api_default {
return new default_myvote();}
public static function action_open_bulletin ($poll_ID){
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
return new default_register ($poll_ID);}
return new default_bulletin($poll_ID);}
public static function action_user_main(){

View File

@ -0,0 +1,25 @@
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Genre', 'Fantasy & Sci Fi', 'Romance', 'Mystery/Crime', 'General',
'Western', 'Literature', { role: 'annotation' } ],
['2010', 10, 24, 20, 32, 18, 5, ''],
['2020', 16, 22, 23, 30, 16, 9, ''],
['2030', 28, 19, 29, 30, 12, 13, ''],
]);
var options = {
width: 600,
height: 400,
legend: { position: 'top', maxLines: 3 },
bar: { groupWidth: '75%' },
isStacked: true,
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>

View File

@ -1,3 +1,4 @@
<?php
SYSTEM\autoload::registerFolder(dirname(__FILE__).'','');
//SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_mojotrollz_server_handling','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_uvote_vote_edit','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/saimod_uvote_data_input','');

View File

@ -1,2 +1,3 @@
<?php
//\SYSTEM\SAI\sai::register('saimod_mojotrollz_server_handling');
\SYSTEM\SAI\sai::register('saimod_uvote_vote_edit');
\SYSTEM\SAI\sai::register('saimod_uvote_data_input');

View File

@ -0,0 +1,5 @@
<button id="realm_start" class="btn">(re)start realm</button>
<button id="realm_stop" class="btn">stop realm</button>
</br></br>
<button id="world_start" class="btn">(re)start world</button>
<button id="world_stop" class="btn">stop world</button>

View File

@ -0,0 +1,55 @@
function init_saimod_uvote_data_input(){
$('#realm_start').click(function(){
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: 'saimod_mojotrollz_server_handling',
action: 'realmstart'
},
type: 'POST',
});
update_realmstatus();
});
$('#realm_stop').click(function(){
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: 'saimod_mojotrollz_server_handling',
action: 'realmstop'
},
type: 'POST',
});
update_realmstatus();
});
$('#world_start').click(function(){
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: 'saimod_mojotrollz_server_handling',
action: 'worldstart'
},
type: 'POST',
});
update_worldstatus();
});
$('#world_stop').click(function(){
$.ajax({
url: SAI_ENDPOINT,
data: { sai_mod: 'saimod_mojotrollz_server_handling',
action: 'worldstop'
},
type: 'POST',
});
update_worldstatus();
});
}
function update_realmstatus(){
$('status_realm').load(SAI_ENDPOINT+'sai_mod=saimod_mojotrollz_server_handling&action=realmstatus');
}
function update_worldstatus(){
$('status_world').load(SAI_ENDPOINT+'sai_mod=saimod_mojotrollz_server_handling&action=world status');
}

View File

@ -0,0 +1,14 @@
<?php
class saimod_uvote_data_input extends \SYSTEM\SAI\SaiModule {
public function saimod_uvote_data_input(){
$vars = array();
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/main.tpl', $vars);}
public static function html_li_menu(){return '<li><a href="#" saimenu="saimod_uvote_data_input">data completion</a></li><li class="divider"></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod_saimod_uvote_vote_edit_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array(
\SYSTEM\WEBPATH(new PSAI(),'saimod_uvote_data_input/saimod_uvote_data_input.js')
));}
public static function sai_mod_saimod_uvote_data_input_flag_css(){}
}

View File

@ -0,0 +1,74 @@
<input type="text" id="vote_title" placeholder="${vote_title}"/>
<input type="text" id="poll_ID" placeholder="${poll_ID}"/>
<br>
<br>
<h4>Eingebracht durch</h4>
<label><input type="checkbox" id="checkbox_breg" style="margin-top: -1px;">BReg</label>
<label><input type="checkbox" id="checkbox_cdu" style="margin-top: -1px;">CDU</label>
<label><input type="checkbox" id="checkbox_csu" style="margin-top: -1px;">CSU</label>
<label><input type="checkbox" id="checkbox_spd" style="margin-top: -1px;">SPD</label>
<label><input type="checkbox" id="checkbox_b90" style="margin-top: -1px;">B90</label>
<label><input type="checkbox" id="checkbox_linke" style="margin-top: -1px;">LINKE</label>
<input type="text" placeholder="sonstige, hier eintragen"/>
<br>
<h4>Politikfelder</h4>
<div style="float: left; padding-right: 5px;">
<label><input type="checkbox" id="checkbox_Agrarpolitik" style="margin-top: -1px;">Agrarpolitik</label>
<label><input type="checkbox" id="checkbox_Außenpolitik" style="margin-top: -1px;">Außenpolitik</label>
<label><input type="checkbox" id="checkbox_Bildungspolitik" style="margin-top: -1px;">Bildungspolitik</label>
<label><input type="checkbox" id="checkbox_Energiepolitik" style="margin-top: -1px;">Energiepolitik</label>
<label><input type="checkbox" id="checkbox_Ernaehrungspolitik" style="margin-top: -1px;">Ernaehrungspolitik</label>
<label><input type="checkbox" id="checkbox_Gesundheitspolitik" style="margin-top: -1px;">Gesundheitspolitik</label>
<label><input type="checkbox" id="checkbox_Innenpolitik" style="margin-top: -1px;">Innenpolitik</label>
<label><input type="checkbox" id="checkbox_Kulturpolitik" style="margin-top: -1px;">Kulturpolitik</label>
<label><input type="checkbox" id="checkbox_Medienpolitik" style="margin-top: -1px;">Medienpolitik</label>
</div>
<label><input type="checkbox" id="checkbox_Migrationspolitik" style="margin-top: -1px;">Migrationspolitik</label>
<label><input type="checkbox" id="checkbox_Sicherheitspolitik" style="margin-top: -1px;">Sicherheitspolitik</label>
<label><input type="checkbox" id="checkbox_Sozialpolitik" style="margin-top: -1px;">Sozialpolitik</label>
<label><input type="checkbox" id="checkbox_Sportpolitik" style="margin-top: -1px;">Sportpolitik</label>
<label><input type="checkbox" id="checkbox_Umweltpolitik" style="margin-top: -1px;">Umweltpolitik</label>
<label><input type="checkbox" id="checkbox_Verkehrspolitik" style="margin-top: -1px;">Verkehrspolitik</label>
<label><input type="checkbox" id="checkbox_Verteidigungspolitik" style="margin-top: -1px;">Verteidigungspolitik</label>
<label><input type="checkbox" id="checkbox_Wirtschaftspolitik" style="margin-top: -1px;">Wirtschaftspolitik</label>
<label><input type="checkbox" id="checkbox_Europapolitik" style="margin-top: -1px;">Europapolitik</label>
<h4>poll start</h4>
<input type="text" placeholder="JJJJ-TT-MM"/> - 00:00
<h4>poll end</h4>
<input type="text" placeholder="JJJJ-TT-MM"/> - 00:00
<div id="user_main" style="border: 2px solid #ccc; right: 0px; position: fixed; padding: 0px; padding-right: 10px; width: 35%; top: 50px; bottom: 50px; overflow-y: scroll;">
<div style="margin-right: 10px;">
<img src="${frontend_logos}logo2.png" style="float: right" height="100%" width="200px"/>
<h5>Auf einen Blick</h5>
<form action="/html/tags/html_form_tag_action.cfm" method="post">
<br />
<textarea name="vote_quick" id="vote_quick">Insert Info into here!</textarea>
<br />
<input type="submit" value="Submit" />
</form>
<br>
<a class="btn btn-green btnvote_yes"
id="btnvote_yes"
style="width: 65px;"
poll_ID="${poll_ID}"><font
size="3">Pro</font></a>
<a class="btn btn-red btnvote_no"
style="width: 65px;"
href="#"
poll_ID="${poll_ID}"><font
size="3">Contra</font></a>
<a class="btn btn-grey btnvote_off"
style="width: 65px;"
href="#"
poll_ID="${poll_ID}"><font
size="3">Enthaltung</font></a>
</div>
</div>
<br>
<a class="btn btn-primary" id="vote_submit">Submit</a>

View File

@ -0,0 +1 @@

View File

@ -0,0 +1,22 @@
<?php
class saimod_uvote_vote_edit extends \SYSTEM\SAI\SaiModule {
public static function sai_mod__SYSTEM_SAI_saimod_uvote_vote_edit_action_add($id, $category){
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
$res = null;
$res = $con->prepare('addText' ,'INSERT INTO uvote_votes (ID) VALUES ($1);', array($poll_ID));
return $res->affectedRows() == 0 ? \SYSTEM\LOG\JsonResult::error(new \SYSTEM\LOG\WARNING("no data added")) : \SYSTEM\LOG\JsonResult::ok();
}
public static function sai_mod_saimod_uvote_vote_edit(){
$vars = array();
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
return \SYSTEM\PAGE\replace::replaceFile(dirname(__FILE__).'/main.tpl', $vars);}
public static function html_li_menu(){return '<li><a href="#" saimenu="saimod_uvote_vote_edit">votemask</a></li><li class="divider"></li>';}
public static function right_public(){return false;}
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
public static function sai_mod_saimod_uvote_vote_edit_flag_js(){return \SYSTEM\LOG\JsonResult::toString(array(
\SYSTEM\WEBPATH(new PSAI(),'saimod_uvote_vote_edit/saimod_uvote_vote_edit.js')
));}
public static function sai_mod_saimod_uvote_data_input_flag_css(){}
}