summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2013-05-01 14:12:45 +0200
committerDominique Martinet <asmadeus@codewreck.org>2015-11-08 14:27:59 +0100
commit7c5af1d86c4716f11f259533f72556c2a7ffe65b (patch)
treedc4cbe2de8156f45a7366075c3756d9a6631f215
parent80733675c8979de9ee5efe3d93170003e9845169 (diff)
addraid: enter on search doesn't submit form, clicking/enter toggles add entry, strips empty line on first add
-rw-r--r--templates/default/admin/addraid.html57
1 files changed, 44 insertions, 13 deletions
diff --git a/templates/default/admin/addraid.html b/templates/default/admin/addraid.html
index 3afd05d..1b8e1fa 100644
--- a/templates/default/admin/addraid.html
+++ b/templates/default/admin/addraid.html
@@ -19,12 +19,12 @@ function pop_parse_log()
log = window.open('parse_{MSG_GAME_NAME}.php{SID}','log','scrollbars=yes,resizable=yes,toolbar=no,status=yes,height=570,width=600,screenX=50,screenY=25,left=100,top=75')
log.focus();
}
-function fnSearch( searchField, searchItem )
+function fnSearch()
{
thisForm = document.post;
- searchBox = thisForm.elements[searchField];
- selectBox = thisForm.elements[searchItem];
+ searchBox = thisForm.elements['memberSearch'];
+ selectBox = thisForm.elements['member_name'];
reSearch = new RegExp( searchBox.value, "i" );
@@ -40,33 +40,48 @@ function fnSearch( searchField, searchItem )
}
function addMember( newMember )
{
+ thisForm = document.post;
+
// poll the select box if newMember doesn't exist
if( newMember == null )
{
+ fromField = thisForm.member_name;
+
+ fromSize = fromField.options.length
+
+
+ newMember = fromField.options[fromField.selectedIndex].value;
}
// get the current value of the textarea box
- thisForm = document.post;
strMembers = new String( thisForm.raid_attendees.value );
// parse the member names into an array
arrMembers = strMembers.split(/[\n\r]/);
- // add the new member to the array
- arrMembers.push( newMember );
-
// prune out any duplicates
var seenIt = { };
+ seenIt[""] = 1; // anything true to remove empty lines
for ( var i = arrMembers.length - 1; i >= 0; i-- )
{
var thisOne = arrMembers[i];
if ( seenIt[thisOne] )
{
arrMembers[i] = null;
- }
- seenIt[thisOne] = true;
+ } else {
+ // ugly hack to remember position and be true for 0... WTB typed language.
+ seenIt[thisOne] = i + 1;
+ }
}
+ // add or remove the new member to the array
+ if ( seenIt[newMember] )
+ {
+ arrMembers[seenIt[newMember] - 1] = null;
+ } else {
+ arrMembers.push( newMember );
+ }
+
arrMembersOut = new Array();
len = arrMembers.length
for ( var i = 0; i < len; i++ )
@@ -84,10 +99,26 @@ function addMember( newMember )
thisForm.raid_attendees.value = strMembersOut;
thisForm.memberSearch.value = "";
- thisForm.memberSearch.focus();
+// thisForm.memberSearch.focus();
return false;
}
+function dontSubmit(e, fnEnter, fnAny)
+{
+ var key;
+
+ if (window.event)
+ key = window.event.keyCode; //IE
+ else
+ key = e.which; //Firefox & others
+
+ if(key == 13) {
+ if (fnEnter) fnEnter();
+ return false;
+ } else {
+ if (fnAny) fnAny();
+ }
+}
</script>
<form method="post" action="{F_ADD_RAID}" name="post" onsubmit="return check_form(this)">
@@ -104,11 +135,11 @@ function addMember( newMember )
<table width="100%" border="0" cellpadding="3" cellspacing="0" class="borderless">
<tr>
- <td colspan="3">{L_SEARCH_MEMBERS}: <input type="text" name="memberSearch" size="35" maxlength="255" value="" class="input" onkeyup="fnSearch(this.name, 'member_name')" /></td>
- </tr>
+ <td colspan="3">{L_SEARCH_MEMBERS}: <input type="text" name="memberSearch" size="35" maxlength="255" value="" class="input" onkeypress="return dontSubmit(event);" onkeyup="return dontSubmit(event, addMember, fnSearch);" /></td>
+ </tr>
<tr>
<td>
- <select size="30" name="member_name" class="input" onchange="addMember(this.value);">
+ <select size="30" name="member_name" class="input" onclick="addMember(this.value);">
<!-- BEGIN members_row -->
<option value="{members_row.VALUE}">{members_row.OPTION}</option>
<!-- END members_row -->