486 lines
16 KiB
PHP
486 lines
16 KiB
PHP
<?php
|
|
|
|
function addStartEventListeners()
|
|
{
|
|
// To tweek the scroll functionality specifically for Windows phone
|
|
// Added for Windows Phone
|
|
echo "if (window.navigator.msPointerEnabled) {";
|
|
echo "addEventListener('MSPointerDown', function(event) {";
|
|
echo "
|
|
|
|
// Store touche coordinates
|
|
coordinateY = event.clientY;
|
|
coordinateX = event.clientX;
|
|
|
|
move = false;
|
|
";
|
|
echo " },false);";
|
|
echo "} else {";
|
|
// To tweek the scroll functionality for others
|
|
echo "addEventListener('touchstart', function(event) {";
|
|
echo "
|
|
// Store touche coordinates
|
|
coordinateY = event.touches[0].clientY;
|
|
coordinateX = event.touches[0].clientX;
|
|
|
|
move = false;
|
|
";
|
|
echo " },false);";
|
|
echo "}";
|
|
}
|
|
|
|
|
|
function addMoveEventListeners()
|
|
{
|
|
// To tweek the scroll functionality specifically for Windows Phone
|
|
// Added for Windows Phone
|
|
echo "if (window.navigator.msPointerEnabled) {";
|
|
echo "addEventListener('MSPointerMove', function(event) {";
|
|
echo "
|
|
move = checkMoveTouch(coordinateY , event.clientY, coordinateX , event.clientX);
|
|
return false;
|
|
";
|
|
echo " },false);";
|
|
echo "} else {";
|
|
// To tweek the scroll functionality
|
|
echo "addEventListener('touchmove', function(event) {";
|
|
echo "
|
|
move = checkMoveTouch(coordinateY , event.touches[0].clientY, coordinateX , event.touches[0].clientX);
|
|
return false;
|
|
";
|
|
echo " },false);";
|
|
echo "}";
|
|
|
|
}
|
|
|
|
function addLoginEventListeners($buttonId)
|
|
{
|
|
echo"$('#" . $buttonId . "').on('tap', function(event) {";
|
|
// Prevent ghost click on iOS
|
|
echo "preventGhostClick(event);";
|
|
loginOrOut();
|
|
echo "});";
|
|
}
|
|
|
|
function loginOrOut()
|
|
{
|
|
global $_PAGE_INFO;
|
|
|
|
if (BUTTON_VIBRATE) {
|
|
// Vibrate when touch
|
|
echo "navigator.notification.vibrate(" . BUTTON_VIBRATE . ");";
|
|
}
|
|
|
|
// Check if there is internet connection
|
|
echo "if (Online){";
|
|
// Check if user is logged in on MTinfo
|
|
if(isset($_SESSION[$_PAGE_INFO['id']]['logged_on'])){
|
|
// Go to store en logout
|
|
echo "loadApp('?href=app/di_store/store_index.php','". ucfirst(strtolower(app_("Busy"))) . "...','". strtolower(app_("loading")) . "');";
|
|
}else{
|
|
// Go to login page
|
|
echo "loadApp('?id=" . $_PAGE_INFO['id'] . "&href=app/di_login/login.php','". ucfirst(strtolower(app_("Busy"))) . "...','". strtolower(app_("loading")) . "');";
|
|
}
|
|
echo "}else{";
|
|
echo "setToastAlert('" . strtoupper(app_('No internet connection')) . ". " . strtoupper(app_('Do you want to close the app')) . "?','" . app_('Ok') . "','" . app_('Cancel') . "','closeApp();');";
|
|
echo "}";
|
|
}
|
|
|
|
function addStoreButtonEventListeners($buttonId)
|
|
{
|
|
global $_PAGE_INFO;
|
|
|
|
echo "$('#" . $buttonId . "').on('tap', function(event) {
|
|
// Prevent ghost click on iOS
|
|
preventGhostClick(event);
|
|
// Set jquery mobile load spinner
|
|
$.mobile.showPageLoadingMsg();
|
|
// Go to store
|
|
loadApp('?id=" . $_PAGE_INFO['id'] . "&href=app/di_store/store_index.php','". ucfirst(strtolower(app_("Busy"))) . "','". ucfirst(strtolower(app_("loading"))) ."');
|
|
// hide jquery mobile load spinner
|
|
$.mobile.hidePageLoadingMsg();";
|
|
|
|
if(BUTTON_VIBRATE){
|
|
// Vibrate when touch
|
|
echo "navigator.notification.vibrate(" . BUTTON_VIBRATE . ");";
|
|
}
|
|
echo "});";
|
|
|
|
onButtonMouseLeave($buttonId, "app/Shopping_normal.png");
|
|
onButtonMouseEnter($buttonId, "app/Shopping_push.png");
|
|
}
|
|
|
|
function addHomeButtonMouseEventListeners($buttonId)
|
|
{
|
|
onButtonMouseLeave($buttonId, "app/Home_normal.png");
|
|
onButtonMouseEnter($buttonId, "app/Home_push.png");
|
|
}
|
|
|
|
function addRefreshButtonEventListeners($buttonId, $href, $projectname, $showMsg, $beforeAjaxPost = null)
|
|
{
|
|
echo "$('#" . $buttonId . "').on('tap', function(event) {";
|
|
// Prevent ghost click on iOS
|
|
echo "preventGhostClick(event);";
|
|
|
|
global $_PAGE_INFO;
|
|
|
|
if (BUTTON_VIBRATE) {
|
|
// Vibrate when touch
|
|
echo "navigator.notification.vibrate(" . BUTTON_VIBRATE . ");";
|
|
}
|
|
|
|
echo "if (Online){";
|
|
|
|
// Set jquery mobile load spinner
|
|
echo "$.mobile.showPageLoadingMsg();";
|
|
|
|
if ($beforeAjaxPost) {
|
|
echo $beforeAjaxPost . "();";
|
|
}
|
|
|
|
// Nothing to do already in home page of projecten
|
|
echo "ajax_post('". $projectname ."','refresh','?id=" . $_PAGE_INFO['id'] . "&href=" . $href . "','". $showMsg ."');";
|
|
echo "}else{
|
|
setToastAlert('" . app_('No internet connection') . "','" . app_('Ok') . "');
|
|
}";
|
|
echo "});";
|
|
|
|
addRefreshButtonMouseEventListeners($buttonId);
|
|
}
|
|
|
|
function addRefreshButtonMouseEventListeners($buttonId)
|
|
{
|
|
onButtonMouseLeave($buttonId, "app/refresh_button_normal.png");
|
|
onButtonMouseEnter($buttonId, "app/refresh_button_push.png");
|
|
}
|
|
|
|
function onButtonMouseEnter($buttonId, $relativeImagePath) {
|
|
onButtonEventChangeImage($buttonId, $relativeImagePath, 'mouseenter vmouseover');
|
|
}
|
|
|
|
function onButtonMouseLeave($buttonId, $relativeImagePath) {
|
|
echo "$('#" . $buttonId . "').on('mouseleave vmouseout', function() {
|
|
// Add slight delay to prevent the button from being stuck in the 'pressed' state
|
|
setTimeout(function(){
|
|
// Change background color of image (push button)
|
|
$('#" . $buttonId . "').css('background-image','url(" . IMAGES_PATH . $relativeImagePath . ")');
|
|
}, 5);";
|
|
echo "});";
|
|
}
|
|
|
|
function onButtonEventChangeImage($buttonId, $relativeImagePath, $event) {
|
|
echo "$('#" . $buttonId . "').on('". $event ."', function() {
|
|
// Change background color of image (push button)
|
|
$('#" . $buttonId . "').css('background-image','url(" . IMAGES_PATH . $relativeImagePath . ")');";
|
|
echo "});";
|
|
}
|
|
|
|
function addCommentEventListeners($docx_id, $number_commentsx, $comment_clicked)
|
|
{
|
|
echo"$('#document_comment_drop_down_up_" . $docx_id . "').on('tap', function(event) {";
|
|
// Prevent ghost click on iOS
|
|
echo "preventGhostClick(event);";
|
|
commentEnd($docx_id, $number_commentsx, $comment_clicked);
|
|
echo "});";
|
|
}
|
|
|
|
function commentEnd($docx_id, $number_commentsx, $comment_clicked)
|
|
{
|
|
// Check click event
|
|
echo "if((typeof comment_clicked[".$docx_id."] == 'undefined') || (comment_clicked[".$docx_id."] == '0')){";
|
|
|
|
// Only one comment open at the time
|
|
echo "if(typeof docj_id == 'undefined'){
|
|
docj_id = '" . $docx_id . "';
|
|
number_commentsj = '" . $number_commentsx . "';
|
|
}else{
|
|
deleteCommentBox( docj_id,'" . IMAGES_PATH . "app/',number_commentsj);
|
|
docj_id = '" . $docx_id . "';
|
|
number_commentsj = '" . $number_commentsx . "';
|
|
}";
|
|
|
|
// change onclick event when comment isn't close by the "-" sign
|
|
// but to open an other comment so the onclick event wasn't change
|
|
echo "if(typeof getstoreCommentClicked() != 'undefined'){
|
|
var test = getstoreCommentClicked();
|
|
comment_clicked[test] = '0'
|
|
}";
|
|
|
|
if(BUTTON_VIBRATE){
|
|
// Vibrate when touch
|
|
echo "navigator.notification.vibrate(" . BUTTON_VIBRATE . ");";
|
|
}
|
|
|
|
// Check en download and open the selected file
|
|
echo "showCommentBox('" . $docx_id . "','" . IMAGES_PATH . "app/','" . $number_commentsx . "');";
|
|
|
|
// Store id, imagepath and nr of comments
|
|
echo "storeComment('" . $docx_id . "','" . IMAGES_PATH . "app/', '" . $number_commentsx . "');";
|
|
|
|
// Store open/close variable
|
|
echo "storeCommentClicked('" . $docx_id . "');";
|
|
|
|
// Set other click event
|
|
echo "comment_clicked[".$docx_id."] = '1'";
|
|
|
|
echo"}else{";
|
|
if(BUTTON_VIBRATE){
|
|
// Vibrate when touch
|
|
echo "navigator.notification.vibrate(" . BUTTON_VIBRATE . ");";
|
|
}
|
|
|
|
echo "deleteCommentBox('" . $docx_id . "','" . IMAGES_PATH . "app/','" . $number_commentsx . "');";
|
|
|
|
// Set other click event
|
|
echo "comment_clicked[".$docx_id."] = '0'";
|
|
|
|
echo"}";
|
|
}
|
|
|
|
function addDocumentEventListeners($docx_id, $docx_url, $docx_downpath, $docx_openpath, $docx_filesize, $mimetypex)
|
|
{
|
|
echo"$('#doc_" . $docx_id . "').on('tap', function(event) {";
|
|
// Prevent ghost click on iOS
|
|
echo "preventGhostClick(event);";
|
|
documentEnd($docx_url, $docx_downpath, $docx_openpath, $docx_filesize, $mimetypex);
|
|
echo " });";
|
|
}
|
|
|
|
function documentEnd($docx_url, $docx_downpath, $docx_openpath, $docx_filesize, $mimetypex)
|
|
{
|
|
global $_PAGE_INFO;
|
|
|
|
if(BUTTON_VIBRATE){
|
|
// Vibrate when touch
|
|
echo "navigator.notification.vibrate(" . BUTTON_VIBRATE . ");";
|
|
}
|
|
|
|
// Check if it's not an app portal
|
|
if(!isset($_SESSION[$_PAGE_INFO['id']]['APP_PORTAL'])){
|
|
// Normal app
|
|
|
|
// Check device
|
|
if(stristr($_SERVER['HTTP_USER_AGENT'], "MTINFO_APP_ANDROID") !== FALSE){
|
|
// Android
|
|
|
|
// Check en download and open the selected file
|
|
echo "checkIfFileExists('" . $docx_url . "','" . $docx_downpath . "','" . $mimetypex . "','" . $docx_openpath . "','" . strtoupper(app_('No sdcard inserted')) . "','" . strtoupper(app_('Ok')) ."','" . $docx_filesize . "');";
|
|
}else if(stristr($_SERVER['HTTP_USER_AGENT'], "MTINFO_APP_IOS") !== FALSE){
|
|
//iOS
|
|
// Download and open the file
|
|
echo "checkIfFileExists('" . $docx_url . "','" . $docx_downpath . "','iOS','" . $docx_openpath . "','" . strtoupper(app_('No sdcard inserted')) . "','" . strtoupper(app_('Ok')) ."','" . $docx_filesize . "');";
|
|
}else if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']),"msapphost") !== FALSE || strpos(strtolower($_SERVER['HTTP_USER_AGENT']),"windows phone") !== FALSE) {
|
|
// WP8
|
|
// Download and open the file
|
|
echo "checkIfFileExists('" . $docx_url . "','" . $docx_downpath . "','windows','" . $docx_openpath . "','" . strtoupper(app_('No sdcard inserted')) . "','" . strtoupper(app_('Ok')) . "','" . $docx_filesize . "');";
|
|
}
|
|
}else{
|
|
// Portal app
|
|
echo "downloadFilePortal('" . $docx_url . "');";
|
|
}
|
|
}
|
|
|
|
function addGlobeEventListeners($docx_id, $docx)
|
|
{
|
|
echo"$('#globe_" . $docx_id . "').on('tap', function(event) {";
|
|
// Prevent ghost click on iOS
|
|
echo "preventGhostClick(event);";
|
|
globeEnd($docx);
|
|
echo " });";
|
|
}
|
|
|
|
function globeEnd($docx)
|
|
{
|
|
global $_PAGE_INFO;
|
|
|
|
if(BUTTON_VIBRATE){
|
|
// Vibrate when touch
|
|
echo "navigator.notification.vibrate(" . BUTTON_VIBRATE . ");";
|
|
}
|
|
|
|
// Check of Portal App
|
|
if(!isset($_SESSION[$_PAGE_INFO['id']]['APP_PORTAL'])){
|
|
// Normal app
|
|
|
|
// Check device platform
|
|
echo"
|
|
switch(device.platform){
|
|
case 'Android':
|
|
_device ='Android';
|
|
// Call maps or earth (user can choose)
|
|
var ref = window.open('geo:" . $docx['latitude'] . "," . $docx['longitude'] . "', '_system');
|
|
break;
|
|
|
|
case 'iOS':
|
|
_device ='iOS';
|
|
// Call google maps browser with the coordinates
|
|
var ref = window.open('https://maps.google.com/?q=" . $docx['latitude'] . "," . $docx['longitude'] . "', '_system');
|
|
break;
|
|
|
|
case 'windows':
|
|
_device ='windows';
|
|
// Call google maps browser with the coordinates
|
|
var ref = window.open('https://maps.google.com/?q=" . $docx['latitude'] . "," . $docx['longitude'] . "', '_blank', 'location=yes;fullscreen=yes');
|
|
break;
|
|
|
|
default:
|
|
var ref = window.open('https://maps.google.com/?q=" . $docx['latitude'] . "," . $docx['longitude'] . "', '_system');
|
|
break;
|
|
}";
|
|
}else{
|
|
|
|
// Portal app
|
|
echo"var ref = window.open('https://maps.google.com/?q=" . $docx['latitude'] . "," . $docx['longitude'] . "', '_system');";
|
|
}
|
|
}
|
|
|
|
function addSaveChangesEventListeners($buttonId, $profile_id)
|
|
{
|
|
echo"$('#" . $buttonId . "').on('tap', function(event) {";
|
|
// Prevent ghost click on iOS
|
|
echo "preventGhostClick(event);";
|
|
saveChanges($profile_id);
|
|
echo "});";
|
|
}
|
|
|
|
|
|
function saveChanges($profile_id)
|
|
{
|
|
global $_PAGE_INFO;
|
|
|
|
// To tweek the scroll functionality
|
|
echo " // Check if all fields are filled in
|
|
if($('#firstname').val() && $('#lastname').val() && $('#email').val() && $('#mobilenr').val() && $('#dvpnumber').val() && $('#company').val() && $('#function').val() && $('#dvpphoto_1').val()){
|
|
|
|
$.mobile.showPageLoadingMsg();
|
|
|
|
var user_input = {};
|
|
|
|
// Clear array
|
|
user_input = {};
|
|
|
|
// Store qeustion and answer
|
|
user_input['firstname'] = $('#firstname').val();
|
|
user_input['lastname'] = $('#lastname').val();
|
|
user_input['email'] = $('#email').val();
|
|
user_input['mobilenr'] = $(mobilenr).val();
|
|
user_input['dvpnumber'] = $('#dvpnumber').val();
|
|
|
|
// Check if firstaid is checked
|
|
if($('#firstaid').prop('checked')){
|
|
user_input['firstaid'] = 'yes';
|
|
}else{
|
|
user_input['firstaid'] = 'no';
|
|
}
|
|
|
|
user_input['company'] = $('#company').val();
|
|
user_input['function'] = $('#function').val();
|
|
user_input['dvpphoto_1'] = $('#dvpphoto_1').val();
|
|
user_input['profile_id'] = " . $profile_id . ";
|
|
|
|
// Parse array so it can be send with ajax_post
|
|
var json_user_input = JSON.stringify(user_input);
|
|
|
|
// call add profile page
|
|
ajax_post(encodeURIComponent(json_user_input),'change_profile','?id=" . $_PAGE_INFO['id'] . "&href=app/di_app_profile/store_profile.php','');
|
|
}else{
|
|
setToastAlert('" . app_('All fields must be filled in') . "','" . app_('Ok') . "','','','','','');
|
|
}
|
|
|
|
if(" .BUTTON_VIBRATE ."){
|
|
// Vibrate when touch
|
|
navigator.notification.vibrate(" . BUTTON_VIBRATE . ");
|
|
}";
|
|
}
|
|
|
|
|
|
function addDeleteProfileButtonEventListeners($buttonId)
|
|
{
|
|
echo"$('#" . $buttonId . "').on('tap', function(event) {";
|
|
// Prevent ghost click on iOS
|
|
echo "preventGhostClick(event);";
|
|
deleteProfile();
|
|
echo " });";
|
|
}
|
|
|
|
function deleteProfile()
|
|
{
|
|
global $_PAGE_INFO;
|
|
|
|
echo "$.mobile.showPageLoadingMsg();
|
|
|
|
// call add profile page
|
|
ajax_post('','delete_profile','?id=" . $_PAGE_INFO['id'] . "&href=app/di_app_profile/store_profile.php','');
|
|
|
|
if(" .BUTTON_VIBRATE ."){
|
|
// Vibrate when touch
|
|
navigator.notification.vibrate(" . BUTTON_VIBRATE . ");
|
|
}";
|
|
}
|
|
|
|
|
|
function addSigninCodeEventListeners($projectx,$user)
|
|
{
|
|
echo"$('#signin_" . $projectx['id'] . "').on('tap', function(event) {";
|
|
// Prevent ghost click on iOS
|
|
echo "preventGhostClick(event);";
|
|
signinCode($projectx,$user);
|
|
echo " });";
|
|
}
|
|
|
|
function signinCode($projectx,$user){
|
|
// To tweek the scroll functionality
|
|
echo "
|
|
if(Online){";
|
|
if (BUTTON_VIBRATE) {
|
|
// Vibrate when touch
|
|
echo "navigator.notification.vibrate(" . BUTTON_VIBRATE . ");";
|
|
}
|
|
|
|
$settings['project'] = $projectx['id'];
|
|
$settings['user'] = $user;
|
|
|
|
// Get signin code
|
|
$project_signin = db_fetch_project_user_login_code($settings);
|
|
|
|
// Check if project is released (not released no code in db)
|
|
if(isset($project_signin['code']) && !empty($project_signin['code'])){
|
|
$project_code = strtoupper(app_('Signin code')) . "<br>" . strtoupper($project_signin['code']);
|
|
}else{
|
|
$project_code = strtoupper(app_('Project has not been released!'));
|
|
}
|
|
|
|
echo"
|
|
|
|
// Create delay else onclick event of toaster will fire
|
|
setTimeout(function(){
|
|
setToastAlert('" . $project_code . "','" . app_('Ok') . "');
|
|
},50)
|
|
|
|
|
|
}else{
|
|
setToastAlert('" . app_('No internet connection') . "','" . app_('Ok') . "');
|
|
}";
|
|
}
|
|
|
|
function AddEventListenerTrash($id,$volgnummer,$chapter,$active_onclick){
|
|
echo"$('#" . $id . "').on('tap', function(event) {";
|
|
// Prevent ghost click on iOS
|
|
echo "preventGhostClick(event);";
|
|
AddedTrash($volgnummer,$chapter,$active_onclick);
|
|
echo "});";
|
|
}
|
|
|
|
function AddedTrash($volgnummer,$chapter,$active_onclick){
|
|
global $_PAGE_INFO;
|
|
if($active_onclick){
|
|
echo"
|
|
// Show loader
|
|
$.mobile.showPageLoadingMsg();
|
|
|
|
ajax_post('". $volgnummer."','" . $chapter['enquete'] . "','?id=" . $_PAGE_INFO['id'] . "&href=app/di_app_projects/delete_item_trash.php','');
|
|
";
|
|
}
|
|
}
|
|
|
|
?>
|