%META:TOPICINFO{author="TWikiContributor" date="1352798346" format="1.1" version="4"}%
%META:TOPICPARENT{name="TagMePlugin"}%
---+!! Tag-me: Create New Tag

%STARTINCLUDE%
<table class="tagmeNavigation" border="0" cellpadding="3" cellspacing="0"><tr>
<td>&nbsp; &nbsp;</td>
<td bgcolor="#d7dced" style="background-image: url(%PUBURLPATH%/%SYSTEMWEB%/TagMePlugin/gray-gradient-1.png); border: solid 1px #d7dced;">&nbsp; *Create New Tag* &nbsp;</td>
<td>&nbsp;</td>
<td bgcolor="#eef0f8" style="background-image: url(%PUBURLPATH%/%SYSTEMWEB%/TagMePlugin/gray-gradient-2.png); border: solid 1px #d7dced;">&nbsp; [[%BASEWEB%.TagMeRenameTag][Rename Tag]] &nbsp;</td>
<td>&nbsp;</td>
<td bgcolor="#eef0f8" style="background-image: url(%PUBURLPATH%/%SYSTEMWEB%/TagMePlugin/gray-gradient-2.png); border: solid 1px #d7dced;">&nbsp; [[%BASEWEB%.TagMeDeleteTag][Delete Tag]] &nbsp;</td>
</tr></table>
<table border="0" cellpadding="5" cellspacing="0" style="width:100%;">
<tr bgcolor="#d7dced"><td style="width:100%;"></td></tr>
</table>
%STARTSECTION{"create"}%
Create a new tag - then add it to a topic.

<noautolink><form name="addtag" action="%SCRIPTURL{viewauth}%/%BASEWEB%/%BASETOPIC%" method="post" onsubmit="return cleanTag(this.newtag.value);">%TAGME{ tpaction="%URLPARAM{"newaction" default="newtaginit"}%" tag="%URLPARAM{newtag}%" note="%URLPARAM{newtagnote}%" }%
<div class="twikiFormSteps">
<div class="twikiFormStep twikiLast">
Name of new tag: <input type="text" class="twikiInputField" name="newtag" id="newtag" size="30" value="%URLPARAM{"createtag"}%" onblur="this.value=cleanTag(this.value)" /> <input %IF{"context inactive" then="disabled"}% type="submit" class="twikiSubmit" value="%MAKETEXT{"Create"}%" />
</div>
</div>
<input type="hidden" name="newaction" value="newtag" />
<input type="hidden" name="from" value="%URLPARAM{"from"}%" />
<input type="hidden" name="newtagnote" value="%IF{"defined from" then="Return to [<nop>[%URLPARAM{from}%]]"}%" />
</form>
</noautolink>
%ENDSECTION{"create"}%

%STARTSECTION{"existing"}%
Existing tags: %TAGME{ tpaction="showalltags" format="[[%SCRIPTURL{view}%/%SYSTEMWEB%/TagMeSearch?tag=$tag][$tag]]" separator=", " }%
%ENDSECTION{"existing"}%

%BR%
<span class="twikiGrayText">Other tag options: [[%BASEWEB%.TagMeViewAllTags][View all tags]], %IF{"'%TAGMEPLUGIN_USER_AGNOSTIC%' = 'on'" else="[[%BASEWEB%.TagMeViewMyTags][View my tags]], "}%[[%BASEWEB%.TagMeSearch][Search tags]]</span>

%STARTSECTION{"cleanTagJavascript"}%
<script language="javascript" type="text/javascript">
<!-- // <pre>-hide
function cleanTag(inTagString) {
   var shouldTranslate = '%TAGMEPLUGIN_NORMALIZE_TAG_INPUT%';
   var cleanName = "";
   if (shouldTranslate == 'on') {
      cleanName = translateEntities(inTagString);
   } else {
      cleanName = makeSafe(inTagString);
   }
   return cleanName;
}
/**
Translates international characters to ASCII.
*/
function translateEntities(inText) {
   var translated = '';
   for ( var i = 0; i < inText.length; i++ ) {
      var ch = inText.charAt( i );
      var chVal = ch.charCodeAt(0);
      var ch2 = '';
      if( (chVal==192) || (chVal==193) || (chVal==194) || (chVal==195) ) { ch = 'A'; }
      if( chVal==196) { ch = 'A'; ch2 = 'E'; }
      if( chVal==197) { ch = 'A'; ch2 = 'A'; }
      if( chVal==198) { ch = 'A'; ch2 = 'E'; }
      if( chVal==199) { ch = 'C'; }
      if( (chVal==200) || (chVal==201) || (chVal==202) || (chVal==203) ) { ch = 'E'; }
      if( (chVal==204) || (chVal==205) || (chVal==206) || (chVal==207) ) { ch = 'I'; }
      if( chVal==208) { ch = 'd'; }
      if( chVal==209) { ch = 'N'; }
      if( (chVal==210) || (chVal==211) || (chVal==212) || (chVal==213) ) { ch = 'O'; }
      if( chVal==214) { ch = 'O'; ch2 = 'E'; }
      if( chVal==216) { ch = 'O'; ch2 = 'E'; }
      if( (chVal==217) || (chVal==218) || (chVal==219) ) { ch = 'U'; }
      if( chVal==220) { ch = 'U'; ch2 = 'E'; }
      if( chVal==221) { ch = 'Y'; }
      if( chVal==222) { ch = 'P'; }
      if( chVal==223) { ch = 's'; ch2 = 's'; }
      if( (chVal==224) || (chVal==225) || (chVal==226) || (chVal==227) ) { ch = 'a'; }
      if( chVal==228) { ch = 'a'; ch2 = 'e'; }
      if( chVal==229) { ch = 'a'; ch2 = 'a'; }
      if( chVal==230) { ch = 'a'; ch2 = 'e'; }
      if( chVal==231) { ch = 'c'; }
      if( (chVal==232) || (chVal==233) || (chVal==234) || (chVal==235) ) { ch = 'e'; }
      if( (chVal==236) || (chVal==237) || (chVal==238) || (chVal==239) ) { ch = 'i'; }
      if( chVal==240) { ch = 'd'; }
      if( chVal==241) { ch = 'n'; }
      if( (chVal==242) || (chVal==243) || (chVal==244) || (chVal==245) ) { ch = 'o'; }
      if( chVal==246) { ch = 'o'; ch2 = 'e'; }
      if( chVal==248) { ch = 'o'; ch2 = 'e'; }
      if( (chVal==249) || (chVal==250) || (chVal==251) ) { ch = 'u'; }
      if( chVal==252) { ch = 'u'; ch2 = 'e'; }
      if( chVal==253) { ch = 'y'; }
      if( chVal==254) { ch = 'p'; }
      if( chVal==255) { ch = 'y'; }
      ch = toUnderscore(ch);
      ch = ch.toLowerCase();
      if( ((ch>='a')&&(ch<='z')) || ((ch>='0')&&(ch<='9')) || (ch=='_') ) { translated += ch }
      if( ch2!='' ) { translated += ch2; }
   }
   // remove double underscores
   var re = new RegExp(/_+/g);
   translated = translated.replace(re, "_");
   return translated;
}
function toUnderscore (inChar) {
   if (inChar.length == 0) return "";
   var safeChar = inChar;
   if( ((safeChar=='-') || (safeChar==' ') || (safeChar=='/')) ) { safeChar = '_'; }
   return safeChar;
}
function makeSafe (inText) {
   if (inText.length == 0) return "";
   var re = new RegExp(/[\x01-\x1f^\#\,\'\"\|\*]/g);
   var perlSafeString = inText.replace(re, "");
   return perlSafeString;
}
addLoadEvent(setHandyFocus);
function setHandyFocus () {
   document.getElementById('newtag').focus();
}
// </pre>-hide -->
</script>

%ENDSECTION{"cleanTagJavascript"}%
%STOPINCLUDE%
