From 4b27ec441ae5fce40733462100431f901c1db8a9 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sat, 17 Aug 2013 19:07:51 +0300 Subject: [PATCH] [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 --- phpBB/styles/prosilver/template/forum_fn.js | 58 +++++++++++++++ .../prosilver/template/memberlist_im.html | 72 +------------------ 2 files changed, 59 insertions(+), 71 deletions(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 4b02093b3e..fc6c418b2e 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -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 */ diff --git a/phpBB/styles/prosilver/template/memberlist_im.html b/phpBB/styles/prosilver/template/memberlist_im.html index 68aed0b3dd..8e7842e631 100644 --- a/phpBB/styles/prosilver/template/memberlist_im.html +++ b/phpBB/styles/prosilver/template/memberlist_im.html @@ -3,7 +3,7 @@

{L_SEND_IM}

-
+
@@ -85,74 +85,4 @@ {L_CLOSE_WINDOW} - -