From cb333417a5319faa9f8bf857777fd002e9991fd0 Mon Sep 17 00:00:00 2001 From: Nael Date: Sat, 8 Mar 2014 21:35:41 +0100 Subject: [PATCH] fuck js --- uVote/api/api_uvote.php | 5 ++ uVote/api/votes/votes.php | 15 +++- .../dbd/qq/UVOTE_DATA_USER_COMMENT_INSERT.php | 12 ++++ .../qq/UVOTE_GENERATE_COMMENTS_PER_POLL.php | 11 +++ uVote/dbd/qq/UVOTE_GENERATE_VOTELIST.php | 2 +- uVote/dbd/qq/UVOTE_GENERATE_VOTELIST_EXP.php | 11 +++ uVote/page/default_bulletin/bulletin.tpl | 69 +++++++++---------- uVote/page/default_bulletin/comment.tpl | 4 ++ .../default_bulletin/default_bulletin.php | 25 +++++++ .../default_bulletin/icons_table_parties.tpl | 2 +- uVote/page/default_bulletin/table_parties.tpl | 2 +- uVote/page/default_page/full_vote.tpl | 2 +- uVote/page/default_page/js/loadtexts.js | 53 ++++++++++++-- uVote/page/default_page/page.tpl | 2 +- .../page/user_list_ended/user_list_ended.php | 2 +- uVote/page/user_main_urVote/urVote.tpl | 3 +- 16 files changed, 168 insertions(+), 52 deletions(-) create mode 100644 uVote/dbd/qq/UVOTE_DATA_USER_COMMENT_INSERT.php create mode 100644 uVote/dbd/qq/UVOTE_GENERATE_COMMENTS_PER_POLL.php create mode 100644 uVote/dbd/qq/UVOTE_GENERATE_VOTELIST_EXP.php create mode 100644 uVote/page/default_bulletin/comment.tpl diff --git a/uVote/api/api_uvote.php b/uVote/api/api_uvote.php index de2bbfe..4aea6ee 100644 --- a/uVote/api/api_uvote.php +++ b/uVote/api/api_uvote.php @@ -10,6 +10,11 @@ class api_uvote extends \SYSTEM\API\api_login { } + public static function call_vote_action_comment($poll_ID, $c_choice, $c_txt, $c_src) { + return votes::write_comment($poll_ID, $c_choice, $c_txt, $c_src); + + } + public static function call_vote_action_new_vote($ID, $title, $iframe_link) { return votes::write_poll($ID, $title, $iframe_link); diff --git a/uVote/api/votes/votes.php b/uVote/api/votes/votes.php index ee64d1c..11a86e4 100644 --- a/uVote/api/votes/votes.php +++ b/uVote/api/votes/votes.php @@ -27,13 +27,21 @@ class votes { public static function getAllVotesOfGroup($groupid){ return \DBD\UVOTE_GENERATE_VOTELIST::QA(array($groupid));} + public static function getAllExpVotesOfGroup($groupid){ + return \DBD\UVOTE_GENERATE_VOTELIST_EXP::QA(array($groupid));} + + public static function getUserComments($poll_ID, $c_choice){ + return \DBD\UVOTE_GENERATE_COMMENTS_PER_POLL::QA(array($poll_ID, $c_choice));} + public static function countAllPolls(){ $res = \DBD\UVOTE_DATA_COUNT_VOTES::QQ(); return $res;} public static function insertPartyChoice($poll_ID, $party, $votes_pro, $votes_contra, $nr_attending, $total, $choice){ return \DBD\UVOTE_GENERATE_VOTELIST::QI(array($poll_ID, $party, $votes_pro, $votes_contra, $nr_attending, $total, $choice));} - + + public static function insertUserComment($c_choice, $poll_ID, $user_ID, $c_txt, $c_src, $timestamp){ + return \DBD\UVOTE_DATA_USER_COMMENT_INSERT::QI(array($c_choice, $poll_ID, $user_ID, $c_txt, $c_src, $timestamp));} /*public static function getVoteOfGroup($poll_ID){ $con = new \SYSTEM\DB\Connection(new \DBD\uVote()); $res = $con->prepare( 'selVoteByGrp', @@ -177,6 +185,11 @@ class votes { throw new ERROR("You need to be logged in.");} return \DBD\UVOTE_DATA_USER_ADD_DATA_INSERT::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id, $location, $birthyear, $gender, $children, \SYSTEM\SECURITY\Security::getUser()->id, $location, $birthyear, $gender, $children));} + public static function write_comment($poll_ID, $c_choice, $c_txt, $c_src){ + if(!\SYSTEM\SECURITY\Security::isLoggedIn()){ + throw new ERROR("You need to be logged in.");} + return \DBD\UVOTE_DATA_USER_COMMENT_INSERT::Q1(array($c_choice, $poll_ID, \SYSTEM\SECURITY\Security::getUser()->id, $c_txt, $c_src));} + public static function get_add_data(){ return \DBD\UVOTE_DATA_USER_ADD_DATA::Q1(array(\SYSTEM\SECURITY\Security::getUser()->id)); } diff --git a/uVote/dbd/qq/UVOTE_DATA_USER_COMMENT_INSERT.php b/uVote/dbd/qq/UVOTE_DATA_USER_COMMENT_INSERT.php new file mode 100644 index 0000000..6785731 --- /dev/null +++ b/uVote/dbd/qq/UVOTE_DATA_USER_COMMENT_INSERT.php @@ -0,0 +1,12 @@ + NOW() ORDER BY (time_end-time_start) ASC;' );}} \ No newline at end of file diff --git a/uVote/dbd/qq/UVOTE_GENERATE_VOTELIST_EXP.php b/uVote/dbd/qq/UVOTE_GENERATE_VOTELIST_EXP.php new file mode 100644 index 0000000..232dabb --- /dev/null +++ b/uVote/dbd/qq/UVOTE_GENERATE_VOTELIST_EXP.php @@ -0,0 +1,11 @@ + +

${title}

-
-${openvote_help_text}${title}${openvote_help_text1} -
-
-
+
${vote_buttons} -
+
-
-
-
- ${voice_weight} -
+
+ ${openvote_help_text} + ${title} + ${openvote_help_text1}
-
- -
- + +
+ ${voice_weight} +
+
+
${bars_user}
-
- +
${bars_bt}
- -
+
${icons_party} ${choice_party} -
- +
+
+
+ +
+ ${comments_pro} + ${comments_con} + + + +
+
${submit}
+
+ - \ No newline at end of file diff --git a/uVote/page/default_bulletin/comment.tpl b/uVote/page/default_bulletin/comment.tpl new file mode 100644 index 0000000..8f01cea --- /dev/null +++ b/uVote/page/default_bulletin/comment.tpl @@ -0,0 +1,4 @@ +
${timestamp}
+
${c_txt}
+
${c_src}
+
\ No newline at end of file diff --git a/uVote/page/default_bulletin/default_bulletin.php b/uVote/page/default_bulletin/default_bulletin.php index eaa7509..f96da42 100644 --- a/uVote/page/default_bulletin/default_bulletin.php +++ b/uVote/page/default_bulletin/default_bulletin.php @@ -55,6 +55,27 @@ class default_bulletin extends SYSTEM\PAGE\Page { return $result; } + private function get_pro_comments (){ + $result = ''; + $vars = votes::getUserComments($this->poll_ID, 1); + foreach($vars as $com){ + $com['c_txt'] = utf8_encode($com['c_txt']); + $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/comment.tpl'), $com); + } + return $result; + + } + private function get_con_comments (){ + $result = ''; + $vars = votes::getUserComments($this->poll_ID, 2); + + foreach($vars as $com){ + $com['c_txt'] = utf8_encode($com['c_txt']); + $result .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_bulletin/comment.tpl'), $com); + } + return $result; + + } private function bars_user(){ $bars = votes::get_barsperusers($this->poll_ID,false); $bars['vote_yes_perc'] = round($bars['yes_perc']*100,0); @@ -174,12 +195,16 @@ class default_bulletin extends SYSTEM\PAGE\Page { $vars['bars_party'] = ''; $vars['icons_party'] = ''; $vars['vote_class'] = $this->vote_choice(); + $vars['comments_pro'] = ''; + $vars['comments_con'] = ''; $vars['js'] = $this->js(); $vars['css'] = $this->css(); $vars['vote_buttons'] = $this->vote_buttons($poll_expired,$user_vote); // $vars['p_fields'] = $this->p_fields(); if($user_vote){ + $vars['comments_pro'] = $this->get_pro_comments(); + $vars['comments_con'] = $this->get_con_comments(); $vars['icons_party'] = $this->icons_party(); $vars['choice_party'] = $this->choice_party(); $vars['bars_party'] = $this->bars_party(); diff --git a/uVote/page/default_bulletin/icons_table_parties.tpl b/uVote/page/default_bulletin/icons_table_parties.tpl index 97038a8..b082c99 100644 --- a/uVote/page/default_bulletin/icons_table_parties.tpl +++ b/uVote/page/default_bulletin/icons_table_parties.tpl @@ -1,5 +1,5 @@
${urvote_party_table_desc}
-
+
diff --git a/uVote/page/default_bulletin/table_parties.tpl b/uVote/page/default_bulletin/table_parties.tpl index ff02ccc..aced008 100644 --- a/uVote/page/default_bulletin/table_parties.tpl +++ b/uVote/page/default_bulletin/table_parties.tpl @@ -1,4 +1,4 @@ -
+
${party_yes}%
${party_no}%
diff --git a/uVote/page/default_page/full_vote.tpl b/uVote/page/default_page/full_vote.tpl index f181275..6d87166 100644 --- a/uVote/page/default_page/full_vote.tpl +++ b/uVote/page/default_page/full_vote.tpl @@ -3,7 +3,7 @@ Quelle: ${iframe_link}
- +
diff --git a/uVote/page/default_page/js/loadtexts.js b/uVote/page/default_page/js/loadtexts.js index 9733643..d8b7d32 100644 --- a/uVote/page/default_page/js/loadtexts.js +++ b/uVote/page/default_page/js/loadtexts.js @@ -36,18 +36,20 @@ $(document).ready(function() { //load_user_main_tab('user_main_uVote'); }); - $('#user_list').load('./?action=user_list', function(){ + $('#user_list').load('./?action=user_list', function(){ + $('#tabs_user_list a').click(function (e) { + e.preventDefault(); + $(this).tab('show'); + load_user_list_tab($(this).attr('action')); + + }); $('.btn_vote').click(function () { //vote_click($(this).attr('poll_ID')); $('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID')); open_vote($(this).attr('poll_ID')); register_registerform(); }); - $('#tabs_user_list a').click(function (e) { - e.preventDefault(); - $(this).tab('show'); - load_user_list_tab($(this).attr('action')); - }); + //load_user_main_tab('user_main_uVote'); }); @@ -130,10 +132,22 @@ function load_user_list_tab(action){ switch(action){ case 'user_list_active': - $('#tab_active').load('./?action='+ action); + $('#tab_active').load('./?action='+ action); + $('.btn_vote').click(function () { + //vote_click($(this).attr('poll_ID')); + $('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID')); + open_vote($(this).attr('poll_ID')); + register_registerform(); + }); return; case 'user_list_ended': $('#tab_ended').load('./?action='+ action); + $('.btn_vote').click(function () { + //vote_click($(this).attr('poll_ID')); + $('#user_main').load('./?action=open_bulletin&poll_ID=' + $(this).attr('poll_ID')); + open_vote($(this).attr('poll_ID')); + register_registerform(); + }); return; default: } @@ -185,6 +199,22 @@ function vote_click (poll_ID, vote) { } }); } +function submit_c_data (poll_ID, c_choice) { + var c_txt = document.getElementById("c_txt_pro").textContent; + var c_src = document.getElementById("c_src_pro").textContent; + alert(c_choice); + $.getJSON('./api.php?call=vote&action=comment&poll_ID=' + poll_ID + '&c_choice=' + c_choice + '&c_txt=' + c_txt + '&c_src=' + c_src, function(data) { + var items = []; + if(data.status == true){ + alert("success"); + $('#user_main').load('./?action=open_bulletin&poll_ID=' + poll_ID, function(){ + open_vote(poll_ID); + }); + } else { + alert(data.result.message); + } + }); +} function submit_add_data () { var a = document.getElementById("location"); @@ -244,9 +274,18 @@ function open_vote (poll_ID) { $('.btnvote_off').click(function () { vote_click($(this).attr('poll_ID'),3); }); + $('.submit_pro').click(function () { + submit_c_data($(this).attr('poll_ID',1)); + alert('success'); + }); + $('.submit_con').click(function () { + submit_c_data($(this).attr('poll_ID')); + alert('success'); + }); $('#test').click(function(){ $('#myModal').modal(); }); + register_registerform(); }); } diff --git a/uVote/page/default_page/page.tpl b/uVote/page/default_page/page.tpl index f76d114..eaff81b 100644 --- a/uVote/page/default_page/page.tpl +++ b/uVote/page/default_page/page.tpl @@ -70,7 +70,7 @@
-
+
diff --git a/uVote/page/user_list_ended/user_list_ended.php b/uVote/page/user_list_ended/user_list_ended.php index 75dc13c..f4567da 100644 --- a/uVote/page/user_list_ended/user_list_ended.php +++ b/uVote/page/user_list_ended/user_list_ended.php @@ -41,7 +41,7 @@ class user_list_ended extends SYSTEM\PAGE\Page { public function generate_votelist(){ $result = array('',''); - $votes = votes::getAllVotesOfGroup(1); + $votes = votes::getAllExpVotesOfGroup(1); foreach($votes as $vote){ $time_remain = strtotime($vote['time_end'])- microtime(true); $time_span = strtotime($vote['time_end']) - strtotime($vote['time_start']); diff --git a/uVote/page/user_main_urVote/urVote.tpl b/uVote/page/user_main_urVote/urVote.tpl index 0fa43ba..ac9ef02 100644 --- a/uVote/page/user_main_urVote/urVote.tpl +++ b/uVote/page/user_main_urVote/urVote.tpl @@ -18,7 +18,8 @@
${user_temp_votes}
-
+
+
${user_overall_votes}