implemented database query for poll bars
This commit is contained in:
parent
ba878e5327
commit
c4e33fc943
@ -12,13 +12,30 @@ class votes {
|
||||
|
||||
return $result;
|
||||
}
|
||||
private static function getProgessbar($percentage){
|
||||
$vars = array('percentage' => $percentage);
|
||||
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/closedvoteinfo.tpl'), $vars);
|
||||
}
|
||||
public static function get_openinfo($poll_ID){
|
||||
$con = new \SYSTEM\DB\Connection(new \DBD\uVote());
|
||||
$res = $con->prepare( 'selVoteByID',
|
||||
'SELECT * FROM `uvote_votes` WHERE `ID` = ?;',
|
||||
array($poll_ID));
|
||||
$result = $res->next();
|
||||
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/openvoteinfo.tpl'),$result == NULL ? array() : $result);
|
||||
$res = $res->next();
|
||||
$result = array();
|
||||
$parties = array('cdu', 'spd', 'fdp', 'b90', 'linke');
|
||||
$pb = "";
|
||||
$part = $con->prepare( 'selVoteByPoll_ID',
|
||||
'SELECT * FROM `uvote_votes_per_party` WHERE `poll_ID` =' .$poll_ID.';',
|
||||
array($party, $votes_pro, $votes_contra, $nr_attending));
|
||||
foreach($parties as $party){
|
||||
$vars = array('votes_pro' => $party['votes_pro'], 'votes_contra' => $party['votes_contra'], 'nr_attending' => $party['nr_attending'],);
|
||||
$pb .= self::getProgessbar($votes_pro);
|
||||
}
|
||||
$result['graph_right'] = $pb;
|
||||
$result = array_merge($result,$res, $part);
|
||||
|
||||
return SYSTEM\PAGE\replace::replaceFile(SYSTEM\SERVERPATH(new PPAGE(),'default_page/openvoteinfo.tpl'),$result);
|
||||
}
|
||||
public static function write_vote($poll_ID, $vote){
|
||||
if(!\SYSTEM\SECURITY\Security::isLoggedIn()){
|
||||
|
||||
@ -38,6 +38,9 @@ class PageApi extends \SYSTEM\PAGE\PageClass {
|
||||
}
|
||||
|
||||
public static function action_developer(){
|
||||
require_once '../system/sai/autoload.inc.php';
|
||||
//require_once 'dasense/sai/autoload.inc.php';
|
||||
//require_once 'dasense/sai/register_modules.php';
|
||||
return new \SYSTEM\SAI\saigui();}
|
||||
|
||||
}
|
||||
@ -1,7 +1,3 @@
|
||||
<div class="span6" style="margin: 0;">
|
||||
<div class="hero_unit" style="margin: 0; padding: 20px; background-color: gainsboro; width: 95%;"
|
||||
<p>${text}</p>
|
||||
<li class="divider"></li>
|
||||
<p>${text}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="progress progress-info progress-striped">
|
||||
<div class="bar" style="width: ${percentage}%"></div>
|
||||
</div>
|
||||
@ -16,9 +16,9 @@ $(document).ready(function() {
|
||||
vote_click($(this).attr('poll_ID'),3);
|
||||
});
|
||||
|
||||
$('.btn_openvoteinfo').click(function () {
|
||||
$('.btn_openvoteinfo').click(function () {
|
||||
if($("#openvoteinfo"+$(this).attr('poll_ID')).is(':visible')){
|
||||
$('#openvoteinfo'+$(this).attr('poll_ID')).slideUp('slow');
|
||||
$('#openvoteinfo'+$(this).attr('poll_ID')).slideUp('slow');
|
||||
}else{
|
||||
load_openvoteinfo($(this).attr('poll_ID'));
|
||||
}
|
||||
@ -99,160 +99,13 @@ function load_openvoteinfo (poll_ID){
|
||||
}
|
||||
|
||||
function vote_click (poll_ID, vote) {
|
||||
$.get('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + '&vote=' + vote, function (data) {
|
||||
dataTmp = data;
|
||||
}).complete(function() {
|
||||
alert (poll_ID);
|
||||
});
|
||||
}
|
||||
|
||||
function loadAjaxContent(url) {
|
||||
var dataTmp;
|
||||
$.get(url, function (data) {
|
||||
dataTmp = data;
|
||||
bodyelem = $("html,body");
|
||||
bodyelem.animate();
|
||||
}).complete(function() {
|
||||
$('#site-content-wrapper').slideUp({duration: 'slow',
|
||||
complete: function(){
|
||||
$('#site-content').html(dataTmp);
|
||||
$('#site-content-wrapper').slideDown('slow');
|
||||
site_content_is_visible = true;
|
||||
}});
|
||||
});
|
||||
}
|
||||
function loadUrlPic(url_pic) {
|
||||
var dataTmp;
|
||||
$.get(url_pic, function (data) {
|
||||
dataTmp = data;
|
||||
bodyelem = $("html,body");
|
||||
bodyelem.animate();
|
||||
}).complete(function() {
|
||||
$('.carousel-inner').slideUp({duration: 'slow',
|
||||
complete: function(){
|
||||
$('#pic').html(dataTmp);
|
||||
$('.carousel-inner').slideDown('slow');
|
||||
site_content_is_visible = true;
|
||||
}});
|
||||
});
|
||||
}
|
||||
|
||||
function loadApiPic(id) {
|
||||
var dataTmp;
|
||||
$.get('./api.php?call=img&id='+id, function (data) {
|
||||
dataTmp = data;
|
||||
bodyelem = $("html,body");
|
||||
bodyelem.animate();
|
||||
}).complete(function() {
|
||||
|
||||
});
|
||||
}/* jQuery on document ready */
|
||||
$(document).ready(function() {
|
||||
// handle navigation link click
|
||||
$('.navbar ul li a').not('#menu_uvote').click(function () {
|
||||
loadAjaxContent($(this).attr('url'));
|
||||
|
||||
//loadUrlPic($(this).attr('url'));
|
||||
});
|
||||
$('.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);
|
||||
});
|
||||
|
||||
$('.btn_openvoteinfo').click(function () {
|
||||
alert ("#openvoteinfo"+$(this).attr('poll_ID')('time_end'));
|
||||
if($("#openvoteinfo"+$(this).attr('poll_ID')).not(":visible")){
|
||||
load_openvoteinfo($(this).attr('poll_ID'));
|
||||
}
|
||||
else{
|
||||
exit;
|
||||
$.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);
|
||||
}
|
||||
});
|
||||
// $('#register_btn').click(function () {
|
||||
// account_create ($(this).attr ('#inputEmail'))
|
||||
// });
|
||||
//jqBootstrapValidation
|
||||
$("#form_register input").not("[type=submit]").jqBootstrapValidation(
|
||||
{
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
// alert ('.api.php?call=account&action=create&username=' + $('#bt_login_user').val() + '&password_sha=' + $.sha1($('#bt_login_password').val()) + '&email=' + $('#bt_login_user').val() + '&locale=deDE');
|
||||
$.get('./api.php?call=account&action=create&username=' + $('#bt_login_user').val() + '&password_sha=' + $.sha1($('#bt_login_password').val()) + '&email=' + $('#bt_login_user').val() + '&locale=deDE', function (data) {
|
||||
if(data == 1){
|
||||
window.location.reload();
|
||||
} else {
|
||||
$('#help-block-user-password-combi-wrong').attr('style', 'display: block;');
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$("#form_login input").not("[type=submit]").jqBootstrapValidation(
|
||||
{
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
// alert ('.api.php?call=account&action=create&username=' + $('#bt_login_user').val() + '&password_sha=' + $.sha1($('#bt_login_password').val()) + '&email=' + $('#bt_login_user').val() + '&locale=deDE');
|
||||
$.get('./api.php?call=account&action=login&username=' + $('#login_email').val() + '&password_sha=' + $.sha1($('#login_password').val()) + '&password_md5=' + $.md5($('#login_password').val()), function (data) {
|
||||
if(data == 1){
|
||||
window.location.reload();
|
||||
} else {
|
||||
$('#help-block-user-password-combi-wrong').attr('style', 'display: block;');
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
$("#form_logout input").not("[type=submit]").jqBootstrapValidation(
|
||||
{
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
$.get('./api.php?call=account&action=logout', function (data) {
|
||||
window.location.reload();
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
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;
|
||||
}).complete(function() {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function load_openvoteinfo (poll_ID){
|
||||
var openvoteinfo;
|
||||
$.get('./api.php?call=vote&action=openinfo&poll_ID=' + poll_ID, function (data) {
|
||||
openvoteinfo = data;
|
||||
bodyelem = $("");
|
||||
bodyelem.animate();
|
||||
}).complete(function() {
|
||||
$('#openvoteinfo'+poll_ID).slideUp({duration: 'slow',
|
||||
complete: function(){
|
||||
$('#openvoteinfo'+poll_ID).html(openvoteinfo);
|
||||
$('#openvoteinfo'+poll_ID).slideDown('slow');
|
||||
site_content_is_visible = true;
|
||||
}});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
function vote_click (poll_ID, vote) {
|
||||
$.get('./api.php?call=vote&action=vote&poll_ID=' + poll_ID + '&vote=' + vote, function (data) {
|
||||
dataTmp = data;
|
||||
}).complete(function() {
|
||||
alert (poll_ID);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,15 @@
|
||||
${graph_right}
|
||||
<div class="span6" style="margin: 0;">
|
||||
<div class="hero_unit" style="margin: 0; padding: 20px; background-color: gainsboro; width: 95%;"
|
||||
<div class="hero_unit" style="margin: 0; padding: 20px; background-color: gainsboro; width: 95%;">
|
||||
<p>${text}</p>
|
||||
<li class="divider"></li>
|
||||
<p>${text}</p>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="hero_unit" style="width: 100%; padding: 0; margin: 0;">
|
||||
|
||||
</div>
|
||||
@ -8,7 +8,7 @@ box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.5);">
|
||||
<h3>${vote_title}</h3>
|
||||
|
||||
|
||||
<div class="span5" id="openvoteinfo${poll_ID}{time_end}" style="margin: 0; display: none;">
|
||||
<div class="span5" id="openvoteinfo${poll_ID}" style="margin: 0; display: none;">
|
||||
|
||||
</div>
|
||||
<br>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user