@@ -313,22 +313,26 @@ try {
313313 throw err ;
314314} ;
315315
316- function checkMatch ( obj ) { //Remove trailing whitespace in object keys and values & check correctness of user input
316+ function checkMatch ( obj , fix ) { //Remove trailing whitespace in object keys and values & check correctness of user input
317+ fix = fix || false ;
317318 try { //make sure that folder names have no illegal characters
318319 for ( var key in obj ) { //Convert keys to lower case for better matching
319320 if ( obj . hasOwnProperty ( key ) ) {
320- t = obj [ key ] . trim ( ) . replace ( / ^ \\ | \\ $ / g, '' ) ;
321+ t = obj [ key ] . trim ( ) . replace ( / ^ \\ | \\ $ / g, '' ) . trim ( ) ;
321322 delete obj [ key ] ;
322323 k = key . trim ( ) . toLowerCase ( ) ;
323324 obj [ k ] = t ;
324325 if ( exclrgxp . test ( obj [ k ] ) ) //Can't continue until the problem is fixed
325- throw new Error ( 'Illegal characters in folder name entry: "' + obj [ k ] + '" for name "' + k + '"' ) ;
326+ if ( ! fix )
327+ throw new Error ( 'Illegal characters in folder name entry: "' + obj [ k ] + '" for name "' + k + '"' )
328+ else
329+ obj [ k ] = t . replace ( exclrgxp , '-' ) ;
326330 } ;
327331 } ;
328332 } catch ( err ) {
329- if ( ! debug )
330- alert ( err . name + ': ' + err . message ) ; //Gotta always notify the user
331- throw err ;
333+ if ( ! debug )
334+ alert ( err . name + ': ' + err . message ) ; //Gotta always notify the user
335+ throw err ;
332336 } ; //TODO: even more checks here
333337} ;
334338
@@ -674,7 +678,8 @@ function swap(txt){ //Swap roman tags consisting of 2 words
674678 ) ;
675679} ;
676680
677- function selected ( inp ) { //Hide the corresponding roman tag from results when it has been selected
681+ function selected ( e ) { //Hide the corresponding roman tag from results when it has been selected
682+ $ ( e . target ) . css ( 'background-color' , '' ) ;
678683 ansi = $ ( 'td.ansi' ) ; // as a translation for kanji tag
679684 kanji = $ ( 'td.kanji' ) . find ( 'input.txt' ) ; //that's not a filename, fyi
680685 knj = { } ;
@@ -683,16 +688,19 @@ function selected(inp){ //Hide the corresponding roman tag from res
683688 $ . each ( ansi , function ( ix , vl ) { //Have to show a previously hidden tag if another was selected
684689 if ( vl . textContent . trim ( ) == v . value . trim ( ) )
685690 $ ( vl ) . parent ( ) . attr ( 'hidden' , 'hidden' ) ;
686- }
687- ) ;
688- }
689- ) ;
690- $ . each ( ansi , function ( ix , vl ) { //I don't even remember how and why this works
691- if ( ( ! knj [ vl . textContent . trim ( ) ] ) && ( ! $ ( vl ) . parent ( ) . attr ( 'ignore' ) ) )
692- $ ( vl ) . parent ( ) . removeAttr ( 'hidden' ) ; // but it does
693- }
694- ) ;
695- } ;
691+ } ) ;
692+ } ) ;
693+ $ . each ( ansi , function ( ix , vl ) {
694+ if ( ( ! knj [ vl . textContent . trim ( ) ] ) && ( ! $ ( vl ) . parent ( ) . attr ( 'ignore' ) ) )
695+ $ ( vl ) . parent ( ) . removeAttr ( 'hidden' ) ;
696+ } ) ;
697+ var test = { tag :e . target . value } ;
698+ checkMatch ( test , true ) ;
699+ if ( test . tag != e . target . value ) {
700+ $ ( e . target ) . css ( 'background-color' , '#ffff00' ) ;
701+ e . target . value = test . tag ;
702+ }
703+ }
696704
697705function mkUniq ( arr ) { //Sorts an array and ensures uniqueness of its elements
698706 to = { } ;
@@ -746,6 +754,7 @@ function onCmplt(){ //Mark image as saved in the tag database
746754
747755function submit ( ) { //Collects entered translations for missing tags
748756 tgs = $ ( 'td.cell' ) ; //saves them to databases and relaunches tag analysis with new data
757+ $ ( 'input.category' ) . parent ( ) . parent ( ) . css ( "background-color" , "" ) ;
749758 missing = false ;
750759 $ . each ( tgs , function ( i , v ) {
751760 if ( $ ( v ) . parent ( ) . attr ( 'ignore' ) ) {
@@ -765,13 +774,13 @@ function submit(){ //Collects entered translations for missing tag
765774 cat = $ ( v ) . find ( 'input.category' ) ;
766775 if ( tg . length ) {
767776 if ( ! isANSI ( tg ) && ! allowUnicode ) {
768- $ ( v ) . find ( 'input.txt' ) . css ( "background-color" , "#ffC080 " ) ;
777+ $ ( v ) . find ( 'input.txt' ) . css ( "background-color" , "#ffb080 " ) ;
769778 missing = true ; //Indicate unicode characters in user input
770779 }
771780 else if ( cat [ 0 ] . checked ) //name category was selected for this tag
772- names . set ( v . textContent . trim ( ) . toLowerCase ( ) , tg . replace ( exclrgxp , '-' ) )
781+ names . set ( v . textContent . trim ( ) . toLowerCase ( ) , tg )
773782 else if ( cat [ 1 ] . checked ) //meta category was selected
774- meta . set ( v . textContent . trim ( ) . toLowerCase ( ) , tg . replace ( exclrgxp , '-' ) )
783+ meta . set ( v . textContent . trim ( ) . toLowerCase ( ) , tg )
775784 else { //no category was selected, indicate missing input
776785 $ ( cat [ 0 ] . parentNode . parentNode ) . css ( "background-color" , "#ff8080" ) ;
777786 missing = true ;
@@ -785,12 +794,11 @@ function submit(){ //Collects entered translations for missing tag
785794 }
786795 ) ;
787796 tbd = $ ( '#translations > tbody' ) [ 0 ] ;
788- to = missing ?1000 :10 ; //If there was missing input, delay before applying changes to show that
789- setTimeout ( function ( ) {
797+ if ( ! missing ) {
790798 tbd . parentNode . removeChild ( tbd ) ;
791799 tb . hide ( ) ;
792800 analyzeTags ( ) ;
793- } , to ) ;
801+ } ;
794802} ;
795803
796804function ex ( ) { //Export auxiliary tag databases as a text file
0 commit comments