Version 2.0.1

This commit is contained in:
dmzx
2017-04-28 08:00:39 +02:00
parent 28f847ecff
commit 6405c7c7ab
45 changed files with 398 additions and 135 deletions

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1,2 @@
<!-- INCLUDECSS @dmzx_mchat/mchat.css -->
<!-- INCLUDECSS @dmzx_mchat/mchat_custom.css -->

View File

@@ -0,0 +1,11 @@
/**
*
* @package phpBB Extension - mChat
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
.mchat-wrapper {
height: 100%;
}

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -4,7 +4,7 @@
* @copyright (c) 2009 Shapoval Andrey Vladimirovich (AllCity) ~ http://allcity.net.ru/
* @copyright (c) 2013 Rich McGirr (RMcGirr83) http://rmcgirr83.org
* @copyright (c) 2015 dmzx - http://www.dmzx-web.net
* @copyright (c) 2016 kasimi - mail@kasimi.net
* @copyright (c) 2016 kasimi - https://kasimi.net
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*
*/
@@ -72,11 +72,35 @@ jQuery.fn.reverse = function(reverse) {
return reverse === 'undefined' || reverse ? jQuery(this.toArray().reverse()) : this;
};
function StorageWrapper(storage, prefix) {
this.prefix = prefix;
try {
this.storage = window[storage];
this.storage.setItem(prefix, prefix);
this.storage.removeItem(prefix);
} catch (e) {
this.storage = false;
}
}
StorageWrapper.prototype.get = function(key) {
return this.storage && this.storage.getItem(this.prefix + key);
};
StorageWrapper.prototype.set = function(key, value) {
this.storage && this.storage.setItem(this.prefix + key, value);
};
StorageWrapper.prototype.remove = function(key) {
return this.storage && this.storage.removeItem(this.prefix + key);
};
jQuery(function($) {
"use strict";
$.extend(mChat, {
storage: new StorageWrapper('localStorage', mChat.cookie + 'mchat_'),
ajaxRequest: function(mode, sendHiddenFields, data) {
var deferred = $.Deferred();
if (sendHiddenFields) {
@@ -88,73 +112,77 @@ jQuery(function($) {
timeout: Math.min(mChat.refreshTime, 10000),
type: 'POST',
dataType: 'json',
data: data
}).done(function(json, status, xhr) {
var data = {
data: data,
additionalData: {
mode: mode,
json: json,
status: status,
xhr: xhr,
handle: true
};
$(mChat).trigger('mchat_ajax_done_before', [data]);
if (data.handle) {
if (json[mode]) {
deferred.resolve(data.json, data.status, data.xhr);
} else {
deferred.reject(data.xhr, data.status, mChat.lang.parserErr);
deferred: deferred
}
}).done(mChat.ajaxDone).fail(deferred.reject);
return deferred.promise().fail(mChat.ajaxFail);
},
ajaxDone: function(json, status, xhr) {
var data = {
mode: this.additionalData.mode,
json: json,
status: status,
xhr: xhr,
handle: true
};
$(mChat).trigger('mchat_ajax_done_before', [data]);
if (data.handle) {
if (json[this.additionalData.mode]) {
this.additionalData.deferred.resolve(data.json, data.status, data.xhr);
} else {
this.additionalData.deferred.reject(data.xhr, data.status, mChat.lang.parserErr);
}
}
},
ajaxFail: function(xhr, textStatus, errorThrown) {
if (mChat.pageIsUnloading) {
return;
}
if (typeof console !== 'undefined' && console.log) {
console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown + ' (' + xhr.responseText + ')');
}
var data = {
mode: this.additionalData.mode,
xhr: xhr,
textStatus: textStatus,
errorThrown: errorThrown,
updateSession: function() {
if (this.xhr.status == 403) {
mChat.endSession(true);
} else if (this.xhr.status == 400) {
mChat.resetSession();
}
}
}).fail(deferred.reject);
return deferred.promise().fail(function(xhr, textStatus, errorThrown) {
if (mChat.pageIsUnloading) {
return;
}
if (typeof console !== 'undefined' && console.log) {
console.log('AJAX error. status: ' + textStatus + ', message: ' + errorThrown + ' (' + xhr.responseText + ')');
}
var data = {
mode: mode,
xhr: xhr,
textStatus: textStatus,
errorThrown: errorThrown,
updateSession: function() {
if (this.xhr.status == 403) {
mChat.endSession(true);
} else if (this.xhr.status == 400) {
mChat.resetSession();
}
}
};
$(mChat).trigger('mchat_ajax_fail_before', [data]);
mChat.sound('error');
mChat.cached('status-load', 'status-ok', 'status-paused').hide();
mChat.cached('status-error').show();
var responseText;
try {
responseText = data.xhr.responseJSON.message || data.errorThrown;
} catch (e) {
responseText = data.errorThrown;
}
if (responseText && responseText !== 'timeout') {
phpbb.alert(mChat.lang.err, responseText);
}
data.updateSession();
});
};
$(mChat).trigger('mchat_ajax_fail_before', [data]);
mChat.sound('error');
mChat.cached('status-load', 'status-ok', 'status-paused').hide();
mChat.cached('status-error').show();
var responseText;
try {
responseText = data.xhr.responseJSON.message || data.errorThrown;
} catch (e) {
responseText = data.errorThrown;
}
if (responseText && responseText !== 'timeout') {
phpbb.alert(mChat.lang.err, responseText);
}
data.updateSession();
},
sound: function(file) {
if (!mChat.pageIsUnloading && !localStorage.getItem(mChat.cookie + 'mchat_no_sound')) {
var data = {
audio: mChat.cached('sound-' + file).get(0),
file: file,
play: true
};
$(mChat).trigger('mchat_sound_before', [data]);
if (data.play && data.audio.duration) {
data.audio.pause();
data.audio.currentTime = 0;
data.audio.play();
}
var data = {
audio: mChat.cached('sound-' + file).get(0),
file: file,
play: !mChat.pageIsUnloading && mChat.cached('user-sound').is(':checked')
};
$(mChat).trigger('mchat_sound_before', [data]);
if (data.play && data.audio && data.audio.duration) {
data.audio.pause();
data.audio.currentTime = 0;
data.audio.play();
}
},
titleAlert: function() {
@@ -171,9 +199,9 @@ jQuery(function($) {
var $elem = mChat.cached(name);
$elem.stop().slideToggle(200, function() {
if ($elem.is(':visible')) {
localStorage.setItem(mChat.cookie + 'mchat_show_' + name, 'yes');
mChat.storage.set('show_' + name, 'yes');
} else {
localStorage.removeItem(mChat.cookie + 'mchat_show_' + name);
mChat.storage.remove('show_' + name);
}
});
},
@@ -214,15 +242,15 @@ jQuery(function($) {
mChat.pauseSession();
var originalInputValue = mChat.cached('input').val();
var inputValue = originalInputValue;
var color = localStorage.getItem(mChat.cookie + 'mchat_color');
var color = mChat.storage.get('color');
if (color && inputValue.indexOf('[color=') === -1) {
inputValue = '[color=#' + color + '] ' + inputValue + ' [/color]';
}
mChat.cached('input').val('').focus();
mChat.cached('input').val('').trigger('update.autogrow').focus();
mChat.refresh(inputValue).done(function() {
mChat.resetSession();
}).fail(function() {
mChat.cached('input').val(originalInputValue);
mChat.cached('input').val(originalInputValue).trigger('update.autogrow');
}).always(function() {
mChat.cached('add').prop('disabled', false);
setTimeout(function() {
@@ -320,7 +348,7 @@ jQuery(function($) {
handleWhoisResponse: function(json) {
var $whois = $(json.whois);
var $userlist = $whois.find('#mchat-userlist');
if (localStorage.getItem(mChat.cookie + 'mchat_show_userlist')) {
if (mChat.storage.get('show_userlist')) {
$userlist.show();
}
mChat.cached('whois').replaceWith($whois);
@@ -484,8 +512,9 @@ jQuery(function($) {
var selector = '.mchat-time[data-mchat-relative-update]';
clearInterval($message.find(selector).addBack(selector).data('mchat-relative-interval'));
},
timeLeftRegex: /\d\d:(\d\d:\d\d)/,
timeLeft: function(sessionTime) {
return (new Date(sessionTime * 1000)).toUTCString().match(/(\d\d:\d\d:\d\d)/)[0];
return (new Date(sessionTime * 1000)).toUTCString().match(mChat.timeLeftRegex)[mChat.timeout >= 3600000 ? 0 : 1];
},
countDown: function() {
mChat.sessionTime -= 1;
@@ -562,25 +591,30 @@ jQuery(function($) {
mention: function() {
var $container = $(this).closest('.mchat-message');
var username = $container.data('mchat-username');
var usercolor = $container.data('mchat-usercolor');
if (usercolor) {
username = '[b][color=' + usercolor + ']' + username + '[/color][/b]';
} else if (mChat.allowBBCodes) {
username = '[b]' + username + '[/b]';
if (mChat.allowBBCodes) {
var usercolor = $container.data('mchat-usercolor');
var profileUrl = $container.find(".mchat-message-header a[class^='username']").prop('href');
if (usercolor) {
username = '[url=' + profileUrl + '][b][color=' + usercolor + ']' + username + '[/color][/b][/url]';
} else {
username = '[url=' + profileUrl + '][b]' + username + '[/b][/url]';
}
}
insert_text('@ ' + username + ', ');
insert_text(mChat.lang.mention.format({username: username}));
},
quote: function() {
var $container = $(this).closest('.mchat-message');
var username = $container.data('mchat-username');
var quote = $container.data('mchat-message');
insert_text('[quote="' + username + '"] ' + quote + '[/quote]');
mChat.cached('input').trigger('update.autogrow');
},
like: function() {
var $container = $(this).closest('.mchat-message');
var username = $container.data('mchat-username');
var quote = $container.data('mchat-message');
insert_text('[i]' + mChat.lang.likes + '[/i][quote="' + username + '"] ' + quote + '[/quote]');
mChat.cached('input').trigger('update.autogrow');
},
ip: function() {
popup(this.href, 750, 500);
@@ -618,13 +652,13 @@ jQuery(function($) {
}, 1);
}
mChat.cached('user-sound').prop('checked', mChat.playSound && !localStorage.getItem(mChat.cookie + 'mchat_no_sound')).change(function() {
mChat.cached('user-sound').prop('checked', mChat.playSound && !mChat.storage.get('no_sound')).change(function() {
if (this.checked) {
localStorage.removeItem(mChat.cookie + 'mchat_no_sound');
mChat.storage.remove('no_sound');
} else {
localStorage.setItem(mChat.cookie + 'mchat_no_sound', 'yes');
mChat.storage.set('no_sound', 'yes');
}
}).change();
});
$.each(mChat.removeBBCodes.split('|'), function(i, bbcode) {
var bbCodeClass = '.bbcode-' + bbcode.replaceMany({
@@ -639,7 +673,7 @@ jQuery(function($) {
$('#bbpalette,#abbc3_bbpalette,#color_wheel').prop('onclick', null).attr('data-mchat-toggle', 'colour');
$.each(['userlist', 'smilies', 'bbcodes', 'colour'], function(i, elem) {
if (localStorage.getItem(mChat.cookie + 'mchat_show_' + elem)) {
if (mChat.storage.get('show_' + elem)) {
mChat.cached(elem).toggle();
}
});
@@ -693,17 +727,17 @@ jQuery(function($) {
e.stopImmediatePropagation();
var $this = $(this);
var newColor = $this.data('color');
if (localStorage.getItem(mChat.cookie + 'mchat_color') === newColor) {
localStorage.removeItem(mChat.cookie + 'mchat_color');
if (mChat.storage.get('color') === newColor) {
mChat.storage.remove('color');
} else {
localStorage.setItem(mChat.cookie + 'mchat_color', newColor);
mChat.storage.set('color', newColor);
mChat.cached('colour').find('.colour-palette a').removeClass('remember-color');
}
$this.toggleClass('remember-color');
}
});
var color = localStorage.getItem(mChat.cookie + 'mchat_color');
var color = mChat.storage.get('color');
if (color) {
mChat.cached('colour').find('.colour-palette a[data-color="' + color + '"]').addClass('remember-color');
}

View File

@@ -53,6 +53,7 @@
delConfirm : '{LA_MCHAT_DELCONFIRM}',
sessOut : '{LA_MCHAT_SESSION_OUT}',
sessEnds : '{LA_MCHAT_SESSION_ENDS_JS}',
mention : '{LA_MCHAT_MENTION}',
refreshYes : '{A_MCHAT_REFRESH_YES}',
refreshNo : '{LA_MCHAT_REFRESH_NO}',
charCount : '<!-- IF MCHAT_MESSAGE_LNGTH -->{LA_MCHAT_CHARACTER_COUNT_LIMIT}<!-- ELSE -->{LA_MCHAT_CHARACTER_COUNT}<!-- ENDIF -->',

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -30,3 +30,11 @@ ul.mchat-buttons > li {
.mchat-footer label {
padding-left: 3px;
}
@media only screen and (max-width: 700px), only screen and (max-device-width: 700px) {
#mchat-body {
overflow: auto;
}
}

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -7,6 +7,18 @@
*
*/
.forabg.mchat-wrapper {
padding: 0;
}
.mchat-wrapper .collapse-box h2 a {
color: #888;
}
.mchat-wrapper .collapse-box h2 a:before {
content: '' !important;
}
.icon-mchat > a:before {
content: '\f086';
font-family: 'FontAwesome';

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->

View File

@@ -1,4 +1,4 @@
<!-- IF not MCHAT_IS_ARCHIVE_PAGE -->
<!-- IF (MCHAT_CUSTOM_HEIGHT or MCHAT_INDEX_HEIGHT) and not MCHAT_IS_ARCHIVE_PAGE -->
<style>
#mchat-messages {
height: <!-- IF MCHAT_IS_CUSTOM_PAGE -->{MCHAT_CUSTOM_HEIGHT}<!-- ELSE -->{MCHAT_INDEX_HEIGHT}<!-- ENDIF -->px;

View File

@@ -76,7 +76,7 @@
</fieldset>
</div>
<div id="mchat-main">
<div id="mchat-main"<!-- IF MCHAT_MESSAGE_TOP --> class="mchat-messages-top"<!-- ENDIF -->>
<!-- IF MCHAT_STATIC_MESS and not MCHAT_IS_ARCHIVE_PAGE -->
<ul class="topiclist forums">
<li class="row mchat-static">{MCHAT_STATIC_MESS}</li>

View File

@@ -12,8 +12,16 @@
<!-- ENDIF -->
<div class="mchat-message-wrapper">
<!-- INCLUDE @dmzx_mchat/mchat_messages_icons.html -->
<div class="mchat-message-header">{mchatrow.MCHAT_USERNAME_FULL} &bull; <span class="mchat-time" title="{mchatrow.MCHAT_DATETIME}"<!-- IF mchatrow.MCHAT_MINUTES_AGO != -1 --> data-mchat-minutes-ago="{mchatrow.MCHAT_MINUTES_AGO}" data-mchat-relative-update="{mchatrow.MCHAT_RELATIVE_UPDATE}"<!-- ENDIF -->>{mchatrow.MCHAT_TIME}</span></div>
<div class="mchat-text">{mchatrow.MCHAT_MESSAGE}</div>
<div class="mchat-message-header">
<!-- EVENT dmzx_mchat_messages_header_before -->
{mchatrow.MCHAT_USERNAME_FULL} &bull; <span class="mchat-time" title="{mchatrow.MCHAT_DATETIME}"<!-- IF mchatrow.MCHAT_MINUTES_AGO != -1 --> data-mchat-minutes-ago="{mchatrow.MCHAT_MINUTES_AGO}" data-mchat-relative-update="{mchatrow.MCHAT_RELATIVE_UPDATE}"<!-- ENDIF -->>{mchatrow.MCHAT_TIME}</span>
<!-- EVENT dmzx_mchat_messages_header_after -->
</div>
<div class="mchat-text">
<!-- EVENT dmzx_mchat_messages_text_before -->
{mchatrow.MCHAT_MESSAGE}
<!-- EVENT dmzx_mchat_messages_text_after -->
</div>
</div>
</li>
<!-- END mchatrow -->

View File

@@ -1,4 +1,5 @@
<!-- EVENT dmzx_mchat_messages_icons_before -->
<!-- IF not S_IS_BOT -->
<!-- DEFINE $MCHAT_ALLOW_MENTION = MCHAT_ALLOW_USE and not mchatrow.MCHAT_IS_POSTER and not MCHAT_IS_ARCHIVE_PAGE -->
<!-- DEFINE $MCHAT_ALLOW_QUOTE = MCHAT_ALLOW_USE and S_BBCODE_ALLOWED and MCHAT_ALLOW_QUOTE and not MCHAT_IS_ARCHIVE_PAGE -->
@@ -23,3 +24,5 @@
</ul>
<!-- ENDIF -->
<!-- ENDIF -->
<!-- EVENT dmzx_mchat_messages_icons_after -->

View File

@@ -69,7 +69,6 @@
</li>
<!-- IF MCHAT_TIMEOUT --><li><span id="mchat-session">{MCHAT_SESSION_TIMELEFT}</span></li><!-- ENDIF -->
<!-- IF not MCHAT_SOUND_DISABLED --><li class="mchat-sound"><input type="checkbox" id="mchat-user-sound"<!-- IF MCHAT_SOUND --> checked="checked"<!-- ENDIF --> /><label for="mchat-user-sound">{L_MCHAT_USESOUND}</label></li><!-- ENDIF -->
<li><span class="mchat-copyright" title="{MCHAT_AUTHOR_NAMES}">&copy;</span></li>
</ul>
</div>
<!-- ENDIF -->

View File

@@ -337,8 +337,13 @@ textarea#mchat-input {
content: '';
}
.mchat-footer label {
#mchat-user-sound {
margin: 0;
}
#mchat-user-sound + label {
padding-right: 0;
padding-left: 5px;
}
#mchat-legend {
@@ -383,6 +388,7 @@ textarea#mchat-input {
#mchat-input {
width: 95% !important;
font-size: 16px;
}
}

View File

@@ -0,0 +1 @@
<!-- DEFINE $MCHAT_USE_WHITE_MESSAGE_ICONS = TRUE -->