@@ -5,19 +5,22 @@ export default class PolyglotHooks {
55 */
66 static renderChatLog ( chatlog , html , data ) {
77 game . polyglot . renderChatLog = true ;
8- const input = game . settings . get ( "polyglot" , "displayCheckbox" )
9- ? `<input id="polyglot-checkbox" type="checkbox" ${ game . settings . get ( "polyglot" , "checkbox" ) ? "checked" : "" } >`
10- : "" ;
118 const polyglotDiv = document . createElement ( "div" ) ;
129 polyglotDiv . setAttribute ( "id" , "polyglot" ) ;
1310 polyglotDiv . classList . add ( "polyglot" , "polyglot-lang-select" , "flexrow" ) ;
14- polyglotDiv . innerHTML = `${ input } <select id='polyglot-language' name='polyglot-language'></select>` ;
11+ polyglotDiv . innerHTML = "<select id='polyglot-language' name='polyglot-language'></select>" ;
12+ polyglotDiv . addEventListener ( "contextmenu" , ( event ) => {
13+ const setting = ! game . settings . get ( "polyglot" , "checkbox" ) ;
14+ game . settings . set ( "polyglot" , "checkbox" , setting ) ;
15+ if ( setting ) game . polyglot . tomSelect . enable ( ) ;
16+ else game . polyglot . tomSelect . disable ( ) ;
17+ } ) ;
1518 html . querySelector ( ".chat-controls" ) . insertAdjacentElement ( "afterend" , polyglotDiv ) ;
1619 html . querySelector ( ".polyglot-lang-select select" ) . addEventListener ( "change" , ( ev ) => {
1720 const lang = ev . target . value ;
1821 game . polyglot . lastSelection = lang ;
1922 } ) ;
20- html . querySelector ( "input[id='polyglot-checkbox']" ) . addEventListener ( "change" , ( ev ) => {
23+ html . querySelector ( "input[id='polyglot-checkbox']" ) ? .addEventListener ( "change" , ( ev ) => {
2124 game . settings . set ( "polyglot" , "checkbox" , ev . target . checked ) ;
2225 } ) ;
2326 game . polyglot . updateUserLanguages ( html ) ;
@@ -60,8 +63,7 @@ export default class PolyglotHooks {
6063 * @returns {Boolean }
6164 */
6265 static preCreateChatMessage ( message , data , options , userId ) {
63- const isCheckboxEnabled = ! game . settings . get ( "polyglot" , "displayCheckbox" )
64- || game . polyglot . chatElement . querySelector ( "input#polyglot-checkbox" ) . checked ;
66+ const isCheckboxEnabled = ! game . settings . get ( "polyglot" , "checkbox" ) ;
6567 const isMessageLink = game . polyglot . _isMessageLink ( data . content ) ;
6668 const isMessageInlineRoll = / \[ \[ ( .* ?) \] \] / g. test ( data . content ) ;
6769 // Message preprended by /desc from either Cautious GM Tools or Narrator Tools modules
0 commit comments