2014-06-20 20:26:06 -04:00
|
|
|
'use strict';
|
|
|
|
var cur_call = null;
|
2014-07-11 18:27:03 -04:00
|
|
|
var confMan = null;
|
2014-06-20 20:26:06 -04:00
|
|
|
var verto;
|
|
|
|
var ringing = false;
|
2014-07-17 16:03:57 -04:00
|
|
|
var autocall = false;
|
2014-07-24 01:13:32 -04:00
|
|
|
var chatting_with = false;
|
2014-07-17 16:03:57 -04:00
|
|
|
|
|
|
|
$( ".selector" ).pagecontainer({ "theme": "a" });
|
2014-06-20 20:26:06 -04:00
|
|
|
|
|
|
|
function display(msg) {
|
|
|
|
$("#calltitle").html(msg);
|
|
|
|
}
|
|
|
|
|
2014-07-11 18:27:03 -04:00
|
|
|
function clearConfMan() {
|
|
|
|
if (confMan) {
|
|
|
|
confMan.destroy();
|
|
|
|
confMan = null;
|
2014-06-20 20:26:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$("#conf").hide();
|
2014-07-24 01:13:32 -04:00
|
|
|
$("#message").hide();
|
|
|
|
chatting_with = null;
|
2014-06-20 20:26:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
function goto_dialog(where) {
|
2014-07-17 16:03:57 -04:00
|
|
|
$( ":mobile-pagecontainer" ).pagecontainer( "change", "#dialog-" + where, { role: "dialog" } );
|
2014-06-20 20:26:06 -04:00
|
|
|
}
|
|
|
|
|
2014-07-17 16:03:57 -04:00
|
|
|
function goto_page(where, force) {
|
|
|
|
$( ":mobile-pagecontainer" ).pagecontainer( "change", "#page-" + where);
|
2014-06-20 20:26:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
var first_login = false;
|
|
|
|
var online_visible = false;
|
|
|
|
function online(on) {
|
|
|
|
if (on) {
|
|
|
|
$("#online").show();
|
|
|
|
$("#offline").hide();
|
|
|
|
first_login = true;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$("#online").hide();
|
|
|
|
$("#offline").show();
|
|
|
|
}
|
|
|
|
|
|
|
|
online_visible = on;
|
|
|
|
}
|
|
|
|
|
2014-07-24 01:13:32 -04:00
|
|
|
function setupChat() {
|
|
|
|
$("#chatwin").html("");
|
|
|
|
|
|
|
|
$("#chatsend").click(function() {
|
|
|
|
if (!cur_call && chatting_with) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-24 13:58:12 -04:00
|
|
|
cur_call.message({to: chatting_with,
|
|
|
|
body: $("#chatmsg").val(),
|
|
|
|
from_msg_name: cur_call.params.caller_id_name,
|
|
|
|
from_msg_number: cur_call.params.caller_id_number
|
|
|
|
});
|
2014-07-24 01:13:32 -04:00
|
|
|
$("#chatmsg").val("");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#chatmsg").keyup(function (event) {
|
|
|
|
if (event.keyCode == 13 && !event.shiftKey) {
|
|
|
|
$( "#chatsend" ).trigger( "click" );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
function check_vid() {
|
|
|
|
var use_vid = $("#use_vid").is(':checked');
|
|
|
|
return use_vid;
|
|
|
|
}
|
|
|
|
|
2014-08-25 18:41:58 -04:00
|
|
|
function messageTextToJQ(body) {
|
|
|
|
// Builds a jQuery collection from body text, linkifies http/https links, imageifies http/https links to images, and doesn't allow script injection
|
|
|
|
|
|
|
|
var match, $link, img_url, $body_parts = $(), rx = /(https?:\/\/[^ \n\r]+|\n\r|\n|\r)/;
|
|
|
|
|
|
|
|
while ((match = rx.exec(body)) !== null) {
|
|
|
|
if (match.index !== 0) {
|
|
|
|
$body_parts = $body_parts.add(document.createTextNode(body.substr(0, match.index)));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (match[0].match(/^(\n|\r|\n\r)$/)) {
|
|
|
|
// Make a BR from a newline
|
|
|
|
$body_parts = $body_parts.add($('<br />'));
|
|
|
|
body = body.substr(match.index + match[0].length);
|
|
|
|
} else {
|
|
|
|
// Make a link (or image)
|
|
|
|
$link = $('<a target="_blank" />').attr('href', match[0]);
|
|
|
|
|
|
|
|
if (match[0].search(/\.(gif|jpe?g|png)/) > -1) {
|
|
|
|
// Make an image
|
|
|
|
img_url = match[0];
|
|
|
|
|
|
|
|
// Handle dropbox links
|
|
|
|
if (img_url.indexOf('dropbox.com') !== -1) {
|
|
|
|
if (img_url.indexOf('?dl=1') === -1 && img_url.indexOf('?dl=0') === -1) {
|
|
|
|
img_url += '?dl=1';
|
|
|
|
} else if (img_url.indexOf('?dl=0') !== -1) {
|
|
|
|
img_url = img_url.replace(/dl=0$/, 'dl=1');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$link.append($('<img border="0" class="chatimg" />').attr('src', img_url));
|
|
|
|
} else {
|
|
|
|
// Make a link
|
|
|
|
$link.text(match[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
body = body.substr(match.index + match[0].length);
|
|
|
|
$body_parts = $body_parts.add($link);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (body) {
|
|
|
|
$body_parts = $body_parts.add(document.createTextNode(body));
|
|
|
|
}
|
|
|
|
|
|
|
|
return $body_parts;
|
|
|
|
} // END function messageTextToJQ
|
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
var callbacks = {
|
|
|
|
|
|
|
|
onMessage: function(verto, dialog, msg, data) {
|
|
|
|
|
|
|
|
switch (msg) {
|
|
|
|
case $.verto.enum.message.pvtEvent:
|
2014-07-24 01:13:32 -04:00
|
|
|
// console.error("pvtEvent", data.pvtData);
|
2014-06-20 20:26:06 -04:00
|
|
|
if (data.pvtData) {
|
|
|
|
switch (data.pvtData.action) {
|
2014-07-11 18:27:03 -04:00
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
case "conference-liveArray-part":
|
2014-07-11 18:27:03 -04:00
|
|
|
clearConfMan();
|
2014-06-20 20:26:06 -04:00
|
|
|
break;
|
|
|
|
case "conference-liveArray-join":
|
2014-07-11 18:27:03 -04:00
|
|
|
clearConfMan();
|
|
|
|
confMan = new $.verto.confMan(verto, {
|
|
|
|
tableID: "#conf_list",
|
|
|
|
statusID: "#conf_count",
|
|
|
|
mainModID: "#conf_mod",
|
|
|
|
displayID: "#conf_display",
|
|
|
|
dialog: dialog,
|
|
|
|
hasVid: check_vid(),
|
|
|
|
laData: data.pvtData
|
|
|
|
});
|
2014-06-20 20:26:06 -04:00
|
|
|
|
|
|
|
$("#conf").show();
|
2014-07-24 01:13:32 -04:00
|
|
|
$("#chatwin").html("");
|
|
|
|
$("#message").show();
|
|
|
|
|
|
|
|
chatting_with = data.pvtData.chatID;
|
2014-06-20 20:26:06 -04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case $.verto.enum.message.info:
|
2014-07-24 16:31:35 -04:00
|
|
|
var body = data.body;
|
|
|
|
|
2014-08-25 18:41:58 -04:00
|
|
|
/*
|
|
|
|
// This section has been replaced with messageTextToJQ function
|
|
|
|
|
2014-07-24 16:31:35 -04:00
|
|
|
if (body.match(/\.gif|\.jpg|\.jpeg|\.png/)) {
|
2014-07-24 17:03:08 -04:00
|
|
|
var mod = "";
|
|
|
|
if (body.match(/dropbox.com/)) {
|
|
|
|
mod = "?dl=1";
|
|
|
|
}
|
|
|
|
body = body.replace(/(http[s]{0,1}:\/\/\S+)/g, "<a target='_blank' href='$1'>$1<br><img border='0' class='chatimg' src='$1'" + mod + "><\/a>");
|
2014-07-24 16:31:35 -04:00
|
|
|
} else {
|
|
|
|
body = body.replace(/(http[s]{0,1}:\/\/\S+)/g, "<a target='_blank' href='$1'>$1<\/a>");
|
|
|
|
}
|
2014-07-24 01:13:32 -04:00
|
|
|
|
2014-07-24 13:58:12 -04:00
|
|
|
if (body.slice(-1) !== "\n") {
|
|
|
|
body += "\n";
|
|
|
|
}
|
|
|
|
body = body.replace(/(?:\r\n|\r|\n)/g, '<br />');
|
2014-07-24 16:31:35 -04:00
|
|
|
|
2014-08-25 18:41:58 -04:00
|
|
|
var from = data.from_msg_name || data.from;
|
|
|
|
|
2014-07-24 13:58:12 -04:00
|
|
|
$("#chatwin").append("<span class=chatuid>" + from + ":</span><br>" + body);
|
2014-07-24 01:13:32 -04:00
|
|
|
$('#chatwin').animate({"scrollTop": $('#chatwin')[0].scrollHeight}, "fast");
|
2014-08-25 18:41:58 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
var from = data.from_msg_name || data.from;
|
|
|
|
|
|
|
|
$('#chatwin')
|
|
|
|
.append($('<span class="chatuid" />').text(from + ':'))
|
|
|
|
.append($('<br />'))
|
|
|
|
.append(messageTextToJQ(body))
|
|
|
|
.append($('<br />'));
|
|
|
|
$('#chatwin').animate({"scrollTop": $('#chatwin')[0].scrollHeight}, "fast");
|
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
break;
|
|
|
|
case $.verto.enum.message.display:
|
|
|
|
var party = dialog.params.remote_caller_id_name + "<" + dialog.params.remote_caller_id_number + ">";
|
|
|
|
display("Talking to: " + dialog.cidString());
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
onDialogState: function(d) {
|
|
|
|
cur_call = d;
|
|
|
|
|
2014-06-29 15:00:35 -04:00
|
|
|
if (d.state == $.verto.enum.state.ringing) {
|
|
|
|
ringing = true;
|
|
|
|
} else {
|
|
|
|
ringing = false;
|
|
|
|
}
|
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
switch (d.state) {
|
|
|
|
case $.verto.enum.state.ringing:
|
|
|
|
display("Call From: " + d.cidString());
|
|
|
|
|
|
|
|
$("#ansbtn").click(function() {
|
|
|
|
cur_call.answer({
|
2014-07-18 13:05:07 -04:00
|
|
|
useStereo: $("#use_stereo").is(':checked'),
|
|
|
|
callee_id_name: $("#name").val(),
|
|
|
|
callee_id_number: $("#cid").val(),
|
2014-06-20 20:26:06 -04:00
|
|
|
});
|
|
|
|
$('#dialog-incoming-call').dialog('close');
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#declinebtn").click(function() {
|
|
|
|
cur_call.hangup();
|
|
|
|
$('#dialog-incoming-call').dialog('close');
|
|
|
|
});
|
|
|
|
|
|
|
|
goto_dialog("incoming-call");
|
|
|
|
$("#dialog-incoming-call-txt").text("Incoming call from: " + d.cidString());
|
|
|
|
|
|
|
|
if (d.params.wantVideo) {
|
|
|
|
$("#vansbtn").click(function() {
|
|
|
|
$("#use_vid").prop("checked", true);
|
|
|
|
cur_call.answer({
|
|
|
|
useVideo: true,
|
|
|
|
useStereo: $("#use_stereo").is(':checked')
|
|
|
|
});
|
|
|
|
});
|
|
|
|
// the buttons in this jquery mobile wont hide .. gotta wrap them in a div as a workaround
|
|
|
|
$("#vansdiv").show();
|
|
|
|
} else {
|
|
|
|
$("#vansdiv").hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2014-07-17 16:03:57 -04:00
|
|
|
case $.verto.enum.state.trying:
|
|
|
|
display("Calling: " + d.cidString());
|
|
|
|
goto_page("incall");
|
|
|
|
break;
|
2014-07-14 11:38:39 -04:00
|
|
|
case $.verto.enum.state.early:
|
2014-06-20 20:26:06 -04:00
|
|
|
case $.verto.enum.state.active:
|
|
|
|
display("Talking to: " + d.cidString());
|
|
|
|
goto_page("incall");
|
|
|
|
break;
|
|
|
|
case $.verto.enum.state.hangup:
|
2014-07-14 12:25:43 -04:00
|
|
|
$("#main_info").html("Call ended with cause: " + d.cause);
|
2014-07-24 01:13:32 -04:00
|
|
|
goto_page("main");
|
2014-06-20 20:26:06 -04:00
|
|
|
case $.verto.enum.state.destroy:
|
2014-07-14 12:25:43 -04:00
|
|
|
$("#hangup_cause").html("");
|
2014-07-11 18:27:03 -04:00
|
|
|
clearConfMan();
|
2014-07-24 01:13:32 -04:00
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
cur_call = null;
|
|
|
|
break;
|
|
|
|
case $.verto.enum.state.held:
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
display("");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
onWSLogin: function(v, success) {
|
|
|
|
display("");
|
|
|
|
|
2014-06-29 15:00:35 -04:00
|
|
|
cur_call = null;
|
|
|
|
ringing = false;
|
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
if (success) {
|
|
|
|
online(true);
|
|
|
|
|
2014-07-17 16:03:57 -04:00
|
|
|
/*
|
2014-06-20 20:26:06 -04:00
|
|
|
verto.subscribe("presence", {
|
|
|
|
handler: function(v, e) {
|
|
|
|
console.error("PRESENCE:", e);
|
|
|
|
}
|
2014-07-17 16:03:57 -04:00
|
|
|
});
|
|
|
|
*/
|
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
if (!window.location.hash) {
|
|
|
|
goto_page("main");
|
|
|
|
}
|
2014-07-17 16:03:57 -04:00
|
|
|
|
|
|
|
if (autocall) {
|
|
|
|
autocall = false;
|
|
|
|
docall();
|
|
|
|
}
|
2014-06-20 20:26:06 -04:00
|
|
|
} else {
|
2014-08-24 19:29:22 -04:00
|
|
|
goto_page("main");
|
2014-06-20 20:26:06 -04:00
|
|
|
goto_dialog("login-error");
|
|
|
|
}
|
|
|
|
|
|
|
|
},
|
|
|
|
onWSClose: function(v, success) {
|
2015-01-05 22:14:35 -05:00
|
|
|
display("");
|
|
|
|
online(false);
|
2014-06-20 20:26:06 -04:00
|
|
|
var today = new Date();
|
|
|
|
$("#errordisplay").html("Connection Error.<br>Last Attempt: " + today);
|
|
|
|
goto_page("main");
|
|
|
|
},
|
|
|
|
|
|
|
|
onEvent: function(v, e) {
|
2014-07-17 16:03:57 -04:00
|
|
|
console.debug("GOT EVENT", e);
|
2014-06-20 20:26:06 -04:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
$("#hold").click(function(e) {
|
|
|
|
cur_call.toggleHold();
|
|
|
|
goto_dialog("hold");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#cancelxferbtn").click(function(e) {
|
|
|
|
$("#xferto").val("");
|
|
|
|
$("#xferdiv").hide();
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".startxferbtn").click(function(e) {
|
|
|
|
if ($('#xferdiv').is(':visible')) {
|
|
|
|
var xfer = $("#xferto").val();
|
|
|
|
if (xfer) {
|
|
|
|
cur_call.transfer(xfer);
|
|
|
|
}
|
|
|
|
$("#xferto").val("");
|
|
|
|
$("#xferdiv").hide();
|
|
|
|
} else {
|
|
|
|
$("#xferdiv").show();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#clearbtn").click(function(e) {
|
|
|
|
$("#ext").val("");
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".dialbtn").click(function(e) {
|
|
|
|
$("#ext").val($("#ext").val() + e.currentTarget.textContent);
|
|
|
|
});
|
|
|
|
|
|
|
|
$(".dtmf").click(function(e) {
|
|
|
|
if ($('#xferdiv').is(':visible')) {
|
|
|
|
$("#xferto").val($("#xferto").val() + e.currentTarget.textContent);
|
|
|
|
} else {
|
|
|
|
cur_call.dtmf(e.currentTarget.textContent);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#hupbtn").click(function() {
|
|
|
|
verto.hangup();
|
|
|
|
cur_call = null;
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#webcam").click(function() {
|
|
|
|
check_vid();
|
|
|
|
});
|
|
|
|
|
2014-07-17 16:03:57 -04:00
|
|
|
function docall() {
|
2014-06-20 20:26:06 -04:00
|
|
|
$('#ext').trigger('change');
|
|
|
|
|
|
|
|
if (cur_call) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-07-14 12:25:43 -04:00
|
|
|
$("#main_info").html("Trying");
|
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
cur_call = verto.newCall({
|
|
|
|
destination_number: $("#ext").val(),
|
|
|
|
caller_id_name: $("#name").val(),
|
|
|
|
caller_id_number: $("#cid").val(),
|
|
|
|
useVideo: check_vid(),
|
|
|
|
useStereo: $("#use_stereo").is(':checked')
|
|
|
|
});
|
2014-07-17 16:03:57 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$("#callbtn").click(function() {
|
|
|
|
docall();
|
2014-06-20 20:26:06 -04:00
|
|
|
});
|
|
|
|
|
|
|
|
function pop(id, cname, dft) {
|
|
|
|
var tmp = $.cookie(cname) || dft;
|
|
|
|
$.cookie(cname, tmp, {
|
|
|
|
expires: 365
|
|
|
|
});
|
|
|
|
$(id).val(tmp).change(function() {
|
|
|
|
$.cookie(cname, $(id).val(), {
|
|
|
|
expires: 365
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function init() {
|
2014-07-11 18:27:03 -04:00
|
|
|
cur_call = null;
|
|
|
|
|
2014-08-11 15:29:45 -04:00
|
|
|
if (!autocall) {
|
|
|
|
pop("#ext", "verto_demo_ext", "3500");
|
|
|
|
}
|
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
pop("#name", "verto_demo_name", "FreeSWITCH User");
|
|
|
|
pop("#cid", "verto_demo_cid", "1008");
|
|
|
|
pop("#textto", "verto_demo_textto", "1000");
|
|
|
|
|
|
|
|
pop("#login", "verto_demo_login", "1008");
|
|
|
|
pop("#passwd", "verto_demo_passwd", "1234");
|
|
|
|
|
|
|
|
pop("#hostName", "verto_demo_hostname", window.location.hostname);
|
|
|
|
pop("#wsURL", "verto_demo_wsurl", "wss://" + window.location.hostname + ":8082");
|
|
|
|
|
|
|
|
var tmp = $.cookie("verto_demo_vid_checked") || "false";
|
|
|
|
$.cookie("verto_demo_vid_checked", tmp, {
|
|
|
|
expires: 365
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#use_vid").prop("checked", tmp === "true").change(function(e) {
|
|
|
|
tmp = $("#use_vid").is(':checked');
|
|
|
|
$.cookie("verto_demo_vid_checked", tmp ? "true" : "false", {
|
|
|
|
expires: 365
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
tmp = $.cookie("verto_demo_stereo_checked") || "false";
|
|
|
|
$.cookie("verto_demo_stereo_checked", tmp, {
|
|
|
|
expires: 365
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#use_stereo").prop("checked", tmp === "true").change(function(e) {
|
|
|
|
tmp = $("#use_stereo").is(':checked');
|
|
|
|
$.cookie("verto_demo_stereo_checked", tmp ? "true" : "false", {
|
|
|
|
expires: 365
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-10-21 15:56:10 -04:00
|
|
|
tmp = $.cookie("verto_demo_stun_checked") || "true";
|
2014-08-01 16:20:00 -04:00
|
|
|
$.cookie("verto_demo_stun_checked", tmp, {
|
|
|
|
expires: 365
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#use_stun").prop("checked", tmp === "true").change(function(e) {
|
|
|
|
tmp = $("#use_stun").is(':checked');
|
|
|
|
$.cookie("verto_demo_stun_checked", tmp ? "true" : "false", {
|
|
|
|
expires: 365
|
|
|
|
});
|
|
|
|
if (verto) {
|
|
|
|
verto.iceServers(tmp);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
verto = new $.verto({
|
|
|
|
login: $("#login").val() + "@" + $("#hostName").val(),
|
|
|
|
passwd: $("#passwd").val(),
|
|
|
|
socketUrl: $("#wsURL").val(),
|
|
|
|
tag: "webcam",
|
|
|
|
ringFile: "sounds/bell_ring2.wav",
|
|
|
|
videoParams: {
|
|
|
|
"minWidth": "1280",
|
2015-03-25 14:30:20 -04:00
|
|
|
"minHeight": "720",
|
|
|
|
"minFrameRate": 30
|
2014-08-01 16:20:00 -04:00
|
|
|
},
|
2014-10-13 19:26:20 -04:00
|
|
|
audioParams: {
|
|
|
|
googAutoGainControl: false,
|
|
|
|
googNoiseSuppression: false,
|
|
|
|
googHighpassFilter: false
|
|
|
|
},
|
2014-08-01 16:20:00 -04:00
|
|
|
iceServers: $("#use_stun").is(':checked')
|
2014-07-11 18:27:03 -04:00
|
|
|
},callbacks);
|
2014-06-20 20:26:06 -04:00
|
|
|
|
|
|
|
$("#login").change(function(e) {
|
|
|
|
$("#cid").val(e.currentTarget.value);
|
|
|
|
$.cookie("verto_demo_cid", e.currentTarget.value, {
|
|
|
|
expires: 365
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#vtxtbtn").click(function() {
|
|
|
|
verto.message({
|
|
|
|
to: $("#textto").val(),
|
|
|
|
body: $("#textmsg").val()
|
|
|
|
});
|
|
|
|
$("#textmsg").val("");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#logoutbtn").click(function() {
|
|
|
|
verto.logout();
|
|
|
|
online(false);
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#loginbtn").click(function() {
|
|
|
|
online(false);
|
|
|
|
verto.loginData({
|
|
|
|
login: $("#login").val() + "@" + $("#hostName").val(),
|
|
|
|
passwd: $("#passwd").val()
|
|
|
|
});
|
|
|
|
verto.login();
|
|
|
|
goto_page("main");
|
|
|
|
});
|
|
|
|
|
|
|
|
$("#xferdiv").hide();
|
|
|
|
$("#webcam").hide();
|
|
|
|
|
|
|
|
online(false);
|
2014-07-24 01:13:32 -04:00
|
|
|
|
|
|
|
setupChat();
|
|
|
|
|
2014-07-24 12:03:36 -04:00
|
|
|
$("#ext").keyup(function (event) {
|
|
|
|
if (event.keyCode == 13) {
|
|
|
|
$( "#callbtn" ).trigger( "click" );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-07-24 14:17:55 -04:00
|
|
|
$(document).keypress(function(event) {
|
2014-07-24 14:43:05 -04:00
|
|
|
if (!(cur_call && event.target.id == "page-incall")) return;
|
2014-07-24 14:17:55 -04:00
|
|
|
var key = String.fromCharCode(event.keyCode);
|
|
|
|
var i = parseInt(key);
|
|
|
|
|
2014-07-24 14:43:05 -04:00
|
|
|
|
2014-07-24 14:17:55 -04:00
|
|
|
if (key === "#" || key === "*" || key === "0" || (i > 0 && i <= 9)) {
|
|
|
|
cur_call.dtmf(key);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2014-08-05 14:41:28 -04:00
|
|
|
if (window.location.hostname !== "webrtc.freeswitch.org") {
|
|
|
|
$("#directory").hide();
|
|
|
|
}
|
2014-06-20 20:26:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
2014-07-15 15:11:48 -04:00
|
|
|
var hash = window.location.hash.substring(1);
|
2014-07-29 13:16:56 -04:00
|
|
|
var a = [];
|
2014-07-15 15:11:48 -04:00
|
|
|
|
|
|
|
if (hash && hash.indexOf("page-") == -1) {
|
|
|
|
window.location.hash = "";
|
2014-07-17 16:03:57 -04:00
|
|
|
$("#ext").val(hash);
|
2014-07-15 15:11:48 -04:00
|
|
|
autocall = true;
|
|
|
|
}
|
|
|
|
|
2014-07-29 13:16:56 -04:00
|
|
|
if (hash && (a = hash.split("&"))) {
|
|
|
|
window.location.hash = a[0];
|
|
|
|
}
|
|
|
|
|
2014-06-20 20:26:06 -04:00
|
|
|
init();
|
2014-07-15 15:11:48 -04:00
|
|
|
|
2014-07-17 16:03:57 -04:00
|
|
|
});
|
2014-07-15 15:11:48 -04:00
|
|
|
|
|
|
|
|
2014-07-17 16:03:57 -04:00
|
|
|
var lastTo = 0;
|
2014-07-15 15:11:48 -04:00
|
|
|
|
2014-07-17 16:03:57 -04:00
|
|
|
$(document).bind("pagecontainerchange", function(e, data) {
|
2014-06-20 20:26:06 -04:00
|
|
|
|
2014-07-17 16:03:57 -04:00
|
|
|
if (lastTo) {
|
|
|
|
clearTimeout(lastTo);
|
2014-06-20 20:26:06 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
switch (window.location.hash) {
|
|
|
|
|
|
|
|
case "#page-incall":
|
2014-07-17 16:03:57 -04:00
|
|
|
lastTo = setTimeout(function() {
|
2014-06-20 20:26:06 -04:00
|
|
|
if (!cur_call) {
|
|
|
|
goto_page("main");
|
|
|
|
}
|
2014-07-17 16:03:57 -04:00
|
|
|
}, 1000);
|
2014-06-20 20:26:06 -04:00
|
|
|
|
|
|
|
break;
|
|
|
|
|
2014-07-17 16:03:57 -04:00
|
|
|
case "#page-main":
|
2014-07-24 01:13:32 -04:00
|
|
|
if (cur_call) {
|
|
|
|
goto_page("incall");
|
|
|
|
}
|
2014-07-17 16:03:57 -04:00
|
|
|
break;
|
2014-06-20 20:26:06 -04:00
|
|
|
case "#page-login":
|
|
|
|
|
2014-07-17 16:03:57 -04:00
|
|
|
lastTo = setTimeout(function() {
|
2014-06-20 20:26:06 -04:00
|
|
|
if (online_visible) {
|
|
|
|
goto_page("main");
|
|
|
|
}
|
|
|
|
},
|
|
|
|
1000);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
2014-07-17 16:03:57 -04:00
|
|
|
|