Ignore spectators option

This commit is contained in:
Guangcong Luo
2013-04-13 17:06:51 -07:00
parent a103b28897
commit d6f4ee20e0
2 changed files with 12 additions and 3 deletions

View File

@@ -4525,13 +4525,14 @@ function Battle(frame, logFrame, noPreload) {
case 'chat':
case 'c':
name = args[1];
if (self.ignoreSpects && !self.getSide(name).battle) break;
args.shift();
args.shift();
var message = args.join('|');
if (message.substr(0,2) === '//') {
self.log('<div class="chat"><strong style="' + hashColor(toUserid(self.getSide(name).name)) + '">' + self.sanitize(name) + ':</strong> <em>' + messageSanitize(message.substr(1)) + '</em></div>', preempt);
self.log('<div class="chat"><strong style="' + hashColor(toUserid(name)) + '">' + self.sanitize(name) + ':</strong> <em>' + messageSanitize(message.substr(1)) + '</em></div>', preempt);
} else if (message.substr(0,4).toLowerCase() === '/me ') {
self.log('<div class="chat"><strong style="' + hashColor(toUserid(self.getSide(name).name)) + '">&bull;</strong> <em>' + self.sanitize(name) + ' <i>' + messageSanitize(message.substr(4)) + '</i></em></div>', preempt);
self.log('<div class="chat"><strong style="' + hashColor(toUserid(name)) + '">&bull;</strong> <em>' + self.sanitize(name) + ' <i>' + messageSanitize(message.substr(4)) + '</i></em></div>', preempt);
} else if (message.substr(0,14).toLowerCase() === '/data-pokemon ') {
self.log('<div class="chat"><ul class=\"utilichart\">'+Chart.pokemonRow(Tools.getTemplate(message.substr(14)),'',{})+'<li style=\"clear:both\"></li></ul></div>', preempt);
} else if (message.substr(0,11).toLowerCase() === '/data-item ') {
@@ -4541,7 +4542,7 @@ function Battle(frame, logFrame, noPreload) {
} else if (message.substr(0,11).toLowerCase() === '/data-move ') {
self.log('<div class="chat"><ul class=\"utilichart\">'+Chart.moveRow(Tools.getMove(message.substr(11)),'',{})+'<li style=\"clear:both\"></li></ul></div>', preempt);
} else {
self.log('<div class="chat"><strong style="' + hashColor(toUserid(self.getSide(name).name)) + '">' + self.sanitize(name) + ':</strong> <em>' + messageSanitize(message) + '</em></div>', preempt);
self.log('<div class="chat"><strong style="' + hashColor(toUserid(name)) + '">' + self.sanitize(name) + ':</strong> <em>' + messageSanitize(message) + '</em></div>', preempt);
}
break;
case 'chatmsg':

View File

@@ -3176,6 +3176,11 @@ function overlay(overlayType, data) {
contents += '<p><label class="optlabel"><input type="checkbox" id="pref_showjoins"'+(Tools.prefs.get('showjoins')?' checked="checked"':'')+'> Always show joins/leaves in lobby chat</label></p>';
contents += '<p><label class="optlabel"><input type="checkbox" id="pref_showbattles"'+(Tools.prefs.get('showbattles')?' checked="checked"':'')+'> Always show battle starts in lobby chat</label></p>';
if (curRoom.battle) {
contents += '<h3>Current room</h3>';
contents += '<p><label class="optlabel"><input type="checkbox" id="pref_ignorespects"'+(curRoom.battle.ignoreSpects?' checked="checked"':'')+'> Ignore spectators</label></p>';
}
contents += '<p><button type="submit"><strong>Save</strong></button> <button onclick="overlayClose();return false">Cancel</button></p>';
break;
case 'avatars':
@@ -3324,6 +3329,9 @@ function overlaySubmit(e, overlayType) {
Tools.prefs.set('showjoins', !!$('#pref_showjoins')[0].checked, false);
Tools.prefs.set('showbattles', !!$('#pref_showbattles')[0].checked, false);
Tools.prefs.set('noanim', !!$('#pref_noanim')[0].checked, false);
if (curRoom.battle) {
curRoom.battle.ignoreSpects = !!$('#pref_ignorespects').prop('checked');
}
Tools.prefs.save();
overlayClose();
break;