menu for list. not working though. strange bug in js

This commit is contained in:
Nael 2014-03-08 02:37:16 +01:00
parent cd21275543
commit dd2feab740
11 changed files with 298 additions and 34 deletions

View File

@ -6,12 +6,7 @@ $(document).ready(function() {
//loadUrlPic($(this).attr('url'));
});*/
$('.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();
});
/*$('.btn_openvoteinfo').click(function () {
@ -23,9 +18,43 @@ $(document).ready(function() {
});*/
//jqBootstrapValidation
$("#form_login input").not("[type=submit]").jqBootstrapValidation({
$('#user_main').load('./?action=user_main', function(){
register_registerform();
$('#feedback_submit').click(function (data){
var test = $('textarea#feedback_text').val();
send_feedback(test);
});
$('#tabs_user_main a').click(function (e) {
e.preventDefault();
$(this).tab('show');
load_user_main_tab($(this).attr('action'));
});
//load_user_main_tab('user_main_uVote');
});
$('#user_list').load('./?action=user_list', function(){
$('.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');
});
});
$("#form_login input").not("[type=submit]").jqBootstrapValidation({
preventSubmit: true,
submitError: function($form, event, errors) {},
submitSuccess: function($form, event){
@ -52,25 +81,8 @@ $(document).ready(function() {
}
});
$('#user_main').load('./?action=user_main', function(){
register_registerform();
$('#feedback_submit').click(function (data){
var test = $('textarea#feedback_text').val();
send_feedback(test);
});
$('#tabs_user_main a').click(function (e) {
e.preventDefault();
$(this).tab('show');
load_user_main_tab($(this).attr('action'));
});
//load_user_main_tab('user_main_uVote');
});
});
function register_registerform(){
console.log("wegwegwegwegwegweg");
$("#register_user_form input").not("[type=submit]").jqBootstrapValidation(
{
preventSubmit: true,
@ -97,7 +109,6 @@ function load_user_main_tab(action){
switch(action){
case 'user_main_uVote':
window.location.reload();
$('#tab_uVote').load('./?action='+ action);
return;
case 'user_main_urVote':
@ -114,7 +125,19 @@ function load_user_main_tab(action){
default:
}
}
function load_user_list_tab(action){
switch(action){
case 'user_list_active':
$('#tab_active').load('./?action='+ action);
return;
case 'user_list_ended':
$('#tab_ended').load('./?action='+ action);
return;
default:
}
}
function account_create(inputEmail, inputPassword){
$.get('./api.php?call=account&action=create&username=' + NULL + '&password_sha=' + password + '&email=' + email + '&locale=deDE', function (data) {
@ -211,7 +234,7 @@ $.ajax({
}
function open_vote (poll_ID) {
$('#list').load('./api.php?call=vote&action=open_vote&poll_ID=' + poll_ID, function(){
$('#user_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);
});

View File

@ -3,7 +3,6 @@
<input class="span2" type="password" id="login_password" placeholder="Passwort">
<button type="submit" class="btn">Login</button>
</form> -->
<form class="navbar-form pull-right" style="" id="form_login">
<div class="control-group">
<div class="help-block"style="float: left; padding: 0;"></div>

View File

@ -72,8 +72,8 @@
<div id="user_main" style="position: absolute; padding: 0; padding-top: 0px; width: 50%;"></div>
<div id="list" style="padding: 0px; width: 50%; float: right;">
${votelist}
<div id="user_list" style="padding: 0px; width: 50%; float: right;">
</div>
</div>

View File

@ -13,7 +13,10 @@ class page_uvote extends \SYSTEM\API\api_default {
public static function action_user_main(){
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
return new default_register ();}
return new user_main();}
return new user_main();}
public static function action_user_list(){
return new user_list();}
public static function action_user_main_uVote(){
return new user_main_uVote();}

View File

@ -6,4 +6,7 @@ SYSTEM\autoload::registerFolder(dirname(__FILE__).'/default_bulletin','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_uVote','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_urVote','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_myVote','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_main_myVote','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list_active','');
SYSTEM\autoload::registerFolder(dirname(__FILE__).'/user_list_ended','');

View File

@ -0,0 +1,11 @@
<div class="tabbable" style="padding-right: 50px;">
<ul class="nav nav-tabs" id="tabs_user_list">
<li class="active"><a href="#tab_active" action="user_list_active">aktive Abstimmungen</a></li>
<li class=""><a href="#tab_ended" action="user_list_ended">abgelaufene Abstimmungen</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="tab_active">${active}</div>
<div class="tab-pane" id="tab_ended" style="overflow: hidden;"></div>
</div>
</div>

View File

@ -0,0 +1,15 @@
<?php
class user_list extends SYSTEM\PAGE\Page {
public function html(){
$vars = array();
$uv = new user_list_active();
$vars['frontend_logos'] = \SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_CONFIG_PATH_BASEURL).'api.php?call=img&cat=frontend_logos&id=';
$vars['active'] = $uv->html();
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_list/list_menu.tpl'),$vars);
}
}

View File

@ -0,0 +1 @@
${votelist}

View File

@ -0,0 +1,105 @@
<?php
class user_list_active extends SYSTEM\PAGE\Page {
private function get_party_per_poll($choice){
switch($choice){
case 1:
return 'PRO';
case 2:
return 'CON';
case 3:
return 'ENT';
default:
return 'NONE';
}
}
private static function tablerow_class($choice){
switch($choice){
case 1:
return 'pro';
case 2:
return 'con';
case 3:
return 'ent';
default:
return 'open';
}
}
private static function badge_class($choice){
switch($choice){
case 1:
return 'badge-success';
case 2:
return 'badge-important';
case 3:
return 'badge-info';
default:
return '';
}
}
public function generate_votelist(){
$result = array('','');
$votes = votes::getAllVotesOfGroup(1);
foreach($votes as $vote){
$time_remain = strtotime($vote['time_end'])- microtime(true);
$time_span = strtotime($vote['time_end']) - strtotime($vote['time_start']);
$vote_count = votes::get_count_user_votes_per_poll($vote['ID']);
$vote['title'] = utf8_encode($vote['title']);
$vote['time_left'] = round($time_remain/($time_span+1)*100,0);
$vote['time_done'] = 100-$vote['time_left'];
$vote['full_vote_btn'] = $time_remain > 0 ? 'Abstimmen' : 'Ansehen';
$vote['uv'] = $vote['bt'] = '';
$vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5';
$user_vote = votes::getUserPollData($vote['ID']);
$vote['vote_class'] = $this->tablerow_class($user_vote);
if($user_vote){
//user vote
$vote['vote_class'] = $this->tablerow_class($user_vote);
//bt vote
$party_votes = votes::get_barsperparty($vote['ID']);
$vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']);
foreach($party_votes as $pv){
$vote['bt'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote_bt.tpl'),
array( 'party' => $pv['party'],
'choice' => $this->get_party_per_poll($pv['choice']),
'choice_class' => $this->badge_class($pv['choice'])));
}
//uvote vote
$uvote = votes::get_users_choice_per_poll($vote['ID']);
$vote['uv_vote_class'] = count($uvote) > 0 ? $this->tablerow_class($uvote[0]['choice']) : '';
foreach($uvote as $v){
$vote['uv'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote_uv.tpl'),
array( 'badge' => self::badge_class($v['choice']),
'perc' => $v['count'] > 0 ? round($v['count']/$vote_count['count']*100, 2) : 0));
}
}
if($time_remain > 0){
$result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote.tpl'), $vote);
} else {
$result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote.tpl'), $vote);
}
}
return $result[0].$result[1];
}
public function html(){
$vars = array();
$vars['votelist'] = $this->generate_votelist();
$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, \SYSTEM\locale::getStrings(DBD\locale_string::VALUE_CATEGORY_MAINPAGE));
$vars = array_merge($vars, \SYSTEM\locale::getStrings(150));
$vars = array_merge($vars, \SYSTEM\locale::getStrings(110));
$vars = array_merge($vars, \SYSTEM\locale::getStrings(100));
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_list_active/active.tpl'), $vars);
}
}

View File

@ -0,0 +1 @@
${votelist}

View File

@ -0,0 +1,103 @@
<?php
class user_list_ended extends SYSTEM\PAGE\Page {
private function get_party_per_poll($choice){
switch($choice){
case 1:
return 'PRO';
case 2:
return 'CON';
case 3:
return 'ENT';
default:
return 'NONE';
}
}
private static function tablerow_class($choice){
switch($choice){
case 1:
return 'pro';
case 2:
return 'con';
case 3:
return 'ent';
default:
return 'open';
}
}
private static function badge_class($choice){
switch($choice){
case 1:
return 'badge-success';
case 2:
return 'badge-important';
case 3:
return 'badge-info';
default:
return '';
}
}
public function generate_votelist(){
$result = array('','');
$votes = votes::getAllVotesOfGroup(1);
foreach($votes as $vote){
$time_remain = strtotime($vote['time_end'])- microtime(true);
$time_span = strtotime($vote['time_end']) - strtotime($vote['time_start']);
$vote_count = votes::get_count_user_votes_per_poll($vote['ID']);
$vote['title'] = utf8_encode($vote['title']);
$vote['time_left'] = round($time_remain/($time_span+1)*100,0);
$vote['time_done'] = 100-$vote['time_left'];
$vote['full_vote_btn'] = $time_remain > 0 ? 'Abstimmen' : 'Ansehen';
$vote['uv'] = $vote['bt'] = '';
$vote['uv_count'] = $vote_count['count'] > 4 ? $vote_count['count'] : '< 5';
$user_vote = votes::getUserPollData($vote['ID']);
$vote['vote_class'] = $this->tablerow_class($user_vote);
if($user_vote){
//user vote
$vote['vote_class'] = $this->tablerow_class($user_vote);
//bt vote
$party_votes = votes::get_barsperparty($vote['ID']);
$vote['bt_vote_class'] = $this->tablerow_class($vote['bt_choice']);
foreach($party_votes as $pv){
$vote['bt'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote_bt.tpl'),
array( 'party' => $pv['party'],
'choice' => $this->get_party_per_poll($pv['choice']),
'choice_class' => $this->badge_class($pv['choice'])));
}
//uvote vote
$uvote = votes::get_users_choice_per_poll($vote['ID']);
$vote['uv_vote_class'] = count($uvote) > 0 ? $this->tablerow_class($uvote[0]['choice']) : '';
foreach($uvote as $v){
$vote['uv'] .= \SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote_uv.tpl'),
array( 'badge' => self::badge_class($v['choice']),
'perc' => $v['count'] > 0 ? round($v['count']/$vote_count['count']*100, 2) : 0));
}
}
if($time_remain > 0){
$result[0] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote.tpl'), $vote);
} else {
$result[1] .= SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/vote.tpl'), $vote);
}
}
return $result[0].$result[1];
}
public function html(){
$vars = array();
$vars['votelist'] = $this->generate_votelist();
$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, \SYSTEM\locale::getStrings(DBD\locale_string::VALUE_CATEGORY_MAINPAGE));
$vars = array_merge($vars, \SYSTEM\locale::getStrings(150));
$vars = array_merge($vars, \SYSTEM\locale::getStrings(110));
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'user_list_ended/ended.tpl'), $vars);
}
}