Files
opensourcepos/application/views/partial/header_js.php
jekkos 7b674b2e3f Fix submit in items, customers and sales (#716)
Add again new button functionality in items (#712)
Bugfixes for csrf tokens (#599)
2016-07-04 23:20:14 +02:00

40 lines
1.2 KiB
PHP

<script type="text/javascript">
// live clock
var clock_tick = function clock_tick() {
setInterval('update_clock();', 1000);
}
// start the clock immediatly
clock_tick();
var update_clock = function update_clock() {
document.getElementById('liveclock').innerHTML = moment().format("<?php echo dateformat_momentjs($this->config->item('dateformat').' '.$this->config->item('timeformat'))?>");
}
$.notifyDefaults({ placement: {
align: '<?php echo $this->config->item('config_notify_horizontal_position'); ?>',
from: '<?php echo $this->config->item('config_notify_vertical_position'); ?>'
}});
var post = $.post;
var csrf_token = function() {
return Cookies.get('<?php echo $this->config->item('csrf_cookie_name'); ?>');
};
var csrf_form_base = function() {
return { <?php echo $this->security->get_csrf_token_name(); ?> : function () { return csrf_token(); } };
};
$.post = function() {
post.call(this, arguments[0], $.extend(arguments[1], csrf_form_base()));
};
var setup_csrf_token = function() {
$('input[name="<?php echo $this->security->get_csrf_token_name(); ?>"]').val(csrf_token());
};
setup_csrf_token();
$(document).ajaxComplete(setup_csrf_token);
</script>