This repository has been archived on 2023-09-06. You can view files and clone it, but cannot push or open issues or pull requests.
vn-softphone/static/js/event.js

87 lines
1.7 KiB
JavaScript

$(window).on('load', function() {
/**
* Incoming/Outgoint calls
*/
/* if (!Softphone.isOnCall()) {
let number = Util.query('number');
Softphone.call(number);
} */
/**
* Make new call
*/
$(document).on('click', '#call', function() {
let number = $('#callNumber').val();
if (number)
Softphone.call(number, options);
return false;
});
/**
* Insert key on call field
*/
$(document).on('click', '#zero, #one, #two, #three, #four, '
+ '#five, #six, #seven, #eight, #nine, #asterisk, #pad', padKey);
/**
* History
*/
$(document).on('click', '#history', function() {
Util.navigate('#content', '/history');
return false;
});
/**
* Show/Hide dialpad
*/
$(document).on('click', '#dial', function() {
Util.navigate('#side', '/dialpad');
return false;
});
/**
* Accept incoming call
*/
$(document).on('click', '#accept', function() {
Softphone.answer(options);
return false;
});
/**
* Decline incoming call
*/
$(document).on('click', '#decline', function() {
Softphone.hangup();
return false;
});
/**
* Pad keys
* @param {Object} event Event object
*/
function padKey(event) {
let key = event.target.innerHTML;
let keyName = event.target.id;
document.getElementById('callNumber').value += key;
audio.addTrack(keyName);
audio.play();
event.preventDefault();
}
});
/**
* Prevent page reload without confirmation
*/
window.addEventListener("beforeunload", function (event) {
event.returnValue = "\o/";
});