Code backup
This commit is contained in:
2026-05-10 16:59:01 +02:00
commit 368d6fafea
796 changed files with 315310 additions and 0 deletions
+786
View File
@@ -0,0 +1,786 @@
// Accounts page
webphone_api._accounts = (function ()
{
function onCreate (event) // called only once - bind events here
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _accounts: onCreate");
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_accounts')
{
MeasureAccountst();
}
});
webphone_api.$('#accounts_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_accounts_menu").on("click", function() { CreateOptionsMenu('#accounts_menu_ul'); });
webphone_api.$("#btn_accounts_menu").attr("title", webphone_api.stringres.get("hint_menu"));
webphone_api.$(".minus_btn").attr("title", webphone_api.stringres.get("hint_removephone"));
webphone_api.$("#btn_add_acc").attr("title", webphone_api.stringres.get("accounts_add_hint"));
webphone_api.$( "#page_accounts" ).keyup(function( event )
{
HandleKeyUp(event);
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: onCreate", err); }
}
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _accounts: onStart");
webphone_api.global.isAccountsStarted = true;
webphone_api.$("#btn_add_acc").on("click", function() { AddAccount(); });
webphone_api.$('#acc_add_p').html(webphone_api.stringres.get('add_account'));
document.getElementById('aec_label_phone').innerHTML = webphone_api.stringres.get('contact_phone');
webphone_api.$("#accounts_list").attr("data-filter-placeholder", webphone_api.stringres.get("ct_search_hint"));
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#page_accounts'), -30) );
if (!webphone_api.common.isNull(document.getElementById('addeditct_btnback')))
{
document.getElementById('addeditct_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get('btn_cancel');
}
var mainAcc = '';
if (!webphone_api.common.isNull(webphone_api.global.sipaccounts) && webphone_api.global.sipaccounts.length > 0)
{
// get active account
var activeacc_name = "";
for (var i = 0; i < webphone_api.global.sipaccounts.length; i++)
{
var sipitem = webphone_api.global.sipaccounts[i];
if (sipitem.ismain === true)
{
activeacc_name = sipitem.username;
if (!webphone_api.common.isNull(sipitem.serveraddress) && sipitem.serveraddress.length > 0)
{
activeacc_name = activeacc_name + '@' + sipitem.serveraddress;
}
break;
}
}
if (!webphone_api.common.isNull(activeacc_name) && activeacc_name.length > 0)
{
mainAcc = webphone_api.stringres.get('active_account') + ' ' + activeacc_name + '. ';
}
}
var textInstr = webphone_api.stringres.get('accounts_instructions1') + ' '
+ mainAcc + webphone_api.stringres.get('accounts_instructions2');
webphone_api.$("#text_instructions").html(textInstr);
// needed for proper display and scrolling of listview
MeasureAccountst();
document.getElementById('accounts_title').innerHTML = webphone_api.stringres.get('accounts_title');
webphone_api.$("#accounts_title").attr("title", webphone_api.stringres.get("hint_page"));
PopulateData();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: onStart", err); }
}
function MeasureAccountst() // resolve window height size change
{
try{
webphone_api.$('#page_accounts').css('min-height', 'auto'); // must be set when softphone is skin in div
var heightTemp = webphone_api.common.GetDeviceHeight() - webphone_api.$("#accounts_header").height(); // - webphone_api.$('#acc_footer').height();
heightTemp = heightTemp - 5;
webphone_api.$("#page_accounts_content").height(heightTemp);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: MeasureAccountst", err); }
}
var atemplate = '' +
'<div class="acc_item" id="acc_item_[NR]">' +
'<div class="acc_control">' +
'<input type="checkbox" class="acc_checkbox" id="acc_checkbox_[NR]" title="' + webphone_api.stringres.get('accounts_endis_hint') + '" name="acc_checkbox_[NR]" [ENABLE_CHECKED]>' +
'<input type="radio" class="acc_radio" id="acc_radio_[NR]" title="' + webphone_api.stringres.get('accounts_main_hint') + '" name="acc_active_selection" [MAIN_CHECKED]>' +
'</div>' +
'<div class="acc_username" id="acc_username_[NR]">[USERNAME]</div>' +
'<div class="acc_remove"><button id="btn_remove_account_[NR]" title="' + webphone_api.stringres.get('accounts_remove_hint') + '" class="btn_remove_account noshadow ui-btn-inline ui-btn ui-btn-corner-all ui-btn-b ui-icon-minus ui-btn-icon-notext">Remove</button></div>' +
'<div class="separator_color_bg"><!--//--></div>' +
'</div>';
function PopulateData()
{
try{
// check/uncheck radio buttons
var form = '';
// extraregisteraccounts = server,usr,pwd,ival;server2,usr2,pwd2, ival;
if (webphone_api.common.isNull(webphone_api.global.sipaccounts) || webphone_api.global.sipaccounts.length < 1)
{
webphone_api.$('.btn_remove_account').off('click');
webphone_api.$('#acc_list').html('<br /><br />' + webphone_api.stringres.get('noaccounts'));
return;
}
for (var i = 0; i < webphone_api.global.sipaccounts.length; i++)
{
var sipitem = webphone_api.global.sipaccounts[i];
var htmlitem = webphone_api.common.ReplaceAll(atemplate, '[NR]', i.toString());
var acc_name = sipitem.username;
if (!webphone_api.common.isNull(sipitem.serveraddress) && sipitem.serveraddress.length > 0)
{
acc_name = acc_name + '@' + sipitem.serveraddress;
}
htmlitem = htmlitem.replace('[USERNAME]', acc_name);
if (sipitem.ismain === true)
{
htmlitem = htmlitem.replace('[MAIN_CHECKED]', 'checked="checked"');
}else
{
htmlitem = htmlitem.replace('[MAIN_CHECKED]', '');
}
if (sipitem.enabled === true)
{
htmlitem = htmlitem.replace('[ENABLE_CHECKED]', 'checked="checked"');
}else
{
htmlitem = htmlitem.replace('[ENABLE_CHECKED]', '');
}
form = form + htmlitem;
}
webphone_api.$('#acc_list').html(form);
webphone_api.$('#acc_list').trigger('create');
webphone_api.$('.btn_remove_account').on('click', function (e)
{
try{
var id = webphone_api.$(this).attr('id');
if (!webphone_api.common.isNull(id) && id.lastIndexOf('_') > 0)
{
var idxstr = id.substring(id.lastIndexOf('_') + 1);
if (!webphone_api.common.isNull(idxstr) && webphone_api.common.IsNumber(idxstr) === true)
{
var idx = webphone_api.common.StrToInt(idxstr);
DeleteAccountPopup(idx);
}
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: remove account", err); }
});
webphone_api.$('.acc_checkbox').on('change', function (e)
{
try{
var id = webphone_api.$(this).attr('id');
if (!webphone_api.common.isNull(id) && id.lastIndexOf('_') > 0)
{
var checked = document.getElementById(id).checked;
var idxstr = id.substring(id.lastIndexOf('_') + 1);
if (!webphone_api.common.isNull(idxstr) && webphone_api.common.IsNumber(idxstr) === true)
{
var idx = webphone_api.common.StrToInt(idxstr);
webphone_api.global.sipaccounts[idx].enabled = checked;
var anychecked = false;
for (var i = 0; i < webphone_api.global.sipaccounts.length; i++)
{
if (i !== idx && webphone_api.global.sipaccounts[i].enabled === true)
{
anychecked = true;
break;
}
}
if (!anychecked)
{
if (webphone_api.global.sipaccounts.length > 1)
{
for (var i = 0; i < webphone_api.global.sipaccounts.length; i++)
{
if (i !== idx)
{
webphone_api.global.sipaccounts[i].enabled = true;
document.getElementById('acc_checkbox_' + i).checked = true;
// reset ismain
for (var j = 0; j < webphone_api.global.sipaccounts.length; j++) { webphone_api.global.sipaccounts[j].ismain = false; }
webphone_api.global.sipaccounts[i].ismain = true;
webphone_api.$('#acc_radio_' + i).prop('checked', true);
break;
}
}
}else
{
webphone_api.global.sipaccounts[0].enabled = true;
document.getElementById(id).checked = true;
// reset ismain
for (var j = 0; j < webphone_api.global.sipaccounts.length; j++) { webphone_api.global.sipaccounts[j].ismain = false; }
webphone_api.global.sipaccounts[0].ismain = true;
webphone_api.$('#acc_radio_0').prop('checked', true);
}
}else
{
if (checked === false && webphone_api.global.sipaccounts[idx].ismain === true)
{
// if we uncheck/disable the main account, then select another main account
for (var i = 0; i < webphone_api.global.sipaccounts.length; i++)
{
if (i === idx || webphone_api.global.sipaccounts[i].enabled === false) { continue; }
// reset ismain
for (var j = 0; j < webphone_api.global.sipaccounts.length; j++) { webphone_api.global.sipaccounts[j].ismain = false; }
webphone_api.global.sipaccounts[i].ismain = true;
break;
}
}
}
for (var i = 0; i < webphone_api.global.sipaccounts.length; i++)
{
if(webphone_api.$('#acc_radio_' + i).is(':checked'))
{
webphone_api.global.sipaccounts.ismain = true;
}else
{
webphone_api.global.sipaccounts.ismain = false;
}
}
webphone_api.$('.acc_checkbox').off('change');
webphone_api.common.SaveSipAccounts();
setTimeout(function ()
{
PopulateData();
}, 0);
}
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: change ismain", err); }
});
webphone_api.$(".acc_radio").change(function ()
{
try{
for (var i = 0; i < webphone_api.global.sipaccounts.length; i++)
{
if(webphone_api.$('#acc_radio_' + i).is(':checked'))
{
// reset ismain
for (var j = 0; j < webphone_api.global.sipaccounts.length; j++) { webphone_api.global.sipaccounts[j].ismain = false; }
webphone_api.global.sipaccounts[i].ismain = true;
if (webphone_api.global.sipaccounts[i].enabled === false)
{
webphone_api.global.sipaccounts[i].enabled = true;
}
webphone_api.$('.acc_radio').off('change');
webphone_api.common.SaveSipAccounts();
setTimeout(function ()
{
PopulateData();
}, 0);
break;
}
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: select ismain", err); }
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: PopulateData", err); }
}
function DeleteAccountPopup(idx, popupafterclose)
{
try{
var popupWidth = webphone_api.common.GetDeviceWidth();
if ( !webphone_api.common.isNull(popupWidth) && webphone_api.common.IsNumber(popupWidth) && popupWidth > 100 )
{
popupWidth = Math.floor(popupWidth / 1.2);
}else
{
popupWidth = 220;
}
if(popupWidth > 400) popupWidth = 400;
else if(popupWidth < 120) popupWidth = 120;
var acc_username = webphone_api.global.sipaccounts[idx].username;
var template = '' +
'<div id="adialog_deleteaccount" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:' + popupWidth + 'px;">' +
'<div data-role="header" data-theme="b">' +
'<a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a>' +
'<h1 class="adialog_title">' + webphone_api.stringres.get('accounts_remove_hint') + '</h1>' +
'</div>' +
'<div role="main" class="ui-content adialog_content adialog_alert">' +
'<span> ' + webphone_api.stringres.get('accounts_remove_msg') + ': ' + acc_username + ' </span>' +
// '<a href="javascript:;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back">' + webphone_api.stringres.get('btn_close') + '</a>' +
// '<a href="javascript:;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back" data-transition="flow">Delete</a>' +
'</div>' +
'<div data-role="footer" data-theme="b" class="adialog_footer">' +
'<a href="javascript:;" id="btn_adialog_ok" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">' + webphone_api.stringres.get('btn_ok') + '</a>' +
'<a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">' + webphone_api.stringres.get('btn_cancel') + '</a>' +
'</div>' +
'</div>';
popupafterclose = popupafterclose ? popupafterclose : function () {};
webphone_api.$.mobile.activePage.append(template).trigger("create");
//-- webphone_api.$.mobile.activePage.append(template).trigger("pagecreate");
webphone_api.$.mobile.activePage.find(".closePopup").bind("tap", function (e)
{
webphone_api.$.mobile.activePage.find(".messagePopup").popup("close");
});
webphone_api.$.mobile.activePage.find(".messagePopup").bind(
{
popupbeforeposition: function()
{
webphone_api.$(this).unbind("popupbeforeposition");//.remove();
var maxHeight = Math.floor( webphone_api.common.GetDeviceHeight() * 0.6 ); // webphone_api.$(window).height() - 120;
if (webphone_api.$(this).height() > maxHeight)
{
webphone_api.$('.messagePopup .ui-content').height(maxHeight);
}
}
});
webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind(
{
popupafterclose: function ()
{
webphone_api.$(this).unbind("popupafterclose").remove();
webphone_api.$('#btn_adialog_ok').off('click');
popupafterclose();
}
});
//-- listen for enter onclick, and click OK button
//-- no need for this, because it reloads the page
//-- webphone_api.$( "#adialog_deleteaccount" ).keypress(function( event )
//-- {
//-- if ( event.which === 13 )
//-- {
//-- event.preventDefault();
//-- webphone_api.$("#btn_adialog_ok").click();
//-- }else
//-- {
//-- return;
//-- }
//-- });
webphone_api.$('#btn_adialog_ok').on('click', function ()
{
try{
webphone_api.global.sipaccounts.splice(idx, 1);
webphone_api.common.PutToDebugLog(2, 'EVENT, _accounts, account removed: ' + idx);
var anychecked = false;
for (var i = 0; i < webphone_api.global.sipaccounts.length; i++)
{
if (i !== idx && webphone_api.global.sipaccounts[i].enabled === true)
{
anychecked = true;
}
}
if (!anychecked)
{
if (webphone_api.global.sipaccounts.length > 1)
{
for (var i = 0; i < webphone_api.global.sipaccounts.length; i++)
{
if (i !== idx)
{
webphone_api.global.sipaccounts[i].enabled = true;
document.getElementById('acc_checkbox_' + i).checked = true;
// reset ismain
for (var j = 0; j < webphone_api.global.sipaccounts.length; j++) { webphone_api.global.sipaccounts[j].ismain = false; }
webphone_api.global.sipaccounts[i].ismain = true;
webphone_api.$('#acc_radio_' + i).prop('checked', true);
break;
}
}
}else
{
if (!webphone_api.common.isNull(webphone_api.global.sipaccounts) && webphone_api.global.sipaccounts.length > 0)
{
webphone_api.global.sipaccounts[0].enabled = true;
//document.getElementById(id).checked = true;
document.getElementById('acc_checkbox_0').checked = true;
// reset ismain
for (var j = 0; j < webphone_api.global.sipaccounts.length; j++) { webphone_api.global.sipaccounts[j].ismain = false; }
webphone_api.global.sipaccounts[0].ismain = true;
webphone_api.$('#acc_radio_0').prop('checked', true);
}
}
}
webphone_api.common.SaveSipAccounts();
PopulateData();
if (webphone_api.global.sipaccounts.length < 1)
{
AddAccount();
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: DeleteAccountPopup inner OK", err); }
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: DeleteAccountPopup", err); }
}
function AddAccount(popupafterclose)
{
try{
var popupWidth = webphone_api.common.GetDeviceWidth();
if ( !webphone_api.common.isNull(popupWidth) && webphone_api.common.IsNumber(popupWidth) && popupWidth > 100 )
{
popupWidth = Math.floor(popupWidth / 1.2);
}else
{
popupWidth = 220;
}
if(popupWidth > 400) popupWidth = 400;
else if(popupWidth < 120) popupWidth = 120;
var accounts_hint_server = webphone_api.stringres.get('accounts_hint_server');
var accounts_hint_user = webphone_api.stringres.get('accounts_hint_user');
var accounts_hint_password = webphone_api.stringres.get('accounts_hint_password');
var accounts_hint_callerid = webphone_api.stringres.get('accounts_hint_callerid');
var accounts_hint_displayname = webphone_api.stringres.get('accounts_hint_displayname');
var accounts_hint_proxy = webphone_api.stringres.get('accounts_hint_proxy');
var accounts_hint_realm = webphone_api.stringres.get('accounts_hint_realm');
var accounts_hint_regival = webphone_api.stringres.get('accounts_hint_regival');
var serverHtml = '';
if (webphone_api.common.ShowServerInput() === true)
{
var srv = webphone_api.common.GetParameter('serveraddress_user');
var val = '';
if (!webphone_api.common.isNull(srv) && srv.length > 0) { val = 'value="' + srv + '"'; }
serverHtml = '<label for="addacc_serveraddress">' + webphone_api.stringres.get('addacc_server') + ':</label>'+
'<input type="text" id="addacc_serveraddress" name="addacc_serveraddress" data-theme="a" autocapitalize="off" ' + val + ' placeholder="' + accounts_hint_server + '" />';
}
var pwdautocomplete = webphone_api.common.GetParameterInt('pwdautocomplete', -1);
var autocompleteflag = '';
if(pwdautocomplete === 1) autocompleteflag = 'autocomplete="on"';
else if(pwdautocomplete == 0) autocompleteflag = 'autocomplete="off"';
var hidepassword = webphone_api.common.GetParameterInt('hidepassword', 4);
var pwdinputtype = 'text';
if(hidepassword > 1) pwdinputtype = 'password';
var template = '' +
'<div id="addaccountpopup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:' + popupWidth + 'px;">' +
'<div data-role="header" data-theme="b">' +
'<a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a>' +
'<h1 class="adialog_title">' + webphone_api.stringres.get('addaccount_title') + '</h1>' +
'</div>' +
'<div role="main" class="ui-content adialog_content" style="margin-right: 1em;">' +
'<style>#addaccountpopup LABEL{ text-align: left; font-size: .8em; }</style>' +
'<span>' + webphone_api.stringres.get('addaccount_msg') + '</span>' +
serverHtml +
'<label for="addacc_username">' + webphone_api.stringres.get('addacc_user') + ':</label>'+
'<input type="text" id="addacc_username" name="addacc_username" data-theme="a" autocapitalize="off" placeholder="' + accounts_hint_user+ '" />' +
'<label for="addacc_password">' + webphone_api.stringres.get('addacc_password') + ':</label>'+
'<input type="'+pwdinputtype+'" id="addacc_password" name="addacc_password" data-theme="a" autocapitalize="off" '+autocompleteflag+' placeholder="' + accounts_hint_password + '" />' +
'<br />' +
'<a href="javascript:;" id="show_hide_advanced">' + webphone_api.stringres.get('ac_showadvanced') + '</a>' +
'<br />' +
'<br />' +
'<div id="addaccountpopup_advanced" style="display: none; margin-left: 2em;">' +
'<label for="addacc_callerid">' + webphone_api.stringres.get('sett_display_name_username') + ':</label>'+
'<input type="text" id="addacc_callerid" name="addacc_callerid" value="" data-theme="a" autocapitalize="off" placeholder="' + accounts_hint_callerid + '" />' +
'<label for="addacc_displayname">' + webphone_api.stringres.get('sett_display_name_displayname') + ':</label>'+
'<input type="text" id="addacc_displayname" name="addacc_displayname" value="" data-theme="a" autocapitalize="off" placeholder="' + accounts_hint_displayname + '" />' +
'<label for="addacc_proxyaddress">' + webphone_api.stringres.get('sett_display_name_proxyaddress') + ':</label>'+
'<input type="text" id="addacc_proxyaddress" name="addacc_proxyaddress" value="" data-theme="a" autocapitalize="off" placeholder="' + accounts_hint_proxy + '" />' +
'<label for="addacc_realm">' + webphone_api.stringres.get('sett_display_name_realm') + ':</label>'+
'<input type="text" id="addacc_realm" name="addacc_realm" value="" data-theme="a" autocapitalize="off" placeholder="' + accounts_hint_realm + '" />' +
'<br /><label for="addacc_ival">' + webphone_api.stringres.get('addacc_ival') + ':</label>'+
'<input type="text" id="addacc_ival" name="addacc_ival" value="3600" data-theme="a" autocapitalize="off" placeholder="' + accounts_hint_regival + '" />' +
'</div>'+
'</div>' +
'<div data-role="footer" data-theme="b" class="adialog_footer">' +
'<a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">' + webphone_api.stringres.get('btn_ok') + '</a>' +
'<a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">' + webphone_api.stringres.get('btn_cancel') + '</a>' +
'</div>' +
'</div>';
var popupafterclose = function () {};
webphone_api.$.mobile.activePage.append(template).trigger("create");
webphone_api.$.mobile.activePage.find(".closePopup").bind("tap", function (e)
{
webphone_api.$.mobile.activePage.find(".messagePopup").popup("close");
});
webphone_api.$.mobile.activePage.find(".messagePopup").bind(
{
popupbeforeposition: function()
{
//webphone_api.$(this).unbind("popupbeforeposition");//.remove();
var maxHeight = Math.floor( webphone_api.common.GetDeviceHeight() * 0.6 ); // webphone_api.$(window).height() - 120;
if (webphone_api.$(this).height() > maxHeight + 100)
{
webphone_api.$('.messagePopup .ui-content').height(maxHeight);
}
}
});
webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind(
{
popupafterclose: function ()
{
webphone_api.$(this).unbind("popupafterclose").remove();
webphone_api.$('#adialog_positive').off('click');
webphone_api.$('#adialog_negative').off('click');
popupafterclose();
}
});
webphone_api.$('#adialog_positive').on('click', function (event)
{
var srv = webphone_api.$('#addacc_serveraddress').val();
var usr = webphone_api.$('#addacc_username').val();
var pwd = webphone_api.$('#addacc_password').val();
var callerid = webphone_api.$('#addacc_callerid').val();
var displayname = webphone_api.$('#addacc_displayname').val();
var proxyaddress = webphone_api.$('#addacc_proxyaddress').val();
var realm = webphone_api.$('#addacc_realm').val();
var ivalstr = webphone_api.$('#addacc_ival').val();
webphone_api.$( '#addaccountpopup' ).on( 'popupafterclose', function( event )
{
if (webphone_api.common.GetBrowser() === 'MSIE') { event.preventDefault(); }
webphone_api.common.PutToDebugLog(5,"EVENT, accounts AddAccount ok onclick");
ManuallyClosePopup(webphone_api.$.mobile.activePage.find(".messagePopup"));
if (webphone_api.common.ShowServerInput() === true)
{
if (webphone_api.common.isNull(srv) || srv.length < 1) { webphone_api.common.ShowToast(webphone_api.stringres.get('addacc_invalid') + ' ' + webphone_api.stringres.get('addacc_server')); return; }
}else
{
srv = webphone_api.common.GetParameter('serveraddress');
if (webphone_api.common.isNull(srv) || srv.length < 1) { srv = webphone_api.common.GetParameter('serveraddress_user'); }
}
if (webphone_api.common.isNull(usr) || usr.length < 1) { webphone_api.common.ShowToast(webphone_api.stringres.get('addacc_invalid') + ' ' + webphone_api.stringres.get('addacc_user')); return; }
if (webphone_api.common.isNull(pwd) || pwd.length < 1) { webphone_api.common.ShowToast(webphone_api.stringres.get('addacc_invalid') + ' ' + webphone_api.stringres.get('addacc_password')); return; }
if (webphone_api.common.isNull(ivalstr) || ivalstr.length < 1 || !webphone_api.common.IsNumber(ivalstr)) { webphone_api.common.ShowToast(webphone_api.stringres.get('addacc_invalid') + ' ' + webphone_api.stringres.get('addacc_ival')); return; }
srv = webphone_api.common.NormalizeInput(srv, 0);
usr = webphone_api.common.NormalizeInput(usr, 0);
ivalstr = webphone_api.common.NormalizeInput(ivalstr, 0);
if (webphone_api.common.isNull(callerid)) { callerid = ''; }
if (webphone_api.common.isNull(displayname)) { displayname = ''; }
if (webphone_api.common.isNull(proxyaddress)) { proxyaddress = ''; }
if (webphone_api.common.isNull(realm)) { realm = ''; }
callerid = webphone_api.common.NormalizeInput(callerid, 0);
displayname = webphone_api.common.NormalizeInput(displayname, 0);
proxyaddress = webphone_api.common.NormalizeInput(proxyaddress, 0);
realm = webphone_api.common.NormalizeInput(realm, 0);
if (webphone_api.common.isNull(ivalstr) || webphone_api.common.IsNumber(ivalstr) == false) { ivalstr = '3600'; }
var ival = webphone_api.common.StrToInt(ivalstr);
var ismain = false;
if (webphone_api.global.sipaccounts.length < 1) { ismain = true; }
webphone_api.common.AddOneAcc(srv, usr, pwd, ival, true, ismain, false, callerid, displayname, proxyaddress, realm);
PopulateData();
});
});
webphone_api.$('#adialog_negative').on('click', function (event)
{
if (webphone_api.common.GetBrowser() === 'MSIE') { event.preventDefault(); }
ManuallyClosePopup(webphone_api.$.mobile.activePage.find(".messagePopup"));
});
webphone_api.$('#show_hide_advanced').on('click', function (event)
{
if (webphone_api.$('#addaccountpopup_advanced').is(':visible'))
{
webphone_api.$('#addaccountpopup_advanced').hide();
webphone_api.$('#show_hide_advanced').html(webphone_api.stringres.get('ac_showadvanced'));
var maxHeight = Math.floor( webphone_api.common.GetDeviceHeight() * 0.6 ); // webphone_api.$(window).height() - 120;
if (webphone_api.$('.messagePopup .ui-content').height() > maxHeight + 100)
{
webphone_api.$('.messagePopup .ui-content').height(maxHeight);
}
}else
{
webphone_api.$('#addaccountpopup_advanced').show();
webphone_api.$('#show_hide_advanced').html(webphone_api.stringres.get('ac_hideadvanced'));
var maxHeight = Math.floor( webphone_api.common.GetDeviceHeight() * 0.6 ); // webphone_api.$(window).height() - 120;
if (webphone_api.$('.messagePopup .ui-content').height() > maxHeight + 100)
{
webphone_api.$('.messagePopup .ui-content').height(maxHeight);
}
}
if (webphone_api.common.GetBrowser() === 'MSIE') { event.preventDefault(); }
ManuallyClosePopup(webphone_api.$.mobile.activePage.find(".messagePopup"));
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: AddAccount", err); }
}
function HandleKeyUp(event)
{
try{
//-- don't catch input if a popup is open, because popups can have input boxes, and we won't be able to write into them
if (webphone_api.$(".ui-page-active .ui-popup-active").length > 0)
{
return false;
}
var charCode = (event.keyCode) ? event.keyCode : event.which; // workaround for firefox
if ( charCode === 8) // backspace
{
event.preventDefault();
webphone_api.$.mobile.back();
}
//-- else if ( charCode === 13)
//-- {
//-- event.preventDefault();
//-- webphone_api.$("#btn_call").click();
//-- }
return false;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: HandleKeyUp", err); }
}
function ManuallyClosePopup(popupelement) // workaround for IE, sometimes popups are not closed simply by clicking the button, so we close it manually
{
try{
if (webphone_api.common.isNull(popupelement) || webphone_api.common.isNull(popupelement.popup)) { return; }
if (webphone_api.common.GetBrowser() === 'MSIE')
{
popupelement.popup("close");
}
else if (webphone_api.common.GetBrowser() === 'Firefox')
{
setTimeout(function ()
{
try{
popupelement.popup("close"); // it will throw exception in may cases
} catch(err) { ; }
}, 200);
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: ManuallyClosePopup", err); }
}
var MENUITEM_ACCOUNTS_CLOSE = '#menuitem_accounts_close';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.IsWindowsSoftphone())
{
webphone_api.$( "#btn_accounts_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _accounts: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _accounts: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_ACCOUNTS_CLOSE + '"><a data-rel="back">' + webphone_api.stringres.get('btn_close') + '</a></li>' ).listview('refresh');
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#accounts_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#accounts_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_ACCOUNTS_CLOSE:
webphone_api.$.mobile.back();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: MenuItemSelected", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _accounts: onStop");
webphone_api.global.isAccountsStarted = false;
webphone_api.$('.btn_remove_account').off('click');
webphone_api.$('#btn_add_acc').off('click');
webphone_api.$('#acc_list').html('');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_accounts: onStop", err); }
}
function onDestroy (event){} // deprecated by onstop
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop,
onDestroy: onDestroy
};
})();
@@ -0,0 +1,898 @@
// AddEditContact page
webphone_api._addeditcontact = (function ()
{
var action = '';
var numberToAdd = '';
var nameToAdd = '';
var ctid = -1;
var name = '';
var nameField = null;
var contact = null;
var numbers = null;
var types = null;
function onCreate (event) // called only once - bind events here
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _addeditcontact: onCreate");
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_addeditcontact')
{
MeasureAddeditcontact();
}
});
webphone_api.$('#addeditcontact_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_addeditcontact_menu").on("click", function() { CreateOptionsMenu('#addeditcontact_menu_ul'); });
webphone_api.$("#btn_addeditcontact_menu").attr("title", webphone_api.stringres.get("hint_menu"));
webphone_api.$("#btn_save_aec").on("click", function() { SaveContact(); });
webphone_api.$("#btn_revert_aec").on("click", function() { webphone_api.$.mobile.back(); });
webphone_api.$("#btn_add_aec").on("click", function() { AddPhoneField(null, null, true); });
webphone_api.$("#btn_add_aec").attr("title", webphone_api.stringres.get("hint_addphone"));
webphone_api.$(".minus_btn").attr("title", webphone_api.stringres.get("hint_removephone"));
webphone_api.$("#btn_add_aec_details").on("click", function() { AddDetailsField(); });
webphone_api.$("#btn_add_aec_details").attr("title", webphone_api.stringres.get("addeditct_hint_adddetails"));
var fieldcount = webphone_api.$('#aec_number_fields').children().length;
if (!webphone_api.common.isNull(fieldcount) && fieldcount > 0)
{
for (var i = 0; i < fieldcount; i++)
{
(function (i)
{
webphone_api.$('#btn_type_aec_' + i).on('click', function() { ChooseType(i, webphone_api.$(this).html()); });
webphone_api.$('#btn_minus_aec_' + i).on('click', function() { RemoveEntry(i); });
}(i));
}
}
webphone_api.$( "#page_addeditcontact" ).keyup(function(event)
{
HandleKeyUp(event);
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: onCreate", err); }
}
function HandleKeyUp(event)
{
try{
//-- don't catch input if a popup is open, because popups can have input boxes, and we won't be able to write into them
if (webphone_api.$(".ui-page-active .ui-popup-active").length > 0)
{
return false;
}
var charCode = (event.keyCode) ? event.keyCode : event.which; // workaround for firefox
if (charCode === 13) // enter
{
webphone_api.$("#btn_save_aec").click();
event.preventDefault();
}
else if (charCode === 27) // ESC or Backspace
{
webphone_api.$("#btn_revert_aec").click();
event.preventDefault();
}
return false;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: HandleKeyUp", err); }
}
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _addeditcontact: onStart");
webphone_api.global.isAddeditcontactStarted = true;
//-- webphone_api.$("#phone_number").attr("placeholder", webphone_api.stringres.get("phone_nr"));
//-- document.getElementById("app_name_addeditcontact").innerHTML = webphone_api.common.GetBrandName();
document.getElementById('aec_label_name').innerHTML = webphone_api.stringres.get('contact_name');
webphone_api.$('#aec_name').attr('placeholder', webphone_api.stringres.get('contact_name'));
webphone_api.$('#aec_lastname').attr('placeholder', webphone_api.stringres.get('contact_lastname'));
document.getElementById('aec_label_phone').innerHTML = webphone_api.stringres.get('contact_phone');
document.getElementById('btn_save_aec').innerHTML = webphone_api.stringres.get('btn_save');
document.getElementById('btn_revert_aec').innerHTML = webphone_api.stringres.get('btn_cancel');
webphone_api.$("#addeditcontact_list").attr("data-filter-placeholder", webphone_api.stringres.get("ct_search_hint"));
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#page_addeditcontact'), -30) );
if (!webphone_api.common.isNull(document.getElementById('addeditct_btnback')))
{
document.getElementById('addeditct_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get('btn_cancel');
}
webphone_api.$('#aec_label_details').html(webphone_api.stringres.get('addeditct_addfield'));
webphone_api.$('#aec_entry_email label').html(webphone_api.stringres.get('addeditct_label_email') + ':');
webphone_api.$('#aec_entry_address label').html(webphone_api.stringres.get('addeditct_label_address') + ':');
webphone_api.$('#aec_entry_notes label').html(webphone_api.stringres.get('addeditct_label_notes') + ':');
webphone_api.$('#aec_entry_website label').html(webphone_api.stringres.get('addeditct_label_website') + ':');
// needed for proper display and scrolling of listview
MeasureAddeditcontact();
setTimeout(function () { MeasureAddeditcontact(); }, 1000);
action = webphone_api.common.GetIntentParam(webphone_api.global.intentaddeditct, 'action');
if (!webphone_api.common.isNull(action) && action.length > 0)
{
if (action === 'add')
{
numberToAdd = webphone_api.common.GetIntentParam(webphone_api.global.intentaddeditct, 'numbertoadd');
nameToAdd = webphone_api.common.GetIntentParam(webphone_api.global.intentaddeditct, 'nametoadd');
if (webphone_api.common.isNull(nameToAdd)) { nameToAdd = ''; }
document.getElementById('addeditct_title').innerHTML = webphone_api.stringres.get('addeditct_title_new');
}else if (action === 'edit')
{
try{
ctid = webphone_api.common.StrToInt(webphone_api.common.GetIntentParam(webphone_api.global.intentaddeditct, 'ctid'));
} catch(errin) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: onStart can't convert contact id", errin); }
contact = webphone_api.global.ctlist[ctid];
numbers = contact[webphone_api.common.CT_NUMBER];
types = contact[webphone_api.common.CT_PTYPE];
document.getElementById('addeditct_title').innerHTML = webphone_api.stringres.get('addeditct_title_edit');
}else
{
webphone_api.$.mobile.back();
}
}
webphone_api.$("#addeditct_title").attr("title", webphone_api.stringres.get("hint_page"));
if (!webphone_api.common.isNull(contact) && contact.length > 0) { name = contact[webphone_api.common.CT_NAME]; }
nameField = document.getElementById('aec_name');
if (action === 'add' && !webphone_api.common.isNull(nameField))
{
nameField.focus(); // setting cursor to text input
}
PopulateData();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: onStart", err); }
}
function MeasureAddeditcontact() // resolve window height size change
{
try{
webphone_api.$('#page_addeditcontact').css('min-height', 'auto'); // must be set when softphone is skin in div
var heightTemp = webphone_api.common.GetDeviceHeight() - webphone_api.$("#addeditcontact_header").height() - webphone_api.$('#aec_footer').height();
heightTemp = heightTemp - 5;
webphone_api.$("#page_addeditcontact_content").height(heightTemp);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: MeasureAddeditcontact", err); }
}
function PopulateData()
{
try{
if (action === 'add')
{
if (nameToAdd.length > 0) { nameField.value = nameToAdd; }
if (!webphone_api.common.isNull(numberToAdd) && numberToAdd.length > 0)
{
AddPhoneField('', webphone_api.common.Trim(numberToAdd), false);
}else
{
AddPhoneField('', '', false);
}
}else if (action === 'edit')
{
nameField.value = webphone_api.common.Trim(name);
if (ctid < 0)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, _addeditcontact PopulateData incorrect ctid');
return;
}
if (webphone_api.common.isNull(numbers) || numbers.length < 1)
{
return;
}
var availableLayouts = webphone_api.$('#aec_number_fields').children().length;
for (var i = 0; i < numbers.length; i++)
{
if (i >= availableLayouts) { break; }
var typetmp = '';
if (!webphone_api.common.isNull(types[i])) typetmp = types[i];
AddPhoneField(typetmp, numbers[i], false);
}
var ctemail = contact[webphone_api.common.CT_EMAIL];
var ctaddress = contact[webphone_api.common.CT_ADDRESS];
var ctnotes = contact[webphone_api.common.CT_NOTES];
var ctwebsite = contact[webphone_api.common.CT_WEBSITE];
if (!webphone_api.common.isNull(ctemail) && webphone_api.common.Trim(ctemail).length > 0) { webphone_api.$('#number_aec_email').val(ctemail); webphone_api.$('#aec_entry_email').show(); }
if (!webphone_api.common.isNull(ctaddress) && webphone_api.common.Trim(ctaddress).length > 0) { webphone_api.$('#number_aec_address').val(ctaddress); webphone_api.$('#aec_entry_address').show(); }
if (!webphone_api.common.isNull(ctnotes) && webphone_api.common.Trim(ctnotes).length > 0) { webphone_api.$('#number_aec_notes').val(ctnotes); webphone_api.$('#aec_entry_notes').show(); }
if (!webphone_api.common.isNull(ctwebsite) && webphone_api.common.Trim(ctwebsite).length > 0) { webphone_api.$('#number_aec_website').val(ctwebsite); webphone_api.$('#aec_entry_website').show(); }
}
//hide add field button, if all possible fields are already added
//email, address, notes, website
if (webphone_api.$('#aec_entry_email').is(':visible') && webphone_api.$('#aec_entry_address').is(':visible') && webphone_api.$('#aec_entry_notes').is(':visible') && webphone_api.$('#aec_entry_website').is(':visible'))
{
webphone_api.$('#aec_add_deatils').hide();
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: PopulateData", err); }
}
function AddPhoneField(type, number, isonclick)
{
try{
if (isonclick)
{
webphone_api.common.PutToDebugLog(5, 'EVENT, _addeditcontact: AddPhoneField on click');
}
// default value
if (webphone_api.common.isNull(type) || type.length < 3) { type = 'phone'; }
if (webphone_api.common.isNull(number)) { number = ''; }
var fieldcount = webphone_api.$('#aec_number_fields').children().length;
var elements = webphone_api.$('#aec_number_fields').children();
if (webphone_api.common.isNull(fieldcount) || fieldcount < 1) { return; }
for (var i = 0; i < fieldcount; i++)
{
var newelement = document.getElementById('aec_entry_' + i);
if ( !webphone_api.common.isNull(newelement) && newelement.style.display === 'none')
{
newelement.style.display = 'block';
webphone_api.$('#btn_type_aec_' + i).html(webphone_api.stringres.get(type));
webphone_api.$('#number_aec_' + i).val(number);
if (isonclick) { webphone_api.$('#btn_type_aec_' + i).click(); } // display choose type if new field added
break;
}
}
/*
var template =
'<div id="aec_entry_' + fieldcount + '" class="aec_numbers">' +
'<button id="btn_type_aec_' + fieldcount + '" class="aec_phonetype ui-btn-inline ui-btn ui-btn-corner-all ui-btn-b noshadow">' + webphone_api.stringres.get(type)+ '</button>' +
'<input type="text" value="' + number + '" id="number_aec_' + fieldcount + '" name="number" data-theme="a"/>' +
'<div id="btn_minus_aec_' + fieldcount + '" class="minus_btn"><button class="aec_remove noshadow ui-btn-inline ui-btn ui-btn-corner-all ui-btn-b ui-icon-minus ui-btn-icon-notext">Remove</button></div>' +
'</div>';
webphone_api.$('#aec_number_fields').append(template).trigger('create');*/
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: AddPhoneField", err); }
}
function AddDetailsField(popupafterclose)
{
try{
var popupWidth = webphone_api.common.GetDeviceWidth();
if ( !webphone_api.common.isNull(popupWidth) && webphone_api.common.IsNumber(popupWidth) && popupWidth > 100 )
{
popupWidth = Math.floor(popupWidth / 1.2);
}else
{
popupWidth = 220;
}
if(popupWidth > 400) popupWidth = 400;
else if(popupWidth < 120) popupWidth = 120;
var list = '';
//email, address, notes, website
var i_email = '<li id="#addfield_item_email"><a data-rel="back">' + webphone_api.stringres.get('addeditct_label_email') + '</a></li>';
var i_address = '<li id="#addfield_item_address"><a data-rel="back">' + webphone_api.stringres.get('addeditct_label_address') + '</a></li>';
var i_notes = '<li id="#addfield_item_notes"><a data-rel="back">' + webphone_api.stringres.get('addeditct_label_notes') + '</a></li>';
var i_website = '<li id="#addfield_item_website"><a data-rel="back">' + webphone_api.stringres.get('addeditct_label_website') + '</a></li>';
if (!webphone_api.$('#aec_entry_email').is(':visible')) { list = list + i_email; }
if (!webphone_api.$('#aec_entry_address').is(':visible')) { list = list + i_address; }
if (!webphone_api.$('#aec_entry_notes').is(':visible')) { list = list + i_notes; }
if (!webphone_api.$('#aec_entry_website').is(':visible')) { list = list + i_website; }
var template = '' +
'<div id="addfieldpopup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:' + popupWidth + 'px; min-width: ' + Math.floor(popupWidth * 0.6) + 'px;">' +
'<div data-role="header" data-theme="b">' +
'<a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a>' +
'<h1 class="adialog_title">' + webphone_api.stringres.get('addeditct_hint_adddetails') + '</h1>' +
'</div>' +
'<div role="main" class="ui-content adialog_content" style="padding: 0; margin: 0;">' +
'<ul id="addfieldpopup_ul" data-role="listview" data-inset="true" data-icon="false" style="margin: 0;">' +
list +
'</ul>' +
// '<a href="javascript:;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back">' + webphone_api.stringres.get('btn_close') + '</a>' +
// '<a href="javascript:;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back" data-transition="flow">Delete</a>' +
'</div>' +
// '<div data-role="footer" data-theme="b" class="adialog_footer">' +
// '<a href="javascript:;" style="width: 98%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">' + webphone_api.stringres.get('btn_close') + '</a>' +
// '</div>' +
'</div>';
popupafterclose = popupafterclose ? popupafterclose : function () {};
webphone_api.$.mobile.activePage.append(template).trigger("create");
webphone_api.$.mobile.activePage.find(".closePopup").bind("tap", function (e)
{
webphone_api.$.mobile.activePage.find(".messagePopup").popup("close");
});
webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind(
{
popupafterclose: function ()
{
webphone_api.$(this).unbind("popupafterclose").remove();
webphone_api.$('#addfieldpopup_ul').off('click', 'li');
popupafterclose();
}
});
webphone_api.$('#addfieldpopup_ul').on('click', 'li', function(event)
{
var itemid = webphone_api.$(this).attr('id');
webphone_api.$( '#addfieldpopup' ).on( 'popupafterclose', function( event )
{
if (itemid === '#addfield_item_email') { webphone_api.$('#aec_entry_email').show(); }
if (itemid === '#addfield_item_address') { webphone_api.$('#aec_entry_address').show(); }
if (itemid === '#addfield_item_notes') { webphone_api.$('#aec_entry_notes').show(); }
if (itemid === '#addfield_item_website') { webphone_api.$('#aec_entry_website').show(); }
//hide add field button, if all possible fields are already added
//email, address, notes, website
if (webphone_api.$('#aec_entry_email').is(':visible') && webphone_api.$('#aec_entry_address').is(':visible') && webphone_api.$('#aec_entry_notes').is(':visible') && webphone_api.$('#aec_entry_website').is(':visible'))
{
webphone_api.$('#aec_add_deatils').hide();
}
});
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: AddDetailsField", err); }
}
function ChooseType (idnr, type, popupafterclose)
{
try{
var popupWidth = webphone_api.common.GetDeviceWidth();
if ( !webphone_api.common.isNull(popupWidth) && webphone_api.common.IsNumber(popupWidth) && popupWidth > 100 )
{
popupWidth = Math.floor(popupWidth / 1.2);
}else
{
popupWidth = 220;
}
if(popupWidth > 400) popupWidth = 400;
else if(popupWidth < 120) popupWidth = 120;
var checked_phone = '';
var checked_home = '';
var checked_mobile = '';
var checked_work = '';
var checked_other = '';
var checked_fax_home = '';
var checked_fax_work = '';
var checked_pager = '';
var checked_sip = '';
if (!webphone_api.common.isNull(type) && type.length > 0)
{
if (type === webphone_api.stringres.get('phone')) { checked_phone = 'checked="checked"'; }
if (type === webphone_api.stringres.get('home')) { checked_home = 'checked="checked"'; }
if (type === webphone_api.stringres.get('mobile')) { checked_mobile = 'checked="checked"'; }
if (type === webphone_api.stringres.get('work')) { checked_work = 'checked="checked"'; }
if (type === webphone_api.stringres.get('other')) { checked_other = 'checked="checked"'; }
if (type === webphone_api.stringres.get('fax_home')) { checked_fax_home = 'checked="checked"'; }
if (type === webphone_api.stringres.get('fax_work')) { checked_fax_work = 'checked="checked"'; }
if (type === webphone_api.stringres.get('pager')) { checked_pager = 'checked="checked"'; }
if (type === webphone_api.stringres.get('sip')) { checked_sip = 'checked="checked"'; }
}else
{
// default value
checked_phone = 'checked="checked"';
}
var radiob = '' +
'<form>' +
'<fieldset data-role="controlgroup">' +
'<input name="phone_type" id="radio_phone" value="on" ' + checked_phone + ' type="radio">' +
'<label for="radio_phone">' + webphone_api.stringres.get('phone') + '</label>' +
'<input name="phone_type" id="radio_home" value="on" ' + checked_home + ' type="radio">' +
'<label for="radio_home">' + webphone_api.stringres.get('home') + '</label>' +
'<input name="phone_type" id="radio_mobile" value="on" ' + checked_mobile + ' type="radio">' +
'<label for="radio_mobile">' + webphone_api.stringres.get('mobile') + '</label>' +
'<input name="phone_type" id="radio_work" value="on" ' + checked_work + ' type="radio">' +
'<label for="radio_work">' + webphone_api.stringres.get('work') + '</label>' +
'<input name="phone_type" id="radio_other" value="on" ' + checked_other + ' type="radio">' +
'<label for="radio_other">' + webphone_api.stringres.get('other') + '</label>' +
'<input name="phone_type" id="radio_fax_home" value="on" ' + checked_fax_home + ' type="radio">' +
'<label for="radio_fax_home">' + webphone_api.stringres.get('fax_home') + '</label>' +
'<input name="phone_type" id="radio_fax_work" value="on" ' + checked_fax_work + ' type="radio">' +
'<label for="radio_fax_work">' + webphone_api.stringres.get('fax_work') + '</label>' +
'<input name="phone_type" id="radio_pager" value="on" ' + checked_pager + ' type="radio">' +
'<label for="radio_pager">' + webphone_api.stringres.get('pager') + '</label>' +
'<input name="phone_type" id="radio_sip" value="on" ' + checked_sip + ' type="radio">' +
'<label for="radio_sip">' + webphone_api.stringres.get('sip') + '</label>' +
'</fieldset>' +
'</form>';
var template = '' +
'<div data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:' + popupWidth + 'px; min-width: ' + Math.floor(popupWidth * 0.6) + 'px;">' +
'<div data-role="header" data-theme="b">' +
'<a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a>' +
'<h1 class="adialog_title">' + webphone_api.stringres.get('contact_alert_title') + '</h1>' +
'</div>' +
'<div role="main" class="ui-content">' +
radiob +
'</div>' +
// '<div data-role="footer" data-theme="b" class="adialog_footer">' +
// '<a href="javascript:;" style="width: 98%;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">' + webphone_api.stringres.get('btn_close') + '</a>' +
// '</div>' +
'</div>';
popupafterclose = popupafterclose ? popupafterclose : function () {};
webphone_api.$.mobile.activePage.append(template).trigger("create");
webphone_api.$.mobile.activePage.find(".closePopup").bind("tap", function (e)
{
webphone_api.$.mobile.activePage.find(".messagePopup").popup("close");
});
webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind(
{
popupafterclose: function ()
{
webphone_api.$(this).unbind("popupafterclose").remove();
popupafterclose();
}
});
webphone_api.$(":radio").on ("change", function (event)
{
webphone_api.$.mobile.activePage.find(".messagePopup").popup("close");
var newtype = webphone_api.$(this).attr ("id");
if (webphone_api.common.isNull(newtype) || newtype.length < 1) { return; }
var pos = newtype.indexOf('_');
if (pos > 0 && pos < newtype.length)
{
newtype = newtype.substring(pos + 1);
}
//-- alert (webphone_api.$(this).attr ("id"));
webphone_api.$('#btn_type_aec_' + idnr).html(webphone_api.stringres.get(newtype));
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: ChooseType", err); }
}
function RemoveEntry (idnr)
{
try{
var elem = document.getElementById('aec_entry_' + idnr);
if (!webphone_api.common.isNull(elem))
{
elem.style.display = 'none';
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: RemoveEntry", err); }
}
function SaveContact()
{
try{
if (action === 'add')
{
SaveNewContact();
}else if (action === 'edit')
{
SaveEditedContact();
}else
{
return;
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: SaveContact", err); }
}
function SaveEditedContact()
{
try{
var currName = nameField.value;
if (webphone_api.common.isNull(currName)) { currName = ''; }
currName = webphone_api.common.Trim(currName);
var fieldcount = webphone_api.$('#aec_number_fields').children().length;
if (webphone_api.common.isNull(fieldcount) || fieldcount < 1)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, SaveEditedContact fieldcount is null');
return;
}
var numbersTemp = [];
var typesTemp = [];
var idx = 0;
for (var i = 0; i < fieldcount; i++)
{
var itemField = document.getElementById('aec_entry_' + i);
var nrtemp = webphone_api.$('#number_aec_' + i).val();
var typefieldTemp = webphone_api.$('#btn_type_aec_' + i).html();
var tptemp = webphone_api.stringres.get('mobile');
if (webphone_api.common.isNull(itemField) || itemField.style.display === 'none')
{
continue;
}
if ( webphone_api.common.isNull(nrtemp) || (webphone_api.common.Trim(nrtemp)).length < 1 )
{
continue;
}
if (typefieldTemp === webphone_api.stringres.get('phone')) { tptemp = 'phone'; }
if (typefieldTemp === webphone_api.stringres.get('home')) { tptemp = 'home'; }
if (typefieldTemp === webphone_api.stringres.get('mobile')) { tptemp = 'mobile'; }
if (typefieldTemp === webphone_api.stringres.get('work')) { tptemp = 'work'; }
if (typefieldTemp === webphone_api.stringres.get('other')) { tptemp = 'other'; }
if (typefieldTemp === webphone_api.stringres.get('fax_home')) { tptemp = 'fax_home'; }
if (typefieldTemp === webphone_api.stringres.get('fax_work')) { tptemp = 'fax_work'; }
if (typefieldTemp === webphone_api.stringres.get('pager')) { tptemp = 'pager'; }
if (typefieldTemp === webphone_api.stringres.get('sip')) { tptemp = 'sip'; }
//-- ['John Doe', ['40724335123', '0268123456'], ['home', 'work'], '0', '13464346', '0', '0']
numbersTemp[idx] = nrtemp;
typesTemp[idx] = tptemp;
idx ++;
}
if (webphone_api.common.isNull(numbersTemp) || numbersTemp.length < 1)
{
if (currName.length < 1)
{
webphone_api.common.ShowToast(webphone_api.stringres.get('contact_no_nunber'));
return;
}
//-- new contact-nal nem kell kerni szamot
//-- ranezni, hogy van-e benne space, s ha nincs akkor rakja be telefonszamnak
if (currName.indexOf(' ') < 0)
{
var tmptype = 'phone';
if (!webphone_api.common.IsNumber(currName)) { tmptype = 'sip'; }
numbersTemp.push(currName);
typesTemp.push(tmptype);
}
}
if (currName.length < 1) { currName = numbersTemp[0]; }
var modified = (webphone_api.common.GetTickCount()).toString();
var ctemail = '';
var ctaddress = '';
var ctnotes = '';
var ctwebsite = '';
if (webphone_api.$('#number_aec_email').is(':visible'))
{
ctemail = webphone_api.$('#number_aec_email').val();
if (webphone_api.common.isNull(ctemail)) { ctemail = ''; } else { ctemail = webphone_api.common.Trim(ctemail); }
}
if (webphone_api.$('#number_aec_address').is(':visible'))
{
ctaddress = webphone_api.$('#number_aec_address').val();
if (webphone_api.common.isNull(ctaddress)) { ctaddress = ''; } else { ctaddress = webphone_api.common.Trim(ctaddress); }
ctaddress = webphone_api.common.ReplaceAll(ctaddress, '\r\n', ' ');
ctaddress = webphone_api.common.ReplaceAll(ctaddress, '\n', ' ');
ctaddress = webphone_api.common.ReplaceAll(ctaddress, ',', ' ');
}
if (webphone_api.$('#number_aec_notes').is(':visible'))
{
ctnotes = webphone_api.$('#number_aec_notes').val();
if (webphone_api.common.isNull(ctnotes)) { ctnotes = ''; } else { ctnotes = webphone_api.common.Trim(ctnotes); }
ctnotes = webphone_api.common.ReplaceAll(ctnotes, '\r\n', ' ');
ctnotes = webphone_api.common.ReplaceAll(ctnotes, '\n', ' ');
ctnotes = webphone_api.common.ReplaceAll(ctnotes, ',', ' ');
}
if (webphone_api.$('#number_aec_website').is(':visible'))
{
ctwebsite = webphone_api.$('#number_aec_website').val();
if (webphone_api.common.isNull(ctwebsite)) { ctwebsite = ''; } else { ctwebsite = webphone_api.common.Trim(ctwebsite); }
}
var ctTemp = [];
ctTemp[webphone_api.common.CT_NAME] = currName;
ctTemp[webphone_api.common.CT_NUMBER] = numbersTemp;
ctTemp[webphone_api.common.CT_PTYPE] = typesTemp;
ctTemp[webphone_api.common.CT_USAGE] = contact[webphone_api.common.CT_USAGE];
ctTemp[webphone_api.common.CT_LASTMODIF] = modified;
ctTemp[webphone_api.common.CT_DELFLAG] = contact[webphone_api.common.CT_DELFLAG];
ctTemp[webphone_api.common.CT_FAV] = contact[webphone_api.common.CT_FAV];
ctTemp[webphone_api.common.CT_EMAIL] = ctemail;
ctTemp[webphone_api.common.CT_ADDRESS] = ctaddress;
ctTemp[webphone_api.common.CT_NOTES] = ctnotes;
ctTemp[webphone_api.common.CT_WEBSITE] = ctwebsite;
ctTemp[webphone_api.common.CT_LASTACTIVE] = webphone_api.common.GetTickCount().toString();
ctTemp[webphone_api.common.CT_ISFROMSYNC] = '0';
webphone_api.global.ctlist[ctid] = ctTemp;
webphone_api.global.wasCtModified = true;
webphone_api.common.SortContacts();
setTimeout(function ()
{
webphone_api.common.ShowToast(webphone_api.stringres.get('contact_saved'));
}, 300);
webphone_api.$.mobile.back();
return;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: SaveEditedContact", err); }
try{ webphone_api.common.ShowToast(webphone_api.stringres.get('contact_save_error')); webphone_api.$.mobile.back(); } catch(err) { ; }
}
function SaveNewContact()
{
try{
var currName = nameField.value;
if (webphone_api.common.isNull(currName)) { currName = ''; }
currName = webphone_api.common.Trim(currName);
var fieldcount = webphone_api.$('#aec_number_fields').children().length;
if (webphone_api.common.isNull(fieldcount) || fieldcount < 1)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, SaveNewContact fieldcount is null');
return;
}
var numbersTemp = [];
var typesTemp = [];
var idx = 0;
for (var i = 0; i < fieldcount; i++)
{
var nrtemp = webphone_api.$('#number_aec_' + i).val();
var typefieldTemp = webphone_api.$('#btn_type_aec_' + i).html();
var tptemp = webphone_api.stringres.get('mobile');
if ( webphone_api.common.isNull(nrtemp) || (webphone_api.common.Trim(nrtemp)).length < 1 )
{
continue;
}
if (typefieldTemp === webphone_api.stringres.get('phone')) { tptemp = 'phone'; }
if (typefieldTemp === webphone_api.stringres.get('home')) { tptemp = 'home'; }
if (typefieldTemp === webphone_api.stringres.get('mobile')) { tptemp = 'mobile'; }
if (typefieldTemp === webphone_api.stringres.get('work')) { tptemp = 'work'; }
if (typefieldTemp === webphone_api.stringres.get('other')) { tptemp = 'other'; }
if (typefieldTemp === webphone_api.stringres.get('fax_home')) { tptemp = 'fax_home'; }
if (typefieldTemp === webphone_api.stringres.get('fax_work')) { tptemp = 'fax_work'; }
if (typefieldTemp === webphone_api.stringres.get('pager')) { tptemp = 'pager'; }
if (typefieldTemp === webphone_api.stringres.get('sip')) { tptemp = 'sip'; }
//-- ['John Doe', ['40724335123', '0268123456'], ['home', 'work'], '0', '13464346', '0', '0']
numbersTemp[idx] = nrtemp;
typesTemp[idx] = tptemp;
idx ++;
}
if (webphone_api.common.isNull(numbersTemp) || numbersTemp.length < 1)
{
if (currName.length < 1)
{
webphone_api.common.ShowToast(webphone_api.stringres.get('contact_no_nunber'));
return;
}
//-- new contact-nal nem kell kerni szamot
//-- ranezni, hogy van-e benne space, s ha nincs akkor rakja be telefonszamnak
if (currName.indexOf(' ') < 0)
{
var tmptype = 'phone';
if (!webphone_api.common.IsNumber(currName)) { tmptype = 'sip'; }
numbersTemp.push(currName);
typesTemp.push(tmptype);
}
}
if (currName.length < 1) { currName = numbersTemp[0]; }
var modified = (webphone_api.common.GetTickCount()).toString();
var ctemail = '';
var ctaddress = '';
var ctnotes = '';
var ctwebsite = '';
if (webphone_api.$('#number_aec_email').is(':visible'))
{
ctemail = webphone_api.$('#number_aec_email').val();
if (webphone_api.common.isNull(ctemail)) { ctemail = ''; } else { ctemail = webphone_api.common.Trim(ctemail); }
}
if (webphone_api.$('#number_aec_address').is(':visible'))
{
ctaddress = webphone_api.$('#number_aec_address').val();
if (webphone_api.common.isNull(ctaddress)) { ctaddress = ''; } else { ctaddress = webphone_api.common.Trim(ctaddress); }
ctaddress = webphone_api.common.ReplaceAll(ctaddress, '\r\n', ' ');
ctaddress = webphone_api.common.ReplaceAll(ctaddress, '\n', ' ');
ctaddress = webphone_api.common.ReplaceAll(ctaddress, ',', ' ');
}
if (webphone_api.$('#number_aec_notes').is(':visible'))
{
ctnotes = webphone_api.$('#number_aec_notes').val();
if (webphone_api.common.isNull(ctnotes)) { ctnotes = ''; } else { ctnotes = webphone_api.common.Trim(ctnotes); }
ctnotes = webphone_api.common.ReplaceAll(ctnotes, '\r\n', ' ');
ctnotes = webphone_api.common.ReplaceAll(ctnotes, '\n', ' ');
ctnotes = webphone_api.common.ReplaceAll(ctnotes, ',', ' ');
}
if (webphone_api.$('#number_aec_website').is(':visible'))
{
ctwebsite = webphone_api.$('#number_aec_website').val();
if (webphone_api.common.isNull(ctwebsite)) { ctwebsite = ''; } else { ctwebsite = webphone_api.common.Trim(ctwebsite); }
}
var ctTemp = [];
ctTemp[webphone_api.common.CT_NAME] = currName;
ctTemp[webphone_api.common.CT_NUMBER] = numbersTemp;
ctTemp[webphone_api.common.CT_PTYPE] = typesTemp;
ctTemp[webphone_api.common.CT_USAGE] = '0';
ctTemp[webphone_api.common.CT_LASTMODIF] = modified;
ctTemp[webphone_api.common.CT_DELFLAG] = '0';
ctTemp[webphone_api.common.CT_FAV] = '0';
ctTemp[webphone_api.common.CT_EMAIL] = ctemail;
ctTemp[webphone_api.common.CT_ADDRESS] = ctaddress;
ctTemp[webphone_api.common.CT_NOTES] = ctnotes;
ctTemp[webphone_api.common.CT_WEBSITE] = ctwebsite;
ctTemp[webphone_api.common.CT_LASTACTIVE] = webphone_api.common.GetTickCount().toString();
ctTemp[webphone_api.common.CT_ISFROMSYNC] = '0';
webphone_api.global.ctlist.push(ctTemp);
webphone_api.global.wasCtModified = true;
webphone_api.common.SortContacts();
setTimeout(function ()
{
webphone_api.common.ShowToast(webphone_api.stringres.get('contact_saved'));
}, 300);
webphone_api.$.mobile.back();
return;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: SaveNewContact", err); }
try{ webphone_api.common.ShowToast(webphone_api.stringres.get('contact_save_error')); webphone_api.$.mobile.back(); } catch(err2) { ; }
}
var MENUITEM_ADDEDITCONTACT_SAVE = '#menuitem_addeditcontact_save';
var MENUITEM_ADDEDITCONTACT_REVERT = '#menuitem_addeditcontact_revert';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.IsWindowsSoftphone())
{
webphone_api.$( "#btn_addeditcontact_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _addeditcontact: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _addeditcontact: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_ADDEDITCONTACT_SAVE + '"><a data-rel="back">' + webphone_api.stringres.get('btn_save') + '</a></li>' ).listview('refresh');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_ADDEDITCONTACT_REVERT + '"><a data-rel="back">' + webphone_api.stringres.get('btn_revert') + '</a></li>' ).listview('refresh');
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#addeditcontact_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#addeditcontact_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_ADDEDITCONTACT_SAVE:
SaveContact();
break;
case MENUITEM_ADDEDITCONTACT_REVERT:
webphone_api.$.mobile.back();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: MenuItemSelected", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _addeditcontact: onStop");
webphone_api.global.isAddeditcontactStarted = false;
// reset phone fields display
var fieldcount = webphone_api.$('#aec_number_fields').children().length;
if (webphone_api.common.isNull(fieldcount) || fieldcount < 1) { return; }
for (var i = 0; i < fieldcount; i++)
{
var newelement = document.getElementById('aec_entry_' + i);
if ( !webphone_api.common.isNull(newelement))
{
newelement.style.display = 'none';
}
}
webphone_api.$('#aec_entry_email').hide();
webphone_api.$('#aec_entry_address').hide();
webphone_api.$('#aec_entry_notes').hide();
webphone_api.$('#aec_entry_website').hide();
webphone_api.$('#aec_entry_email').val('');
webphone_api.$('#aec_entry_address').val('');
webphone_api.$('#aec_entry_notes').val('');
webphone_api.$('#aec_entry_website').val('');
webphone_api.$('#aec_add_deatils').show();
if (!webphone_api.common.isNull(nameField)) { nameField.value = ''; }
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_addeditcontact: onStop", err); }
}
function onDestroy (event){} // deprecated by onstop
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop,
onDestroy: onDestroy
};
})();
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,385 @@
// Call History Details page
webphone_api._callhistorydetails = (function ()
{
var ctid = -1;
var chentry = null;
function onCreate (event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _callhistorydetails: onCreate");
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_callhistorydetails')
{
MeasureCallhistorydetails();
}
});
webphone_api.$('#callhistorydetails_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_callhistorydetails_menu").on("click", function() { CreateOptionsMenu('#callhistorydetails_menu_ul'); });
webphone_api.$( "#page_callhistorydetails" ).keyup(function( event )
{
HandleKeyUp(event);
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: onCreate", err); }
}
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _callhistorydetails: onStart");
webphone_api.global.isCallhistorydetailsStarted = true;
setTimeout(function() // otherwise keyup will not work, because the element is not focused
{
webphone_api.$("#page_callhistorydetails").focus();
}, 100);
//-- document.getElementById("app_name_callhistorydetails").innerHTML = webphone_api.common.GetBrandName();
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#page_callhistorydetails'), -30) );
if (!webphone_api.common.isNull(document.getElementById('callhistorydetails_title')))
{
document.getElementById('callhistorydetails_title').innerHTML = webphone_api.stringres.get("chdetails_title");
}
webphone_api.$("#callhistorydetails_title").attr("title", webphone_api.stringres.get("hint_page"));
if (!webphone_api.common.isNull(document.getElementById('chdetails_btnback')))
{
document.getElementById('chdetails_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get("chdetails_btnback_txt");
}
// needed for proper display of page height
MeasureCallhistorydetails();
try { ctid = webphone_api.common.StrToInt( webphone_api.common.GetIntentParam(webphone_api.global.intentchdetails, 'ctid') ); } catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: onStart can't convert ctid to INT", err); }
chentry = webphone_api.global.chlist[ctid];
PopulateData();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: onStart", err); }
}
function MeasureCallhistorydetails() // resolve window height size change
{
try{
//-- var pgh = webphone_api.common.GetDeviceHeight() - 1; webphone_api.$('#page_callhistorydetails').css('min-height', pgh + 'px'); // must be set when softphone is skin in div
webphone_api.$('#page_callhistorydetails').css('min-height', 'auto'); // must be set when softphone is skin in div
var heightTemp = webphone_api.common.GetDeviceHeight() - webphone_api.$("#callhistorydetails_header").height();
heightTemp = heightTemp - 3;
webphone_api.$("#page_callhistorydetails_content").height(heightTemp);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorylist: MeasureCallhistorydetails", err); }
}
function PopulateData()
{
try{
if (webphone_api.common.isNull(chentry) || chentry.length < 1)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, _callhistorydetails PopulateData entry is NULL');
return;
}
webphone_api.$("#page_callhistorydetails_content").html('');
var content = '<div id="ch_contact_name">' + chentry[webphone_api.common.CH_NAME] + '</div>';
var number = chentry[webphone_api.common.CH_NUMBER];
var type = chentry[webphone_api.common.CH_TYPE];
var typestr = '';
if (type === '0') { typestr = webphone_api.stringres.get('ch_outgoing'); }
else if (type === '1') { typestr = webphone_api.stringres.get('ch_incoming'); }
else { typestr = webphone_api.stringres.get('ch_missed'); }
var iconCallPng = 'icon_call.png';
var iconMsgPng = 'icon_message.png';
var iconVideoPng = 'btn_video_txt.png';
if (webphone_api.common.GetColortheme() === 22 || webphone_api.common.GetColortheme() === 23)
{
iconCallPng = 'icon_call_grey.png';
iconMsgPng = 'icon_message_grey.png';
iconVideoPng = 'btn_video_txt_grey.png';
}
if (!webphone_api.common.isNull(number) && number.length > 0)
{
var itemCall =
'<div id="ch_entry" class="ch_container">' +
'<div id="ch_call_entry" class="ch_call">' +
'<div class="ch_data">' +
'<div class="ch_type">' + typestr + '</div>' +
'<div class="ch_number">' + chentry[webphone_api.common.CH_NUMBER] + '</div>' +
'</div>' +
'<div class="ch_icon">' +
'<img src="' + webphone_api.common.GetElementSource() + 'images/' + iconCallPng + '" />' +
'</div>' +
'</div>' +
'</div>';
var itemMsg =
'<div id="ch_entry" class="ch_container">' +
'<div id="ch_msg_entry" class="ch_call">' +
'<div class="ch_data">' +
'<div class="ch_type">' + webphone_api.stringres.get('send_msg') + '</div>' +
'<div class="ch_number">' + chentry[webphone_api.common.CH_NUMBER] + '</div>' +
'</div>' +
'<div class="ch_icon">' +
'<img src="' + webphone_api.common.GetElementSource() + 'images/' + iconMsgPng + '" />' +
'</div>' +
'</div>' +
'</div>';
var itemVideo = '';
if (webphone_api.common.GetParameter2('video') === '1' || (webphone_api.common.GetParameter2('video') === '-1' && webphone_api.common.getuseengine() === webphone_api.global.ENGINE_WEBRTC))
{
itemVideo =
'<div id="ch_entry" class="ch_container">' +
'<div id="ch_video_entry" class="ch_call">' +
'<div class="ch_data">' +
'<div class="ch_type">' + webphone_api.stringres.get('video_call') + '</div>' +
'<div class="ch_number">' + chentry[webphone_api.common.CH_NUMBER] + '</div>' +
'</div>' +
'<div class="ch_icon">' +
'<img src="' + webphone_api.common.GetElementSource() + 'images/' + iconVideoPng + '" />' +
'</div>' +
'</div>' +
'</div>';
}
//-- handle hidesettings
if (webphone_api.common.HideSettings('chat', webphone_api.stringres.get('sett_display_name_' + 'chat'), 'chat', true) === true || webphone_api.common.GetParameterInt('textmessaging', -1) == 0)
{
itemMsg = '';
}
if (webphone_api.common.CanIUseVideo() === false) { itemVideo = ''; }
content = content + itemCall + itemMsg + itemVideo;
}
webphone_api.$("#page_callhistorydetails_content").html(content);
// add event listeners
if (!webphone_api.common.isNull(number) && number.length > 0)
{
webphone_api.$('#ch_call_entry').on('click', function() { OnItemClick(0); });
webphone_api.$('#ch_msg_entry').on('click', function() { OnItemClick(1); });
webphone_api.$('#ch_video_entry').on('click', function() { OnItemClick(2); });
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: PopulateData", err); }
}
var trigerred = false; // handle multiple clicks
function OnItemClick(type) // type: 0=call, 1=chat, 2=video call
{
try{
if (trigerred) { return; }
trigerred = true;
setTimeout(function ()
{
trigerred = false;
}, 1000);
if (type === 0)
{
StartCall(false);
}
else if (type === 1)
{
StartChatSms();
}
else if (type === 2)
{
StartCall(true);
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: OnItemClick", err); }
}
function StartCall(isvideo)
{
try{
webphone_api.common.SaveParameter('redial', chentry[webphone_api.common.CH_NUMBER]);
webphone_api.common.PutToDebugLog(4, 'EVENT, _callhistorydetails initiate call to: ' + chentry[webphone_api.common.CH_NUMBER]);
setTimeout(function () //-- timeout, so webphone_api.$.mobile.back(); won't close call page
{
if (isvideo === true)
{
webphone_api.videocall(chentry[webphone_api.common.CH_NUMBER]);
}else
{
//webphone_api.call(-1, chentry[webphone_api.common.CH_NUMBER], chentry[webphone_api.common.CH_NAME]);
webphone_api.call(chentry[webphone_api.common.CH_NUMBER], -1);
}
}, 100);
webphone_api.$.mobile.back();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: StartCall", err); }
}
function StartChatSms()
{
try{
webphone_api.common.StartMsg(chentry[webphone_api.common.CH_NUMBER], '', '_callhistorydetails');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: StartChatSms", err); }
}
function HandleKeyUp(event)
{
try{
//-- don't catch input if a popup is open, because popups can have input boxes, and we won't be able to write into them
if (webphone_api.$(".ui-page-active .ui-popup-active").length > 0)
{
return false;
}
var charCode = (event.keyCode) ? event.keyCode : event.which; // workaround for firefox
if (charCode === 8) // backspace
{
event.preventDefault();
webphone_api.$.mobile.back();
}
return false;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: HandleKeyUp", err); }
}
var MENUITEM_CALLHISTORYDETAILS_CREATE = '#menuitem_callhistorydetails_create';
var MENUITEM_CALLHISTORYDETAILS_EDIT = '#menuitem_callhistorydetails_edit';
var MENUITEM_CALLHISTORYDETAILS_CALL = '#menuitem_callhistorydetails_call';
var MENUITEM_CALLHISTORYDETAILS_MESSAGE = '#menuitem_callhistorydetails_message';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.IsWindowsSoftphone())
{
webphone_api.$( "#btn_callhistorydetails_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _callhistorydetails: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _callhistorydetails: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
if (webphone_api.common.GetContactIdFromNumber(chentry[webphone_api.common.CH_NUMBER]) < 0) // check if contact exists
{
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CALLHISTORYDETAILS_CREATE + '"><a data-rel="back">' + webphone_api.stringres.get('menu_createcontact') + '</a></li>' ).listview('refresh');
}else
{
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CALLHISTORYDETAILS_EDIT + '"><a data-rel="back">' + webphone_api.stringres.get('menu_editcontact') + '</a></li>' ).listview('refresh');
}
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CALLHISTORYDETAILS_CALL + '"><a data-rel="back">' + webphone_api.stringres.get('menu_call') + '</a></li>' ).listview('refresh');
// handle hidesettings
if (webphone_api.common.HideSettings('chat', webphone_api.stringres.get('sett_display_name_' + 'chat'), 'chat', true) === false || webphone_api.common.GetParameterInt('textmessaging', -1) == 0)
{
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CALLHISTORYDETAILS_MESSAGE + '"><a data-rel="back">' + webphone_api.stringres.get('menu_message') + '</a></li>' ).listview('refresh');
}
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#callhistorydetails_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#callhistorydetails_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_CALLHISTORYDETAILS_CREATE:
CreateContact();
break;
case MENUITEM_CALLHISTORYDETAILS_EDIT:
EditContact();
break;
case MENUITEM_CALLHISTORYDETAILS_CALL:
StartCall();
break;
case MENUITEM_CALLHISTORYDETAILS_MESSAGE:
StartChatSms();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: MenuItemSelected", err); }
}
function CreateContact()
{
try{
webphone_api.global.intentaddeditct[0] = 'action=add';
webphone_api.global.intentaddeditct[1] = 'numbertoadd=' + chentry[webphone_api.common.CH_NUMBER];
var name = chentry[webphone_api.common.CH_NAME];
if (webphone_api.common.isNull(name) || name.length < 1 || name === chentry[webphone_api.common.CH_NUMBER]) { name = ''; }
webphone_api.global.intentaddeditct[2] = 'nametoadd=' + name;
webphone_api.$.mobile.changePage("#page_addeditcontact", { transition: "pop", role: "page" });
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: CreateContact", err); }
}
function EditContact()
{
try{
var ctid = webphone_api.common.GetContactIdFromNumber(chentry[webphone_api.common.CH_NUMBER]);
if (ctid < 0) // means there is no contact found
{
CreateContact();
return;
}
webphone_api.global.intentaddeditct[0] = 'action=edit';
webphone_api.global.intentaddeditct[1] = 'ctid=' + ctid;
webphone_api.$.mobile.changePage("#page_addeditcontact", { transition: "pop", role: "page" });
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: EditContact", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _callhistorydetails: onStop");
webphone_api.global.isCallhistorydetailsStarted = false;
webphone_api.$("#page_callhistorydetails_content").html('');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_callhistorydetails: onStop", err); }
}
function onDestroy (event){} // deprecated by onstop
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop,
onDestroy: onDestroy
};
})();
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,871 @@
// Contact Details page
webphone_api._contactdetails = (function ()
{
var ctid = -1;
var contact = null;
var iscontact = false; // true if it's a saved contact in contacts list
var frompage = '';
var isfavorite = false; // is contact favorite
function onCreate (event) // called only once - bind events here
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _contactdetails: onCreate");
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_contactdetails')
{
MeasureContactdetails();
}
});
webphone_api.$('#contactdetails_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_contactdetails_menu").on("click", function() { CreateOptionsMenu('#contactdetails_menu_ul'); });
webphone_api.$("#btn_contactdetails_menu").attr("title", webphone_api.stringres.get("hint_menu"));
webphone_api.$( "#page_contactdetails" ).keyup(function( event )
{
HandleKeyUp(event);
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: onCreate", err); }
}
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _contactdetails: onStart");
webphone_api.global.isContactdetailsStarted = true;
setTimeout(function() // otherwise keyup will not work, because the element is not focused
{
webphone_api.$("#page_contactdetails").focus();
}, 100);
//-- document.getElementById("app_name_contactdetails").innerHTML = webphone_api.common.GetBrandName();
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#page_contactdetails'), -30) );
if (!webphone_api.common.isNull(document.getElementById('contactdetails_title')))
{
document.getElementById('contactdetails_title').innerHTML = webphone_api.stringres.get("ctdetails_title");
}
webphone_api.$("#contactdetails_title").attr("title", webphone_api.stringres.get("hint_page"));
if (!webphone_api.common.isNull(document.getElementById('ctdetails_btnback')))
{
document.getElementById('ctdetails_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get("ctdetails_btnback_txt");
}
// needed for proper display of page height
MeasureContactdetails();
var modified = (webphone_api.common.GetTickCount()).toString();
var ctname = webphone_api.common.GetIntentParam(webphone_api.global.intentctdetails, 'ctname');
var ctnumber = webphone_api.common.GetIntentParam(webphone_api.global.intentctdetails, 'ctnumber');
try { ctid = webphone_api.common.StrToInt( webphone_api.common.GetIntentParam(webphone_api.global.intentctdetails, 'ctid') ); } catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: onStart can't convert ctid to INT", err); }
if (ctid < 0 && !webphone_api.common.isNull(ctnumber) && ctnumber.length > 0)
{
ctid = webphone_api.common.GetContactIdFromNumber(ctnumber);
}
if (ctid >= 0)
{
iscontact = true;
contact = webphone_api.global.ctlist[ctid];
}
//-- PopulateData();
if (ctid >= 0)
{
webphone_api.$("#btn_contactdetails_favorite").show();
isfavorite = webphone_api.common.ContactIsFavorite(ctid);
if (isfavorite === true)
{
webphone_api.$("#btn_contactdetails_favorite").attr('src', '' + webphone_api.common.GetElementSource() + 'images/btn_star_on_normal_holo_light.png').attr("title", webphone_api.stringres.get("menu_ct_unsetfavorite"));
}else
{
webphone_api.$("#btn_contactdetails_favorite").attr('src', '' + webphone_api.common.GetElementSource() + 'images/btn_star_off_normal_holo_light.png').attr("title", webphone_api.stringres.get("menu_ct_setfavorite"));
}
}else
{
iscontact = false;
if (webphone_api.common.isNull(ctname)) { ctname = ''; }
if (webphone_api.common.isNull(ctnumber)) { ctnumber = ''; }
if (ctname.length > 0 && ctname === ctnumber)
{
ctname = webphone_api.common.GetContactNameFromNumber(ctnumber);
}
contact = [];
contact[webphone_api.common.CT_NAME] = ctname;
contact[webphone_api.common.CT_NUMBER] = [ctnumber];
contact[webphone_api.common.CT_PTYPE] = ['other'];
contact[webphone_api.common.CT_USAGE] = '0';
contact[webphone_api.common.CT_LASTMODIF] = modified;
contact[webphone_api.common.CT_DELFLAG] = '0';
contact[webphone_api.common.CT_FAV] = '0';
contact[webphone_api.common.CT_EMAIL] = '';
contact[webphone_api.common.CT_ADDRESS] = '';
contact[webphone_api.common.CT_NOTES] = '';
contact[webphone_api.common.CT_WEBSITE] = '';
contact[webphone_api.common.CT_LASTACTIVE] = '0';
}
PopulateData();
frompage = webphone_api.common.GetIntentParam(webphone_api.global.intentctdetails, 'frompage');
if (frompage === 'dialpad' && !webphone_api.common.isNull(document.getElementById('ctdetails_btnback')))
{
document.getElementById('ctdetails_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get("go_back_btn_txt");
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: onStart", err); }
}
function MeasureContactdetails() // resolve window height size change
{
try{
//-- var pgh = webphone_api.common.GetDeviceHeight() - 1; webphone_api.$('#page_contactdetails').css('min-height', pgh + 'px'); // must be set when softphone is skin in div
webphone_api.$('#page_contactdetails').css('min-height', 'auto'); // must be set when softphone is skin in div
var heightTemp = webphone_api.common.GetDeviceHeight() - webphone_api.$("#contactdetails_header").height();
heightTemp = heightTemp - 3;
webphone_api.$("#page_contactdetails_content").height(heightTemp);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: MeasureContactdetails", err); }
}
var isctblocked = false;
function PopulateData()
{
var enablepres = false;
var presencequery = [];
try{
if (webphone_api.common.isNull(contact) || contact.length < 1)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, _contactdetails PopulateData contact is NULL');
return;
}
webphone_api.$("#page_contactdetails_content").html('');
var content = '<div id="contact_name">' +
'<p>' + contact[webphone_api.common.CT_NAME] + '</p>' +
'<div id="contact_blocked">' +
'<img src="' + webphone_api.common.GetElementSource() + 'images/icon_block.png" id="contact_blocked_img" />' +
'</div>' +
'<div id="contact_favorite">' +
'<img id="btn_contactdetails_favorite" style="display: none;" src="' + webphone_api.common.GetElementSource() + 'images/btn_star_off_normal_holo_light.png" title="" />' +
'</div>' +
'</div>';
var numbers = contact[webphone_api.common.CT_NUMBER];
var types = contact[webphone_api.common.CT_PTYPE];
if (webphone_api.common.UsePresence2() === true)
{
enablepres = true;
}
// check if contact is blocked
if (!webphone_api.common.isNull(numbers) && numbers.length > 0)
{
if (webphone_api.common.IsContactBlocked(null, numbers)) { isctblocked = true; }
}
var iconCallPng = 'icon_call.png';
var iconMsgPng = 'icon_message.png';
var iconVideoPng = 'btn_video_txt.png';
if (webphone_api.common.GetColortheme() === 22 || webphone_api.common.GetColortheme() === 23)
{
iconCallPng = 'icon_call_grey.png';
iconMsgPng = 'icon_message_grey.png';
iconVideoPng = 'btn_video_txt_grey.png';
}
var canmodifycontact = true;
if(webphone_api.common.GetParameterInt('serveraddressbook_allowedit', 1) == 0) canmodifycontact = false;
var NOW = webphone_api.common.GetTickCount();
if (!webphone_api.common.isNull(numbers) && numbers.length > 0)
{
for (var i = 0; i < numbers.length; i++)
{
var presenceimg = ''; //<img src="images/presence_available.png" />
if (enablepres)
{
var presence = '-1';
var lastcheck = 0; // timestamp last checked presence
var presobj = webphone_api.global.presenceHM[numbers[i]];
if (!webphone_api.common.isNull(presobj))
{
presence = presobj[webphone_api.common.PRES_STATUS];
var laststr = presobj[webphone_api.common.PRES_TIME];
if (!webphone_api.common.isNull(laststr) && webphone_api.common.IsNumber(laststr))
lastcheck = webphone_api.common.StrToInt(laststr);
}
// -1=not exists(undefined), 0=offline, 1=invisible, 2=idle, 3=pending, 4=DND, 5=online
if (webphone_api.common.isNull(presence) || presence.length < 1 || presence === '-1'/* || (lastcheck > 0 && NOW - lastcheck > 20000)*/)
{
presenceimg = '';
if (webphone_api.common.isNull(presencequery)) { presencequery = []; }
if (presencequery.indexOf(numbers[i]) < 0)
{
presencequery.push(numbers[i]);
}
}
else if (presence === '0') // offline
{
presenceimg = '<img src="' + webphone_api.common.GetElementSource() + 'images/presence_grey.png" />';
}
else if (presence === '1') // invisible
{
presenceimg = '<img src="' + webphone_api.common.GetElementSource() + 'images/presence_white.png" />';
}
else if (presence === '2') // idle
{
presenceimg = '<img src="' + webphone_api.common.GetElementSource() + 'images/presence_yellow.png" />';
}
else if (presence === '3') // pending
{
presenceimg = '<img src="' + webphone_api.common.GetElementSource() + 'images/presence_orange.png" />';
}
else if (presence === '4') // DND
{
presenceimg = '<img src="' + webphone_api.common.GetElementSource() + 'images/presence_red.png" />';
}
else if (presence === '5') // online
{
presenceimg = '<img src="' + webphone_api.common.GetElementSource() + 'images/presence_green.png" />';
}
else
{
presenceimg = '';
}
}
//-- don't display "Call other", just "Call"
var type = webphone_api.stringres.get('type_' + types[i]);
if (numbers.length < 2) { type = webphone_api.common.Trim(type.substring(0, type.indexOf(' '))); }
var itemcall =
'<div id="ct_entry_' + i + '" class="cd_container">' +
'<div id="cd_call_' + i + '" class="cd_call">' +
'<div class="cd_data">' +
'<div class="cd_type">' + type + '</div>' +
'<div class="cd_number">' + numbers[i] + '</div>' +
'</div>' +
'<div class="cd_icon">' +
presenceimg + '<img src="' + webphone_api.common.GetElementSource() + 'images/' + iconCallPng + '" />' +
'</div>' +
'</div>' +
'</div>';
var itemmsg =
'<div id="ct_entry_' + i + '" class="cd_container">' +
'<div id="cd_msg_' + i + '" class="cd_call">' +
'<div class="cd_data">' +
'<div class="cd_type">' + webphone_api.stringres.get('send_msg') + '</div>' +
'<div class="cd_number">' + numbers[i] + '</div>' +
'</div>' +
'<div class="cd_icon">' +
presenceimg + '<img src="' + webphone_api.common.GetElementSource() + 'images/' + iconMsgPng + '" />' +
'</div>' +
'</div>' +
'</div>';
var itemvideo = '';
if (webphone_api.common.CanIUseVideo() === true)
{
itemvideo =
'<div id="ct_entry_' + i + '" class="cd_container">' +
'<div id="cd_video_' + i + '" class="cd_call">' +
'<div class="cd_data">' +
'<div class="cd_type">' + webphone_api.stringres.get('video_call') + '</div>' +
'<div class="cd_number">' + numbers[i] + '</div>' +
'</div>' +
'<div class="cd_icon">' +
presenceimg + '<img src="' + webphone_api.common.GetElementSource() + 'images/' + iconVideoPng + '" />' +
'</div>' +
'</div>' +
'</div>';
}
// handle hidesettings
if (webphone_api.common.HideSettings('chat', webphone_api.stringres.get('sett_display_name_' + 'chat'), 'chat', true) === true || webphone_api.common.GetParameterInt('textmessaging', -1) == 0)
{
itemmsg = '';
}
content = content + itemcall + itemmsg + itemvideo;
}
}
var backtitle = '';
if (frompage === 'dialpad')
{
backtitle = webphone_api.stringres.get('btn_close');
}else
{
backtitle = webphone_api.stringres.get('ctdetails_btnback_txt');
}
var controls = '';
if (webphone_api.common.CanIUseScreensharing() === true)
{
controls = controls +
'<div id="ct_screensh" class="cd_container">' +
'<div id="ct_screensh_entry_button" class="cd_call">' +
'<div class="cd_button">' + webphone_api.stringres.get('menu_screenshare') + '</div>' +
'</div>' +
'</div>';
}
if (webphone_api.common.GetConfigBool('hasfiletransfer', true) !== false && webphone_api.common.IsMizuServerOrGateway())
{
//OPSSTART
if (webphone_api.common.Glft() === true)
//OPSEND
controls = controls +
'<div id="ct_filetransf" class="cd_container">' +
'<div id="ct_filetransf_entry_button" class="cd_call">' +
'<div class="cd_button">' + webphone_api.stringres.get('filetransf_title') + '</div>' +
'</div>' +
'</div>';
}
if (iscontact)
{
if(canmodifycontact)
{
controls = controls +
'<div id="ct_edit_entry" class="cd_container">' +
'<div id="ct_edit_entry_button" class="cd_call">' +
'<div class="cd_button">' + webphone_api.stringres.get('menu_editcontact') + '</div>' +
'</div>' +
'</div>' +
'<div id="ct_delete_entry" class="cd_container">' +
'<div id="ct_delete_entry_button" class="cd_call">' +
'<div class="cd_button">' + webphone_api.stringres.get('menu_deletecontact') + '</div>' +
'</div>' +
'</div>';
}
}else
{
controls = controls +
'<div id="ct_save_entry" class="cd_container">' +
'<div id="ct_save_entry_button" class="cd_call">' +
'<div class="cd_button">' + webphone_api.stringres.get('menu_createcontact') + '</div>' +
'</div>' +
'</div>';
}
controls = controls +
'<div id="ct_allcontacts_entry" class="cd_container">' +
'<div id="ct_allcontacts_entry_button" class="cd_call">' +
'<div class="cd_button">' + backtitle + '</div>' +
'</div>' +
'</div>';
content = content + controls;
webphone_api.$("#page_contactdetails_content").html(content);
if (isctblocked === true)
{
webphone_api.$('#contact_blocked_img').show();
}
// add event listeners
if (!webphone_api.common.isNull(numbers) && numbers.length > 0)
{
for (var i = 0; i < numbers.length; i++)
{
(function (i)
{
webphone_api.$('#cd_call_' + i).on('click', function() { OnItemClick(i, 0); });
webphone_api.$('#cd_msg_' + i).on('click', function() { OnItemClick(i, 1); });
webphone_api.$('#cd_video_' + i).on('click', function() { OnItemClick(i, 2); });
}(i));
}
}
webphone_api.$('#ct_screensh_entry_button').on('click', function() { ScreenSh(); });
webphone_api.$('#ct_filetransf_entry_button').on('click', function() { FileTrasnf(); });
webphone_api.$('#ct_edit_entry_button').on('click', function() { EditContact(); });
webphone_api.$('#ct_delete_entry_button').on('click', function() { DeleteContactPopup(); });
webphone_api.$('#ct_save_entry_button').on('click', function() { SaveContact(); });
webphone_api.$('#ct_allcontacts_entry_button').on('click', function() { webphone_api.$.mobile.back(); });
// handle favorite
webphone_api.$("#btn_contactdetails_favorite").off("click");
webphone_api.$("#btn_contactdetails_favorite").on("click", function()
{
ToggleFavorite();
});
if (ctid >= 0) // means it's a contact, not JUST A NUMBER
{
webphone_api.$("#btn_contactdetails_favorite").show();
isfavorite = webphone_api.common.ContactIsFavorite(ctid);
if (isfavorite === true)
{
webphone_api.$("#btn_contactdetails_favorite").attr('src', '' + webphone_api.common.GetElementSource() + 'images/btn_star_on_normal_holo_light.png').attr("title", webphone_api.stringres.get("menu_ct_unsetfavorite"));
}else
{
webphone_api.$("#btn_contactdetails_favorite").attr('src', '' + webphone_api.common.GetElementSource() + 'images/btn_star_off_normal_holo_light.png').attr("title", webphone_api.stringres.get("menu_ct_setfavorite"));
}
}
// END handle favorite
if (enablepres && !webphone_api.common.isNull(presencequery) && presencequery.length > 0)
{
var ulist = '';
for (var i = 0; i < presencequery.length; i++)
{
if (webphone_api.common.isNull(presencequery[i]) || webphone_api.common.Trim(presencequery[i]).length < 1) { continue; }
if (ulist.length > 0) { ulist = ulist + ','; }
ulist = ulist + presencequery[i];
}
if (!webphone_api.common.isNull(ulist) && ulist.length > 0)
{
ulist = webphone_api.common.ReplaceAll(ulist, '-', '');
ulist = webphone_api.common.ReplaceAll(ulist, ')', '');
ulist = webphone_api.common.ReplaceAll(ulist, '(', '');
webphone_api.common.PresenceGet2(ulist);
}
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: PopulateData", err); }
}
function ScreenSh() // opens page message with the contact's number
{
try{
webphone_api.common.PutToDebugLog(2, 'EVENT, _contactdetails: ScreenSh');
var numbers = contact[webphone_api.common.CT_NUMBER];
if (webphone_api.common.isNull(numbers) || numbers.length < 1)
{
webphone_api.common.PutToDebugLog(1, 'ERROR,' + webphone_api.stringres.get('ct_menu_error'));
webphone_api.common.ShowToast('ERROR,' + webphone_api.stringres.get('ct_menu_error'));
return;
}
if (numbers.length === 1)
{
webphone_api.screenshare(numbers[0]);
return;
}else
{
webphone_api.common.PickContactNumber(ctid, function(pick_nr, pick_name)
{
webphone_api.screenshare(pick_nr);
});
return;
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: ScreenSh", err); }
}
function FileTrasnf() // opens page message with the contact's number
{
try{
webphone_api.common.PutToDebugLog(2, 'EVENT, _contactdetails: FileTrasnf');
var numbers = contact[webphone_api.common.CT_NUMBER];
if (webphone_api.common.isNull(numbers) || numbers.length < 1)
{
webphone_api.common.PutToDebugLog(1, 'ERROR,' + webphone_api.stringres.get('ct_menu_error'));
webphone_api.common.ShowToast('ERROR,' + webphone_api.stringres.get('ct_menu_error'));
return;
}
if (numbers.length === 1)
{
webphone_api.common.FileTransfer(numbers[0]);
return;
}else
{
webphone_api.common.PickContactNumber(ctid, function(pick_nr, pick_name)
{
webphone_api.common.FileTransfer(pick_nr);
});
return;
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: FileTrasnf", err); }
}
function ToggleFavorite()
{
try{
if (isfavorite === true)
{
webphone_api.$("#btn_contactdetails_favorite").attr('src', '' + webphone_api.common.GetElementSource() + 'images/btn_star_off_normal_holo_light.png').attr("title", webphone_api.stringres.get("menu_ct_setfavorite"));
webphone_api.common.ContactSetFavorite(ctid, false);
}else
{
webphone_api.$("#btn_contactdetails_favorite").attr('src', '' + webphone_api.common.GetElementSource() + 'images/btn_star_on_normal_holo_light.png').attr("title", webphone_api.stringres.get("menu_ct_unsetfavorite"));
webphone_api.common.ContactSetFavorite(ctid, true);
}
isfavorite = !isfavorite;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: ToggleFavorite", err); }
}
var trigerred = false; // handle multiple clicks
function OnItemClick(contactid, type) // type: 0=call, 1=chat, 2=video call
{
try{
if (trigerred) { return; }
trigerred = true;
setTimeout(function ()
{
trigerred = false;
}, 1000);
if (webphone_api.common.isNull(contactid)) { return; }
var numbers = contact[webphone_api.common.CT_NUMBER];
var to = numbers[contactid];
var name = contact[webphone_api.common.CT_NAME];
if (type === 0)
{
webphone_api.common.PutToDebugLog(4, 'EVENT, _contactdetails initiate call to: ' + to);
setTimeout(function () //-- timeout, so webphone_api.$.mobile.back(); won't close call page
{
webphone_api.call(to, -1);
}, 100);
if (webphone_api.common.getuseengine() === 'p2p')
{
return;
}
webphone_api.$.mobile.back();
}
else if (type === 1)
{
webphone_api.common.StartMsg(to, '', '_contactdetails');
}
else if (type === 2)
{
webphone_api.common.PutToDebugLog(4, 'EVENT, _contactdetails initiate video call to: ' + to);
webphone_api.videocall(to);
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: OnItemClick", err); }
}
function HandleKeyUp(event)
{
try{
//-- don't catch input if a popup is open, because popups can have input boxes, and we won't be able to write into them
if (webphone_api.$(".ui-page-active .ui-popup-active").length > 0)
{
return false;
}
var charCode = (event.keyCode) ? event.keyCode : event.which; // workaround for firefox
if (charCode === 8) // backspace
{
event.preventDefault();
webphone_api.$.mobile.back();
}
//-- else if (charCode === 13)
//-- {
//-- event.preventDefault();
//-- webphone_api.$("#btn_call").click();
//-- }
return false;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: HandleKeyUp", err); }
}
var MENUITEM_CONTACTDETAILS_EDIT = '#menuitem_contactdetails_edit';
var MENUITEM_CONTACTDETAILS_DELETE = '#menuitem_contactdetails_delete';
var MENUITEM_CONTACTDETAILS_CREATE = '#menuitem_contactdetails_create';
var MENUITEM_CONTACTDETAILS_BLOCKCT = '#menuitem_contactdetails_blockct';
var MENUITEM_CONTACTDETAILS_FAVORITE = '#menuitem_contactdetails_favorite';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
var canmodifycontact = true;
if(webphone_api.common.GetParameterInt('serveraddressbook_allowedit', 1) == 0) canmodifycontact = false;
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.IsWindowsSoftphone())
{
webphone_api.$( "#btn_contactdetails_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _contactdetails: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _contactdetails: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
if(canmodifycontact)
{
if (iscontact)
{
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CONTACTDETAILS_EDIT + '"><a data-rel="back">' + webphone_api.stringres.get('menu_editcontact') + '</a></li>' ).listview('refresh');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CONTACTDETAILS_DELETE + '"><a data-rel="back">' + webphone_api.stringres.get('menu_deletecontact') + '</a></li>' ).listview('refresh');
}else
{
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CONTACTDETAILS_CREATE + '"><a data-rel="back">' + webphone_api.stringres.get('menu_createcontact') + '</a></li>' ).listview('refresh');
}
}
var blocktitle = webphone_api.stringres.get('menu_block_contact');
if (isctblocked === true) { blocktitle = webphone_api.stringres.get('menu_unblock_contact'); }
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CONTACTDETAILS_BLOCKCT + '"><a data-rel="back">' + blocktitle + '</a></li>' ).listview('refresh');
var favtitle = webphone_api.stringres.get('menu_ct_setfavorite');
if (isfavorite === true) { favtitle = webphone_api.stringres.get('menu_ct_unsetfavorite'); }
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CONTACTDETAILS_FAVORITE + '"><a data-rel="back">' + favtitle + '</a></li>' ).listview('refresh');
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#contactdetails_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#contactdetails_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_CONTACTDETAILS_EDIT:
EditContact();
break;
case MENUITEM_CONTACTDETAILS_DELETE:
DeleteContactPopup();
break;
case MENUITEM_CONTACTDETAILS_CREATE:
SaveContact();
break;
case MENUITEM_CONTACTDETAILS_BLOCKCT:
ToggleCtBlocked();
break;
case MENUITEM_CONTACTDETAILS_FAVORITE:
ToggleFavorite();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: MenuItemSelected", err); }
}
function ToggleCtBlocked()
{
try{
if (isctblocked === true)
{
isctblocked = false;
webphone_api.$('#contact_blocked_img').hide();
var numbers = contact[webphone_api.common.CT_NUMBER];
if (!webphone_api.common.isNull(numbers) && numbers.length > 0)
{
webphone_api.common.UnBlockContact(null, numbers);
}
}else
{
isctblocked = true;
webphone_api.$('#contact_blocked_img').show();
var numbers = contact[webphone_api.common.CT_NUMBER];
if (!webphone_api.common.isNull(numbers) && numbers.length > 0)
{
webphone_api.common.BlockContact(null, numbers);
}
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: ToggleCtBlocked", err); }
}
function SaveContact()
{
try{
webphone_api.global.intentaddeditct[0] = 'action=add';
webphone_api.global.intentaddeditct[1] = 'numbertoadd=' + contact[webphone_api.common.CT_NUMBER][0];
var name = contact[webphone_api.common.CT_NAME];
if (webphone_api.common.isNull(name) || name.length < 1 || name === contact[webphone_api.common.CT_NUMBER][0]) { name = ''; }
webphone_api.global.intentaddeditct[2] = 'nametoadd=' + name;
webphone_api.$.mobile.changePage("#page_addeditcontact", { transition: "pop", role: "page" });
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: CreateContact", err); }
}
function EditContact() // open AddEditContact activity
{
try{
webphone_api.global.intentaddeditct[0] = 'action=edit';
webphone_api.global.intentaddeditct[1] = 'ctid=' + ctid;
webphone_api.$.mobile.changePage("#page_addeditcontact", { transition: "pop", role: "page" });
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: EditContact", err); }
}
function DeleteContactPopup(popupafterclose)
{
try{
var popupWidth = webphone_api.common.GetDeviceWidth();
if ( !webphone_api.common.isNull(popupWidth) && webphone_api.common.IsNumber(popupWidth) && popupWidth > 100 )
{
popupWidth = Math.floor(popupWidth / 1.2);
}else
{
popupWidth = 220;
}
if(popupWidth > 400) popupWidth = 400;
else if(popupWidth < 120) popupWidth = 120;
var template = '' +
'<div id="delete_contact_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:' + popupWidth + 'px;">' +
'<div data-role="header" data-theme="b">' +
'<a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a>' +
'<h1 class="adialog_title">' + webphone_api.stringres.get('menu_deletecontact') + '</h1>' +
'</div>' +
'<div role="main" class="ui-content adialog_content adialog_alert">' +
'<span> ' + webphone_api.stringres.get('contact_delete_msg') + ' </span>' +
// '<a href="javascript:;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back">' + webphone_api.stringres.get('btn_close') + '</a>' +
// '<a href="javascript:;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back" data-transition="flow">Delete</a>' +
'</div>' +
'<div data-role="footer" data-theme="b" class="adialog_footer">' +
'<a href="javascript:;" id="btn_adialog_ok" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">' + webphone_api.stringres.get('btn_ok') + '</a>' +
'<a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">' + webphone_api.stringres.get('btn_cancel') + '</a>' +
'</div>' +
'</div>';
popupafterclose = popupafterclose ? popupafterclose : function () {};
webphone_api.$.mobile.activePage.append(template).trigger("create");
//-- webphone_api.$.mobile.activePage.append(template).trigger("pagecreate");
webphone_api.$.mobile.activePage.find(".closePopup").bind("tap", function (e)
{
webphone_api.$.mobile.activePage.find(".messagePopup").popup("close");
});
webphone_api.$.mobile.activePage.find(".messagePopup").bind(
{
popupbeforeposition: function()
{
webphone_api.$(this).unbind("popupbeforeposition");//.remove();
var maxHeight = Math.floor( webphone_api.common.GetDeviceHeight() * 0.6 ); // webphone_api.$(window).height() - 120;
if (webphone_api.$(this).height() > maxHeight)
{
webphone_api.$('.messagePopup .ui-content').height(maxHeight);
}
}
});
webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind(
{
popupafterclose: function ()
{
webphone_api.$(this).unbind("popupafterclose").remove();
webphone_api.$('#btn_adialog_ok').off('click');
popupafterclose();
}
});
webphone_api.$('#btn_adialog_ok').on('click', function ()
{
DeleteContact();
});
//-- webphone_api.global.ctlist.splice(ctid, 1);
//-- webphone_api.common.SaveContactsFile(function (issaved) { webphone_api.common.PutToDebugLog(4, 'EVENT, _contactdetails: DeleteContact SaveContactsFile: ' + issaved.toString()); });
//-- webphone_api.$.mobile.back();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: DeleteContactPopup", err); }
}
function DeleteContact()
{
try{
webphone_api.$( '#delete_contact_popup' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#delete_contact_popup' ).off( 'popupafterclose' );
webphone_api.global.ctlist.splice(ctid, 1);
webphone_api.common.SaveContactsFile(function (issaved) { webphone_api.common.PutToDebugLog(4, 'EVENT, _contactdetails: DeleteContact SaveContactsFile: ' + issaved.toString()); });
webphone_api.$.mobile.back();
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: DeleteContact", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _contactdetails: onStop");
webphone_api.global.isContactdetailsStarted = false;
webphone_api.$('#contact_blocked_img').hide();
isctblocked = false;
webphone_api.$("#page_contactdetails_content").html('');
webphone_api.$("#btn_contactdetails_favorite").off("click");
ctid = -1;
contact = null;
iscontact = false;
frompage = '';
isfavorite = false;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_contactdetails: onStop", err); }
}
function onDestroy (event){} // deprecated by onstop
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop,
onDestroy: onDestroy,
PopulateData: PopulateData
};
})();
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+145
View File
@@ -0,0 +1,145 @@
/* global webphone_api.$, common */
// Customizable page: extra1
webphone_api._extra1 = (function ()
{
/** Page navigation can be done by calling jQuery mobile "changePage()" method:
webphone_api.$.mobile.changePage("#PAGE_ID", { transition: "none", role: "page" });
Example: webphone_api.$.mobile.changePage("#page_extra1", { transition: "none", role: "page" });
To "close" this page and return to the previous page, call jQuery mobile method: webphone_api.$.mobile.back();
*/
/** !!! IMPORTANT NOTES:
1. The webphone is a single page application built using jQuery mobile framework.
Every jQuery mobile "page" defined in softphone.html has a corresponding Javascript file in /softphone/ directory.
Pages in softphone.html are <DIV> elements with the following attribute: data-role="page"
2. jQuery namespace within the webphone is changed from "$" to "webphone_api.$"
*/
/** This lifecycle function is called only once per session, when the user navigates to the page for the first time.
* This is where most initialization should go: attaching event listeners, initializing static page content, etc.
*/
function onCreate (event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra1: onCreate");
webphone_api.$('#extra1_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_extra1_menu").on("click", function() { CreateOptionsMenu('#extra1_menu_ul'); });
// set page title
webphone_api.$("#extra1_title").html('Page Extra 1');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra1: onCreate", err); }
}
/** This lifecycle function is called every time the user navigates to this page.
* This is where dynamic content can be added/refreshed.
*/
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra1: onStart");
// set back button text
webphone_api.$('#extra1_btnback').html('< Go back');
MeasureExtra1();
PopulateData();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra1: onStart", err); }
}
/** resolve window height size/resize changes */
function MeasureExtra1()
{
webphone_api.$('#page_extra1').css('min-height', 'auto'); // must be set when softphone is skin in div
var contentHeight = webphone_api.common.GetDeviceHeight() - webphone_api.$("#extra1_header").height() - 3;
webphone_api.$("#page_extra1_content").height(contentHeight);
}
/** dynamically add content to page */
function PopulateData()
{
try{
var pageContent = '<p>Content data of page Extra 1</p>';
webphone_api.$("#page_extra1_content").html(pageContent);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra1: PopulateData", err); }
}
/** adding menu items
this function will be called every time the user clicks on the "Menu" button in the top-right corner of the page
*/
var MENUITEM_EXTRA1_BACK = '#menuitem_extra1_back';
function CreateOptionsMenu (menuId)
{
try{
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _extra1: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _extra1: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
// add menu items
var itemTitle = 'Go back';
webphone_api.$(menuId).append( '<li id="' + MENUITEM_EXTRA1_BACK + '"><a data-rel="back">' + itemTitle + '</a></li>' ).listview('refresh');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra1: CreateOptionsMenu", err); }
}
/**
handle Menu actions here
called when user clicks on a Menu item
*/
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#extra1_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#extra1_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_EXTRA1_BACK:
MenuActionGoBack();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra1: MenuItemSelected", err); }
}
function MenuActionGoBack() // go back to previous page
{
webphone_api.$.mobile.back();
}
/** This lifecycle function is called every time the user navigates away from this page.
* This is where you can save data that the user modified, clear dynamically added page content, etc.
*/
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra1: onStop");
// clear page content
webphone_api.$("#page_extra_content").html('');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra1: onStop", err); }
}
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop
};
})();
+145
View File
@@ -0,0 +1,145 @@
/* global webphone_api.$, common */
// Customizable page: extra2
webphone_api._extra2 = (function ()
{
/** Page navigation can be done by calling jQuery mobile "changePage()" method:
webphone_api.$.mobile.changePage("#PAGE_ID", { transition: "none", role: "page" });
Example: webphone_api.$.mobile.changePage("#page_extra2", { transition: "none", role: "page" });
To "close" this page and return to the previous page, call jQuery mobile method: webphone_api.$.mobile.back();
*/
/** !!! IMPORTANT NOTES:
1. The webphone is a single page application built using jQuery mobile framework.
Every jQuery mobile "page" defined in softphone.html has a corresponding Javascript file in /softphone/ directory.
Pages in softphone.html are <DIV> elements with the following attribute: data-role="page"
2. jQuery namespace within the webphone is changed from "$" to "webphone_api.$"
*/
/** This lifecycle function is called only once per session, when the user navigates to the page for the first time.
* This is where most initialization should go: attaching event listeners, initializing static page content, etc.
*/
function onCreate (event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra2: onCreate");
webphone_api.$('#extra2_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_extra2_menu").on("click", function() { CreateOptionsMenu('#extra2_menu_ul'); });
// set page title
webphone_api.$("#extra2_title").html('Page Extra 2');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra2: onCreate", err); }
}
/** This lifecycle function is called every time the user navigates to this page.
* This is where dynamic content can be added/refreshed.
*/
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra2: onStart");
// set back button text
webphone_api.$('#extra2_btnback').html('< Go back');
MeasureExtra2();
PopulateData();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra2: onStart", err); }
}
/** resolve window height size/resize changes */
function MeasureExtra2()
{
webphone_api.$('#page_extra2').css('min-height', 'auto'); // must be set when softphone is skin in div
var contentHeight = webphone_api.common.GetDeviceHeight() - webphone_api.$("#extra2_header").height() - 3;
webphone_api.$("#page_extra2_content").height(contentHeight);
}
/** dynamically add content to page */
function PopulateData()
{
try{
var pageContent = '<p>Content data of page Extra 2</p>';
webphone_api.$("#page_extra2_content").html(pageContent);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra2: PopulateData", err); }
}
/** adding menu items
this function will be called every time the user clicks on the "Menu" button in the top-right corner of the page
*/
var MENUITEM_EXTRA1_BACK = '#menuitem_extra2_back';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _extra2: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _extra2: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
// add menu items
var itemTitle = 'Go back';
webphone_api.$(menuId).append( '<li id="' + MENUITEM_EXTRA1_BACK + '"><a data-rel="back">' + itemTitle + '</a></li>' ).listview('refresh');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra2: CreateOptionsMenu", err); }
}
/**
handle Menu actions here
called when user clicks on a Menu item
*/
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#extra2_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#extra2_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_EXTRA1_BACK:
MenuActionGoBack();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra2: MenuItemSelected", err); }
}
function MenuActionGoBack() // go back to previous page
{
webphone_api.$.mobile.back();
}
/** This lifecycle function is called every time the user navigates away from this page.
* This is where you can save data that the user modified, clear dynamically added page content, etc.
*/
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra2: onStop");
// clear page content
webphone_api.$("#page_extra_content").html('');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra2: onStop", err); }
}
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop
};
})();
+145
View File
@@ -0,0 +1,145 @@
/* global webphone_api.$, common */
// Customizable page: extra3
webphone_api._extra3 = (function ()
{
/** Page navigation can be done by calling jQuery mobile "changePage()" method:
webphone_api.$.mobile.changePage("#PAGE_ID", { transition: "none", role: "page" });
Example: webphone_api.$.mobile.changePage("#page_extra3", { transition: "none", role: "page" });
To "close" this page and return to the previous page, call jQuery mobile method: webphone_api.$.mobile.back();
*/
/** !!! IMPORTANT NOTES:
1. The webphone is a single page application built using jQuery mobile framework.
Every jQuery mobile "page" defined in softphone.html has a corresponding Javascript file in /softphone/ directory.
Pages in softphone.html are <DIV> elements with the following attribute: data-role="page"
2. jQuery namespace within the webphone is changed from "$" to "webphone_api.$"
*/
/** This lifecycle function is called only once per session, when the user navigates to the page for the first time.
* This is where most initialization should go: attaching event listeners, initializing static page content, etc.
*/
function onCreate (event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra3: onCreate");
webphone_api.$('#extra3_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_extra3_menu").on("click", function() { CreateOptionsMenu('#extra3_menu_ul'); });
// set page title
webphone_api.$("#extra3_title").html('Page Extra 3');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra3: onCreate", err); }
}
/** This lifecycle function is called every time the user navigates to this page.
* This is where dynamic content can be added/refreshed.
*/
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra3: onStart");
// set back button text
webphone_api.$('#extra3_btnback').html('< Go back');
MeasureExtra3();
PopulateData();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra3: onStart", err); }
}
/** resolve window height size/resize changes */
function MeasureExtra3()
{
webphone_api.$('#page_extra3').css('min-height', 'auto'); // must be set when softphone is skin in div
var contentHeight = webphone_api.common.GetDeviceHeight() - webphone_api.$("#extra3_header").height() - 3;
webphone_api.$("#page_extra3_content").height(contentHeight);
}
/** dynamically add content to page */
function PopulateData()
{
try{
var pageContent = '<p>Content data of page Extra 3</p>';
webphone_api.$("#page_extra3_content").html(pageContent);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra3: PopulateData", err); }
}
/** adding menu items
this function will be called every time the user clicks on the "Menu" button in the top-right corner of the page
*/
var MENUITEM_EXTRA1_BACK = '#menuitem_extra3_back';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _extra3: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _extra3: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
// add menu items
var itemTitle = 'Go back';
webphone_api.$(menuId).append( '<li id="' + MENUITEM_EXTRA1_BACK + '"><a data-rel="back">' + itemTitle + '</a></li>' ).listview('refresh');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra3: CreateOptionsMenu", err); }
}
/**
handle Menu actions here
called when user clicks on a Menu item
*/
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#extra3_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#extra3_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_EXTRA1_BACK:
MenuActionGoBack();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra3: MenuItemSelected", err); }
}
function MenuActionGoBack() // go back to previous page
{
webphone_api.$.mobile.back();
}
/** This lifecycle function is called every time the user navigates away from this page.
* This is where you can save data that the user modified, clear dynamically added page content, etc.
*/
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra3: onStop");
// clear page content
webphone_api.$("#page_extra_content").html('');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra3: onStop", err); }
}
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop
};
})();
+145
View File
@@ -0,0 +1,145 @@
/* global webphone_api.$, common */
// Customizable page: extra4
webphone_api._extra4 = (function ()
{
/** Page navigation can be done by calling jQuery mobile "changePage()" method:
webphone_api.$.mobile.changePage("#PAGE_ID", { transition: "none", role: "page" });
Example: webphone_api.$.mobile.changePage("#page_extra4", { transition: "none", role: "page" });
To "close" this page and return to the previous page, call jQuery mobile method: webphone_api.$.mobile.back();
*/
/** !!! IMPORTANT NOTES:
1. The webphone is a single page application built using jQuery mobile framework.
Every jQuery mobile "page" defined in softphone.html has a corresponding Javascript file in /softphone/ directory.
Pages in softphone.html are <DIV> elements with the following attribute: data-role="page"
2. jQuery namespace within the webphone is changed from "$" to "webphone_api.$"
*/
/** This lifecycle function is called only once per session, when the user navigates to the page for the first time.
* This is where most initialization should go: attaching event listeners, initializing static page content, etc.
*/
function onCreate (event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra4: onCreate");
webphone_api.$('#extra4_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_extra4_menu").on("click", function() { CreateOptionsMenu('#extra4_menu_ul'); });
// set page title
webphone_api.$("#extra4_title").html('Page Extra 4');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra4: onCreate", err); }
}
/** This lifecycle function is called every time the user navigates to this page.
* This is where dynamic content can be added/refreshed.
*/
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra4: onStart");
// set back button text
webphone_api.$('#extra4_btnback').html('< Go back');
MeasureExtra4();
PopulateData();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra4: onStart", err); }
}
/** resolve window height size/resize changes */
function MeasureExtra4()
{
webphone_api.$('#page_extra4').css('min-height', 'auto'); // must be set when softphone is skin in div
var contentHeight = webphone_api.common.GetDeviceHeight() - webphone_api.$("#extra4_header").height() - 3;
webphone_api.$("#page_extra4_content").height(contentHeight);
}
/** dynamically add content to page */
function PopulateData()
{
try{
var pageContent = '<p>Content data of page Extra 4</p>';
webphone_api.$("#page_extra4_content").html(pageContent);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra4: PopulateData", err); }
}
/** adding menu items
this function will be called every time the user clicks on the "Menu" button in the top-right corner of the page
*/
var MENUITEM_EXTRA1_BACK = '#menuitem_extra4_back';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _extra4: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _extra4: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
// add menu items
var itemTitle = 'Go back';
webphone_api.$(menuId).append( '<li id="' + MENUITEM_EXTRA1_BACK + '"><a data-rel="back">' + itemTitle + '</a></li>' ).listview('refresh');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra4: CreateOptionsMenu", err); }
}
/**
handle Menu actions here
called when user clicks on a Menu item
*/
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#extra4_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#extra4_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_EXTRA1_BACK:
MenuActionGoBack();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra4: MenuItemSelected", err); }
}
function MenuActionGoBack() // go back to previous page
{
webphone_api.$.mobile.back();
}
/** This lifecycle function is called every time the user navigates away from this page.
* This is where you can save data that the user modified, clear dynamically added page content, etc.
*/
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra4: onStop");
// clear page content
webphone_api.$("#page_extra_content").html('');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra4: onStop", err); }
}
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop
};
})();
+145
View File
@@ -0,0 +1,145 @@
/* global webphone_api.$, common */
// Customizable page: extra5
webphone_api._extra5 = (function ()
{
/** Page navigation can be done by calling jQuery mobile "changePage()" method:
webphone_api.$.mobile.changePage("#PAGE_ID", { transition: "none", role: "page" });
Example: webphone_api.$.mobile.changePage("#page_extra5", { transition: "none", role: "page" });
To "close" this page and return to the previous page, call jQuery mobile method: webphone_api.$.mobile.back();
*/
/** !!! IMPORTANT NOTES:
1. The webphone is a single page application built using jQuery mobile framework.
Every jQuery mobile "page" defined in softphone.html has a corresponding Javascript file in /softphone/ directory.
Pages in softphone.html are <DIV> elements with the following attribute: data-role="page"
2. jQuery namespace within the webphone is changed from "$" to "webphone_api.$"
*/
/** This lifecycle function is called only once per session, when the user navigates to the page for the first time.
* This is where most initialization should go: attaching event listeners, initializing static page content, etc.
*/
function onCreate (event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra5: onCreate");
webphone_api.$('#extra5_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_extra5_menu").on("click", function() { CreateOptionsMenu('#extra5_menu_ul'); });
// set page title
webphone_api.$("#extra5_title").html('Page Extra 5');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra5: onCreate", err); }
}
/** This lifecycle function is called every time the user navigates to this page.
* This is where dynamic content can be added/refreshed.
*/
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra5: onStart");
// set back button text
webphone_api.$('#extra5_btnback').html('< Go back');
MeasureExtra5();
PopulateData();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra5: onStart", err); }
}
/** resolve window height size/resize changes */
function MeasureExtra5()
{
webphone_api.$('#page_extra5').css('min-height', 'auto'); // must be set when softphone is skin in div
var contentHeight = webphone_api.common.GetDeviceHeight() - webphone_api.$("#extra5_header").height() - 3;
webphone_api.$("#page_extra5_content").height(contentHeight);
}
/** dynamically add content to page */
function PopulateData()
{
try{
var pageContent = '<p>Content data of page Extra 5</p>';
webphone_api.$("#page_extra5_content").html(pageContent);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra5: PopulateData", err); }
}
/** adding menu items
this function will be called every time the user clicks on the "Menu" button in the top-right corner of the page
*/
var MENUITEM_EXTRA1_BACK = '#menuitem_extra5_back';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _extra5: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _extra5: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
// add menu items
var itemTitle = 'Go back';
webphone_api.$(menuId).append( '<li id="' + MENUITEM_EXTRA1_BACK + '"><a data-rel="back">' + itemTitle + '</a></li>' ).listview('refresh');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra5: CreateOptionsMenu", err); }
}
/**
handle Menu actions here
called when user clicks on a Menu item
*/
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#extra5_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#extra5_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_EXTRA1_BACK:
MenuActionGoBack();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra5: MenuItemSelected", err); }
}
function MenuActionGoBack() // go back to previous page
{
webphone_api.$.mobile.back();
}
/** This lifecycle function is called every time the user navigates away from this page.
* This is where you can save data that the user modified, clear dynamically added page content, etc.
*/
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _extra5: onStop");
// clear page content
webphone_api.$("#page_extra_content").html('');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_extra5: onStop", err); }
}
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop
};
})();
+364
View File
@@ -0,0 +1,364 @@
// File transfer
webphone_api._filetransfer = (function ()
{
function onCreate (event) // called only once - bind events here
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _filetransfer: onCreate");
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_filetransfer')
{
MeasureFiletransfer();
}
});
webphone_api.$('#filetransfer_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_filetransfer_menu").on("click", function() { CreateOptionsMenu('#filetransfer_menu_ul'); });
webphone_api.$("#btn_filetransfer_menu").attr("title", webphone_api.stringres.get("hint_menu"));
webphone_api.$("#btn_filetransfpick").on("click", function() { webphone_api.common.PickContact(PickContactResult); });
webphone_api.$("#btn_filetransfpick").attr("title", webphone_api.stringres.get('hint_choosect'));
webphone_api.$("#filetransfer_btnback").attr("title", webphone_api.stringres.get("hint_btnback"));
//-- webphone_api.$("#btn_filetransf").on("click", function(event) { SendFile(event); });
//-- webphone_api.$("#btn_filetransf").attr("title", webphone_api.stringres.get('hint_filetranf'));
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filetransfer: onCreate", err); }
}
var iframe = document.createElement('iframe');
var actionurl = '';
var lasttarget = '';
function onStart(event)
{
var lastoop = 0;
try{
lastoop = 1;
webphone_api.common.PutToDebugLog(4, "EVENT, _filetransfer: onStart");
webphone_api.global.isFiletransferStarted = true;
if (!webphone_api.common.isNull(document.getElementById('filetransfer_title')))
{
document.getElementById('filetransfer_title').innerHTML = webphone_api.stringres.get("filetransf_title");
}
webphone_api.$("#filetransfer_title").attr("title", webphone_api.stringres.get("hint_page"));
if (!webphone_api.common.isNull(document.getElementById('filetransfer_btnback')))
{
document.getElementById('filetransfer_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get("go_back_btn_txt");
}
lastoop = 2;
var destination = webphone_api.common.GetIntentParam(webphone_api.global.intentfiletransfer, 'destination');
if (webphone_api.common.isNull(destination)) { destination = ''; }
if(destination.length < 1) destination = lasttarget;
if (webphone_api.common.isNull(destination)) { destination = ''; }
if(destination.length < 1) destination = webphone_api.common.GetParameter('lastchattarget');
if (webphone_api.common.isNull(destination)) { destination = ''; }
lastoop = 3;
webphone_api.$('#filetransfpick_input').val(destination);
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#filetransfer_header'), -30) );
webphone_api.$("#filetransfpick_input").attr("placeholder", webphone_api.stringres.get("filetransfer_nr"));
// set focus on destination
setTimeout(function ()
{
var tovalTmp = webphone_api.$("#filetransfpick_input").val();
if (webphone_api.common.isNull(tovalTmp) || (webphone_api.common.Trim(tovalTmp)).length < 1)
{
webphone_api.$("#filetransfpick_input").focus();
}
}, 100);
actionurl = webphone_api.common.GetFiletrasnferFormActionUrl();
var useurlshortener = webphone_api.common.GetParameterInt('useurlshortener', -1);
var urlshortener_orig = webphone_api.common.GetParameter('urlshortener_orig');
var urlshortener_replace = webphone_api.common.GetParameter('urlshortener_replace');
lastoop = 4;
if (webphone_api.common.isNull(urlshortener_orig) || urlshortener_orig.length < 1) { urlshortener_orig = 'https://www.mizu-voip.com/G'; }
if (webphone_api.common.isNull(urlshortener_replace) || urlshortener_replace.length < 1) { urlshortener_replace = 'https://tinyurl.com/qm6oja3'; }
lastoop = 5;
if ((useurlshortener === -1 || useurlshortener === 1)
&& !webphone_api.common.isNull(urlshortener_orig) && urlshortener_orig.length > 0 && !webphone_api.common.isNull(urlshortener_replace) && urlshortener_replace.length > 0
&& actionurl.indexOf(urlshortener_orig) >= 0)
{
lastoop = 6;
actionurl = actionurl.replace(urlshortener_orig, urlshortener_replace);
if(actionurl.indexOf("https://rtc.mizu-voip.com/mvweb") >= 0)
{
actionurl = actionurl.replace('https://rtc.mizu-voip.com/mvweb', 'https://tinyurl.com/yxpz9ce2');
}
}
webphone_api.common.PutToDebugLog(2, 'EVENT, filetransfer actionurl: ' + actionurl);
lastoop = 7;
// add iframe
iframe.style.background = 'transparent';
iframe.style.border = '0';
iframe.style.width = '100%';
iframe.style.overflow = 'hidden';
var html = '<body style="margin 0; padding 0; background: transparent; width: 100%; overflow:hidden; font-size: 1em; color: #cecece;">' +
'<style>' +
'#fileinput { padding: .6em; background: #ffffff; display: inline-block; width: 95%; border: .1em solid #b8b8b8; -webkit-border-radius: .15em; border-radius: .15em;' +
'cursor: pointer; font-weight: bold; font-size: 1em; }' +
'#btn_filetransf { display: inline-block; margin-top: 1.5em; padding: .6em 2em .6em 2em; border: .1em solid #b8b8b8; -webkit-border-radius: .15em; border-radius: .15em;' +
'cursor: pointer; font-weight: bold; font-size: 1em; background: #cccccc; }' +
'#btn_filetransf:hover { background: #ffffff; }' +
'</style>' +
'<form style=" width: 100%; margin: 0; padding: 0;" action="' + actionurl + '" method="post" enctype="multipart/form-data" id="frm_filetransf" name="frm_filetransf" onsubmit="return OnFormSubmit()">' +
'<input type="hidden" id="filepath" name="filepath" value="">' +
'<input name="filedata" type="file" id="fileinput" /><br />' +
'<input type="submit" id="btn_filetransf" value="' + webphone_api.stringres.get('btn_send') + '" title="' + webphone_api.stringres.get('hint_filetranf') + '" />' +
'<script>' +
'function OnFormSubmit(){' +
'var directory = document.getElementById("filepath").value;' +
'var filename = document.getElementById("fileinput").value;' +
'return parent.webphone_api._filetransfer.FileTransferOnSubmit(directory, filename);' +
'}' +
'</script>' +
'</form>' +
'</body>';
//-- document.body.appendChild(iframe);
lastoop = 8;
document.getElementById('ftranf_iframe_container').appendChild(iframe);
iframe.contentWindow.document.open();
iframe.contentWindow.document.write(html);
iframe.contentWindow.document.close();
iframe.onload = function (evt) { FileUploaded(evt); };
var ifrmDoc = iframe.contentDocument || iframe.contentWindow.document;
lastoop = 9;
setTimeout(function ()
{
// fallback for IE7, IE8 addEventListener
if (ifrmDoc.addEventListener)
{
ifrmDoc.addEventListener('click', HandleEventFiletransferStart, false);
}
else if (typeof (ifrmDoc.attachEvent) !== 'undefined' || ifrmDoc.attachEvent != null)
{
ifrmDoc.attachEvent('click', HandleEventFiletransferStart);
}
function HandleEventFiletransferStart(event)
{
var dest = document.getElementById('filetransfpick_input').value;
if (webphone_api.common.isNull(dest) || (webphone_api.common.Trim(dest)).length < 1)
{
event.preventDefault();
webphone_api.$("#filetransfpick_input").focus();
webphone_api.common.ShowToast(webphone_api.stringres.get('filetransf_err'));
return;
}else
{
// set userguid (directory name)
var filepath = webphone_api.common.GetTransferDirectoryName(dest);
ifrmDoc.getElementById('filepath').value = filepath;
webphone_api.common.PutToDebugLog(4, 'EVENT, filetransfer directory: ' + filepath);
}
}
}, 150);
lastoop = 10;
MeasureFiletransfer();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filetransfer: onStart "+lastoop.toString(), err); } //ERROR, catch on _filetransfer: onStart ReferenceError: isNull is not defined (isNull is not defined)
}
// called from iframe -> for onsubmit
var transf_initiated = false;
function FileTransferOnSubmit(directory, filename)
{
try{
webphone_api.common.PutToDebugLog(4, 'EVENT, FileTransferOnSubmit called from iframe form');
webphone_api.common.PutToDebugLog(4, 'EVENT, FileTransferOnSubmit directory: ' + directory + '; filename: ' + filename);
//-- FileTransferOnSubmit directory: 0ecf34d0bd5c69f07b6fa8b654d80a74; filename: C:\fakepath\webphonejar_parameters.txt
if (webphone_api.common.isNull(directory)) { directory = ''; } else { directory = '/' + directory; }
if (webphone_api.common.isNull(filename) || filename.length < 1)
{
webphone_api.common.PutToDebugLog(3, 'ERROR, FileTransfer send failed: ivalid filename: ' + filename);
webphone_api.common.ShowToast(webphone_api.stringres.get('fitransf_failed'));
return false;
}
var pos = filename.lastIndexOf('/');
if (pos >= 0) { filename = filename.substring(pos + 1, filename.length); }
pos = filename.lastIndexOf('\\');
if (pos >= 0) { filename = filename.substring(pos + 1, filename.length); }
// the path of the uploaded file on the server
var transferpath = actionurl + 'filestorage' + directory + '/' + webphone_api.common.NormalizeFilename(filename);
webphone_api.common.PutToDebugLog(4, 'EVENT, FileTransferOnSubmit filepath: ' + transferpath);
webphone_api.$('#ftranf_status').html(webphone_api.stringres.get('ftrnasf_status_processing'));
//-- go back one step in history, otherwise <Back must be clicked 2 times to close the window
//-- setTimeout(function ()
//-- {
//-- webphone_api.$.mobile.back();
//-- webphone_api.common.ShowToast(webphone_api.stringres.get('fitransf_succeded'));
//-- }, 1500);
// send chat to destination
var ahref = '<a href="' + transferpath + '" target="_blank">' + webphone_api.common.NormalizeFilename(filename) + '</a>';
var msg = '[DONT_START_CHAT_WINDOW]' + webphone_api.common.GetSipusername(true) + ' ' + webphone_api.stringres.get('fitransf_chat') + ': ' + ahref;
var to = webphone_api.common.Trim(document.getElementById('filetransfpick_input').value);
lasttarget = to;
webphone_api.common.SaveParameter('lastchattarget',to);
webphone_api.sendchat(to, msg);
transf_initiated = true;
if (webphone_api.common.GetBrowser() === 'Firefox')
{
if (!webphone_api.common.isNull(iframe))
{
document.getElementById('ftranf_iframe_container').removeChild(iframe);
}
FileUploaded(null);
return false;
}else
{
return true;
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filetransfer: FileTransferOnSubmit", err); }
return false;
}
function FileUploaded(evt) // actually it's called on iframe.onload
{
try{
if (transf_initiated === false) { return; }
transf_initiated = false;
webphone_api.$('#ftranf_status').html(webphone_api.stringres.get('ftrnasf_status_waiting'));
// go back one step in history, otherwise <Back must be clicked 2 times to close the window
setTimeout(function ()
{
webphone_api.$.mobile.back();
}, 500);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filetransfer: FileUploaded", err); }
}
function MeasureFiletransfer() // resolve window height size change
{
try{
//-- var pgh = webphone_api.common.GetDeviceHeight() - 1; webphone_api.$('#page_filetransfer').css('min-height', pgh + 'px'); // must be set when softphone is skin in div
webphone_api.$('#page_filetransfer').css('min-height', 'auto'); // must be set when softphone is skin in div
webphone_api.$("#page_filetransfer_content").height(webphone_api.common.GetDeviceHeight() - webphone_api.$("#filetransfer_header").height() - 2);
//-- webphone_api.$("#log_text").height(webphone_api.common.GetDeviceHeight() - webphone_api.$("#filetransfer_header").height() - webphone_api.$("#sendtosupport_container").height() - 5);
//-- webphone_api.$("#log_text").width(webphone_api.common.GetDeviceWidth());
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filetransfer: MeasureFiletransfer", err); }
}
function PickContactResult(number)
{
try{
document.getElementById('filetransfpick_input').value = number;
//-- webphone_api.$("#msg_textarea").focus();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filetransfer: PickContactResult", err); }
}
var MENUITEM_FILETRANSFER_CLOSE = '#menuitem_filetransfer_close';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.GetParameter('devicetype') === webphone_api.common.DEVICE_WIN_SOFTPHONE())
{
webphone_api.$( "#btn_filetransfer_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _filetransfer: CreateOptionsMenu menuid null"); return false; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _filetransfer: CreateOptionsMenu can't get reference to Menu"); return false; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_FILETRANSFER_CLOSE + '"><a data-rel="back">' + webphone_api.stringres.get('menu_close') + '</a></li>' ).listview('refresh');
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filetransfer: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#filetransfer_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#filetransfer_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_FILETRANSFER_CLOSE:
webphone_api.$.mobile.back();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filetransfer: MenuItemSelected", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _filetransfer: onStop");
webphone_api.global.isFiletransferStarted = false;
if (!webphone_api.common.isNull(iframe))
{
document.getElementById('ftranf_iframe_container').removeChild(iframe);
}
document.getElementById('filetransfpick_input').value = '';
webphone_api.$('#ftranf_status').html('');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filetransfer: onStop", err); }
}
function onDestroy (event){} // deprecated by onstop
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop,
onDestroy: onDestroy,
FileTransferOnSubmit: FileTransferOnSubmit
};
})();
+519
View File
@@ -0,0 +1,519 @@
// Filters page
webphone_api._filters = (function ()
{
var filterL = null; // [ [40,00,6,12],[+40,,5,10] ]
function onCreate (event) // called only once - bind events here
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _filters: onCreate");
webphone_api.$('#filters_list').on('click', '.ch_anchor', function(event)
{
OnListItemClick(webphone_api.$(this).attr('id'));
});
webphone_api.$('#filters_list').on('click', '.ch_menu', function(event)
{
OnListItemClick(webphone_api.$(this).attr('id'));
});
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_filters')
{
MeasureFilterslist();
}
});
webphone_api.$('#filters_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_filters_menu").on("click", function() { CreateOptionsMenu('#filters_menu_ul'); });
webphone_api.$("#btn_filters_menu").attr("title", webphone_api.stringres.get("hint_menu"));
webphone_api.$("#btn_add_filters").on("click", function() { AddFilter(false, null); });
webphone_api.$( "#page_filters" ).keyup(function( event )
{
HandleKeyUp(event);
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: onCreate", err); }
}
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _filters: onStart");
webphone_api.global.isFiltersStarted = true;
setTimeout(function() // otherwise keyup will not work, because the element is not focused
{
webphone_api.$("#page_filters").focus();
}, 100);
//--webphone_api.$("#phone_number").attr("placeholder", webphone_api.stringres.get("phone_nr"));
if (!webphone_api.common.isNull(document.getElementById('filters_title')))
{
document.getElementById('filters_title').innerHTML = webphone_api.stringres.get('filters_title');
}
webphone_api.$("#filters_title").attr("title", webphone_api.stringres.get("hint_page"));
webphone_api.$("#filters_label_add").html(webphone_api.stringres.get("filters_add_label"));
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#page_filters'), -30) );
if (!webphone_api.common.isNull(document.getElementById('filters_btnback')))
{
document.getElementById('filters_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get("go_back_btn_txt");
}
// needed for proper display and scrolling of listview
MeasureFilterslist();
// fix for IE 10
if (webphone_api.common.IsIeVersion(10)) { webphone_api.$("#filters_list").children().css('line-height', 'normal'); }
PopulateList();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: onStart", err); }
}
function MeasureFilterslist() // resolve window height size change
{
try{
//--var pgh = webphone_api.common.GetDeviceHeight() - 1; webphone_api.$('#page_filters').css('min-height', pgh + 'px'); // must be set when softphone is skin in div
webphone_api.$('#page_filters').css('min-height', 'auto'); // must be set when softphone is skin in div
// handle page height
var heightTemp = webphone_api.common.GetDeviceHeight() - webphone_api.$("#filters_header").height() - webphone_api.$("#filters_add_section").height();
var margin = webphone_api.common.StrToIntPx( webphone_api.$("#filters_add_section").css("margin-top") ) + webphone_api.common.StrToIntPx( webphone_api.$("#filters_add_section").css("margin-bottom") );
heightTemp = heightTemp - margin - 3;
webphone_api.$("#filters_list").height(heightTemp);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: MeasureFilterslist", err); }
}
function PopulateList() // :no return value; // onlyonserver: display only contacts on server. Controlled by toggle button
{
try{
if ( webphone_api.common.isNull(document.getElementById('filters_list')) )
{
webphone_api.common.PutToDebugLog(2, "ERROR, _filters: PopulateList listelement is null");
return;
}
ReadFilters();
var listview = '';
if (webphone_api.common.isNull(filterL) || filterL.length < 1)
{
webphone_api.$('#filters_list').html('');
webphone_api.$('#filters_list').append(listview).listview('refresh');
webphone_api.common.PutToDebugLog(2, "EVENT, _filters: PopulateList no filters to display");
return;
}
var template = '' +
'<li data-theme="b">' +
'<a id="filteritem_[FID]" class="ch_anchor mlistitem" title="' + webphone_api.stringres.get('filter_edit_hint') + '">' +
'<div class="item_container">' +
'<div class="r_what">' + webphone_api.stringres.get('filter_start') + ': <span>[WHAT]</span></div>' +
'<div class="r_with">' + webphone_api.stringres.get('filter_replace') + ': <span>[WITH]</span></div>' +
'<div class="r_minlen">' + webphone_api.stringres.get('filter_minlen') + ': <span>[MINL]</span></div>' +
'<div class="r_maxlen">' + webphone_api.stringres.get('filter_maxlen') + ': <span>[MAXL]</span></div>' +
'</div>' +
'</a>' +
'<a id="filtermenu_[FID]" class="ch_menu mlistitem">' + webphone_api.stringres.get('filter_delete_hint') + '</a>' +
'</li>';
for (var i = 0; i < filterL.length; i++)
{
var one = filterL[i];
if (webphone_api.common.isNull(one[webphone_api.common.F_WHAT])) { one[webphone_api.common.F_WHAT] = ''; }
if (webphone_api.common.isNull(one[webphone_api.common.F_WITH])) { one[webphone_api.common.F_WITH] = ''; }
if (webphone_api.common.isNull(one[webphone_api.common.F_MIN])) { one[webphone_api.common.F_MIN] = ''; }
if (webphone_api.common.isNull(one[webphone_api.common.F_MAX])) { one[webphone_api.common.F_MAX] = ''; }
var htmlitem = webphone_api.common.ReplaceAll(template, '[FID]', i.toString());
htmlitem = htmlitem.replace('[WHAT]', one[webphone_api.common.F_WHAT]);
htmlitem = htmlitem.replace('[WITH]', one[webphone_api.common.F_WITH]);
htmlitem = htmlitem.replace('[MINL]', one[webphone_api.common.F_MIN]);
htmlitem = htmlitem.replace('[MAXL]', one[webphone_api.common.F_MAX]);
listview = listview + htmlitem;
}
webphone_api.$('#filters_list').html('');
webphone_api.$('#filters_list').append(listview).listview('refresh');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: PopulateList", err); }
}
var trigerredlist = false; // handle multiple clicks
function OnListItemClick (id) // :no return value
{
try{
if (trigerredlist) { return; }
trigerredlist = true;
setTimeout(function ()
{
trigerredlist = false;
}, 1000);
if (webphone_api.common.isNull(id) || id.length < 1)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, _filters OnListItemClick id is NULL');
return;
}
var fid = '';
var pos = id.indexOf('_');
if (pos < 2)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, _filters OnListItemClick invalid id');
return;
}
fid = webphone_api.common.Trim(id.substring(pos + 1));
var idint = 0;
try{
idint = webphone_api.common.StrToInt( webphone_api.common.Trim(fid) );
} catch(errin1) { webphone_api.common.PutToDebugLogException(2, "_filters: OnListItemClick convert fid", errin1); }
if (id.indexOf('filteritem') === 0) // means edit rule
{
AddFilter(true, idint)
}
else if (id.indexOf('filtermen') === 0) // (menu) in this case delete rule
{
DeleteFilter(idint);
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: OnListItemClick", err); }
}
function AddFilter(isedit, fid, popupafterclose)
{
try{
var popupWidth = webphone_api.common.GetDeviceWidth();
if ( !webphone_api.common.isNull(popupWidth) && webphone_api.common.IsNumber(popupWidth) && popupWidth > 100 )
{
popupWidth = Math.floor(popupWidth / 1.2);
}else
{
popupWidth = 220;
}
var fwhat_init = '';
var fwith_init = '';
var minl_init = '';
var maxl_init = '';
if (isedit === true && !webphone_api.common.isNull(fid) && webphone_api.common.IsNumber(fid))
{
var edititem = filterL[fid];
fwhat_init = edititem[webphone_api.common.F_WHAT];
fwith_init = edititem[webphone_api.common.F_WITH];
minl_init = edititem[webphone_api.common.F_MIN];
maxl_init = edititem[webphone_api.common.F_MAX];
if (webphone_api.common.isNull(fwhat_init)) { fwhat_init = ''; }
if (webphone_api.common.isNull(fwith_init)) { fwith_init = ''; }
if (webphone_api.common.isNull(minl_init)) { minl_init = ''; }
if (webphone_api.common.isNull(maxl_init)) { maxl_init = ''; }
}
var template = '' +
'<div id="filter_popup" data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="width:' + popupWidth + 'px; max-width:' + popupWidth + 'px; min-width: ' + Math.floor(popupWidth * 0.6) + 'px;">' +
'<div data-role="header" data-theme="b">' +
'<a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a>' +
'<h1 class="adialog_title">' + webphone_api.stringres.get('filters_add_rule') + '</h1>' +
'</div>' +
'<div role="main" class="ui-content adialog_content" style="padding: 0; margin: 0; width: 100%;">' +
'<div class="filter_left_container">'+
'<label style="width: 100%">' + webphone_api.stringres.get('filter_start') + ':</label>' +
'</div>' +
'<div class="filter_right_container">' +
'<input name="filter_what" id="filter_what" data-highlight="true" data-mini="true" value="' + fwhat_init + '" type="text" autocapitalize="off">' +
'</div>' +
'<div class="filter_left_container">'+
'<label style="width: 100%">' + webphone_api.stringres.get('filter_replace') + ':</label>' +
'</div>' +
'<div class="filter_right_container">' +
'<input name="filter_with" id="filter_with" data-highlight="true" data-mini="true" value="' + fwith_init + '" type="text" autocapitalize="off">' +
'</div>' +
'<div class="filter_left_container">'+
'<label style="width: 100%">' + webphone_api.stringres.get('filter_minlen') + ':</label>' +
'</div>' +
'<div class="filter_right_container">' +
'<input name="filter_min" id="filter_min" data-highlight="true" data-mini="true" value="' + minl_init + '" type="text" autocapitalize="off">' +
'</div>' +
'<div class="filter_left_container">'+
'<label style="width: 100%">' + webphone_api.stringres.get('filter_maxlen') + ':</label>' +
'</div>' +
'<div class="filter_right_container">' +
'<input name="filter_max" id="filter_max" data-highlight="true" data-mini="true" value="' + maxl_init + '" type="text" autocapitalize="off">' +
'</div>' +
// '<a href="javascript:;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back">' + webphone_api.stringres.get('btn_close') + '</a>' +
// '<a href="javascript:;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back" data-transition="flow">Delete</a>' +
'</div>' +
'<div data-role="footer" data-theme="b" class="adialog_footer">' +
'<a href="javascript:;" id="adialog_positive" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">' + webphone_api.stringres.get('btn_ok') + '</a>' +
'<a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">' + webphone_api.stringres.get('btn_cancel') + '</a>' +
'</div>' +
'</div>';
popupafterclose = popupafterclose ? popupafterclose : function () {};
webphone_api.$.mobile.activePage.append(template).trigger("create");
//-- webphone_api.$.mobile.activePage.append(template).trigger("pagecreate");
webphone_api.$.mobile.activePage.find(".closePopup").bind("tap", function (e)
{
webphone_api.$.mobile.activePage.find(".messagePopup").popup("close");
});
webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind(
{
popupafterclose: function ()
{
webphone_api.$(this).unbind("popupafterclose").remove();
popupafterclose();
}
});
webphone_api.$('#adialog_positive').on('click', function (event)
{
webphone_api.common.PutToDebugLog(5,"EVENT, _filters AddFilter ok on click");
var fwhat = webphone_api.$('#filter_what').val();
var fwith = webphone_api.$('#filter_with').val();
var minl = webphone_api.$('#filter_min').val();
var maxl = webphone_api.$('#filter_max').val();
if (webphone_api.common.isNull(fwhat)) { fwhat = ''; }
if (webphone_api.common.isNull(fwith)) { fwith = ''; }
if (webphone_api.common.isNull(minl)) { minl = ''; }
if (webphone_api.common.isNull(maxl)) { maxl = ''; }
fwhat = webphone_api.common.Trim(fwhat);
fwith = webphone_api.common.Trim(fwith);
minl = webphone_api.common.Trim(minl);
maxl = webphone_api.common.Trim(maxl);
fwhat = webphone_api.common.ReplaceAll(fwhat, ',', '_'); fwhat = webphone_api.common.ReplaceAll(fwhat, ';', '_');
fwith = webphone_api.common.ReplaceAll(fwith, ',', '_'); fwith = webphone_api.common.ReplaceAll(fwith, ';', '_');
if (!webphone_api.common.IsNumber(minl)) { minl = ''; }
if (!webphone_api.common.IsNumber(maxl)) { maxl = ''; }
if (fwhat.length < 1 && fwith.length < 1)
{
webphone_api.common.ShowToast(webphone_api.stringres.get('filter_warning'));
return;
}
// add filter to list
var item = [];
item[webphone_api.common.F_WHAT] = fwhat;
item[webphone_api.common.F_WITH] = fwith;
item[webphone_api.common.F_MIN] = minl;
item[webphone_api.common.F_MAX] = maxl;
if (isedit === true && !webphone_api.common.isNull(fid) && webphone_api.common.IsNumber(fid))
{
filterL[fid] = item;
}else
{
filterL.push(item);
}
SaveFilters();
PopulateList();
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: AddFilter", err); }
}
function DeleteFilter(fid)
{
try{
if (webphone_api.common.isNull(fid) || !webphone_api.common.IsNumber(fid) || fid < 0 || fid >= filterL.length)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, _filters: DeleteFilter invalid id: ' + fid);
return;
}
filterL.splice(fid, 1);
SaveFilters();
PopulateList();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: DeleteFilter", err); }
}
function ReadFilters()
{
try{
var fval = webphone_api.common.GetParameter2('filters');
/*
fval = '40,00,6,12;+40,,5,10';
*/
filterL = [];
if (webphone_api.common.isNull(fval) || fval.length < 1)
{
webphone_api.common.PutToDebugLog(3, 'ReadFilters, nothing to read');
return;
}
var itemsL = fval.split(';');
if (webphone_api.common.isNull(itemsL) || itemsL.length < 1) { return; }
for (var i = 0; i < itemsL.length; i++)
{
if (webphone_api.common.isNull(itemsL[i]) || itemsL[i].length < 3) { continue; }
var oneitem = itemsL[i].split(',');
if (webphone_api.common.isNull(oneitem) || oneitem.length !== 4) { continue; }
filterL.push(oneitem);
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: ReadFilters", err); }
}
function SaveFilters()
{
try{
if (webphone_api.common.isNull(filterL))
{
webphone_api.common.PutToDebugLog(3, 'SaveFilters, nothing to save');
return;
}
var fval = '';
for (var i = 0; i < filterL.length; i++)
{
var item = filterL[i];
if (webphone_api.common.isNull(item) || item.length < 3) { continue; }
if (fval.length > 0) { fval = fval + ';'; }
fval = fval + item[webphone_api.common.F_WHAT] + ',' + item[webphone_api.common.F_WITH] + ',' + item[webphone_api.common.F_MIN] + ',' + item[webphone_api.common.F_MAX];
}
if (webphone_api.common.isNull(fval)) { fval = ''; }
webphone_api.common.SaveParameter('filters', fval);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: SaveFilters", err); }
}
function HandleKeyUp(event)
{
try{
//-- don't catch input if a popup is open, because popups can have input boxes, and we won't be able to write into them
if (webphone_api.$(".ui-page-active .ui-popup-active").length > 0)
{
return false;
}
var charCode = (event.keyCode) ? event.keyCode : event.which; // workaround for firefox
if (charCode === 8) // backspace
{
event.preventDefault();
webphone_api.$.mobile.back();
}
//-- else if (charCode === 13)
//-- {
//-- event.preventDefault();
//-- webphone_api.$("#btn_call").click();
//-- }
return false;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: HandleKeyUp", err); }
}
var MENUITEM_FILTERS_CLOSE = '#menuitem_filters_close';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.IsWindowsSoftphone())
{
webphone_api.$( "#btn_filters_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _filters: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _filters: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_FILTERS_CLOSE + '"><a data-rel="back">' + webphone_api.stringres.get('menu_close') + '</a></li>' ).listview('refresh');
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#filters_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#filters_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_FILTERS_CLOSE:
webphone_api.$.mobile.back();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: MenuItemSelected", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _filters: onStop");
webphone_api.global.isFiltersStarted = false;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_filters: onStop", err); }
}
function onDestroy (event){} // deprecated by onstop
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop,
onDestroy: onDestroy
};
})();
@@ -0,0 +1,237 @@
// Internal Browser page
webphone_api._internalbrowser = (function ()
{
var url = '';
var lastpage = '';
var pagetitle = '';
function onCreate (event) // called only once - bind events here
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _internalbrowser: onCreate");
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_internalbrowser')
{
MeasureInternalbrowser();
}
});
webphone_api.$('#internalbrowser_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_internalbrowser_menu").on("click", function() { CreateOptionsMenu('#internalbrowser_menu_ul'); });
webphone_api.$("#btn_internalbrowser_menu").attr("title", webphone_api.stringres.get("hint_menu"));
webphone_api.$("#internalbrowser_btnback").on("click", function(e)
{
CloseBrowser();
e.preventDefault();
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_internalbrowser: onCreate", err); }
}
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _internalbrowser: onStart");
webphone_api.global.isInternalbrowserStarted = true;
webphone_api.$('#page_internalbrowser_content').html('');
url = webphone_api.common.GetIntentParam(webphone_api.global.intentbrowser, 'url');
lastpage = webphone_api.common.GetIntentParam(webphone_api.global.intentbrowser, 'lastpage');
pagetitle = webphone_api.common.GetIntentParam(webphone_api.global.intentbrowser, 'title');
if (!webphone_api.common.isNull(document.getElementById('internalbrowser_title')))
{
if (webphone_api.common.isNull(pagetitle)) { pagetitle = ''; }
document.getElementById('internalbrowser_title').innerHTML = pagetitle;
}
webphone_api.$("#internalbrowser_title").attr("title", webphone_api.stringres.get("hint_page"));
if (!webphone_api.common.isNull(document.getElementById('internalbrowser_btnback')))
{
document.getElementById('internalbrowser_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get("go_back_btn_txt");
}
MeasureInternalbrowser();
if (webphone_api.common.isNull(lastpage))
{
lastpage = '';
}else
{
lastpage = webphone_api.common.Trim(lastpage);
}
webphone_api.$("#page_internalbrowser").css("background", "#FFFFFF");
OpenWebpage();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_internalbrowser: onStart", err); }
}
function MeasureInternalbrowser() // resolve window height size change
{
try{
//--var pgh = webphone_api.common.GetDeviceHeight() - 1; webphone_api.$('#page_internalbrowser').css('min-height', pgh + 'px'); // must be set when softphone is skin in div
webphone_api.$('#page_internalbrowser').css('min-height', 'auto'); // must be set when softphone is skin in div
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#page_internalbrowser'), -30) );
var heightTemp = webphone_api.common.GetDeviceHeight() - webphone_api.$("#internalbrowser_header").height();
heightTemp = heightTemp - 3;
heightTemp = Math.floor(heightTemp);
webphone_api.$("#page_internalbrowser_content").height(heightTemp);
webphone_api.$("#iframe_internalbrowser").width(webphone_api.common.GetDeviceWidth());
webphone_api.$("#iframe_internalbrowser").height(heightTemp - 5);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_internalbrowser: MeasureInternalbrowser", err); }
}
function OpenWebpage()
{
try{
if (webphone_api.common.isNull(url) || url.length < 3 )
{
webphone_api.common.PutToDebugLog(3, 'ERROR, _internalbrowser no url to load: ' + url);
return;
}
var width = webphone_api.common.GetDeviceWidth();
var height = Math.floor( webphone_api.$('#page_internalbrowser_content').height() - 5);
var iframe = '';
var pos = url.indexOf('[POST]');
if (pos > 0)
{
var purl = webphone_api.common.Trim(url.substring(0, pos));
var pdataStr = webphone_api.common.Trim(url.substring(pos + 6));
var pdata = [];
var pdataInput = '';
if (!webphone_api.common.isNull(pdataStr) && pdataStr.length > 0)
{
pdata = pdataStr.split('&');
if (webphone_api.common.isNull(pdata)) { pdata = []; }
}
for (var i = 0; i < pdata.length; i++)
{
if (webphone_api.common.isNull(pdata[i]) || pdata[i].length < 2 || pdata[i].indexOf('=') < 1) { continue; }
var name = pdata[i].substring(0, pdata[i].indexOf('='));
var val = pdata[i].substring(pdata[i].indexOf('=') + 1);
if (webphone_api.common.isNull(name) || name.length < 1 || webphone_api.common.isNull(val)) { continue; }
pdataInput += '<input type="hidden" name="' + name + '" value="' + val + '"/>';
}
iframe = '<form id="internalb_post" target="iframe_internalbrowser" method="post" action="' + purl + '">' +
pdataInput +
'</form>' +
'<iframe allow="microphone; camera; autoplay" frameborder="0" width="' + width + '" height="' + height + '" name="iframe_internalbrowser" id="iframe_internalbrowser" style="margin:0px; padding:0px;" sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-top-navigation"></iframe>' +
'<script type="text/javascript">' +
'document.getElementById("internalb_post").submit();' +
'</script>';
}else
{
//-- var iframe = '<iframe frameborder="0" width="' + width + '" height="' + height + '" src="' + url + '" name="iframe_internalbrowser" id="iframe_internalbrowser" style="margin:0px; padding:0px;"></iframe>';
iframe = '<iframe allow="microphone *; camera *; autoplay *" allowfullscreen="true" frameborder="0" width="' + width + '" height="' + height + '" src="' + url + '" name="iframe_internalbrowser" id="iframe_internalbrowser" style="margin:0px; padding:0px;" sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-top-navigation"></iframe>';
}
webphone_api.$('#page_internalbrowser_content').html(iframe);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_internalbrowser: OpenWebpage", err); }
}
var MENUITEM_CLOSE = '#menuitem_internalbrowser_close';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.GetParameter('devicetype') === webphone_api.common.DEVICE_WIN_SOFTPHONE())
{
webphone_api.$( "#btn_internalbrowser_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _internalbrowser: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _internalbrowser: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CLOSE + '"><a data-rel="back">' + webphone_api.stringres.get('menu_close') + '</a></li>' ).listview('refresh');
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_internalbrowser: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#internalbrowser_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#internalbrowser_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_CLOSE:
CloseBrowser();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_internalbrowser: MenuItemSelected", err); }
}
function CloseBrowser()
{
try{
if (lastpage.length < 2)
{
webphone_api.$.mobile.back();
webphone_api.common.PutToDebugLog(5, 'EVENT, _internalbrowser: CloseBrowser back');
}else
{
webphone_api.$.mobile.changePage("#" + lastpage, { transition: "pop", role: "page" });
webphone_api.common.PutToDebugLog(5, 'EVENT, _internalbrowser: CloseBrowser changepage: ' + lastpage);
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_internalbrowser: CloseBrowser", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _internalbrowser: onStop");
webphone_api.global.isInternalbrowserStarted = false;
webphone_api.$('#page_internalbrowser_content').html('');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_internalbrowser: onStop", err); }
}
function onDestroy (event){} // deprecated by onstop
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop,
onDestroy: onDestroy
};
})();
+345
View File
@@ -0,0 +1,345 @@
// Logview
webphone_api._logview = (function ()
{
function onCreate (event) // called only once - bind events here
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _logview: onCreate");
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_logview')
{
MeasureLogview();
}
});
webphone_api.$('#logview_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_logview_menu").on("click", function() { CreateOptionsMenu('#logview_menu_ul'); });
webphone_api.$("#btn_logview_menu").attr("title", webphone_api.stringres.get("hint_menu"));
webphone_api.$("#support_selectall").on("click", function()
{
webphone_api.$('#log_text').select();
});
webphone_api.$("#sendtosupport").on("click", function()
{
var additionalinfo = 'Build date: ' + webphone_api.common.GetParameter('codegenerated');
webphone_api.common.SendLog(additionalinfo + '&#10;' + webphone_api.global.logs);
});
// it's not working on mobile devices
if (webphone_api.common.GetOs() === 'Android' || webphone_api.common.GetOs() === 'iOS')
{
webphone_api.$("#support_selectall").hide();
}
webphone_api.$("#btn_loghelp").on("click", function()
{
webphone_api.common.AlertDialog(webphone_api.stringres.get('help'), webphone_api.stringres.get('logview_help') + ' ' + webphone_api.common.GetParameter('support_email'), null, null, false);
});
webphone_api.$("#btn_sendlog").on("click", function()
{
webphone_api.common.PutToDebugLog(1, 'EVENT, Log upload succeded');
setTimeout(function ()
{
webphone_api.common.PutToDebugLog(1, 'EVENT, Log upload succeded');
}, 500);
//-- webphone_api.common.ShowToast(webphone_api.stringres.get('logview_msg'), 20000); // this line is blocking submit
//-- setTimeout(function ()
//-- {
//-- webphone_api.$("#btn_loghelp").show();
//-- webphone_api.common.ShowToast(webphone_api.stringres.get('logview_help'));
//-- }, 2000);
//-- webphone_api.$.mobile.back();
if (webphone_api.common.GetParameter('email').length < 1)
{
var myemail = prompt(webphone_api.stringres.get('log_email'));
if (!webphone_api.common.isNull(myemail) && myemail.length > 3)
{
// validate email
if (!webphone_api.common.isNull(myemail.match("^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9|-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")))
{
webphone_api.common.SaveParameter('email', myemail);
}
}
}
var pdesc = prompt(webphone_api.stringres.get('log_description'));
if (webphone_api.common.isNull(pdesc) || pdesc.length < 3)
{
webphone_api.common.ShowToast(webphone_api.stringres.get('log_desc_error'));
return false;
}else
{
var pd = '\n\nProblem description: ' + pdesc + '\n\n';
webphone_api.$('#log_text').html(pd + webphone_api.$('#log_text').html());
//webphone_api.$.mobile.back();
webphone_api.$.mobile.changePage("#page_dialpad", { transition: "none", role: "page", reverse: "true" });
return true;
}
});
if (webphone_api.common.GetOs() !== 'Android' && webphone_api.common.GetOs() !== 'iOS')
{
webphone_api.$('#log_text').attr('readonly', 'readonly');
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_logview: onCreate", err); }
}
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _logview: onStart");
webphone_api.global.isLogviewStarted = true;
if (!webphone_api.common.isNull(document.getElementById('logview_title')))
{
document.getElementById('logview_title').innerHTML = webphone_api.stringres.get("logview_title");
}
webphone_api.$("#logview_title").attr("title", webphone_api.stringres.get("hint_page"));
if (!webphone_api.common.isNull(document.getElementById('logview_btnback')))
{
document.getElementById('logview_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get("go_back_btn_txt");
}
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#logview_header'), -30) );
webphone_api.$("#label_disable_logs").html(webphone_api.stringres.get('disable_logs'));
//-- var email = webphone_api.common.GetConfig('log_email');
//-- if (!webphone_api.common.isNull(email) && email.length > 2)
//-- {
//-- if (!webphone_api.common.isNull(document.getElementById("sendtosupport_link")))
//-- {
//-- document.getElementById("sendtosupport_link").innerHTML = webphone_api.stringres.get("sendtosupport");
//-- }
//-- if (!webphone_api.common.isNull(document.getElementById("support_selectall")))
//-- {
//-- document.getElementById("support_selectall").innerHTML = webphone_api.stringres.get("support_selectall");
//-- }
//-- mailto:test@example.com?subject=subject&body=body
//-- var href = 'mailto:' + webphone_api.common.Trim(email) + '?subject=JSPhone Log&body=' + webphone_api.stringres.get('support_email_body');
//-- href = webphone_api.common.ReplaceAll(href, ' ', '%20');
//-- var href = 'mailto:' + webphone_api.common.Trim(email) + '?subject=' + encodeURIComponent('WebPhone Log') + '&body=' + webphone_api.stringres.get('support_email_body');
//-- webphone_api.$('#sendtosupport_link').attr('href', href);
//-- Spaces between words should be replaced by %20 to ensure that the browser will display the text properly.
//-- }else
//-- {
//-- webphone_api.$("#sendtosupport_container").hide();
//-- }
//handle logsendto option: 0=no options, 1=mizutech upload, 2=email (support email from config)
var logsendto = webphone_api.common.GetConfigInt('logsendto', 1);
var logmanualemail = webphone_api.common.GetParameterInt('logmanualemail', 0);
var email = webphone_api.common.GetParameter('logmanualemail_adress');
if (webphone_api.common.isNull(email) || email.length < 1) { webphone_api.common.GetConfig('supportmail'); }
if (webphone_api.common.isNull(email) || email.length < 1) { webphone_api.common.GetConfig('log_email'); }
//?if (webphone_api.common.isNull(email) || email.length < 1) { webphone_api.common.GetConfig('email'); }
var subject = webphone_api.common.GetParameter('logmanualemail_subject');
if (webphone_api.common.isNull(subject) || subject.length < 1) { subject = encodeURIComponent('WebPhone Log'); }
if ((logsendto === 2 || logmanualemail > 0) && !webphone_api.common.isNull(email) && email.length > 3) // send in email
{
webphone_api.$('#btn_sendlog').hide();
webphone_api.$('#sendtosupport_link').html(webphone_api.stringres.get("sendtosupport"));
webphone_api.$('#sendtosupport_link').show();
//mailto:test@example.com?subject=subject&body=body
//var href = 'mailto:' + webphone_api.common.Trim(email) + '?subject=JSPhone Log&body=' + webphone_api.stringres.get('support_email_body');
//href = webphone_api.common.ReplaceAll(href, ' ', '%20');
var href = 'mailto:' + webphone_api.common.Trim(email) + '?subject=' + subject + '&body=' + webphone_api.stringres.get('support_email_body');
webphone_api.$('#sendtosupport_link').attr('href', href);
//Spaces between words should be replaced by %20 to ensure that the browser will display the text properly.
}else
{
if (logsendto < 1)
{
webphone_api.$("#sendtosupport_container").hide();
}
else if (logsendto === 1) // send to mizu with xlogpush
{
webphone_api.$('#sendtosupport_link').hide();
webphone_api.$("#sendtosupport_container").show();
}
}
//-- PC softphone: no need for send logs in the skin menu
if (webphone_api.common.IsWindowsSoftphone())
{
webphone_api.$('#sendtosupport_link').hide();
}
MeasureLogview();
var additionalinfo = 'Build date: ' + webphone_api.common.GetParameter('codegenerated');
webphone_api.$('#log_text').html(additionalinfo + '&#10;' + webphone_api.global.logs);
//-- webphone_api.$('#log_text').textinput('refresh');
//-- document.getElementById('log_text').value = webphone_api.global.logs;
// add filename parameter to form
if (!webphone_api.common.isNull(document.getElementById('filename')))
{
var srv = webphone_api.common.GetParameter('serveraddress_user');
if (srv.length < 2) { srv = webphone_api.common.GetParameter('serveraddress'); }
try{ if (srv.length < 2 && !webphone_api.common.isNull(webphone_api.parameters) && !webphone_api.common.isNull(webphone_api.parameters.serveraddress)) { srv = webphone_api.parameters.serveraddress; } } catch(errin) { }
if (srv.length < 2) { srv = webphone_api.common.GetConfig('serveraddress'); }
if (webphone_api.common.isNull(srv)) { srv = ''; }
srv = srv.replace('://', '');
var logfilename = webphone_api.common.GetParameter('logform_filename');
if (webphone_api.common.isNull(logfilename) || logfilename.length < 1)
{
logfilename = webphone_api.common.GetSipusername(true);
if (!webphone_api.common.isNull(webphone_api.common.GetParameter('brandname'))) { logfilename = logfilename + '_' + encodeURIComponent(webphone_api.common.GetParameter('brandname')); }
if (!webphone_api.common.isNull(srv)) { logfilename = logfilename + '_' + encodeURIComponent(srv); }
}
webphone_api.common.PutToDebugLog(2, 'EVENT, _logview filename: ' + logfilename);
document.getElementById('filename').value = logfilename;
}
if (!webphone_api.common.isNull(document.getElementById('wplocation')))
{
try{
var loc = window.location.href;
if (!webphone_api.common.isNull(loc) && loc.length > 0)
{
loc = loc.toLowerCase();
var pos = loc.indexOf('#');
if (pos > 0)
{
loc = loc.substring(0, pos);
}
if (webphone_api.common.isNull(loc)) { loc = ''; }
loc = webphone_api.common.Trim(loc);
document.getElementById('wplocation').value = loc;
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_logview: onStart Inner", err); }
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_logview: onStart", err); }
}
function MeasureLogview() // resolve window height size change
{
try{
//-- var pgh = webphone_api.common.GetDeviceHeight() - 1; webphone_api.$('#page_logview').css('min-height', pgh + 'px'); // must be set when softphone is skin in div
webphone_api.$('#page_logview').css('min-height', 'auto'); // must be set when softphone is skin in div
webphone_api.$("#page_logview_content").height(webphone_api.common.GetDeviceHeight() - webphone_api.$("#logview_header").height() - 2);
var ltheight = webphone_api.common.GetDeviceHeight() - webphone_api.$("#logview_header").height() - 5;
if (webphone_api.$('#sendtosupport_container').is(':visible'))
{
ltheight = ltheight - webphone_api.$("#sendtosupport_container").height();
}
webphone_api.$("#log_text").height(ltheight);
webphone_api.$("#log_text").width(webphone_api.common.GetDeviceWidth());
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_logview: MeasureLogview", err); }
}
var MENUITEM_CLOSE = '#menuitem_logview_close';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.GetParameter('devicetype') === webphone_api.common.DEVICE_WIN_SOFTPHONE())
{
webphone_api.$( "#btn_logview_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _logview: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _logview: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CLOSE + '"><a data-rel="back">' + webphone_api.stringres.get('menu_close') + '</a></li>' ).listview('refresh');
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_logview: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#logview_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#logview_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_CLOSE:
webphone_api.$.mobile.back();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_logview: MenuItemSelected", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _logview: onStop");
webphone_api.global.isLogviewStarted = false;
if (webphone_api.$('#disable_logs').prop("checked"))
{
webphone_api.common.SaveParameter('loglevel', '1');
webphone_api.common.SaveParameter('jsscriptevent', '2');
webphone_api.setparameter('jsscriptevent', '2');
webphone_api.global.loglevel = 1;
webphone_api.$('#disable_logs').prop("checked", false).checkboxradio('refresh');
}
webphone_api.$('#log_text').html('');
//-- document.getElementById('log_text').value = '';
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_logview: onStop", err); }
}
function onDestroy (event){} // deprecated by onstop
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop,
onDestroy: onDestroy
};
})();
File diff suppressed because it is too large Load Diff
+516
View File
@@ -0,0 +1,516 @@
webphone_api._messagelist = (function ()
{
function onCreate (event) // called only once - bind events here
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _messagelist: onCreate");
webphone_api.$('#messagelist_list').on('click', 'li', function(event)
{
OnListItemClick(webphone_api.$(this).attr('id'));
});
webphone_api.$('#messagelist_notification_list').on('click', '.nt_anchor', function(event)
{
webphone_api.$("#messagelist_not").panel( "close" );
webphone_api.common.NotificationOnClick2(webphone_api.$(this).attr('id'), false);
});
webphone_api.$('#messagelist_notification_list').on('click', '.nt_menu', function(event)
{
webphone_api.$("#messagelist_not").panel( "close" );
webphone_api.common.NotificationOnClick2(webphone_api.$(this).attr('id'), true);
});
webphone_api.$("#messagelist_not_btn").on("click", function()
{
webphone_api.common.SaveParameter('notification_count2', 0);
webphone_api.common.ShowNotifications2(); // repopulate notifications (hide red dot number)
});
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_messagelist')
{
MeasureMessagelist();
}
});
webphone_api.$('#messagelist_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_messagelist_menu").on("click", function()
{
CreateOptionsMenu('#messagelist_menu_ul');
});
webphone_api.$("#btn_messagelist_menu").attr("title", webphone_api.stringres.get("hint_menu"));
webphone_api.$("#msglist_btnback").attr("title", webphone_api.stringres.get("hint_btnback"));
webphone_api.$("#btn_newmessage").on("click", function()
{
NewMessage();
});
webphone_api.$( "#page_messagelist" ).keyup(function( event )
{
HandleKeyUp(event);
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: onCreate", err); }
}
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _messagelist: onStart");
webphone_api.global.isMessagelistStarted = true;
setTimeout(function() // otherwise keyup will not work, because the element is not focused
{
webphone_api.$("#page_messagelist").focus();
}, 100);
//-- webphone_api.$("#phone_number").attr("placeholder", webphone_api.stringres.get("phone_nr"));
//-- document.getElementById("app_name_messagelist").innerHTML = webphone_api.common.GetBrandName();
webphone_api.$('#btn_newmessage').html(webphone_api.stringres.get('btn_new_message'));
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#page_messagelist'), -30) );
if (!webphone_api.common.isNull(document.getElementById('msglist_title')))
{
document.getElementById('msglist_title').innerHTML = webphone_api.stringres.get("msglist_title");
}
webphone_api.$("#msglist_title").attr("title", webphone_api.stringres.get("hint_page"));
if (!webphone_api.common.isNull(document.getElementById('msglist_btnback')))
{
document.getElementById('msglist_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get("go_back_btn_txt");
}
// needed for proper display and scrolling of listview
MeasureMessagelist();
webphone_api.common.HideMessageNotifications2(); // show only call notification
// fix for IE 10
if (webphone_api.common.IsIeVersion(10)) { webphone_api.$("#messagelist_list").children().css('line-height', 'normal'); }
if (webphone_api.common.IsIeVersion(10)) { webphone_api.$("#messagelist_notification_list").children().css('line-height', 'normal'); }
webphone_api.$("#messagelist_notification_list").height(webphone_api.common.GetDeviceHeight() - 55);
PopulateList();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: onStart", err); }
}
function MeasureMessagelist() // resolve window height size change
{
try{
//-- var pgh = webphone_api.common.GetDeviceHeight() - 1; webphone_api.$('#page_messagelist').css('min-height', pgh + 'px'); // must be set when softphone is skin in div
webphone_api.$('#page_messagelist').css('min-height', 'auto'); // must be set when softphone is skin in div
// handle notifiaction additional_header_right
var notwidth = webphone_api.common.GetDeviceWidth() - webphone_api.$("#messagelist_additional_header_left").width() - webphone_api.$("#messagelist_additional_header_right").width();
var margin = webphone_api.common.StrToIntPx( webphone_api.$("#messagelist_additional_header_left").css("margin-left") );
if (webphone_api.common.isNull(margin) || margin === 0) { margin = 10; }
margin = Math.ceil( margin * 6 );
notwidth = Math.floor(notwidth - margin) - 20;
// handle page height
var heightTemp = webphone_api.common.GetDeviceHeight() - webphone_api.$("#messagelist_header").height() - webphone_api.$("#btn_newmessage_container").height();
heightTemp = Math.floor( heightTemp - 3 );
webphone_api.$("#messagelist_list").height(heightTemp);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: MeasureMessagelist", err); }
}
function LoadMessages()
{
try{
PopulateList();
//-- if (webphone_api.global.isdebugversion)
//-- {
//-- if ( webphone_api.common.isNull(webphone_api.global.ctlist) || webphone_api.global.ctlist.length < 1 )
//-- {
//-- webphone_api.global.ctlist = [];
//-- // String Name, String[] {numbers/sip uris}, String[] {number types}, int usage, long lastmodified, int delete flag, int isfavorit
//-- var ctitem = ['Ambrus Akos', ['40724335358', '0268123456', '13245679'], ['home', 'work', 'other'], '0', '13464346', '0', '0'];
//-- var ctitem2 = ['Ambrus Tunde', ['123456', '987654'], ['other', 'fax_home'], '0', '23464346', '0', '0'];
//-- var ctitem3 = ['Mariska Mari', ['123456', '987654'], ['other', 'fax_home'], '0', '23464346', '0', '0'];
//-- webphone_api.global.ctlist.push(ctitem); webphone_api.global.ctlist.push(ctitem2); webphone_api.global.ctlist.push(ctitem3);
//-- for (var i = 0; i < 12; i++)
//-- {
//-- var ctitem_generated = ['Test_' + i, ['123456_' + i, '987654_' + i], ['other', 'fax_home'], '0', '23464346', '0', '0'];
//-- webphone_api.global.ctlist.push(ctitem_generated);
//-- }
//-- }
//-- }
//-- if (webphone_api.common.isNull(webphone_api.global.ctlist) || webphone_api.global.ctlist.length < 1)
//-- {
//-- webphone_api.common.GetContacts(function (success)
//-- {
//-- if (!success)
//-- {
//-- webphone_api.common.PutToDebugLog(2, 'ERROR, _messagelist: LoadContacts failed');
//-- }
//-- PopulateList();
//-- });
//-- }else
//-- {
//-- PopulateList();
//-- }
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: LoadMessages", err); }
}
function PopulateList() // :no return value
{
try{
if ( webphone_api.common.isNull(document.getElementById('messagelist_list')) )
{
webphone_api.common.PutToDebugLog(2, "ERROR, _messagelist: PopulateList listelement is null");
return;
}
webphone_api.$('#messagelist_list').html('');
// filenames: sms/chat_username_number
//-- isdebugversion
// type_myusername_tousername[#nrofmissedmsg
// var msgfilestest = 'sms_9999_1111[#3,chat_9999_2222,chat_9999_3333,sms_9999_4444,sms_9999_5555,sms_9999_6666';
// webphone_api.common.SaveParameter('messagefiles', msgfilestest);
var files = webphone_api.common.GetParameter('messagefiles');
if (webphone_api.common.isNull(files) || files.length < 3)
{
webphone_api.common.PutToDebugLog(3, 'EVENT, _messagelist: PopulateList no message files');
return;
}
webphone_api.common.PutToDebugLog(2, 'EVENT, _messagelist Starting populate list');
var msglist = [];
if (!webphone_api.common.isNull(files) && files.length > 0)
{
msglist = files.split(',');
}
var listview = '';
for (var i = 0; i < msglist.length; i++)
{
if (webphone_api.common.isNull(msglist[i]) || msglist[i].length < 3) { continue; }
var number = msglist[i].substring( msglist[i].lastIndexOf('_') + 1 );
var type = msglist[i].substring(0, msglist[i].indexOf('_') );
var missedmsg = '';
var nrMissed = 0;
// check if there are missed messages
var pos = number.indexOf('[#');
if (pos > 0)
{
var tmp = number.substring(pos + 2, number.length);
number = number.substring(0, pos);
try{ nrMissed = webphone_api.common.StrToInt( webphone_api.common.Trim(tmp) ); } catch(errin) { }
}
var name = webphone_api.common.GetContactNameFromNumber(number);
if (!webphone_api.common.isNull(nrMissed) && nrMissed > 0)
{
missedmsg = '<span class="ui-li-count">' + nrMissed + '</span>';
}
if (webphone_api.common.isNull(name) || name.length < 1) { name = number; }
var listitem = '' +
'<li id="msgitem_' + i + '"><a class="msg_anchor mlistitem" data-transition="slide">' +
'<div class="msg_item_container">' +
'<div class="msg_name">' + name + ' - <span id="msgitemnumber_' + i + '">' + number + '</span>' + missedmsg + '</div>' +
//'<div class="new_msg_count">4</div>' +//(3) new missed message count
'<div id="msgtype_' + i + '" class="msg_type">' + webphone_api.stringres.get(type) + '</div>' +
'</div>' +
'</a></li>';
listview = listview + listitem;
}
webphone_api.$('#messagelist_list').html('');
webphone_api.$('#messagelist_list').append(listview).listview('refresh');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: PopulateList", err); }
}
function OnListItemClick (id) // :no return value
{
try{
if (webphone_api.common.isNull(id) || id.length < 1)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, _messagelist OnListItemClick id is NULL');
return;
}
var msgid = '';
var pos = id.indexOf('_');
if (pos < 2)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, _messagelist OnListItemClick invalid id');
return;
}
msgid = webphone_api.common.Trim(id.substring(pos + 1));
var to = webphone_api.$('#msgitemnumber_' + msgid).html();
if (webphone_api.common.isNull(to)) { to = ''; }else{ to = webphone_api.common.Trim(to); }
var typestr = webphone_api.$('#msgtype_' + msgid).html();
if (webphone_api.common.isNull(typestr)) { typestr = webphone_api.stringres.get('chat'); }else{ typestr = webphone_api.common.Trim(typestr); }
var action = '';
if (typestr === webphone_api.stringres.get('chat'))
{
action = 'chat';
}else if (typestr === webphone_api.stringres.get('sms'))
{
action = 'sms';
}
//-- webphone_api.sendchat (1, to, '', action);
webphone_api.common.PutToDebugLog(4, 'EVENT, _messagelist: OnListItemClick: action: ' + action + '; to: ' + to);
webphone_api.global.intentmsg[0] = 'action=' + action;
webphone_api.global.intentmsg[1] = 'to=' + to;
webphone_api.global.intentmsg[2] = 'message=';
if (webphone_api.common.GetParameter('devicetype') === webphone_api.common.DEVICE_WIN_SOFTPHONE())
{
webphone_api.$.mobile.changePage("#page_message", { transition: "none", role: "page" });
}else
{
webphone_api.$.mobile.changePage("#page_message", { transition: "slide", role: "page" });
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: OnListItemClick", err); }
}
function NewMessage()
{
try{
webphone_api.common.StartMsg('', '', '_messagelist');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: NewMessage", err); }
}
function HandleKeyUp(event)
{
try{
//-- don't catch input if a popup is open, because popups can have input boxes, and we won't be able to write into them
if (webphone_api.$(".ui-page-active .ui-popup-active").length > 0)
{
return false;
}
var charCode = (event.keyCode) ? event.keyCode : event.which; // workaround for firefox
if (charCode === 8) // backspace
{
event.preventDefault();
webphone_api.$.mobile.back();
}
//-- else if (charCode === 13)
//-- {
//-- event.preventDefault();
//-- webphone_api.$("#btn_call").click();
//-- }
return false;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: HandleKeyUp", err); }
}
var MENUITEM_MESSAGELIST_NEWMESSAGE = '#menuitem_messagelist_newmessage';
var MENUITEM_MESSAGELIST_DELETE = '#menuitem_messagelist_delete';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.IsWindowsSoftphone())
{
webphone_api.$( "#btn_messagelist_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _messagelist: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _messagelist: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_MESSAGELIST_NEWMESSAGE + '"><a data-rel="back">' + webphone_api.stringres.get('btn_new_message') + '</a></li>' ).listview('refresh');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_MESSAGELIST_DELETE + '"><a data-rel="back">' + webphone_api.stringres.get('delete_text') + '</a></li>' ).listview('refresh');
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#messagelist_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#messagelist_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_MESSAGELIST_NEWMESSAGE:
NewMessage();
break;
case MENUITEM_MESSAGELIST_DELETE:
ClearAllHistory();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: MenuItemSelected", err); }
}
function ClearAllHistory(popupafterclose)
{
try{
var files = webphone_api.common.GetParameter('messagefiles');
if (webphone_api.common.isNull(files) || files.length < 3)
{
webphone_api.common.ShowToast(webphone_api.stringres.get('err_msg_7'));
return;
}
var popupWidth = webphone_api.common.GetDeviceWidth();
if ( !webphone_api.common.isNull(popupWidth) && webphone_api.common.IsNumber(popupWidth) && popupWidth > 100 )
{
popupWidth = Math.floor(popupWidth / 1.2);
}else
{
popupWidth = 220;
}
if(popupWidth > 400) popupWidth = 400;
else if(popupWidth < 120) popupWidth = 120;
var template = '' +
'<div data-role="popup" class="ui-content messagePopup" data-overlay-theme="a" data-theme="a" style="max-width:' + popupWidth + 'px;">' +
'<div data-role="header" data-theme="b">' +
'<a href="javascript:;" data-role="button" data-icon="delete" data-iconpos="notext" class="ui-btn-right closePopup">Close</a>' +
'<h1 class="adialog_title">' + webphone_api.stringres.get('delete_text') + '</h1>' +
'</div>' +
'<div role="main" class="ui-content adialog_content adialog_alert">' +
'<span> ' + webphone_api.stringres.get('delete_all_msg_alert') + ' </span>' +
// '<a href="javascript:;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back">' + webphone_api.stringres.get('btn_close') + '</a>' +
// '<a href="javascript:;" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b" data-rel="back" data-transition="flow">Delete</a>' +
'</div>' +
'<div data-role="footer" data-theme="b" class="adialog_footer">' +
'<a href="javascript:;" id="btn_adialog_ok" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back" data-transition="flow">' + webphone_api.stringres.get('btn_ok') + '</a>' +
'<a href="javascript:;" id="adialog_negative" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b adialog_2button" data-rel="back">' + webphone_api.stringres.get('btn_cancel') + '</a>' +
'</div>' +
'</div>';
popupafterclose = popupafterclose ? popupafterclose : function () {};
webphone_api.$.mobile.activePage.append(template).trigger("create");
//-- webphone_api.$.mobile.activePage.append(template).trigger("pagecreate");
webphone_api.$.mobile.activePage.find(".closePopup").bind("tap", function (e)
{
webphone_api.$.mobile.activePage.find(".messagePopup").popup("close");
});
webphone_api.$.mobile.activePage.find(".messagePopup").bind(
{
popupbeforeposition: function()
{
webphone_api.$(this).unbind("popupbeforeposition");//.remove();
var maxHeight = Math.floor( webphone_api.common.GetDeviceHeight() * 0.6 ); // webphone_api.$(window).height() - 120;
if (webphone_api.$(this).height() > maxHeight)
{
webphone_api.$('.messagePopup .ui-content').height(maxHeight);
}
}
});
webphone_api.$.mobile.activePage.find(".messagePopup").popup().popup("open").bind(
{
popupafterclose: function ()
{
webphone_api.$(this).unbind("popupafterclose").remove();
webphone_api.$('#btn_adialog_ok').off('click');
popupafterclose();
}
});
webphone_api.$('#btn_adialog_ok').on('click', function ()
{
var msglist = files.split(',');
for (var i = 0; i < msglist.length; i++)
{
if (webphone_api.common.isNull(msglist[i]) || msglist[i].length < 3) { continue; }
// cut off number of missed messages from file names
var pos = msglist[i].indexOf('[#');
if (pos > 0)
{
msglist[i] = msglist[i].substring(0, pos);
}
var cfile = msglist[i];
(function(){
webphone_api.File.DeleteFile(cfile, function (success)
{
webphone_api.common.PutToDebugLog(3, 'EVENT, _messagelist: ClearAllHistory DeleteFile: ' + cfile + ' status: ' + success.toString());
});
});
}
webphone_api.common.SaveParameter('messagefiles', '');
PopulateList();
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: ClearAllHistory", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _messagelist: onStop");
webphone_api.global.isMessagelistStarted = false;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_messagelist: onStop", err); }
}
function onDestroy (event){} // deprecated by onstop
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop,
onDestroy: onDestroy
};
})();
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+429
View File
@@ -0,0 +1,429 @@
// smscodeverify
webphone_api._smscodeverify = (function ()
{
var username = '';
var password = '';
var userID = '';
function onCreate (event) // called only once - bind events here
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _smscodeverify: onCreate");
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_smscodeverify')
{
MeasureSmscodeverify();
}
});
webphone_api.$('#smscodeverify_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_smscodeverify_menu").on("click", function() { CreateOptionsMenu('#smscodeverify_menu_ul'); });
webphone_api.$("#btn_smscodeverify_menu").attr("title", webphone_api.stringres.get("hint_menu"));
webphone_api.$("#btn_sms_verify").on("click", function() { VerifyPhonenumber(); });
webphone_api.$("#btn_cancel_smscodeverify").on("click", function() { CancelClick(); });
webphone_api.$("#sms_instructions").html(webphone_api.stringres.get('smscode_instrucation'));
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_smscodeverify: onCreate", err); }
}
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _smscodeverify: onStart");
webphone_api.global.isSmscodeverifyStarted = true;
if (!webphone_api.common.isNull(document.getElementById('smscodeverify_title')))
{
document.getElementById('smscodeverify_title').innerHTML = webphone_api.stringres.get('smscodeverify_title');
}
webphone_api.$("#smscodeverify_title").attr("title", webphone_api.stringres.get("hint_page"));
if (!webphone_api.common.isNull(document.getElementById('smscodeverify_btnback')))
{
document.getElementById('smscodeverify_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get("go_back_btn_txt");
}
if (!webphone_api.common.isNull(document.getElementById('btn_sms_verify')))
{
document.getElementById('btn_sms_verify').innerHTML = webphone_api.stringres.get('btn_smsverify');
}
if (!webphone_api.common.isNull(document.getElementById('btn_cancel_smscodeverify')))
{
document.getElementById('btn_cancel_smscodeverify').innerHTML = webphone_api.stringres.get('btn_cancel');
}
webphone_api.global.nuiswebpage = null;
username = webphone_api.common.GetIntentParam(webphone_api.global.intentsmscodeverify, 'username');
password = webphone_api.common.GetIntentParam(webphone_api.global.intentsmscodeverify, 'password');
userID = webphone_api.common.GetIntentParam(webphone_api.global.intentsmscodeverify, 'smsverify_userid');
MeasureSmscodeverify();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_smscodeverify: onStart", err); }
}
function MeasureSmscodeverify() // resolve window height size change
{
try{
//-- var pgh = webphone_api.common.GetDeviceHeight() - 1; webphone_api.$('#page_smscodeverify').css('min-height', pgh + 'px'); // must be set when softphone is skin in div
webphone_api.$('#page_smscodeverify').css('min-height', 'auto'); // must be set when softphone is skin in div
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#page_smscodeverify'), -30) );
var heightTemp = webphone_api.common.GetDeviceHeight() - webphone_api.$("#smscodeverify_header").height() - webphone_api.$("#smscodeverify_footer").height();
heightTemp = heightTemp - 5;
heightTemp = Math.floor(heightTemp);
webphone_api.$("#page_smscodeverify_content").height(heightTemp);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_smscodeverify: MeasureSmscodeverify", err); }
}
function VerifyPhonenumber()
{
var code = "";
try{
if (webphone_api.common.isNull(document.getElementById('sms_code_field')))
{
webphone_api.common.PutToDebugLog(2, 'ERROR, smscodeverify VerifyPhonenumber: input field is NULL');
return;
}
var code = document.getElementById('sms_code_field').nodeValue;
if (webphone_api.common.isNull(code)) { code = ''; }
if (code.length < 2 || code.length > 10)
{
webphone_api.common.ShowToast(webphone_api.stringres.get('sms_verification_error1'));
return;
}
webphone_api.common.PutToDebugLog(2, "EVENT, smscodeverify VerifyPhonenumber code is: " + code);
webphone_api.global.smsCodeUser = code;
code = encodeURIComponent(code);
var usr = encodeURIComponent(username);
var pwd = encodeURIComponent(password);
if (webphone_api.common.isNull(userID) || userID.length < 1)
{
userID = username;
}
//String uritmp = Common.smsverify_url;
var uritmp = webphone_api._newuser.GetUriSecondNU();
if (webphone_api.common.Trim(uritmp).indexOf("*") === 0) { uritmp = uritmp.substring(1); }
uritmp = uritmp.replace("USERNAME", usr);
uritmp = uritmp.replace("PASSWORD", pwd);
uritmp = uritmp.replace("SMSCODE", code);
uritmp = uritmp.replace("DEVICEID", webphone_api.common.GetDeviceId());
uritmp = uritmp.replace("USERID", userID);
//http://185.20.99.144/mvapireq/?apientry=newusercode&authkey=5267734&u_code=SMSCODE&u_username=USERNAME&u_password=PASSWORD&deviceid=DEVICEID&now=415
webphone_api.common.PutToDebugLog(4, "EVENT, VerifyPhonenumber uri: "+uritmp);
webphone_api.common.UriParser(uritmp, '', '', '', '', 'verifysmscode');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_smscodeverify: VerifyPhonenumber", err); }
}
function CancelClick()
{
try{
webphone_api.$.mobile.back();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_smscodeverify: CancelClick", err); }
}
function HttpResponseHandler(resp, action)
{
try{
//if (actionHandler === 'smscodeverify')
if (action === 'smscodeverify' || action === 'verifysmscode')
{
if ((resp.toLowerCase()).indexOf('error') >= 0)
{
webphone_api.common.PutToDebugLog(2, 'ERROR, HttpResponseHandler action: smscodeverify, error: ' + resp);
webphone_api.common.ShowToast(resp);
return;
}
if (action === "verifysmscode")
{
if (resp == null) resp = "";
if (webphone_api.common.isNull(resp)) { resp = ''; }
resp = resp.replace("\"", "");
var tempresp = resp.toLowerCase();
var seconduri = webphone_api._newuser.GetUriSecondNU();
var errorstring = webphone_api.common.GetUrlParamVal(seconduri, "ERRORSTRING");
if (webphone_api.common.isNull(errorstring)) { errorstring = ""; }
errorstring = errorstring.toLowerCase();
// get and display success message if any
var msgtodisplay = webphone_api.common.GetJsonParamVal(resp, "message:");
if (webphone_api.common.isNull(msgtodisplay) || msgtodisplay.length < 1)
{
msgtodisplay = webphone_api.common.GetJsonParamVal(resp, "msg:");
}
if (webphone_api.common.isNull(msgtodisplay) || webphone_api.common.Trim(msgtodisplay).length < 1) { msgtodisplay = resp; }
if (resp.length < 1 || tempresp.indexOf("error") >= 0 || tempresp.indexOf(errorstring) >= 0)
{
webphone_api.common.PutToDebugLog(2, "ERROR, SMS verification failed: " + resp);
webphone_api.common.PutToDebugLog(1, "ERROR," + msgtodisplay);
webphone_api.common.ShowToast(msgtodisplay);
return;
}
var success = webphone_api.common.GetUrlParamVal(seconduri, "SUCCESSSTRING");
if (webphone_api.common.isNull(success)) { success = ""; }
success = success.toLowerCase();
if (success.length > 0)
{
if (tempresp.indexOf(success) >= 0)
{
webphone_api.common.PutToDebugLog(1, "EVENT," + msgtodisplay);
webphone_api.common.PutToDebugLog(2, "EVENT, smscodeverify SUCCEDED" + resp);
}else
{
webphone_api.common.PutToDebugLog(1, "ERROR," + msgtodisplay);
webphone_api.common.PutToDebugLog(2, "ERROR, smscodeverify failed, does not contain SUCCESSSTRING" + resp);
webphone_api.common.ShowToast(msgtodisplay);
return;
}
}
var userid_begin = webphone_api.common.GetUrlParamVal(seconduri, "USERID_BEGIN");
var userid_end = webphone_api.common.GetUrlParamVal(seconduri, "USERID_END");
var username_begin = webphone_api.common.GetUrlParamVal(seconduri, "USERNAME_BEGIN");
var username_end = webphone_api.common.GetUrlParamVal(seconduri, "USERNAME_END");
var password_begin = webphone_api.common.GetUrlParamVal(seconduri, "PASSWORD_BEGIN");
var password_end = webphone_api.common.GetUrlParamVal(seconduri, "PASSWORD_END");
var callerid_begin = webphone_api.common.GetUrlParamVal(seconduri, "CALLERID_BEGIN");
var callerid_end = webphone_api.common.GetUrlParamVal(seconduri, "CALLERID_END");
var name_begin = webphone_api.common.GetUrlParamVal(seconduri, "NAME_BEGIN");
var name_end = webphone_api.common.GetUrlParamVal(seconduri, "NAME_END");
var email_begin = webphone_api.common.GetUrlParamVal(seconduri, "EMAIL_BEGIN");
var email_end = webphone_api.common.GetUrlParamVal(seconduri, "EMAIL_END");
var usr = username;
var pwd = password;
if (email_begin.length > 0 && email_end.length > 0 && resp.indexOf(email_begin) >= 0 && resp.indexOf(email_end) > 0)
{
var email = resp.substring(resp.indexOf(email_begin) + email_begin.length, resp.indexOf(email_end));
webphone_api.common.SaveParameter("email", email);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler NEW email saved: " + email);
}
if (name_begin.length > 0 && name_end.length > 0 && resp.indexOf(name_begin) >= 0 && resp.indexOf(name_end) > 0)
{
var name = resp.substring(resp.indexOf(name_begin) + name_begin.length, resp.indexOf(name_end));
webphone_api.common.SaveParameter("name", name);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler NEW name saved: " + name);
}
if (callerid_begin.length > 0 && callerid_end.length > 0 && resp.indexOf(callerid_begin) >= 0 && resp.indexOf(callerid_end) > 0)
{
var callerid = resp.substring(resp.indexOf(callerid_begin) + callerid_begin.length, resp.indexOf(callerid_end));
webphone_api.common.SaveParameter("username", callerid);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler NEW callerid saved: " + callerid);
}
if (userid_begin.length > 0 && userid_end.length > 0 && resp.indexOf(userid_begin) >= 0 && resp.indexOf(userid_end) > 0)
{
var userid = resp.substring(resp.indexOf(userid_begin) + userid_begin.length, resp.indexOf(userid_end));
webphone_api.common.SaveParameter("userid", userid);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler NEW userid saved: " + userid);
}
if (username_begin.length > 0 && username_end.length > 0 && resp.indexOf(username_begin) >= 0 && resp.indexOf(username_end) > 0)
{
usr = resp.substring(resp.indexOf(username_begin) + username_begin.length, resp.indexOf(username_end));
webphone_api.common.SaveParameter("sipusername", usr);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler NEW username saved: " + usr);
}
var showpwd = false;
if (password_begin.length > 0 && password_end.length > 0 && resp.indexOf(password_begin) >= 0 && resp.indexOf(password_end) > 0)
{
pwd = resp.substring(resp.indexOf(password_begin) + password_begin.length, resp.indexOf(password_end));
webphone_api.common.SaveParameter("password", pwd);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler NEW password saved: " + pwd);
}else
{
// if user already exists, then I will receive encrypted password:
// OK: userdata: Base64XOREncode(password)
if (resp.indexOf("userdata:") >= 0)
{
pwd = resp.substring(resp.indexOf("userdata:") + 9, resp.length);
pwd = pwd.trim();
var key = webphone_api.common.GetParameter('httpreqencryptkey');
if (!webphone_api.common.isNull(key) && key.length > 1)
{
pwd = webphone_api.common.StrDc(pwd, key);
}
webphone_api.common.SaveParameter("password", pwd);
webphone_api.common.SaveParameter("sipusername", usr);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler OLD password saved: " + pwd);
}
else if (pwd.length > 0)
{
webphone_api.common.SaveParameter("password", pwd);
webphone_api.common.SaveParameter("username", usr);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler password saved: " + pwd + "; username: " + username);
// calculate password
}else // int uauthverifypwd: 0=pwd+755+code,1=code (default),2=client supplied
{
var uauthverifypwd = webphone_api.common.GetParameterInt('uauthverifypwd', 2);
if (uauthverifypwd === 0) { pwd = password + "755" + webphone_api.global.smsCodeUser; }
else if (uauthverifypwd === 1) { pwd = webphone_api.global.smsCodeUser; }
else if (uauthverifypwd > 1) { pwd = password; }
webphone_api.common.SaveParameter("password", pwd);
webphone_api.common.SaveParameter("sipusername", usr);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler NEW password saved: " + pwd + "; username: " + username);
showpwd = true;
}
}
// try to guess/find username in http answer; handle common cases
var usrTmp = webphone_api.common.GetJsonParamVal(resp, "sip_username");
if (webphone_api.common.isNull(usrTmp) || usrTmp.length < 1) usrTmp = webphone_api.common.GetJsonParamVal(resp, "sipusername");
if (webphone_api.common.isNull(usrTmp) || usrTmp.length < 1) usrTmp = webphone_api.common.GetJsonParamVal(resp, "username");
if (!webphone_api.common.isNull(usrTmp) && usrTmp.length > 0) usr = usrTmp;
if (!webphone_api.common.isNull(usr) && usr.length > 0)
{
webphone_api.common.SaveParameter("sipusername", usr);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler NEW username saved(autoguessed): " + usr);
}
var pwdTmp = webphone_api.common.GetJsonParamVal(resp, "sip_password");
if (webphone_api.common.isNull(pwdTmp) || pwdTmp.length < 1) pwdTmp = webphone_api.common.GetJsonParamVal(resp, "sippassword");
if (webphone_api.common.isNull(pwdTmp) || pwdTmp.length < 1) pwdTmp = webphone_api.common.GetJsonParamVal(resp, "password");
if (!webphone_api.common.isNull(pwdTmp) && pwdTmp.length > 0) pwd = pwdTmp;
if (!webphone_api.common.isNull(pwd) && pwd.length > 0)
{
webphone_api.common.SaveParameter("password", pwd);
webphone_api.common.PutToDebugLog(2, "EVENT,smscodeverify VerifyThreadHandler NEW password saved(autoguessed): " + usr);
}
if (webphone_api.common.GetParameter("username").length > 0 && webphone_api.common.GetParameter("password").length > 0)
{
if (1 == 2) //if (Settings.instance != null)
{
setTimeout(function ()
{
webphone_api.$("#btn_login").click();
}, 300);
if (showpwd === true)
{
webphone_api.common.AlertDialog(webphone_api.stringres.get('password'), webphone_api.stringres.get('sms_verification_pwdmsg') + ": " +webphone_api.common.GetParameter("password"));
}
}
}
}
webphone_api.$.mobile.back();
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_smscodeverify: HttpResponseHandler", err); }
}
var MENUITEM_VERIFY = '#menuitem_smscodeverify_verify';
var MENUITEM_CANCEL = '#menuitem_smscodeverify_cancel';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.IsWindowsSoftphone())
{
webphone_api.$( "#btn_smscodeverify_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _smscodeverify: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _smscodeverify: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_VERIFY + '"><a data-rel="back">' + webphone_api.stringres.get('btn_smsverify') + '</a></li>' ).listview('refresh');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CANCEL + '"><a data-rel="back">' + webphone_api.stringres.get('btn_cancel') + '</a></li>' ).listview('refresh');
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_smscodeverify: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#smscodeverify_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#smscodeverify_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_VERIFY:
VerifyPhonenumber();
break;
case MENUITEM_CANCEL:
CancelClick();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_smscodeverify: MenuItemSelected", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _smscodeverify: onStop");
webphone_api.global.isSmscodeverifyStarted = false;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_smscodeverify: onStop", err); }
}
function onDestroy (event){} // deprecated by onstop
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop,
onDestroy: onDestroy,
HttpResponseHandler: HttpResponseHandler
};
})();
+295
View File
@@ -0,0 +1,295 @@
// Start page
webphone_api._startpage = (function ()
{
var url = '';
var lastpage = '';
var pagetitle = '';
var text = '';
var type = 0;
function onCreate (event) // called only once - bind events here
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _startpage: onCreate");
webphone_api.$( window ).resize(function() // window resize handling
{
if (webphone_api.$.mobile.activePage.attr('id') === 'page_startpage')
{
MeasureStartpage();
}
});
webphone_api.$('#startpage_menu_ul').on('click', 'li', function(event)
{
MenuItemSelected(webphone_api.$(this).attr('id'));
});
webphone_api.$("#btn_startpage_menu").on("click", function() { CreateOptionsMenu('#startpage_menu_ul'); });
webphone_api.$("#btn_startpage_menu").attr("title", webphone_api.stringres.get("hint_menu"));
webphone_api.$("#startpage_btnback").on("click", function(e)
{
ClosePage();
e.preventDefault();
});
webphone_api.$("#btn_sp_decline").on("click", function()
{
webphone_api.common.PutToDebugLog(5, "EVENT, _startpage: button decline onclick");
ClosePage();
webphone_api.common.OpenSettings(true, 15);
});
webphone_api.$("#btn_sp_accept").on("click", function()
{
try{
webphone_api.common.PutToDebugLog(5, 'EVENT, _startpage: button accept onclick');
var startpage_disp_count = webphone_api.common.GetParameterInt('startpage_disp_count', 0);
startpage_disp_count++;
webphone_api.common.SaveParameter('startpage_disp_count', startpage_disp_count.toString());
ClosePage();
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_startpage: onCreate", err); }
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_startpage: onCreate", err); }
}
function onStart(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _startpage: onStart");
webphone_api.global.isStartpageStarted = true;
webphone_api.$('#page_startpage_content').html('');
url = webphone_api.common.GetIntentParam(webphone_api.global.intentstartpage, 'url');
lastpage = webphone_api.common.GetIntentParam(webphone_api.global.intentstartpage, 'lastpage');
pagetitle = webphone_api.common.GetIntentParam(webphone_api.global.intentstartpage, 'title');
text = webphone_api.common.GetIntentParam(webphone_api.global.intentstartpage, 'text');
var typeStr = webphone_api.common.GetIntentParam(webphone_api.global.intentstartpage, 'type');
if (!webphone_api.common.isNull(typeStr) && webphone_api.common.IsNumber(typeStr))
{
type = webphone_api.common.StrToInt(typeStr);
}
if (!webphone_api.common.isNull(document.getElementById('startpage_title')))
{
if (webphone_api.common.isNull(pagetitle)) { pagetitle = ''; }
document.getElementById('startpage_title').innerHTML = pagetitle;
}
webphone_api.$("#startpage_title").attr("title", webphone_api.stringres.get("hint_page"));
if (!webphone_api.common.isNull(document.getElementById('startpage_btnback')))
{
document.getElementById('startpage_btnback').innerHTML = '<b>&LT;</b>&nbsp;' + webphone_api.stringres.get("go_back_btn_txt");
}
MeasureStartpage();
if (webphone_api.common.isNull(lastpage))
{
lastpage = '';
}else
{
lastpage = webphone_api.common.Trim(lastpage);
}
webphone_api.$("#page_startpage").css("background", "#FFFFFF");
// 0: display once with OK button, 1: display once with confirmation, 2: display always
if (type === 2)
{
webphone_api.$("#btn_sp_accept").attr("title", webphone_api.stringres.get("btn_ok"));
webphone_api.$("#btn_sp_decline").hide();
webphone_api.$("#startpage_btnback").show();
}
else if (type === 1)
{
webphone_api.$("#btn_sp_accept").attr("title", webphone_api.stringres.get("btn_accept"));
webphone_api.$("#btn_sp_decline").attr("title", webphone_api.stringres.get("btn_decline"));
webphone_api.$("#btn_sp_decline").show();
webphone_api.$("#startpage_btnback").hide();
}
else
{
webphone_api.$("#btn_sp_accept").attr("title", webphone_api.stringres.get("btn_ok"));
webphone_api.$("#btn_sp_decline").hide();
webphone_api.$("#startpage_btnback").show();
}
if (text.length > 5)
{
webphone_api.$('#page_startpage_content').html('<div style="text-align: left; margin: .5em;">' +text + '</div>');
return;
}
else if (!webphone_api.common.isNull(url) && url.length > 0)
{
OpenWebpage();
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_startpage: onStart", err); }
}
function MeasureStartpage() // resolve window height size change
{
try{
//--var pgh = webphone_api.common.GetDeviceHeight() - 1; webphone_api.$('#page_startpage').css('min-height', pgh + 'px'); // must be set when softphone is skin in div
webphone_api.$('#page_startpage').css('min-height', 'auto'); // must be set when softphone is skin in div
webphone_api.$(".separator_line_thick").css( 'background-color', webphone_api.common.HoverCalc(webphone_api.common.getBgColor('#page_startpage'), -30) );
var heightTemp = webphone_api.common.GetDeviceHeight() - webphone_api.$("#startpage_header").height() - webphone_api.$("#startpage_footer").height() - webphone_api.$(".separator_line_thick").height() - 2;
heightTemp = heightTemp - 3;
heightTemp = Math.floor(heightTemp);
webphone_api.$("#page_startpage_content").height(heightTemp);
webphone_api.$("#iframe_startpage").width(webphone_api.common.GetDeviceWidth());
webphone_api.$("#iframe_startpage").height(heightTemp - 5);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_startpage: MeasureStartpage", err); }
}
function OpenWebpage()
{
try{
if (webphone_api.common.isNull(url) || url.length < 3 )
{
webphone_api.common.PutToDebugLog(3, 'ERROR, _startpage no url to load: ' + url);
return;
}
var width = webphone_api.common.GetDeviceWidth();
var height = Math.floor( webphone_api.$('#page_startpage_content').height() - 5);
var iframe = '';
var pos = url.indexOf('[POST]');
if (pos > 0)
{
var purl = webphone_api.common.Trim(url.substring(0, pos));
var pdataStr = webphone_api.common.Trim(url.substring(pos + 6));
var pdata = [];
var pdataInput = '';
if (!webphone_api.common.isNull(pdataStr) && pdataStr.length > 0)
{
pdata = pdataStr.split('&');
if (webphone_api.common.isNull(pdata)) { pdata = []; }
}
for (var i = 0; i < pdata.length; i++)
{
if (webphone_api.common.isNull(pdata[i]) || pdata[i].length < 2 || pdata[i].indexOf('=') < 1) { continue; }
var name = pdata[i].substring(0, pdata[i].indexOf('='));
var val = pdata[i].substring(pdata[i].indexOf('=') + 1);
if (webphone_api.common.isNull(name) || name.length < 1 || webphone_api.common.isNull(val)) { continue; }
pdataInput += '<input type="hidden" name="' + name + '" value="' + val + '"/>';
}
iframe = '<form id="internalb_post" target="iframe_startpage" method="post" action="' + purl + '">' +
pdataInput +
'</form>' +
'<iframe allow="microphone *; camera *; autoplay *" allowfullscreen="true" frameborder="0" width="' + width + '" height="' + height + '" name="iframe_startpage" id="iframe_startpage" style="margin:0px; padding:0px;" sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-top-navigation"></iframe>' +
'<script type="text/javascript">' +
'document.getElementById("internalb_post").submit();' +
'</script>';
}else
{
//-- var iframe = '<iframe frameborder="0" width="' + width + '" height="' + height + '" src="' + url + '" name="iframe_startpage" id="iframe_startpage" style="margin:0px; padding:0px;"></iframe>';
iframe = '<iframe style="margin:0px; padding:0px; overflow-x: hidden; overflow-y: auto;" allow="microphone *; camera *; autoplay *" allowfullscreen="true" frameborder="0" width="' + width + '" height="' + height + '" src="' + url + '" name="iframe_startpage" id="iframe_startpage" sandbox="allow-same-origin allow-scripts allow-popups allow-forms allow-top-navigation"></iframe>';
}
webphone_api.$('#page_startpage_content').html(iframe);
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_startpage: OpenWebpage", err); }
}
var MENUITEM_CLOSE = '#menuitem_startpage_close';
function CreateOptionsMenu (menuId) // adding items to menu, called from html
{
try{
// remove data transition for windows softphone, because it's slow
if (webphone_api.common.GetParameter('devicetype') === webphone_api.common.DEVICE_WIN_SOFTPHONE())
{
webphone_api.$( "#btn_startpage_menu" ).removeAttr('data-transition');
}
if ( webphone_api.common.isNull(menuId) || menuId.length < 1 ) { webphone_api.common.PutToDebugLog(2, "ERROR, _startpage: CreateOptionsMenu menuid null"); return; }
if (webphone_api.$(menuId).length <= 0) { webphone_api.common.PutToDebugLog(2, "ERROR, _startpage: CreateOptionsMenu can't get reference to Menu"); return; }
if (menuId.charAt(0) !== '#') { menuId = '#' + menuId; }
webphone_api.$(menuId).html('');
webphone_api.$(menuId).append( '<li id="' + MENUITEM_CLOSE + '"><a data-rel="back">' + webphone_api.stringres.get('menu_close') + '</a></li>' ).listview('refresh');
return true;
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_startpage: CreateOptionsMenu", err); }
return false;
}
function MenuItemSelected(itemid)
{
try{
if (webphone_api.common.isNull(itemid) || itemid.length < 1) { return; }
webphone_api.$( '#startpage_menu' ).on( 'popupafterclose', function( event )
{
webphone_api.$( '#startpage_menu' ).off( 'popupafterclose' );
switch (itemid)
{
case MENUITEM_CLOSE:
ClosePage();
break;
}
});
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_startpage: MenuItemSelected", err); }
}
function ClosePage()
{
try{
if (lastpage.length < 2)
{
webphone_api.$.mobile.back();
webphone_api.common.PutToDebugLog(5, 'EVENT, _startpage: ClosePage back');
}else
{
webphone_api.$.mobile.changePage("#" + lastpage, { transition: "pop", role: "page" });
webphone_api.common.PutToDebugLog(5, 'EVENT, _startpage: ClosePage changepage: ' + lastpage);
}
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_startpage: ClosePage", err); }
}
function onStop(event)
{
try{
webphone_api.common.PutToDebugLog(4, "EVENT, _startpage: onStop");
webphone_api.global.isStartpageStarted = false;
webphone_api.$('#page_startpage_content').html('');
} catch(err) { webphone_api.common.PutToDebugLogException(2, "_startpage: onStop", err); }
}
// public members and methods
return {
onCreate: onCreate,
onStart: onStart,
onStop: onStop
};
})();
+4
View File
@@ -0,0 +1,4 @@
JavaScript files for the softphone skin (softphone.html).
You might edit these files to further customize the softphone skin if the webphone parameter are not enough or doesn't cover your needs.
+540
View File
@@ -0,0 +1,540 @@
//--define([], function() // list and configurations of themes
webphone_api.themes = (function ()
{
var themelist = {
theme_0: // Default
{
name: 'Default',
bgcolorheader: '#0b1325',
bgcolor: '#0b1325',
scrollbarcolor: '#3c3c3c',
listbgcolor: '#2a2a2a',
listitembgcolor: '#353d49',
//buttoncolor: '#643333',
buttoncolor: '#84131f',
buttonhover: '#373737',
buttonbordercolor: '#1f1f1f',
tabcolor: '#333333',
tabselectedcolor: '#22aadd',
bgdialpadnrfield: '#0e4e62',
bgdialpadbtn: '#0e4e62',
bgdialpadfooter: '#0e4e62',
fontctheme: '#31b6e7',
fontcwhite: '#ffffff',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
/*
bgcolorheader: '#1d1d1d',
bgcolor: '#1d1d1d',
scrollbarcolor: '#3c3c3c',
listbgcolor: '#2a2a2a',
listitembgcolor: '#333333',
buttoncolor: '#333333',
buttonhover: '#373737',
buttonbordercolor: '#1f1f1f',
tabcolor: '#333333',
tabselectedcolor: '#22aadd',
bgdialpadnrfield: '#001a22',
bgdialpadbtn: '#001a22',
bgdialpadfooter: '#001a22',
fontctheme: '#31b6e7',
fontcwhite: '#ffffff',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
*/
},
theme_1: // Light Blue
{
name: 'Light Blue',
bgcolorheader: '#4897D3',
bgcolor: '#F1F1F1',
scrollbarcolor: '#9C9B99',
listbgcolor: '#F1F1F1',
listitembgcolor: '#F1F1F1',
buttoncolor: '#4897D3',
buttonhover: '#DEDCDA',
buttonbordercolor: '#E6E6E6',
tabcolor: '#4797D1',
tabselectedcolor: '#6666CC',
bgdialpadnrfield: '#F1F1F1',
bgdialpadbtn: '#F1F1F1', //dialpad background
bgdialpadfooter: '#F1F1F1',
fontctheme: '#4897D3',
fontcwhite: '#2B2B2B',
fontcstatus: '#FFFFFF',
fontfamily: 'sans-serif'
},
theme_2: // Light Green
{
name: 'Light Green',
bgcolorheader: '#efefef',
bgcolor: '#ffffff',
scrollbarcolor: '#cccccc',
listbgcolor: '#ffffff',
listitembgcolor: '#ffffff',
buttoncolor: '#dfdfdf',
buttonhover: '#d1d1d1',
buttonbordercolor: '#bcbcbc',
tabcolor: '#333333',
tabselectedcolor: '#99c55a',
bgdialpadnrfield: '#efefef',
bgdialpadbtn: '#ffffff',
bgdialpadfooter: '#d1d3d1',
fontctheme: '#6dad12',
fontcwhite: '#555755',
fontcstatus: '#555755',
fontfamily: 'sans-serif'
},
theme_3: // Light Orange
{
name: 'Light Orange',
bgcolorheader: '#333333',
bgcolor: '#ff9900',
scrollbarcolor: '#3c3c3c',
listbgcolor: '#ffffff',
listitembgcolor: '#ffffff',
buttoncolor: '#dfdfdf',
buttonhover: '#efefef',
buttonbordercolor: '#333333',
tabcolor: '#333333',
tabselectedcolor: '#666666',
bgdialpadnrfield: '#efefef',
bgdialpadbtn: '#ffffff',
bgdialpadfooter: '#ca602a',
fontctheme: '#ff9900',
fontcwhite: '#555755',
fontcstatus: '#ff9900',
fontfamily: 'sans-serif'
},
theme_4: // Light Purple
{
name: 'Light Purple',
bgcolorheader: '#c5cfea',
bgcolor: '#ffffff',
scrollbarcolor: '#d3d9f4',
listbgcolor: '#ffffff',
listitembgcolor: '#ffffff',
buttoncolor: '#c5cfea',
buttonhover: '#f5f5ff',
buttonbordercolor: '#ffffff',
tabcolor: '#c5cfea',
tabselectedcolor: '#8399ec',
bgdialpadnrfield: '#ffffff',
bgdialpadbtn: '#ffffff',
bgdialpadfooter: '#c5cfea',
fontctheme: '#101113',
fontcwhite: '#101113',
fontcstatus: '#101113',
fontfamily: 'sans-serif'
},
theme_5: // Dark Red
{
name: 'Dark Red',
bgcolorheader: '#2e3238',
bgcolor: '#3A414A',
scrollbarcolor: '#292e34',
listbgcolor: '#3A414A',
listitembgcolor: '#3A414A',
buttoncolor: '#000000',
buttonhover: '#2e383e',
buttonbordercolor: '#000000',
tabcolor: '#2d2b2b',
tabselectedcolor: '#000000',
bgdialpadnrfield: '#3A414A',
bgdialpadbtn: '#3A414A',
bgdialpadfooter: '#3A414A',
fontctheme: '#DD191D',
fontcwhite: '#FF5555',
fontcstatus: '#D7D9DB',
fontfamily: 'sans-serif'
},
theme_6:// Yellow
{
name: 'Yellow',
bgcolorheader: '#fae675',
bgcolor: '#e8c55f',
scrollbarcolor: '#d3b057',
listbgcolor: '#e8c55f',
listitembgcolor: '#fccd01',
buttoncolor: '#f7e778',
buttonhover: '#fae675',
buttonbordercolor: '#988040',
tabcolor: '#d3b057',
tabselectedcolor: '#5d4b23',
bgdialpadnrfield: '#ffffff',
bgdialpadbtn: '#f1e1a8',
bgdialpadfooter: '#916c27',
fontctheme: '#5d4b23',
fontcwhite: '#555755',
fontcstatus: '#5d4b23',
fontfamily: 'sans-serif'
},
theme_7: // Blue
{
name: 'Blue',
bgcolorheader: '#000000',
bgcolor: '#3BBBF5',
scrollbarcolor: '#2983AC',
listbgcolor: '#3BBBF5',
listitembgcolor: '#3BBBF5',
buttoncolor: '#2AAAFF',
buttonhover: '#25A5E0',
buttonbordercolor: '#25A5E0',
tabcolor: '#000000',
tabselectedcolor: '#2AAAFF',
bgdialpadnrfield: '#3BBBF5',
bgdialpadbtn: '#3BBBF5',
bgdialpadfooter: '#3BBBF5',
fontctheme: '#FFFFFF', // dialpad number color
fontcwhite: '#000000',
fontcstatus: '#FFFFFF',
fontfamily: 'sans-serif'
},
theme_8: // Purple
{
name: 'Purple',
bgcolorheader: '#b80581',
bgcolor: '#ffaef3',
scrollbarcolor: '#bd27b2',
listbgcolor: '#ffaef3',
listitembgcolor: '#ffaef3',
buttoncolor: '#d64fcd',
buttonhover: '#fe8cfd',
buttonbordercolor: '#811b73',
tabcolor: '#333333',
tabselectedcolor: '#bd27b2',
bgdialpadnrfield: '#ff10fd',
bgdialpadbtn: '#ffffff',
bgdialpadfooter: '#9603661',
fontctheme: '#ff37c3',
fontcwhite: '#555755',
fontcstatus: '#000000',
fontfamily: 'sans-serif'
},
theme_9: // Turquoise
{
name: 'Turquoise',
bgcolorheader: '#00AAA0',
bgcolor: '#00AAA0',
scrollbarcolor: '#00625C',
listbgcolor: '#00AAA0',
listitembgcolor: '#00AAA0',
buttoncolor: '#8ED2C9',
buttonhover: '#009A91',
buttonbordercolor: '#5ec1c3',
tabcolor: '#00847C',
tabselectedcolor: '#125D79',
bgdialpadnrfield: '#00AAA0',
bgdialpadbtn: '#00AAA0',
bgdialpadfooter: '#00AAA0',
fontctheme: '#125d79',
fontcwhite: '#ffffff',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
},
theme_10: // Light Skin
{
name: 'Light Skin',
bgcolorheader: '#dddddd',
bgcolor: '#f3eeee',
scrollbarcolor: '#ffffff',
listbgcolor: '#ffffff',
listitembgcolor: '#f2eaea',
buttoncolor: '#D6D4D4',
buttonhover: '#F6F0F0',
buttonbordercolor: '#cccccc',
tabcolor: '#dddddd',
tabselectedcolor: '#BEB9B9',
bgdialpadnrfield: '#ffffff',
bgdialpadbtn: '#FAFAFA',
bgdialpadfooter: '#DDDDDD',
fontctheme: '#BAB0B0',
fontcwhite: '#ACA8A8',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
},
theme_11: // Green Orange
{
name: 'Green Orange',
bgcolorheader: '#0B4245',
bgcolor: '#ffffff',
scrollbarcolor: '#115f63',
listbgcolor: '#ffffff',
listitembgcolor: '#f2eaea',
buttoncolor: '#f7f7f7',
buttonhover: '#F6F0F0',
buttonbordercolor: '#e0e0e0',
tabcolor: '#115F63',
tabselectedcolor: '#ff9009',
bgdialpadnrfield: '#ffffff',
bgdialpadbtn: '#FAFAFA',
bgdialpadfooter: '#4DB748',
fontctheme: '#ff9009',
fontcwhite: '#4DB748',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
},
theme_14: //-- customized for Kokotalk
{
name: 'Custom 1',
bgcolorheader: '#000000',
bgcolor: '#1d1d1d',
scrollbarcolor: '#3c3c3c',
listbgcolor: '#2a2a2a',
listitembgcolor: '#333333',
buttoncolor: '#333333',
buttonhover: '#73a41c',
buttonbordercolor: '#1f1f1f',
tabcolor: '#333333',
tabselectedcolor: '#73a41c',
bgdialpadnrfield: '#97ca3d',
bgdialpadbtn: '#97ca3d',
bgdialpadfooter: '#97ca3d',
fontctheme: '#97ca3d',
fontcwhite: '#ffffff',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
},
theme_15: //-- customized for Favafone
{
name: 'Custom 2',
bgcolorheader: '#1d1d1d',
bgcolor: '#1d1d1d',
scrollbarcolor: '#3c3c3c',
listbgcolor: '#2a2a2a',
listitembgcolor: '#333333',
buttoncolor: '#39b54d',
buttonhover: '#32a043',
buttonbordercolor: '#1f1f1f',
tabcolor: '#333333',
tabselectedcolor: '#39b54d',
bgdialpadnrfield: 'url(images/texture_bg_dial.png) repeat #001a22',
bgdialpadbtn: 'url(images/texture_bg_dial.png) repeat #001a22',
bgdialpadfooter: 'url(images/texture_bg_dial.png) repeat #001a22',
fontctheme: '#71bf44',
fontcwhite: '#ffffff',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
},
theme_16: //-- customized for Voipcenter
{
name: 'Custom 3',
bgcolorheader: '#FF9900',
bgcolor: '#ffffff',
scrollbarcolor: '#008B8B',
listbgcolor: '#ffffff',
listitembgcolor: '#ffffff',
buttoncolor: '#FF9900',
buttonhover: '#e6e6e6',
buttonbordercolor: '#ffffff',
tabcolor: '#008B8B',
tabselectedcolor: '#FF9900',
bgdialpadnrfield: '#ffffff',
bgdialpadbtn: '#FF9900',
bgdialpadfooter: '#008B8B',
fontctheme: '#008B8B',
fontcwhite: '#008B8B',
fontcstatus: '#000000',
fontfamily: 'sans-serif'
},
theme_18: //-- voipmuch
{
name: 'Custom 4',
bgcolorheader: '#2e3238',
bgcolor: '#3A414A',
scrollbarcolor: '#292e34',
listbgcolor: '#3A414A',
listitembgcolor: '#3A414A',
buttoncolor: '#000000',
buttonhover: '#2e383e',
buttonbordercolor: '#000000',
tabcolor: '#2d2b2b',
tabselectedcolor: '#000000',
bgdialpadnrfield: '#3A414A',
bgdialpadbtn: '#3A414A',
bgdialpadfooter: '#3A414A',
fontctheme: '#B14E48',
fontcwhite: '#FF5555',
fontcstatus: '#B14E48',
fontfamily: 'sans-serif'
},
theme_19: //-- Labbay
{
name: 'Custom 5',
bgcolorheader: '#0076c0',
bgcolor: '#ffffff',
scrollbarcolor: '#0094da',
listbgcolor: '#ffffff',
listitembgcolor: '#ffffff',
buttoncolor: '#0094da',
buttonhover: '#0076c0',
buttonbordercolor: '#000000',
tabcolor: '#0094da',
tabselectedcolor: '#fcb913',
bgdialpadnrfield: '#ffffff',
bgdialpadbtn: '#ffffff',
bgdialpadfooter: '#fdb813',
fontctheme: '#00a1e7',
fontcwhite: '#fdba13',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
},
theme_21: //-- Custom Blue2
{
name: 'Blue2',
bgcolorheader: '#051318',
bgcolor: '#051318',
scrollbarcolor: '#3c3c3c',
listbgcolor: '#2a2a2a',
listitembgcolor: '#1d414d',
buttoncolor: '#1d414d',
buttonhover: '#325967',
buttonbordercolor: '#1f1f1f',
tabcolor: '#333333',
tabselectedcolor: '#22aadd',
bgdialpadnrfield: 'url(images/texture_bg_dial.png) repeat #0e4e62',
//bgdialpadbtn: '#0e4e62',
bgdialpadbtn: 'url(images/texture_bg_dial.png) repeat #0e4e62',
bgdialpadfooter: 'url(images/texture_bg_dial.png) repeat #0e4e62',
fontctheme: '#31b6e7',
fontcwhite: '#ffffff',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
},
theme_22: //-- Custom iPhone
{
name: 'iPhone',
bgcolorheader: '#ffffff',
bgcolor: '#ffffff',
scrollbarcolor: '#dedede',
listbgcolor: '#ffffff',
listitembgcolor: '#ffffff',
//buttoncolor: '#dedede',
buttoncolor: '#e9e8ec',
buttonhover: '#f1f1f1',
buttonbordercolor: '#cecece',
tabcolor: '#ffffff',
//tabselectedcolor: '#007aff',
tabselectedcolor: '#e9e8ec',
bgdialpadnrfield: '#ffffff',
//bgdialpadbtn: '#0e4e62',
bgdialpadbtn: '#ffffff',
bgdialpadfooter: '#ffffff',
fontctheme: '#000000',
fontcwhite: '#353535',
fontcstatus: '#353535',
fontfamily: 'sans-serif'
},
theme_23: //-- Custom mizu-voip.com
{
name: 'MZ',
bgcolorheader: '#d0eef8',
bgcolor: '#d0eef8',
scrollbarcolor: '#add4e9',
listbgcolor: '#d0eef8',
listitembgcolor: '#d0eef8',
buttoncolor: '#9fc8e4',
buttonhover: '#8fbdd5',
buttonbordercolor: '#cecece',
tabcolor: '#dedede',
tabselectedcolor: '#4094dc',
bgdialpadnrfield: '#ffffff',
//bgdialpadbtn: '#0e4e62',
bgdialpadbtn: '#ffffff',
bgdialpadfooter: '#aad3e9',
fontctheme: '#cb2027',
fontcwhite: '#353535',
fontcstatus: '#353535',
fontfamily: 'sans-serif'
},
theme_24: // WebPhone
{
name: 'Webphone',
bgcolorheader: '#0b1325',
bgcolor: '#0b1325',
scrollbarcolor: '#3c3c3c',
listbgcolor: '#2a2a2a',
listitembgcolor: '#353d49',
//buttoncolor: '#643333',
buttoncolor: '#84131f',
buttonhover: '#373737',
buttonbordercolor: '#1f1f1f',
tabcolor: '#333333',
tabselectedcolor: '#22aadd',
bgdialpadnrfield: '#0e4e62',
bgdialpadbtn: '#0e4e62',
bgdialpadfooter: '#0e4e62',
fontctheme: '#31b6e7',
fontcwhite: '#ffffff',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
},
theme_25: // Custom
{
//BOF CUSTOMSKIN
name: 'Custom',
bgcolorheader: '#0b1325',
bgcolor: '#0b1325',
scrollbarcolor: '#3c3c3c',
listbgcolor: '#2a2a2a',
listitembgcolor: '#353d49',
buttoncolor: '#643333',
buttonhover: '#373737',
buttonbordercolor: '#1f1f1f',
tabcolor: '#333333',
tabselectedcolor: '#22aadd',
bgdialpadnrfield: '#0e4e62',
bgdialpadbtn: '#0e4e62',
bgdialpadfooter: '#0e4e62',
fontctheme: '#31b6e7',
fontcwhite: '#ffffff',
fontcstatus: '#ffffff',
fontfamily: 'sans-serif'
//EOF CUSTOMSKIN
}
};
function gettheme (name)
{
if (typeof (name) === 'undefined' || name === null) { return null; }
name = name.toLowerCase();
if (typeof (themelist[name]) === 'undefined' || themelist[name] === null)
{
return null;
}
return themelist[name];
}
return {
gettheme: gettheme
};
})();