diff options
Diffstat (limited to '')
-rw-r--r-- | main/survey/app/Controllers/JsController.php | 150 |
1 files changed, 125 insertions, 25 deletions
diff --git a/main/survey/app/Controllers/JsController.php b/main/survey/app/Controllers/JsController.php index c9699f8..308fb41 100644 --- a/main/survey/app/Controllers/JsController.php +++ b/main/survey/app/Controllers/JsController.php @@ -14,13 +14,13 @@ use App\Controllers\HelperController as Helper; use App\Models\Model;
use Cache;
use enkaParameters;
-use Mobile_Detect;
use SurveyAdvancedParadataLog;
use SurveyInfo;
use SurveySetting;
use SurveySlideshow;
use Common;
use SurveyPanel;
+use AppSettings;
class JsController extends Controller
{
@@ -64,7 +64,7 @@ class JsController extends Controller {
global $lang;
global $site_url;
- global $secret_captcha;
+ global $site_domain;
global $admin_type;
// Dodaten text pri alertu ce smo v testnem vnosu
@@ -254,8 +254,23 @@ class JsController extends Controller return regex.test(email);
}
+ var missing_hidden = false;
function showMissing(id) {
+
+ // Si zapomnimo, ce so bili missingi skriti - posebej za CDI anketo za posebno vprasanje
+ if($(id).find('.missing:visible').length == 0){
+ missing_hidden = true;
+ }
+ else{
+ missing_hidden = false;
+ }
+
+ // Naknadno prikazemo missing vrednosti
$(id).find('.missing').slideDown();
+
+ // Prikazemo missinge se v dropdownu
+ $(id).find('.active-result').show();
+ $(id).find('option').show();
}
<?
@@ -268,6 +283,7 @@ class JsController extends Controller echo ' var text_num = true; ' . "\n";
echo ' var checkbox_min_limit_alert = false; ' . "\n";
+ $require = '';
$sql = sisplet_query("SELECT * FROM srv_spremenljivka WHERE gru_id='" . get('grupa') . "' AND gru_id != '0' AND reminder > 0 ORDER BY vrstni_red ASC");
while ($row = mysqli_fetch_array($sql)) {
@@ -424,10 +440,9 @@ class JsController extends Controller submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false);
}
';
-
-
- // dropdown
- } elseif ($row['tip'] == 3) {
+ }
+ // dropdown
+ elseif ($row['tip'] == 3) {
$ime = 'vrednost_' . $row['id'];
@@ -438,11 +453,10 @@ class JsController extends Controller echo ' } else { ' . "\n";
echo ' submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
echo ' } ' . "\n";
-
- } //tabele @ drag and drop
+ }
+ // tabele @ drag and drop
elseif (($row['tip'] == 6 && $row['enota'] == 9) || ($row['tip'] == 16 && $row['enota'] == 9)) {
echo '
- //console.log("Drag and drop Tabela en odgovorov");
var bol = true;
var prisotno = $("#half_frame_dropping_' . $row['id'] . '").children("div").attr("value");
if (prisotno){
@@ -454,13 +468,27 @@ class JsController extends Controller }else{
submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'' . $require . '\', \'' . $bol . '\', validation, false, false, false, false);
}
-
-
';
+ }
+ // tabela - max diff
+ elseif ($row['tip'] == 6 && $row['enota'] == 5) {
- // tabele
- //} elseif ($row['tip'] == 6 || $row['tip'] == 16 || $row['tip'] == 19 || $row['tip'] == 20) {
- } elseif (($row['tip'] == 6 && $row['enota'] != 9) || $row['tip'] == 16 || $row['tip'] == 19 || $row['tip'] == 20) {
+ echo ' var bol = false; ' . "\n";
+
+ // Preverimo, ce sta oznaceni vrednosti 1 in 2 (min max)
+ echo ' if ($(\'#spremenljivka_'.$row['id'].'\').find(\'input[value="1"]\').is(\':checked\') && $(\'#spremenljivka_'.$row['id'].'\').find(\'input[value="2"]\').is(\':checked\')) { ' . "\n";
+ echo ' var bol = true; ' . "\n";
+ echo ' } ' . "\n";
+
+ echo ' if (!bol) { ' . "\n";
+ echo ' ' . $bol . ' = false; ' . "\n";
+ echo ' if (!validation) submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'add\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } else { ' . "\n";
+ echo ' if (!validation) submitAlert(\'#spremenljivka_' . $row['id'] . '\', \'remove\', \'require\', \'' . $bol . '\', validation, false, false, false, false); ' . "\n";
+ echo ' } ' . "\n";
+ }
+ // tabele
+ elseif (($row['tip'] == 6 && $row['enota'] != 9) || $row['tip'] == 16 || $row['tip'] == 19 || $row['tip'] == 20) {
echo ' var totalbol = true; ';
@@ -1015,7 +1043,7 @@ class JsController extends Controller // najprej damo pogoj, da se uposteva, samo ce je vprasanje vidno (ker je lahko v ifu)
//echo ' if ( $(\'#spremenljivka_'.$row['id'].'\').css(\'display\') != \'none\' ) { ' ."\n";
- echo ' if ( document.getElementById(\'spremenljivka_' . $row['id'] . '\').style.display != \'none\' ) { ' . "\n";
+ echo ' if ( $(\'#spremenljivka_' . $row['id'] . '\').length && document.getElementById(\'spremenljivka_' . $row['id'] . '\').style.display != \'none\' ) { ' . "\n";
// vsota
if ($row['tip'] == 18) {
@@ -1219,7 +1247,7 @@ class JsController extends Controller }
- if (isset($_GET['disablealert']) && $_GET['disablealert'] == 1) {
+ if (isset($_GET['disableif']) && $_GET['disableif'] == 1) {
echo ' vsota = true; ' . "\n";
echo ' hard = true; ' . "\n";
echo ' soft = true; ' . "\n";
@@ -1330,6 +1358,17 @@ class JsController extends Controller echo ' alert(\'' . $srv_remind_hard_98 . '\'); ' . "\n";
echo ' else if(\'' . $require . '\' == \'require4\') ' . "\n";
echo ' alert(\'' . $srv_remind_hard_97 . '\'); ' . "\n";
+
+ // alert za posebno vprasanje za SURS anketo 113 (1ka.cdi.si)
+ echo '
+ else if(\'' . $site_domain . '\' == \'1ka.cdi.si\' && \'' . $require . '\' == \'require5\' && \'' . $require . '\' == \'require5\' && $(\'#spremenljivka_18178\').length){
+
+ if(!missing_hidden){
+ alert(\'' . $lang['srv_remind_hard2'] . '\');
+ }
+
+ } ' . "\n";
+
echo ' else if(\'' . $require . '\' == \'require5\') ' . "\n";
echo ' alert(\'' . $srv_remind_hard_multi . '\'); ' . "\n";
echo ' else ' . "\n";
@@ -1593,7 +1632,7 @@ class JsController extends Controller $this->generateComputeJS();
// ce je preverjanje pogojev izklopljeno
- if ($_GET['disableif'] != 1) {
+ if (!isset($_GET['disableif']) || $_GET['disableif'] != 1) {
$this->generateBranching();
@@ -1800,8 +1839,8 @@ class JsController extends Controller }
}
- // roleta
- else if ($row['tip'] == 3) {
+ // roleta - desktop
+ else if ($row['tip'] == 3 && get('mobile') == 0) {
echo ' try { ' . "\n";
echo ' if ( ';
$this->generateCondition($row['if_id']);
@@ -1818,8 +1857,26 @@ class JsController extends Controller echo ' } catch (e) {} ' . "\n";
}
+ // roleta - mobile ali tablica
+ else if ($row['tip'] == 3 && get('mobile') != 0) {
+ echo ' try { ' . "\n";
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n";
+
+ echo ' } else { ' . "\n";
+ echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n";
+
+ echo ' } ' . "\n";
+
+ echo $sum;
+
+ echo ' } catch (e) {} ' . "\n";
+ }
// ranking premikanje
- else if ($row['tip'] == 17 && $row['design'] == 2) {
+ else if ($row['tip'] == 17 && $row['design'] == 2 && get('mobile') == '0') {
echo ' try { ' . "\n";
echo ' if ( ';
$this->generateCondition($row['if_id']);
@@ -1839,14 +1896,15 @@ class JsController extends Controller echo ' } catch (e) {} ' . "\n";
}
// ranking prestavljanje
- else if ($row['tip'] == 17 && $row['design'] == 0) {
+ else if ($row['tip'] == 17 && $row['design'] == 0 && get('mobile') == '0') {
+
echo ' try { ' . "\n";
echo ' if ( ';
$this->generateCondition($row['if_id']);
echo ' ) { ' . "\n";
echo ' document.getElementById(\'spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').style.display = \'\'; ' . "\n";
-
+
echo ' } else { ' . "\n";
echo ' $(\'#spremenljivka_' . $row['spr_id'] . '_vrednost_' . $row['id'] . '\').hide(); ' . "\n";
@@ -1854,10 +1912,52 @@ class JsController extends Controller echo ' } ' . "\n";
+
+ // Pri rankingu prestejemo in skrijemo tudi prazne okvirje na desni
+ // Prestejemo skrite
+ echo ' var count = $(\'#prestavljanje_'.$row['spr_id'].'\').find(\'.ranking:hidden\').length; ' . "\n";
+
+ // Prikazemo vse
+ echo ' $(\'#prestavljanje_'.$row['spr_id'].'\').find(\'.dropholder\').find(\'ul li\').show(); ' . "\n";
+
+ // Skrijemo toliko okvirjev kolikor je skritih elementov
+ echo ' for(var i=0; i<count; i++){ $(\'#prestavljanje_'.$row['spr_id'].'\').find(\'.dropholder\').find(\'ul li:visible\').last().hide(); }' . "\n";
+
+
echo $sum;
echo ' } catch (e) {} ' . "\n";
}
+ // ranking ostevilcevanje
+ else if ($row['tip'] == 17 && ($row['design'] == 1 || get('mobile') != '0')) {
+
+ echo ' try { ' . "\n";
+ echo ' if ( ';
+ $this->generateCondition($row['if_id']);
+ echo ' ) { ' . "\n";
+
+ echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'\'; ' . "\n";
+
+ echo ' } else { ' . "\n";
+ echo ' document.getElementById(\'vrednost_if_' . $row['id'] . '\').style.display = \'none\'; ' . "\n";
+
+ echo ' } ' . "\n";
+
+
+ // Pri rankingu prestejemo in skrijemo tudi odvecne vrednosti v dropdownu
+ // Prestejemo vidne
+ echo ' var count_visible = $(\'#spremenljivka_'.$row['spr_id'].'\').find(\'.variabla:visible\').length; ' . "\n";
+
+ // Na novo napolnimo select
+ echo ' $(\'#spremenljivka_'.$row['spr_id'].'\').find(\'select\').empty()' . "\n";
+ echo ' $(\'#spremenljivka_'.$row['spr_id'].'\').find(\'select\').append(\'<option></option>\')' . "\n";
+ echo ' for(var i=1; i<=count_visible; i++){ $(\'#spremenljivka_'.$row['spr_id'].'\').find(\'select\').append(\'<option value="\'+i+\'">\'+i+\'</option>\'); }' . "\n";
+
+
+ echo $sum;
+
+ echo ' } catch (e) {} ' . "\n";
+ }
else {
if ($spremenljivka_dd == $row['spr_id'] && ($orientation_dd == 8 || $enota_dd == 9)) {//ce je drag and drop
echo ' try { ' . "\n";
@@ -2076,7 +2176,7 @@ class JsController extends Controller mt_srand((int)get('usr_id') + (int)$rowb['id']);
// Zgeneriramo random vrstni red
- $order = array_map(create_function('$val', 'return mt_rand();'), range(1, count($questions)));
+ $order = array_map(function($val){return mt_rand();}, range(1, count($questions)));
array_multisort($order, $questions);
$order_in_block = json_encode($questions);
@@ -2104,7 +2204,7 @@ class JsController extends Controller mt_srand((int)get('usr_id') + (int)$rowb['id']);
// Zgeneriramo random vrstni red
- $order = array_map(create_function('$val', 'return mt_rand();'), range(1, count($blocks)));
+ $order = array_map(function($val){return mt_rand();}, range(1, count($blocks)));
array_multisort($order, $blocks);
$order_in_block = json_encode($blocks);
@@ -2716,7 +2816,7 @@ class JsController extends Controller $browser_detect = get_browser($useragent, true);
- $detect = New Mobile_Detect();
+ $detect = New \Detection\MobileDetect;
$detect->setUserAgent($useragent);
// Detect naprave (pc, mobi, tablet, robot)
|