Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8
[1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560
[2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85
[3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50
[4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13
[5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
403WebShell
403Webshell
Server IP : 94.177.8.99  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64
User : www-data ( 33)
PHP Version : 8.1.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/hopeinstoughton_books/inc/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/hopeinstoughton_books/inc/barcode.js
var loc = window.history.location || window.location;
var $ = jQuery.noConflict();

function Barcode() {

	var _this = this;
	var socket;
	var socket_state = 0;
	var socket_queue = [];
	var pricing = [];
	
	function templateRendered(pagedata) {
		$(document).triggerHandler('render', pagedata);		// javascript to be executed once page has loaded
	}

	// is the url handled by this page?
	function _isLocal(href) {
		if (href.indexOf('://') > -1 && href.substr(0, cbk_host.length) != cbk_host)  return false;
		var element = parseUri(href);
		
		for(var i = 0; i < cbk_navigation.length; i++) {
			var uri = cbk_navigation[i];
			if (uri == element.path.substr(0, uri.length)) {
				return true;		// found it
			}
		}
		return false;
	}

	this.processResult = function(data, rewriteurl) {
		if (typeof data.error === 'string') {
			queueNoty(function() {
				var n = noty({
					text        : data.error,
					type        : 'error',
					dismissQueue: true,
					timeout     : 10000,
					closeWith   : ['click'],
					layout      : 'top',
					theme       : 'defaultTheme',
					maxVisible  : 10
				});
			});
			var err = 0;
		} else {
			var err = (data.error) ? data.error.length : 0;
		}
		
		if (typeof data.samepage != 'undefined') {
			cbk_navigation = data.samepage;
			cbk_host = data.host;
		}
		
		var redirect = data.redirect || '';
		if (redirect != '') {
			history.pushState(null, null, redirect);	// change url
			_performTask(redirect);
		}
		
		var page_title = data.page_title || '';
		if (page_title != '') {
			document.title = page_title;
			$('#title_text').html(page_title);
		}
		
		var template = data.template || '';
		if (template != '') {
			var source   = $('#' + template).html();
			if (typeof source === typeof undefined) {
				queueNoty(function() {
					var n = noty({
						text        : 'Website error: Unable to locate template "' + template + '"',
						type        : 'error',
						dismissQueue: true,
						timeout     : 20000,
						closeWith   : ['click'],
						layout      : 'top',
						theme       : 'defaultTheme',
						maxVisible  : 10
					});
				});
			}
			var template = Handlebars.compile(source);
			var $content = $('#the_content');
			$content.html(template(data.data));
			var $content = $('#the_content');
			if (data.content_class) {
				$content.attr('class', data.content_class);		// overwrite all existing classes
			} else {
				$content.removeAttr('class');						// clear out all classes
			}
			if (data.content_href) {
				$content.attr('href', data.content_href);
			} else {
				$content.removeAttr('href');
			}
			if (data.print) {
				socketsend('print:' + data.print);
			}
			try {
				templateRendered(data);
			} catch(e) {
			}
		}
		
		if (typeof data.titlelist != 'undefined') {
			_this.pricing = data.titlelist;
		}
		if (typeof data.dialog != 'undefined') {
			_displayDialog(data.dialog);
		}
		if (typeof data.id != 'undefined') {
			for(var name in data.id) {
				_updateId(name, data.id[name]);
			}
		}
	};
	
	function socketsend(data) {
		if (!socket_state) {
			socket_queue.push(data);
		} else {
			socket.send(data);
		}
	}

	function _updateId(name, name_data) {
		var $name = $('#' + name);
		if (typeof name_data == 'object') {
			var source   = $('#' + name_data.template).html();
			var template = Handlebars.compile(source);
			$name.html(template(name_data.data));
		} else {
			$name.html(name_data);
		}
	}
	
	function _performChange(select) {
		if (select.value == '3' || select.value == '4') {
			$('#l_amt').hide();		$('#amt').hide();
			$('#l_donate').hide();	$('#donate').hide();
			$('#l_chg').hide();		$('#chg').hide();
		} else {
			$('#l_amt').show();		$('#amt').show();
			$('#l_donate').show();	$('#donate').show();
			$('#l_chg').show();		$('#chg').show();
		}
	}
	
	function _performRecalc() {
		var a = $('#amt').val();
		var $c = $('#chg');
		var c = $c.val();
		var d = $('#donate').val();
		var st = $('#subtotal').val();
		var sv = isNaN(parseFloat(st)) ? 0 : parseFloat(st);
		var av = isNaN(parseFloat(a)) ? 0 : parseFloat(a);
		var dv = isNaN(parseFloat(d)) ? 0 : parseFloat(d);
		var x = av - sv - dv;
		$c.val((!isNaN(x)) ? CurrencyFormatted(x) : '');
	}

	function _updatePricing(value) {
		var price = 0.25;
		var saleonly = 0;
		for(var i = 0; i < _this.pricing.length; i += 3) {
			if (value == _this.pricing[i]) {
				price = _this.pricing[i + 1];
				saleonly = _this.pricing[i + 2];
				break;
			}
		}
		$('#sell').val(CurrencyFormatted(price));
		$('#bt_purchase').prop('checked', !!saleonly);
	}
	
	function _submit_form($form) {
		var data = $form.serialize();
		if (typeof action_id !== typeof undefined && action_id !== false) {
			data._id = action_id;
		}
		
		var action = $form.attr('action') || '';
		if (action == '') {
			action = document.location.href;
		}
		
		$.ajax({
			dataType: 'json',
			data: data,
			async: false,
			url: action,
			type: 'POST',
			crossDomain: true,
		}).done(function(data) {
			_this.processResult(data, false);
		});
	}

	function _performTask(href) {
		$.ajax({
			dataType: 'json',
			async: true,
			url: href,
			type: 'GET',
			crossDomain: true,
		}).done(function(data) {
			_this.processResult(data, false);
		});
	}
	
	function _displayDialog(dialogdata) {
		var source   = $('#' + dialogdata.template).html();
		var template = Handlebars.compile(source);
		var $dialog = $('#dialog');
		$dialog
			.html(template(dialogdata.data))
			.dialog({
				buttons: [
					{	text: 'Close',
						click: function() {
							$dialog.dialog('close');
						}
					}],
				title: dialogdata.title,
				width: 600,
				open: function(event, ui){
					setTimeout(function() {
						$dialog.dialog('close');
					}, 5000);
				}
			});
	}

	function _onMessage(params) {
		var action = params.shift();
		switch(action) {
			case 'setstatus':
				var status = parseInt(params.shift());
				if (status < 0) {
					queueNoty(function() {
						var n = noty({
							text        : params.shift(),
							type        : 'error',
							dismissQueue: true,
							timeout     : 10000,
							closeWith   : ['click'],
							layout      : 'top',
							theme       : 'defaultTheme',
							maxVisible  : 10
						});
					});
				}
				break;
			case 'barscan':		// a barcode has been scanned - send it to website (along with current url)
				var element = parseUri(document.location.href);
				var bc = params.shift();
				var data = {bc: bc};
				$('#listen_barcode').text(bc);

				// stocktake location
				var $stock_location = $('#location');
				if ($stock_location.length > 0) {
					data.loc = $stock_location.val();
				}

				var _connectTimer = setTimeout(function() {
					$('#listen_barcode').text('');
				}, 2000);
				$.ajax({
					dataType: 'json',
					async: true,
					url: document.location.href,
					type: 'GET',
					data: data,
					crossDomain: true,
				}).done(function(data) {
					_this.processResult(data, true);
				});
			
				break;
			case 'seterror':
				queueNoty(function() {
					var n = noty({
						text        : params.shift(),
						type        : 'error',
						dismissQueue: true,
						timeout     : 10000,
						closeWith   : ['click'],
						layout      : 'top',
						theme       : 'defaultTheme',
						maxVisible  : 10
					});
				});
			default:
				console.log('unknown action', action);
		}
	};
	
	var base = 'localhost';
	var socket;
	var socket_state = 0;
	var _reconnectTimer = null;
	
	function _connectSocket(showmessage) {
		socket = new WebSocket('ws://' + base + '/websocket/');
		socket._connectTimer = setTimeout(function() {
			socket_state = -1;
			socket.close();
			socket_state = 0;
			if (showmessage) {
				queueNoty(function() {
					var n = noty({
						text        : 'unable to locate barcode scanner software (start the program, reload this page)',
						type        : 'error',
						dismissQueue: true,
						timeout     : 10000,
						closeWith   : ['click'],
						layout      : 'top',
						theme       : 'defaultTheme',
						maxVisible  : 3
					});
				});
			}
		}, 2000);
		socket.onopen = function(event) {
			socket_state = 1;
			clearTimeout(socket._connectTimer);
			if (_reconnectTimer !== null) {
				clearInterval(_reconnectTimer);
				_reconnectTimer = null;
				var n = noty({
					text        : 'connected to barcode scanner software',
					type        : 'success',
					dismissQueue: true,
					timeout     : 4000,
					closeWith   : ['click'],
					layout      : 'top',
					theme       : 'defaultTheme',
					maxVisible  : 3
				});
			}
			socket.send('status');		// what do we have connected?
		};
		socket.onerror = function(error) {
			console.log('WebSocket Error: ', error);
//			_attemptToReconnect();
		};
		socket.onclose = function(error) {
			if (socket_state > 0) {
				queueNoty(function() {
					var n = noty({
						text        : 'connection to barcode scanner software has been lost',
						type        : 'error',
						dismissQueue: true,
						timeout     : 10000,
						closeWith   : ['click'],
						layout      : 'top',
						theme       : 'defaultTheme',
						maxVisible  : 3
					});
				});
			}
			_attemptToReconnect();
		};
		socket.onmessage = function(event) {
			var message = event.data.split(':');
			_onMessage(message);
			if (socket_queue.length) {
				message = socket_queue.shift();
				socket.send(message);
			}
		}
	}

	function _attemptToReconnect() {
		clearInterval(_reconnectTimer);
		socket_state = 0;
		_reconnectTimer = setInterval(function() {
			if (!socket_state) {
				delete socket;
				_connectSocket(false);
			}
		}, 5000);
	}
	_connectSocket(true);
	
	$(document).on('keypress', function(event) {
		var keycode = event.keyCode ? event.keyCode : event.which;
		if (keycode == 32) {
			var redirect = $('#the_content').attr('href');
			if (typeof redirect != 'undefined') {
				history.pushState(null, null, redirect);
				_performTask(redirect);
			}
		}
	}).on('change', 'select#pt', function(event) {
		_performChange(this);

		}).on('blur', 'form.payment #amt, form.payment #donate', function(event) {
		_performRecalc();
		
	}).on('change', '#id.customselectbox', function(event) {
		_updatePricing($(this).val());
	
	}).on('click', '.singleclick, .ajax', function(event) {
		var $this = $(this);
		var href = $this.attr('href');
		if (typeof href != 'undefined') {
			if (typeof cbk_navigation != 'undefined' && _isLocal(href)) {
				if ($this.hasClass('singleclick')) {
					history.pushState(null, null, href);
				}
				_performTask(href);
				event.preventDefault();
			}
		}
		
	}).on('submit', 'form.json', function(event) {
		event.preventDefault();
		var $form = $(this);
		_submit_form($form);
	});

	$(function() {
		window.onpopstate = function(event) {
			if (typeof cbk_navigation != 'undefined' && _isLocal(loc.href)) {
				_performTask(loc.href);
			} else {
				window.location.href = loc.href;
			}
		};
	});

}

bc = new Barcode();

Youez - 2016 - github.com/yon3zu
LinuXploit