[ticket/11795] Move MSN scripts to forum_fn.js

Move MSN scripts to forum_fn.js
Rewrite MSN scripts to remove duplicate code

PHPBB3-11795
This commit is contained in:
Vjacheslav Trushkin 2013-08-17 19:07:51 +03:00
parent e4874c180a
commit 4b27ec441a
2 changed files with 59 additions and 71 deletions

View file

@ -303,6 +303,64 @@ function apply_onkeypress_event() {
jQuery(document).ready(apply_onkeypress_event);
/**
* Run MSN action
*/
function msn_action(action, address)
{
// Does the browser support the MSNM object?
var app = document.getElementById('objMessengerApp');
if (!app || !app.MyStatus) {
var lang = $('form[data-lang-im-msnm-browser]');
if (lang.length) {
alert(lang.attr('data-lang-im-msnm-browser'));
}
return false;
}
// Is MSNM connected?
if (app.MyStatus == 1) {
var lang = $('form[data-lang-im-msnm-connect]');
if (lang.length) {
alert(lang.attr('data-lang-im-msnm-connect'));
}
return false;
}
// Do stuff
try {
switch (action) {
case 'add':
app.AddContact(0, address);
break;
case 'im':
app.InstantMessage(address);
break;
}
}
catch (e) {
return;
}
}
/**
* Add to your contact list
*/
function add_contact(address)
{
msn_action('add', address);
}
/**
* Write IM to contact
*/
function im_contact(address)
{
msn_action('im', address);
}
/**
* Run onload functions
*/

View file

@ -3,7 +3,7 @@
<!-- MSNM info from http://www.cdolive.net/ - doesn't seem to work with MSN Messenger -->
<h2 class="solo">{L_SEND_IM}</h2>
<form method="post" action="{S_IM_ACTION}">
<form method="post" action="{S_IM_ACTION}" data-lang-im-msnm-connect="{L_IM_MSNM_CONNECT|e('html_attr')}" data-lang-im-msnm-browser="{L_IM_MSNM_BROWSER|e('html_attr')}">
<div class="panel bg2">
<div class="inner">
@ -85,74 +85,4 @@
<a href="#" onclick="window.close(); return false;">{L_CLOSE_WINDOW}</a>
<script type="text/javascript">
// <![CDATA[
/** The following will not work with Windows Vista **/
var app = document.getElementById('objMessengerApp');
/**
* Check whether the browser supports this and whether MSNM is connected
*/
function msn_supported()
{
// Does the browser support the MSNM object?
if (app.MyStatus)
{
// Is MSNM connected?
if (app.MyStatus == 1)
{
alert('{LA_IM_MSNM_CONNECT}');
return false;
}
}
else
{
alert('{LA_IM_MSNM_BROWSER}');
return false;
}
return true;
}
/**
* Add to your contact list
*/
function add_contact(address)
{
if (msn_supported())
{
// Could return an error while MSNM is connecting, don't want that
try
{
app.AddContact(0, address);
}
catch (e)
{
return;
}
}
}
/**
* Write IM to contact
*/
function im_contact(address)
{
if (msn_supported())
{
// Could return an error while MSNM is connecting, don't want that
try
{
app.InstantMessage(address);
}
catch (e)
{
return;
}
}
}
// ]]>
</script>
<!-- INCLUDE simple_footer.html -->