|
|
|
|
|
|
|
|
(function ($) { |
|
|
(function ($) { |
|
|
$(function () { |
|
|
$(function () { |
|
|
|
|
|
// http://davidwalsh.name/javascript-debounce-function |
|
|
|
|
|
function debounce(func, wait, immediate) { |
|
|
|
|
|
var timeout; |
|
|
|
|
|
return function () { |
|
|
|
|
|
var context = this, args = arguments; |
|
|
|
|
|
var later = function () { |
|
|
|
|
|
timeout = null; |
|
|
|
|
|
if (!immediate) |
|
|
|
|
|
func.apply(context, args); |
|
|
|
|
|
}; |
|
|
|
|
|
var callNow = immediate && !timeout; |
|
|
|
|
|
clearTimeout(timeout); |
|
|
|
|
|
timeout = setTimeout(later, wait); |
|
|
|
|
|
if (callNow) |
|
|
|
|
|
func.apply(context, args); |
|
|
|
|
|
}; |
|
|
|
|
|
}; |
|
|
/*____________________________________________________________________________________*/ |
|
|
/*____________________________________________________________________________________*/ |
|
|
class People{ |
|
|
class People{ |
|
|
constructor(selector, data){ |
|
|
constructor(selector, data){ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
function list_staff() { |
|
|
function list_staff() { |
|
|
|
|
|
$('div.stafflist div.peopleitem').remove(); |
|
|
$.post(bts().ajax_url, { // POST request |
|
|
$.post(bts().ajax_url, { // POST request |
|
|
_ajax_nonce: bts().nonce, // nonce |
|
|
_ajax_nonce: bts().nonce, // nonce |
|
|
action: "list_staff", // action |
|
|
action: "list_staff", // action |
|
|
}, function(response, status, xhr){ |
|
|
}, function(response, status, xhr){ |
|
|
if (response.status =='success'){ |
|
|
if (response.status =='success'){ |
|
|
response.staff.forEach(function(staff){ |
|
|
|
|
|
var html = bts_people_html(staff); |
|
|
|
|
|
|
|
|
response.users.forEach(function(u){ |
|
|
|
|
|
var html = bts_people_html(u); |
|
|
jQuery('div.stafflist').append(html); |
|
|
jQuery('div.stafflist').append(html); |
|
|
new People("#p" + staff.login, staff); |
|
|
|
|
|
|
|
|
new People("#p" + u.login, u); |
|
|
}); |
|
|
}); |
|
|
}else{ |
|
|
}else{ |
|
|
alert('error getting staff list'); |
|
|
alert('error getting staff list'); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function list_clients() { |
|
|
|
|
|
$('div.clientlist div.peopleitem').remove(); //clear it |
|
|
|
|
|
$.post(bts().ajax_url, { // POST request |
|
|
|
|
|
_ajax_nonce: bts().nonce, // nonce |
|
|
|
|
|
action: "list_client", // action |
|
|
|
|
|
}, function(response, status, xhr){ |
|
|
|
|
|
if (response.status =='success'){ |
|
|
|
|
|
response.users.forEach(function(u){ |
|
|
|
|
|
var html = bts_people_html(u); |
|
|
|
|
|
jQuery('div.clientlist').append(html); |
|
|
|
|
|
new People("#p" + u.login, u); |
|
|
|
|
|
}); |
|
|
|
|
|
}else{ |
|
|
|
|
|
alert('error getting Client list'); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function xero(t){ |
|
|
|
|
|
if (t) |
|
|
|
|
|
$('div.xero i').show(); |
|
|
|
|
|
else |
|
|
|
|
|
$('div.xero i').hide(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function wifi(t){ |
|
|
|
|
|
if (t) |
|
|
|
|
|
$('div.wifi i').show(); |
|
|
|
|
|
else |
|
|
|
|
|
$('div.wifi i').hide(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function init_user_search(){ |
|
|
|
|
|
$('div.b_search input').keyup(debounce(function(){ |
|
|
|
|
|
console.log('key pressed'); |
|
|
|
|
|
}, 500)); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function init_ts(){ |
|
|
function init_ts(){ |
|
|
list_staff(); |
|
|
list_staff(); |
|
|
|
|
|
list_clients(); |
|
|
|
|
|
xero(false); |
|
|
|
|
|
wifi(false); |
|
|
|
|
|
init_user_search(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
init_ts(); |
|
|
init_ts(); |
|
|
/*________________________________________________________________________*/ |
|
|
/*________________________________________________________________________*/ |
|
|
}); |
|
|
}); |