| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage com_vikbooking |
| 5 |
* @author Alessio Gaggii - e4j - Extensionsforjoomla.com |
| 6 |
* @copyright Copyright (C) 2018 e4j - Extensionsforjoomla.com. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 12 |
|
| 13 |
$lic_key = $this->lic_key; |
| 14 |
$lic_date = $this->lic_date; |
| 15 |
$is_pro = $this->is_pro; |
| 16 |
|
| 17 |
JText::script('VBOUPDCOMPLOKCLICK'); |
| 18 |
JText::script('VBOUPDCOMPLNOKCLICK'); |
| 19 |
|
| 20 |
?> |
| 21 |
<div class="viwppro-cnt vikwppro-download"> |
| 22 |
<div class="vikwppro-header"> |
| 23 |
<div class="vikwppro-header-inner"> |
| 24 |
<div class="vikwppro-download-result"> |
| 25 |
<h2><?php VikBookingIcons::e('refresh', 'fa-spin'); ?> <?php echo JText::translate('VBOPROPLWAIT'); ?></h2> |
| 26 |
<h3 class="vikwppro-cur-action"><?php echo JText::translate('VBOPRODLINGPKG'); ?></h3> |
| 27 |
</div> |
| 28 |
<div class="vikwppro-download-progress"> |
| 29 |
<progress value="0" max="100" id="vikwpprogress"></progress> |
| 30 |
</div> |
| 31 |
</div> |
| 32 |
</div> |
| 33 |
<?php |
| 34 |
if (!empty($this->changelog)) { |
| 35 |
?> |
| 36 |
<div class="vikwppro-changelog-wrap"> |
| 37 |
<div class="vikwppro-plg-changelog"> |
| 38 |
<?php echo $this->changelog; ?> |
| 39 |
</div> |
| 40 |
</div> |
| 41 |
<?php |
| 42 |
} |
| 43 |
?> |
| 44 |
</div> |
| 45 |
|
| 46 |
<script type="text/javascript"> |
| 47 |
var vikwprunning = false; |
| 48 |
var vikwcomplete = false; |
| 49 |
|
| 50 |
/** |
| 51 |
* Start the download request |
| 52 |
*/ |
| 53 |
function vikwpStartDownload() { |
| 54 |
if (vikwprunning) { |
| 55 |
return; |
| 56 |
} |
| 57 |
|
| 58 |
// start progress |
| 59 |
vikwprunning = true; |
| 60 |
dispatchProgress(); |
| 61 |
|
| 62 |
// request |
| 63 |
VBOCore.doAjax( |
| 64 |
"<?php echo VikBooking::ajaxUrl('admin.php?option=com_vikbooking&task=license.downloadpro'); ?>", |
| 65 |
{ |
| 66 |
key: "<?php echo $lic_key; ?>" |
| 67 |
}, |
| 68 |
(res) => { |
| 69 |
if (res.indexOf('e4j.error') >= 0 || res.indexOf('e4j.OK') < 0) { |
| 70 |
vikwpStopMonitoring(false); |
| 71 |
alert(res.replace("e4j.error.", "")); |
| 72 |
return; |
| 73 |
} |
| 74 |
// request was successful |
| 75 |
vikwpStopMonitoring(true); |
| 76 |
}, |
| 77 |
(err) => { |
| 78 |
console.error(err); |
| 79 |
// stop the request |
| 80 |
vikwpStopMonitoring(false); |
| 81 |
// display error |
| 82 |
alert(err.responseText || 'Request Failed'); |
| 83 |
} |
| 84 |
); |
| 85 |
} |
| 86 |
|
| 87 |
function vikwpStopMonitoring(result) { |
| 88 |
vikwcomplete = true; |
| 89 |
vikwprunning = false; |
| 90 |
jQuery('#vikwpprogress').attr('value', 100); |
| 91 |
if (result === true) { |
| 92 |
var continuebtn = '<p><button type="button" class="button button-primary" onclick="document.location.href=\'admin.php?option=com_vikbooking\';">'+Joomla.JText._('VBOUPDCOMPLOKCLICK')+'</button></p>'; |
| 93 |
jQuery('.vikwppro-download-result').html('<h1 class="vikwp-download-success"><?php VikBookingIcons::e('check'); ?></h1>'+continuebtn); |
| 94 |
} else { |
| 95 |
var continuebtn = '<p><button type="button" class="button" onclick="document.location.href=\'admin.php?option=com_vikbooking&view=gotopro\';">'+Joomla.JText._('VBOUPDCOMPLOKCLICK')+'</button></p>'; |
| 96 |
jQuery('.vikwppro-download-result').html('<h1 class="vikwp-download-error"><?php VikBookingIcons::e('times'); ?></h1>'+continuebtn); |
| 97 |
jQuery('#vikwpprogress').hide(); |
| 98 |
} |
| 99 |
} |
| 100 |
|
| 101 |
function dispatchProgress() { |
| 102 |
setTimeout(function() { |
| 103 |
if (vikwcomplete) { |
| 104 |
jQuery('#vikwpprogress').attr('value', 100); |
| 105 |
return; |
| 106 |
} |
| 107 |
var curprogress = parseInt(jQuery('#vikwpprogress').attr('value')); |
| 108 |
var nextstep = Math.floor(Math.random() * 5) + 6; |
| 109 |
if ((curprogress + nextstep) > 100) { |
| 110 |
curprogress = 100; |
| 111 |
} else { |
| 112 |
curprogress += nextstep; |
| 113 |
} |
| 114 |
jQuery('#vikwpprogress').attr('value', curprogress); |
| 115 |
if (curprogress < 100) { |
| 116 |
dispatchProgress(); |
| 117 |
} |
| 118 |
}, (Math.floor(Math.random() * 501) + 750)); |
| 119 |
} |
| 120 |
|
| 121 |
jQuery(function() { |
| 122 |
vikwpStartDownload(); |
| 123 |
}); |
| 124 |
</script> |
| 125 |
|