From 42b0799004f61c104590bcd0d528d224ca1bb302 Mon Sep 17 00:00:00 2001 From: Nael Date: Tue, 21 Jan 2014 21:42:14 +0100 Subject: [PATCH] =?UTF-8?q?votes=20werden=20jetzt=20eingef=C3=A4rbt=20<3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uVote/api/api_uvote.php | 7 +- uVote/api/votes/votes.php | 15 ++++ .../default_bulletin/default_bulletin.php | 4 + uVote/page/default_bulletin/js/vote.js | 27 ------- uVote/page/default_page/css/default_page.css | 16 +++- uVote/page/default_page/default_page.php | 22 +++++- uVote/page/default_page/js/loadtexts.js | 31 ++++---- uVote/page/default_page/js/timer.js | 9 --- uVote/page/default_page/page.html | 12 +-- uVote/page/default_page/vote.tpl | 3 +- uVote/page/default_register/register.tpl | 1 - uVote/page/page_uvote.php | 2 + uVote/page/user_main_uVote/uVote.tpl | 25 +++++++ uVote/sai/autoload.inc.php | 3 +- uVote/sai/register_modules.php | 3 +- uVote/sai/saimod_uvote_data_input/main.tpl | 5 ++ .../saimod_uvote_data_input.js | 55 ++++++++++++++ .../saimod_uvote_data_input.php | 14 ++++ uVote/sai/saimod_uvote_vote_edit/main.tpl | 74 +++++++++++++++++++ .../saimod_uvote_vote_edit.js | 1 + .../saimod_uvote_vote_edit.php | 22 ++++++ 21 files changed, 285 insertions(+), 66 deletions(-) delete mode 100644 uVote/page/default_page/js/timer.js create mode 100644 uVote/sai/saimod_uvote_data_input/main.tpl create mode 100644 uVote/sai/saimod_uvote_data_input/saimod_uvote_data_input.js create mode 100644 uVote/sai/saimod_uvote_data_input/saimod_uvote_data_input.php create mode 100644 uVote/sai/saimod_uvote_vote_edit/main.tpl create mode 100644 uVote/sai/saimod_uvote_vote_edit/saimod_uvote_vote_edit.js create mode 100644 uVote/sai/saimod_uvote_vote_edit/saimod_uvote_vote_edit.php diff --git a/uVote/api/api_uvote.php b/uVote/api/api_uvote.php index b5617d9..e9155f0 100644 --- a/uVote/api/api_uvote.php +++ b/uVote/api/api_uvote.php @@ -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); + + } } diff --git a/uVote/api/votes/votes.php b/uVote/api/votes/votes.php index 00350f0..ae15727 100644 --- a/uVote/api/votes/votes.php +++ b/uVote/api/votes/votes.php @@ -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); diff --git a/uVote/page/default_bulletin/default_bulletin.php b/uVote/page/default_bulletin/default_bulletin.php index 429af72..ac72a09 100644 --- a/uVote/page/default_bulletin/default_bulletin.php +++ b/uVote/page/default_bulletin/default_bulletin.php @@ -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 ''; } 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)); diff --git a/uVote/page/default_bulletin/js/vote.js b/uVote/page/default_bulletin/js/vote.js index e80a010..e69de29 100644 --- a/uVote/page/default_bulletin/js/vote.js +++ b/uVote/page/default_bulletin/js/vote.js @@ -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") - } - }); -} \ No newline at end of file diff --git a/uVote/page/default_page/css/default_page.css b/uVote/page/default_page/css/default_page.css index f38aae6..40ee889 100644 --- a/uVote/page/default_page/css/default_page.css +++ b/uVote/page/default_page/css/default_page.css @@ -3,6 +3,18 @@ body { padding-bottom: 40px; } -/*#list { +/*.list { border: 2px solid #ccc; -}*/ \ No newline at end of file +}*/ + +.pro{ + background: lightgreen; +} + +.contra{ + background: lightcoral; +} + +.ent{ + background: lightgray; +} \ No newline at end of file diff --git a/uVote/page/default_page/default_page.php b/uVote/page/default_page/default_page.php index 6c08da9..5469dee 100644 --- a/uVote/page/default_page/default_page.php +++ b/uVote/page/default_page/default_page.php @@ -17,12 +17,30 @@ class default_page extends SYSTEM\PAGE\Page { private function css(){ return '';} + + 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"); diff --git a/uVote/page/default_page/js/loadtexts.js b/uVote/page/default_page/js/loadtexts.js index fbb8afe..b7db66a 100644 --- a/uVote/page/default_page/js/loadtexts.js +++ b/uVote/page/default_page/js/loadtexts.js @@ -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) { diff --git a/uVote/page/default_page/js/timer.js b/uVote/page/default_page/js/timer.js deleted file mode 100644 index 163dee4..0000000 --- a/uVote/page/default_page/js/timer.js +++ /dev/null @@ -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%'); - } - }); -}); \ No newline at end of file diff --git a/uVote/page/default_page/page.html b/uVote/page/default_page/page.html index 77518e4..6ec6f15 100644 --- a/uVote/page/default_page/page.html +++ b/uVote/page/default_page/page.html @@ -21,9 +21,9 @@ -