2021-05-03 00:48:47 +02:00
//=================================================================//
// VARIABLES
//=================================================================//
2021-05-05 09:04:06 +02:00
// Socket IO Object
2021-05-03 00:48:47 +02:00
var socket ;
2021-05-05 09:04:06 +02:00
// UI references for jQuery
2021-05-07 20:32:10 +02:00
var connect _status ;
2021-05-04 15:56:48 +02:00
var button _newgame ;
2021-08-19 12:54:44 +02:00
var button _rndgame ;
2021-05-04 15:56:48 +02:00
var button _save ;
2021-05-22 11:28:40 +02:00
var button _saveas ;
var button _savetofile ;
2021-05-04 15:56:48 +02:00
var button _load ;
2021-05-11 06:27:34 +02:00
var button _import ;
2021-05-29 11:46:03 +02:00
var button _importwi ;
2021-05-16 11:29:39 +02:00
var button _impaidg ;
2021-05-04 15:56:48 +02:00
var button _settings ;
2021-05-11 01:17:10 +02:00
var button _format ;
2021-08-19 13:18:01 +02:00
var button _mode ;
var button _mode _label ;
2021-05-03 00:48:47 +02:00
var button _send ;
var button _actmem ;
var button _actback ;
var button _actretry ;
2021-05-13 07:26:42 +02:00
var button _actwi ;
2021-05-03 00:48:47 +02:00
var game _text ;
var input _text ;
var message _text ;
2021-05-07 20:32:10 +02:00
var settings _menu ;
2021-05-11 01:17:10 +02:00
var format _menu ;
2021-05-13 07:26:42 +02:00
var wi _menu ;
2021-05-05 09:04:06 +02:00
var anote _menu ;
var anote _input ;
var anote _labelcur ;
var anote _slider ;
2021-05-11 06:27:34 +02:00
var popup ;
var popup _title ;
var popup _content ;
var popup _accept ;
var popup _close ;
2021-05-16 11:29:39 +02:00
var aidgpopup ;
var aidgpromptnum ;
var aidg _accept ;
var aidg _close ;
2021-05-22 11:28:40 +02:00
var saveaspopup ;
var saveasinput ;
2021-08-19 12:54:44 +02:00
var topic ;
2021-05-22 11:28:40 +02:00
var saveas _accept ;
var saveas _close ;
var loadpopup ;
var loadcontent ;
var load _accept ;
var load _close ;
var nspopup ;
var ns _accept ;
var ns _close ;
2021-08-19 12:54:44 +02:00
var rspopup ;
var rs _accept ;
var rs _close ;
2021-05-29 11:46:03 +02:00
var seqselmenu ;
var seqselcontents ;
2021-05-03 00:48:47 +02:00
2021-08-19 13:18:01 +02:00
var memorymode = false ;
var gamestarted = false ;
2021-08-23 08:34:27 +02:00
var editmode = false ;
var connected = false ;
var newly _loaded = true ;
2021-08-24 00:26:38 +02:00
var current _editing _chunk = null ;
2021-08-23 08:34:27 +02:00
var chunk _conflict = false ;
2021-09-01 00:22:30 +02:00
var sman _allow _delete = false ;
var sman _allow _rename = false ;
2021-08-19 13:18:01 +02:00
2021-05-05 09:04:06 +02:00
// Key states
var shift _down = false ;
2021-05-03 00:48:47 +02:00
var do _clear _ent = false ;
2021-05-11 01:17:10 +02:00
// Display vars
var allowtoggle = false ;
var formatcount = 0 ;
2021-08-23 08:34:27 +02:00
var allowedit = true ; // Whether clicking on chunks will edit them
2021-05-11 01:17:10 +02:00
2021-08-19 13:18:01 +02:00
// Adventure
var action _mode = 0 ; // 0: story, 1: action
var adventure = false ;
2021-05-03 00:48:47 +02:00
//=================================================================//
// METHODS
//=================================================================//
2021-05-07 20:32:10 +02:00
function addSetting ( ob ) {
// Add setting block to Settings Menu
2021-05-29 11:46:03 +02:00
if ( ob . uitype == "slider" ) {
settings _menu . append ( "<div class=\"settingitem\" > \
< div class = \ "settinglabel\" > \
< div class = \ "justifyleft\" > \
"+ob.label+" < span class = \ "helpicon\">?<span class=\"helptext\">" + ob . tooltip + " < / s p a n > < / s p a n > \
< / d i v > \
< div class = \ "justifyright\" id=\"" + ob . id + "cur\" > \
"+ob.default+" \
< / d i v > \
2021-05-07 20:32:10 +02:00
< / d i v > \
2021-05-29 11:46:03 +02:00
< div > \
< input type = \ "range\" class=\"form-range airange\" min=\"" + ob . min + "\" max=\"" + ob . max + "\" step=\"" + ob . step + "\" id=\"" + ob . id + "\" > \
2021-05-07 20:32:10 +02:00
< / d i v > \
2021-05-29 11:46:03 +02:00
< div class = \ "settingminmax\" > \
< div class = \ "justifyleft\" > \
"+ob.min+" \
< / d i v > \
< div class = \ "justifyright\" > \
"+ob.max+" \
< / d i v > \
2021-05-07 20:32:10 +02:00
< / d i v > \
2021-05-29 11:46:03 +02:00
< / d i v > " ) ;
// Set references to HTML objects
var refin = $ ( "#" + ob . id ) ;
var reflb = $ ( "#" + ob . id + "cur" ) ;
window [ "setting_" + ob . id ] = refin ; // Is this still needed?
window [ "label_" + ob . id ] = reflb ; // Is this still needed?
// Add event function to input
refin . on ( "input" , function ( ) {
socket . send ( { 'cmd' : $ ( this ) . attr ( 'id' ) , 'data' : $ ( this ) . val ( ) } ) ;
} ) ;
} else if ( ob . uitype == "toggle" ) {
settings _menu . append ( "<div class=\"settingitem\" > \
< input type = \ "checkbox\" data-toggle=\"toggle\" data-onstyle=\"success\" id=\"" + ob . id + "\" > \
< span class = \ "formatlabel\">" + ob . label + " < / s p a n > \
< span class = \ "helpicon\">?<span class=\"helptext\">" + ob . tooltip + " < / s p a n > < / s p a n > \
< / d i v > " ) ;
// Tell Bootstrap-Toggle to render the new checkbox
$ ( "input[type=checkbox]" ) . bootstrapToggle ( ) ;
$ ( "#" + ob . id ) . on ( "change" , function ( ) {
if ( allowtoggle ) {
socket . send ( { 'cmd' : $ ( this ) . attr ( 'id' ) , 'data' : $ ( this ) . prop ( 'checked' ) } ) ;
}
2021-08-19 13:18:01 +02:00
if ( ob . id == "setadventure" ) {
setadventure ( $ ( this ) . prop ( 'checked' ) ) ;
}
2021-05-29 11:46:03 +02:00
} ) ;
}
2021-05-07 20:32:10 +02:00
}
2021-05-11 01:17:10 +02:00
function addFormat ( ob ) {
// Check if we need to make a new column for this button
if ( formatcount == 0 ) {
format _menu . append ( "<div class=\"formatcolumn\"></div>" ) ;
}
// Get reference to the last child column
var ref = $ ( "#formatmenu > div" ) . last ( ) ;
// Add format block to Format Menu
ref . append ( "<div class=\"formatrow\" > \
< input type = \ "checkbox\" data-toggle=\"toggle\" data-onstyle=\"success\" id=\"" + ob . id + "\" > \
< span class = \ "formatlabel\">" + ob . label + " < / s p a n > \
< span class = \ "helpicon\">?<span class=\"helptext\">" + ob . tooltip + " < / s p a n > < / s p a n > \
< / d i v > " ) ;
// Tell Bootstrap-Toggle to render the new checkbox
$ ( "input[type=checkbox]" ) . bootstrapToggle ( ) ;
// Add event to input
$ ( "#" + ob . id ) . on ( "change" , function ( ) {
if ( allowtoggle ) {
socket . send ( { 'cmd' : $ ( this ) . attr ( 'id' ) , 'data' : $ ( this ) . prop ( 'checked' ) } ) ;
}
} ) ;
// Increment display variable
formatcount ++ ;
if ( formatcount == 2 ) {
formatcount = 0 ;
}
}
2021-05-11 06:27:34 +02:00
function addImportLine ( ob ) {
popup _content . append ( "<div class=\"popuplistitem\" id=\"import" + ob . num + "\" > \
< div > "+ob.title+" < / d i v > \
< div > "+ob.acts+" < / d i v > \
< div > "+ob.descr+" < / d i v > \
< / d i v > " ) ;
$ ( "#import" + ob . num ) . on ( "click" , function ( ) {
socket . send ( { 'cmd' : 'importselect' , 'data' : $ ( this ) . attr ( 'id' ) } ) ;
highlightImportLine ( $ ( this ) ) ;
} ) ;
}
2021-05-13 07:26:42 +02:00
function addWiLine ( ob ) {
if ( ob . init ) {
2021-08-19 13:48:33 +02:00
if ( ob . selective ) {
wi _menu . append ( "<div class=\"wilistitem\" > \
< div class = \ "wiremove\" > \
< button type = \ "button\" class=\"btn btn-primary heightfull\" id=\"btn_wi" + ob . num + "\" > X < / b u t t o n > \
< button type = \ "button\" class=\"btn btn-success heighthalf hidden\" id=\"btn_widel" + ob . num + "\" > ✓ < / b u t t o n > \
< button type = \ "button\" class=\"btn btn-danger heighthalf hidden\" id=\"btn_wican" + ob . num + "\" > ⮌ < / b u t t o n > \
< / d i v > \
2021-08-24 19:45:20 +02:00
< div class = \ "icon-container wikey\" > \
2021-08-19 13:48:33 +02:00
< input class = \ "form-control heightfull hidden\" type=\"text\" placeholder=\"Key(s)\" id=\"wikey" + ob . num + "\" > \
< input class = \ "form-control heighthalf\" type=\"text\" placeholder=\"Primary Key(s)\" id=\"wikeyprimary" + ob . num + "\" > \
< input class = \ "form-control heighthalf\" type=\"text\" placeholder=\"Secondary Key(s)\" id=\"wikeysecondary" + ob . num + "\" > \
2021-08-24 19:45:20 +02:00
< span class = \ "constant-key-icon " + ( ob . constant ? "constant-key-icon-enabled" : "" ) + " oi oi-pin\" id=\"constant-key-" + ob . num + "\" title=\"Toggle Constant Key mode (if enabled, this world info entry will always be included in memory)\" aria-hidden=\"true\" > < / s p a n > \
2021-08-19 13:48:33 +02:00
< / d i v > \
< div class = \ "wientry\" > \
2021-08-24 19:45:20 +02:00
< textarea class = \ "layer-bottom form-control\" id=\"wientry" + ob . num + "\" placeholder=\"What To Remember\">" + ob . content + " < / t e x t a r e a > \
2021-08-19 13:48:33 +02:00
< / d i v > \
< div class = \ "wiselective\" > \
< button type = \ "button\" class=\"btn btn-success heightfull hidden\" id=\"btn_wiselon" + ob . num + "\" > Enable Selective Mode < / b u t t o n > \
< button type = \ "button\" class=\"btn btn-danger heightfull\" id=\"btn_wiseloff" + ob . num + "\" > Disable Selective Mode < / b u t t o n > \
< / d i v > \
< / d i v > " ) ;
} else {
wi _menu . append ( "<div class=\"wilistitem\" > \
< div class = \ "wiremove\" > \
< button type = \ "button\" class=\"btn btn-primary heightfull\" id=\"btn_wi" + ob . num + "\" > X < / b u t t o n > \
< button type = \ "button\" class=\"btn btn-success heighthalf hidden\" id=\"btn_widel" + ob . num + "\" > ✓ < / b u t t o n > \
< button type = \ "button\" class=\"btn btn-danger heighthalf hidden\" id=\"btn_wican" + ob . num + "\" > ⮌ < / b u t t o n > \
< / d i v > \
2021-08-24 19:45:20 +02:00
< div class = \ "icon-container wikey\" > \
2021-08-19 13:48:33 +02:00
< input class = \ "form-control heightfull\" type=\"text\" placeholder=\"Key(s)\" id=\"wikey" + ob . num + "\" > \
< input class = \ "form-control heighthalf hidden\" type=\"text\" placeholder=\"Primary Key(s)\" id=\"wikeyprimary" + ob . num + "\" > \
< input class = \ "form-control heighthalf hidden\" type=\"text\" placeholder=\"Secondary Key(s)\" id=\"wikeysecondary" + ob . num + "\" > \
2021-08-24 19:45:20 +02:00
< span class = \ "constant-key-icon " + ( ob . constant ? "constant-key-icon-enabled" : "" ) + " oi oi-pin\" id=\"constant-key-" + ob . num + "\" title=\"Toggle Constant Key mode (if enabled, this world info entry will always be included in memory)\" aria-hidden=\"true\" > < / s p a n > \
2021-08-19 13:48:33 +02:00
< / d i v > \
< div class = \ "wientry\" > \
< textarea class = \ "form-control\" id=\"wientry" + ob . num + "\" placeholder=\"What To Remember\">" + ob . content + " < / t e x t a r e a > \
< / d i v > \
< div class = \ "wiselective\" > \
< button type = \ "button\" class=\"btn btn-success heightfull\" id=\"btn_wiselon" + ob . num + "\" > Enable Selective Mode < / b u t t o n > \
< button type = \ "button\" class=\"btn btn-danger heightfull hidden\" id=\"btn_wiseloff" + ob . num + "\" > Disable Selective Mode < / b u t t o n > \
< / d i v > \
< / d i v > " ) ;
}
2021-05-13 07:26:42 +02:00
// Send key value to text input
$ ( "#wikey" + ob . num ) . val ( ob . key ) ;
2021-08-19 13:48:33 +02:00
$ ( "#wikeyprimary" + ob . num ) . val ( ob . key ) ;
$ ( "#wikeysecondary" + ob . num ) . val ( ob . keysecondary ) ;
2021-05-13 07:26:42 +02:00
// Assign delete event to button
$ ( "#btn_wi" + ob . num ) . on ( "click" , function ( ) {
showWiDeleteConfirm ( ob . num ) ;
} ) ;
} else {
// Show WI line item with form fields hidden (uninitialized)
wi _menu . append ( "<div class=\"wilistitem\" > \
< div class = \ "wiremove\" > \
< button type = \ "button\" class=\"btn btn-primary heightfull\" id=\"btn_wi" + ob . num + "\" > + < / b u t t o n > \
< button type = \ "button\" class=\"btn btn-success heighthalf hidden\" id=\"btn_widel" + ob . num + "\" > ✓ < / b u t t o n > \
< button type = \ "button\" class=\"btn btn-danger heighthalf hidden\" id=\"btn_wican" + ob . num + "\" > X < / b u t t o n > \
< / d i v > \
2021-08-24 19:45:20 +02:00
< div class = \ "icon-container wikey\" > \
2021-08-19 13:48:33 +02:00
< input class = \ "form-control heightfull hidden\" type=\"text\" placeholder=\"Key(s)\" id=\"wikey" + ob . num + "\" > \
< input class = \ "form-control heighthalf hidden\" type=\"text\" placeholder=\"Primary Key(s)\" id=\"wikeyprimary" + ob . num + "\" > \
< input class = \ "form-control heighthalf hidden\" type=\"text\" placeholder=\"Secondary Key(s)\" id=\"wikeysecondary" + ob . num + "\" > \
2021-08-24 19:45:20 +02:00
< span class = \ "constant-key-icon oi oi-pin hidden\" id=\"constant-key-" + ob . num + "\" title=\"Toggle Constant Key mode (if enabled, this world info entry will always be included in memory)\" aria-hidden=\"true\" > < / s p a n > \
2021-05-13 07:26:42 +02:00
< / d i v > \
< div class = \ "wientry\" > \
2021-08-24 19:45:20 +02:00
< textarea class = \ "layer-bottom form-control hidden\" id=\"wientry" + ob . num + "\" placeholder=\"What To Remember\">" + ob . content + " < / t e x t a r e a > \
2021-05-13 07:26:42 +02:00
< / d i v > \
2021-08-19 13:48:33 +02:00
< div class = \ "wiselective\" > \
< button type = \ "button\" class=\"btn btn-success heightfull hidden\" id=\"btn_wiselon" + ob . num + "\" > Enable Selective Mode < / b u t t o n > \
< button type = \ "button\" class=\"btn btn-danger heightfull hidden\" id=\"btn_wiseloff" + ob . num + "\" > Disable Selective Mode < / b u t t o n > \
< / d i v > \
2021-05-13 07:26:42 +02:00
< / d i v > " ) ;
// Assign function to expand WI item to button
$ ( "#btn_wi" + ob . num ) . on ( "click" , function ( ) {
expandWiLine ( ob . num ) ;
} ) ;
}
// Assign actions to other elements
2021-08-24 19:45:20 +02:00
wientry _onfocus = function ( ) {
$ ( "#constant-key-" + ob . num ) . addClass ( "constant-key-icon-clickthrough" ) ;
}
wientry _onfocusout = function ( ) {
$ ( "#constant-key-" + ob . num ) . removeClass ( "constant-key-icon-clickthrough" ) ;
}
$ ( "#wikey" + ob . num ) . on ( "focus" , wientry _onfocus ) ;
$ ( "#wikeyprimary" + ob . num ) . on ( "focus" , wientry _onfocus ) ;
$ ( "#wikeysecondary" + ob . num ) . on ( "focus" , wientry _onfocus ) ;
$ ( "#wikey" + ob . num ) . on ( "focusout" , wientry _onfocusout ) ;
$ ( "#wikeyprimary" + ob . num ) . on ( "focusout" , wientry _onfocusout ) ;
$ ( "#wikeysecondary" + ob . num ) . on ( "focusout" , wientry _onfocusout ) ;
2021-05-13 07:26:42 +02:00
$ ( "#btn_wican" + ob . num ) . on ( "click" , function ( ) {
hideWiDeleteConfirm ( ob . num ) ;
} ) ;
$ ( "#btn_widel" + ob . num ) . on ( "click" , function ( ) {
socket . send ( { 'cmd' : 'widelete' , 'data' : ob . num } ) ;
} ) ;
2021-08-19 13:48:33 +02:00
$ ( "#btn_wiselon" + ob . num ) . on ( "click" , function ( ) {
enableWiSelective ( ob . num ) ;
} ) ;
$ ( "#btn_wiseloff" + ob . num ) . on ( "click" , function ( ) {
disableWiSelective ( ob . num ) ;
} ) ;
2021-08-24 19:45:20 +02:00
$ ( "#constant-key-" + ob . num ) . on ( "click" , function ( ) {
element = $ ( "#constant-key-" + ob . num ) ;
if ( element . hasClass ( "constant-key-icon-enabled" ) ) {
socket . send ( { 'cmd' : 'wiconstantoff' , 'data' : ob . num } ) ;
element . removeClass ( "constant-key-icon-enabled" )
} else {
socket . send ( { 'cmd' : 'wiconstanton' , 'data' : ob . num } ) ;
element . addClass ( "constant-key-icon-enabled" ) ;
}
} ) ;
2021-05-13 07:26:42 +02:00
}
function expandWiLine ( num ) {
2021-08-24 19:45:20 +02:00
show ( [ $ ( "#wikey" + num ) , $ ( "#wientry" + num ) , $ ( "#constant-key-" + num ) , $ ( "#btn_wiselon" + num ) ] ) ;
2021-05-13 07:26:42 +02:00
$ ( "#btn_wi" + num ) . html ( "X" ) ;
$ ( "#btn_wi" + num ) . off ( ) ;
// Tell server the WI entry was initialized
socket . send ( { 'cmd' : 'wiinit' , 'data' : num } ) ;
$ ( "#btn_wi" + num ) . on ( "click" , function ( ) {
showWiDeleteConfirm ( num ) ;
} ) ;
}
function showWiDeleteConfirm ( num ) {
hide ( [ $ ( "#btn_wi" + num ) ] ) ;
show ( [ $ ( "#btn_widel" + num ) , $ ( "#btn_wican" + num ) ] ) ;
}
function hideWiDeleteConfirm ( num ) {
show ( [ $ ( "#btn_wi" + num ) ] ) ;
hide ( [ $ ( "#btn_widel" + num ) , $ ( "#btn_wican" + num ) ] ) ;
}
2021-08-19 13:48:33 +02:00
function enableWiSelective ( num ) {
hide ( [ $ ( "#btn_wiselon" + num ) , $ ( "#wikey" + num ) ] ) ;
// Tell server the WI entry is now selective
socket . send ( { 'cmd' : 'wiselon' , 'data' : num } ) ;
2021-08-24 19:45:20 +02:00
$ ( "#wikeyprimary" + num ) . val ( $ ( "#wikey" + num ) . val ( ) ) ;
2021-08-19 13:48:33 +02:00
show ( [ $ ( "#wikeyprimary" + num ) , $ ( "#wikeysecondary" + num ) , $ ( "#btn_wiseloff" + num ) ] ) ;
}
function disableWiSelective ( num ) {
hide ( [ $ ( "#btn_wiseloff" + num ) , $ ( "#wikeyprimary" + num ) , $ ( "#wikeysecondary" + num ) ] ) ;
// Tell server the WI entry is now non-selective
socket . send ( { 'cmd' : 'wiseloff' , 'data' : num } ) ;
2021-08-24 19:45:20 +02:00
$ ( "#wikey" + num ) . val ( $ ( "#wikeyprimary" + num ) . val ( ) ) ;
2021-08-19 13:48:33 +02:00
show ( [ $ ( "#btn_wiselon" + num ) , $ ( "#wikey" + num ) ] ) ;
}
2021-05-11 06:27:34 +02:00
function highlightImportLine ( ref ) {
$ ( "#popupcontent > div" ) . removeClass ( "popuplistselected" ) ;
ref . addClass ( "popuplistselected" ) ;
2021-05-22 11:28:40 +02:00
enableButtons ( [ popup _accept ] ) ;
2021-05-11 06:27:34 +02:00
}
2021-05-05 09:04:06 +02:00
function enableButtons ( refs ) {
for ( i = 0 ; i < refs . length ; i ++ ) {
refs [ i ] . prop ( "disabled" , false ) ;
refs [ i ] . removeClass ( "btn-secondary" ) ;
refs [ i ] . addClass ( "btn-primary" ) ;
}
2021-05-03 00:48:47 +02:00
}
2021-05-05 09:04:06 +02:00
function disableButtons ( refs ) {
for ( i = 0 ; i < refs . length ; i ++ ) {
refs [ i ] . prop ( "disabled" , true ) ;
refs [ i ] . removeClass ( "btn-primary" ) ;
refs [ i ] . addClass ( "btn-secondary" ) ;
}
2021-05-03 00:48:47 +02:00
}
function enableSendBtn ( ) {
2021-05-05 09:04:06 +02:00
enableButtons ( [ button _send ] )
2021-05-03 00:48:47 +02:00
button _send . html ( "Submit" ) ;
}
function disableSendBtn ( ) {
2021-05-05 09:04:06 +02:00
disableButtons ( [ button _send ] )
2021-05-03 00:48:47 +02:00
button _send . html ( "" ) ;
}
function showMessage ( msg ) {
message _text . removeClass ( ) ;
message _text . addClass ( "color_green" ) ;
message _text . html ( msg ) ;
}
function errMessage ( msg ) {
message _text . removeClass ( ) ;
message _text . addClass ( "color_red" ) ;
message _text . html ( msg ) ;
}
function hideMessage ( ) {
message _text . html ( "" ) ;
message _text . removeClass ( ) ;
}
function showWaitAnimation ( ) {
$ ( "#inputrowright" ) . append ( "<img id=\"waitanim\" src=\"static/thinking.gif\"/>" ) ;
}
function hideWaitAnimation ( ) {
$ ( '#waitanim' ) . remove ( ) ;
}
2021-08-26 21:15:42 +02:00
function scrollToBottom ( ) {
setTimeout ( function ( ) {
$ ( '#gamescreen' ) . animate ( { scrollTop : $ ( '#gamescreen' ) . prop ( 'scrollHeight' ) } , 500 ) ;
} , 5 ) ;
}
2021-05-05 09:04:06 +02:00
function hide ( refs ) {
for ( i = 0 ; i < refs . length ; i ++ ) {
refs [ i ] . addClass ( "hidden" ) ;
}
2021-05-03 00:48:47 +02:00
}
2021-05-05 09:04:06 +02:00
function show ( refs ) {
for ( i = 0 ; i < refs . length ; i ++ ) {
refs [ i ] . removeClass ( "hidden" ) ;
}
2021-05-03 00:48:47 +02:00
}
2021-05-11 06:27:34 +02:00
function popupShow ( state ) {
if ( state ) {
popup . removeClass ( "hidden" ) ;
popup . addClass ( "flex" ) ;
2021-05-22 11:28:40 +02:00
disableButtons ( [ popup _accept ] ) ;
2021-05-11 06:27:34 +02:00
} else {
popup . removeClass ( "flex" ) ;
popup . addClass ( "hidden" ) ;
}
}
2021-05-03 00:48:47 +02:00
function enterEditMode ( ) {
2021-08-23 08:34:27 +02:00
editmode = true ;
2021-05-03 00:48:47 +02:00
}
function exitEditMode ( ) {
2021-08-23 08:34:27 +02:00
editmode = false ;
2021-05-03 00:48:47 +02:00
}
function enterMemoryMode ( ) {
2021-08-19 13:18:01 +02:00
memorymode = true ;
setmodevisibility ( false ) ;
2021-05-03 00:48:47 +02:00
showMessage ( "Edit the memory to be sent with each request to the AI." ) ;
button _actmem . html ( "Cancel" ) ;
2021-08-23 19:22:50 +02:00
hide ( [ button _actback , button _actretry , button _actwi ] ) ;
2021-05-05 09:04:06 +02:00
// Display Author's Note field
anote _menu . slideDown ( "fast" ) ;
2021-05-03 00:48:47 +02:00
}
function exitMemoryMode ( ) {
2021-08-19 13:18:01 +02:00
memorymode = false ;
setmodevisibility ( adventure ) ;
2021-05-03 00:48:47 +02:00
hideMessage ( ) ;
button _actmem . html ( "Memory" ) ;
2021-08-23 08:34:27 +02:00
show ( [ button _actback , button _actretry , button _actwi ] ) ;
2021-05-03 00:48:47 +02:00
input _text . val ( "" ) ;
2021-05-05 09:04:06 +02:00
// Hide Author's Note field
anote _menu . slideUp ( "fast" ) ;
2021-05-03 00:48:47 +02:00
}
2021-05-13 07:26:42 +02:00
function enterWiMode ( ) {
showMessage ( "World Info will be added to memory only when the key appears in submitted text or the last action." ) ;
button _actwi . html ( "Accept" ) ;
2021-08-23 08:34:27 +02:00
hide ( [ button _actback , button _actmem , button _actretry , game _text ] ) ;
2021-05-13 07:26:42 +02:00
show ( [ wi _menu ] ) ;
disableSendBtn ( ) ;
}
function exitWiMode ( ) {
hideMessage ( ) ;
button _actwi . html ( "W Info" ) ;
hide ( [ wi _menu ] ) ;
2021-08-23 08:34:27 +02:00
show ( [ button _actback , button _actmem , button _actretry , game _text ] ) ;
2021-05-13 07:26:42 +02:00
enableSendBtn ( ) ;
2021-08-26 21:15:42 +02:00
scrollToBottom ( ) ;
2021-05-13 07:26:42 +02:00
}
function returnWiList ( ar ) {
var list = [ ] ;
var i ;
for ( i = 0 ; i < ar . length ; i ++ ) {
2021-08-24 19:45:20 +02:00
var ob = { "key" : "" , "keysecondary" : "" , "content" : "" , "num" : ar [ i ] , "selective" : false , "constant" : false } ;
2021-08-19 13:48:33 +02:00
ob . selective = $ ( "#wikeyprimary" + ar [ i ] ) . css ( "display" ) != "none"
ob . key = ob . selective ? $ ( "#wikeyprimary" + ar [ i ] ) . val ( ) : $ ( "#wikey" + ar [ i ] ) . val ( ) ;
ob . keysecondary = $ ( "#wikeysecondary" + ar [ i ] ) . val ( )
ob . content = $ ( "#wientry" + ar [ i ] ) . val ( ) ;
2021-08-24 19:45:20 +02:00
ob . constant = $ ( "#constant-key-" + ar [ i ] ) . hasClass ( "constant-key-icon-enabled" ) ;
2021-05-13 07:26:42 +02:00
list . push ( ob ) ;
}
socket . send ( { 'cmd' : 'sendwilist' , 'data' : list } ) ;
}
2021-05-03 00:48:47 +02:00
function dosubmit ( ) {
var txt = input _text . val ( ) ;
2021-08-19 13:18:01 +02:00
socket . send ( { 'cmd' : 'submit' , 'actionmode' : adventure ? action _mode : 0 , 'data' : txt } ) ;
2021-05-03 00:48:47 +02:00
input _text . val ( "" ) ;
hideMessage ( ) ;
2021-05-29 11:46:03 +02:00
hidegenseqs ( ) ;
2021-05-03 00:48:47 +02:00
}
2021-08-19 13:18:01 +02:00
function changemode ( ) {
if ( gamestarted ) {
action _mode += 1 ;
action _mode %= 2 ; // Total number of action modes (Story and Action)
} else {
action _mode = 0 ; // Force "Story" mode if game is not started
}
switch ( action _mode ) {
case 0 : button _mode _label . html ( "Story" ) ; break ;
case 1 : button _mode _label . html ( "Action" ) ; break ;
}
}
2021-05-03 00:48:47 +02:00
function newTextHighlight ( ref ) {
2021-08-23 08:34:27 +02:00
ref . addClass ( "edit-flash" ) ;
2021-05-03 00:48:47 +02:00
setTimeout ( function ( ) {
2021-08-23 08:34:27 +02:00
ref . addClass ( "colorfade" ) ;
ref . removeClass ( "edit-flash" ) ;
2021-05-03 00:48:47 +02:00
setTimeout ( function ( ) {
2021-05-16 11:29:39 +02:00
ref . removeClass ( "colorfade" ) ;
2021-05-03 00:48:47 +02:00
} , 1000 ) ;
2021-08-24 00:52:45 +02:00
} , 50 ) ;
2021-05-03 00:48:47 +02:00
}
2021-05-16 11:29:39 +02:00
function showAidgPopup ( ) {
aidgpopup . removeClass ( "hidden" ) ;
aidgpopup . addClass ( "flex" ) ;
aidgpromptnum . focus ( ) ;
}
function hideAidgPopup ( ) {
aidgpopup . removeClass ( "flex" ) ;
aidgpopup . addClass ( "hidden" ) ;
}
function sendAidgImportRequest ( ) {
socket . send ( { 'cmd' : 'aidgimport' , 'data' : aidgpromptnum . val ( ) } ) ;
hideAidgPopup ( ) ;
aidgpromptnum . val ( "" ) ;
}
2021-05-22 11:28:40 +02:00
function showSaveAsPopup ( ) {
disableButtons ( [ saveas _accept ] ) ;
saveaspopup . removeClass ( "hidden" ) ;
saveaspopup . addClass ( "flex" ) ;
saveasinput . focus ( ) ;
}
function hideSaveAsPopup ( ) {
saveaspopup . removeClass ( "flex" ) ;
saveaspopup . addClass ( "hidden" ) ;
saveasinput . val ( "" ) ;
2021-09-01 00:22:30 +02:00
hide ( [ $ ( ".saveasoverwrite" ) , $ ( ".popuperror" ) ] ) ;
2021-05-22 11:28:40 +02:00
}
function sendSaveAsRequest ( ) {
socket . send ( { 'cmd' : 'saveasrequest' , 'data' : saveasinput . val ( ) } ) ;
}
function showLoadPopup ( ) {
loadpopup . removeClass ( "hidden" ) ;
loadpopup . addClass ( "flex" ) ;
}
function hideLoadPopup ( ) {
loadpopup . removeClass ( "flex" ) ;
loadpopup . addClass ( "hidden" ) ;
loadcontent . html ( "" ) ;
}
function buildLoadList ( ar ) {
disableButtons ( [ load _accept ] ) ;
loadcontent . html ( "" ) ;
showLoadPopup ( ) ;
var i ;
for ( i = 0 ; i < ar . length ; i ++ ) {
2021-09-01 00:22:30 +02:00
loadcontent . append ( "<div class=\"flex\" > \
< div class = \ "loadlistpadding\" > < / d i v > \
< span class = \ "loadlisticon loadlisticon-delete oi oi-x " + ( sman _allow _delete ? "allowed" : "" ) + "\" id=\"loaddelete" + i + "\" " + ( sman _allow _delete ? "title=\"Delete story\"" : "" ) + " aria-hidden=\"true\" > < / s p a n > \
< div class = \ "loadlistpadding\" > < / d i v > \
< span class = \ "loadlisticon loadlisticon-rename oi oi-pencil " + ( sman _allow _rename ? "allowed" : "" ) + "\" id=\"loadrename" + i + "\" " + ( sman _allow _rename ? "title=\"Rename story\"" : "" ) + " aria-hidden=\"true\" > < / s p a n > \
< div class = \ "loadlistpadding\" > < / d i v > \
< div class = \ "loadlistitem\" id=\"load" + i + "\" name=\"" + ar [ i ] . name + "\" > \
< div > "+ar[i].name+" < / d i v > \
< div class = \ "flex-push-right\">" + ar [ i ] . actions + " < / d i v > \
< / d i v > \
2021-05-22 11:28:40 +02:00
< / d i v > " ) ;
$ ( "#load" + i ) . on ( "click" , function ( ) {
enableButtons ( [ load _accept ] ) ;
socket . send ( { 'cmd' : 'loadselect' , 'data' : $ ( this ) . attr ( "name" ) } ) ;
highlightLoadLine ( $ ( this ) ) ;
} ) ;
2021-09-01 00:22:30 +02:00
$ ( "#loaddelete" + i ) . off ( "click" ) . on ( "click" , ( function ( name ) {
return function ( ) {
if ( ! sman _allow _delete ) {
return ;
}
$ ( "#loadcontainerdelete-storyname" ) . text ( name ) ;
$ ( "#btn_dsaccept" ) . off ( "click" ) . on ( "click" , ( function ( name ) {
return function ( ) {
hide ( [ $ ( ".saveasoverwrite" ) , $ ( ".popuperror" ) ] ) ;
socket . send ( { 'cmd' : 'deletestory' , 'data' : name } ) ;
}
} ) ( name ) ) ;
$ ( "#loadcontainerdelete" ) . removeClass ( "hidden" ) . addClass ( "flex" ) ;
}
} ) ( ar [ i ] . name ) ) ;
$ ( "#loadrename" + i ) . off ( "click" ) . on ( "click" , ( function ( name ) {
return function ( ) {
if ( ! sman _allow _rename ) {
return ;
}
$ ( "#newsavename" ) . val ( "" )
$ ( "#loadcontainerrename-storyname" ) . text ( name ) ;
submit = ( function ( name ) {
return function ( ) {
hide ( [ $ ( ".saveasoverwrite" ) , $ ( ".popuperror" ) ] ) ;
socket . send ( { 'cmd' : 'renamestory' , 'data' : name , 'newname' : $ ( "#newsavename" ) . val ( ) } ) ;
}
} ) ( name ) ;
$ ( "#btn_rensaccept" ) . off ( "click" ) . on ( "click" , submit ) ;
$ ( "#loadcontainerrename" ) . removeClass ( "hidden" ) . addClass ( "flex" ) ;
$ ( "#newsavename" ) . val ( name ) . select ( ) ;
}
} ) ( ar [ i ] . name ) ) ;
2021-05-22 11:28:40 +02:00
}
}
function highlightLoadLine ( ref ) {
$ ( "#loadlistcontent > div" ) . removeClass ( "popuplistselected" ) ;
ref . addClass ( "popuplistselected" ) ;
}
function showNewStoryPopup ( ) {
nspopup . removeClass ( "hidden" ) ;
nspopup . addClass ( "flex" ) ;
}
function hideNewStoryPopup ( ) {
nspopup . removeClass ( "flex" ) ;
nspopup . addClass ( "hidden" ) ;
}
2021-08-19 12:54:44 +02:00
function showRandomStoryPopup ( ) {
rspopup . removeClass ( "hidden" ) ;
rspopup . addClass ( "flex" ) ;
}
function hideRandomStoryPopup ( ) {
rspopup . removeClass ( "flex" ) ;
rspopup . addClass ( "hidden" ) ;
}
2021-05-29 11:46:03 +02:00
function setStartState ( ) {
enableSendBtn ( ) ;
enableButtons ( [ button _actmem , button _actwi ] ) ;
2021-08-23 08:34:27 +02:00
disableButtons ( [ button _actback , button _actretry ] ) ;
2021-08-23 19:22:50 +02:00
hide ( [ wi _menu ] ) ;
2021-08-23 08:34:27 +02:00
show ( [ game _text , button _actmem , button _actwi , button _actback , button _actretry ] ) ;
2021-05-29 11:46:03 +02:00
hideMessage ( ) ;
hideWaitAnimation ( ) ;
button _actmem . html ( "Memory" ) ;
button _actwi . html ( "W Info" ) ;
hideAidgPopup ( ) ;
hideSaveAsPopup ( ) ;
hideLoadPopup ( ) ;
hideNewStoryPopup ( ) ;
hidegenseqs ( ) ;
}
function parsegenseqs ( seqs ) {
seqselcontents . html ( "" ) ;
var i ;
for ( i = 0 ; i < seqs . length ; i ++ ) {
seqselcontents . append ( "<div class=\"seqselitem\" id=\"seqsel" + i + "\" n=\"" + i + "\">" + seqs [ i ] . generated _text + "</div>" ) ;
$ ( "#seqsel" + i ) . on ( "click" , function ( ) {
socket . send ( { 'cmd' : 'seqsel' , 'data' : $ ( this ) . attr ( "n" ) } ) ;
} ) ;
}
$ ( '#seqselmenu' ) . slideDown ( "slow" ) ;
}
function hidegenseqs ( ) {
$ ( '#seqselmenu' ) . slideUp ( "slow" , function ( ) {
seqselcontents . html ( "" ) ;
} ) ;
2021-08-26 21:15:42 +02:00
scrollToBottom ( ) ;
2021-05-29 11:46:03 +02:00
}
2021-08-19 13:18:01 +02:00
function setmodevisibility ( state ) {
if ( state ) { // Enabling
show ( [ button _mode ] ) ;
$ ( "#inputrow" ) . addClass ( "show_mode" ) ;
} else { // Disabling
hide ( [ button _mode ] ) ;
$ ( "#inputrow" ) . removeClass ( "show_mode" ) ;
}
}
function setadventure ( state ) {
adventure = state ;
2021-08-26 07:06:57 +02:00
if ( state ) {
game _text . addClass ( "adventure" ) ;
} else {
game _text . removeClass ( "adventure" ) ;
}
2021-08-19 13:18:01 +02:00
if ( ! memorymode ) {
setmodevisibility ( state ) ;
}
}
2021-08-23 08:34:27 +02:00
function autofocus ( event ) {
if ( connected ) {
2021-08-24 17:14:18 +02:00
if ( event . target . tagName == "CHUNK" ) {
current _editing _chunk = event . target ;
}
2021-08-23 08:34:27 +02:00
event . target . focus ( ) ;
} else {
event . preventDefault ( ) ;
}
}
function chunkOnKeyDown ( event ) {
2021-08-24 01:18:09 +02:00
// Make escape commit the changes (Originally we had Enter here to but its not required and nicer for users if we let them type freely
// You can add the following after 27 if you want it back to committing on enter : || (!event.shiftKey && event.keyCode == 13)
if ( event . keyCode == 27 ) {
2021-08-23 20:05:40 +02:00
setTimeout ( function ( ) {
event . target . blur ( ) ;
2021-08-24 00:26:38 +02:00
} , 5 ) ;
2021-08-23 08:34:27 +02:00
event . preventDefault ( ) ;
return ;
}
2021-08-24 00:11:03 +02:00
// Allow left and right arrow keys (and backspace) to move between chunks
2021-08-24 00:00:35 +02:00
switch ( event . keyCode ) {
case 37 : // left
case 39 : // right
2021-08-24 19:32:29 +02:00
old _range = getSelection ( ) . getRangeAt ( 0 ) ;
old _range _start = old _range . startOffset ;
old _range _end = old _range . endOffset ;
old _range _ancestor = old _range . commonAncestorContainer ;
old _range _start _container = old _range . startContainer ;
old _range _end _container = old _range . endContainer ;
2021-08-24 00:00:35 +02:00
setTimeout ( function ( ) {
// Wait a few milliseconds and check if the caret has moved
new _selection = getSelection ( ) ;
2021-08-24 19:32:29 +02:00
new _range = new _selection . getRangeAt ( 0 ) ;
if ( old _range _start != new _range . startOffset || old _range _end != new _range . endOffset || old _range _ancestor != new _range . commonAncestorContainer || old _range _start _container != new _range . startContainer || old _range _end _container != new _range . endContainer ) {
2021-08-24 00:00:35 +02:00
return ;
}
// If it hasn't moved, we're at the beginning or end of a chunk
// and the caret must be moved to a different chunk
chunk = document . activeElement ;
switch ( event . keyCode ) {
case 37 : // left
if ( ( chunk = chunk . previousSibling ) && chunk . tagName == "CHUNK" ) {
range = document . createRange ( ) ;
range . selectNodeContents ( chunk ) ;
range . collapse ( false ) ;
new _selection . removeAllRanges ( ) ;
new _selection . addRange ( range ) ;
}
break ;
case 39 : // right
if ( ( chunk = chunk . nextSibling ) && chunk . tagName == "CHUNK" ) {
chunk . focus ( ) ;
}
}
} , 2 ) ;
return ;
2021-08-24 00:11:03 +02:00
case 8 : // backspace
old _length = document . activeElement . innerText . length ;
setTimeout ( function ( ) {
// Wait a few milliseconds and compare the chunk's length
if ( old _length != document . activeElement . innerText . length ) {
return ;
}
// If it's the same, we're at the beginning of a chunk
if ( ( chunk = document . activeElement . previousSibling ) && chunk . tagName == "CHUNK" ) {
range = document . createRange ( ) ;
selection = getSelection ( ) ;
range . selectNodeContents ( chunk ) ;
range . collapse ( false ) ;
selection . removeAllRanges ( ) ;
selection . addRange ( range ) ;
}
} , 2 ) ;
return
2021-08-24 00:00:35 +02:00
}
2021-08-23 08:34:27 +02:00
// Don't allow any edits if not connected to server
if ( ! connected ) {
event . preventDefault ( ) ;
return ;
}
// Prevent CTRL+B, CTRL+I and CTRL+U when editing chunks
if ( event . ctrlKey || event . metaKey ) { // metaKey is macOS's command key
switch ( event . keyCode ) {
case 66 :
case 98 :
case 73 :
case 105 :
case 85 :
case 117 :
event . preventDefault ( ) ;
return ;
}
}
}
function submitEditedChunk ( event ) {
// Don't do anything if the current chunk hasn't been edited or if someone
// else overwrote it while you were busy lollygagging
2021-08-24 00:26:38 +02:00
if ( current _editing _chunk === null || chunk _conflict ) {
2021-08-23 08:34:27 +02:00
chunk _conflict = false ;
return ;
}
2021-08-24 00:26:38 +02:00
chunk = current _editing _chunk ;
current _editing _chunk = null ;
2021-08-23 08:34:27 +02:00
// Submit the edited chunk if it's not empty, otherwise delete it
2021-08-24 00:26:38 +02:00
if ( chunk . innerText . length ) {
2021-08-26 01:25:57 +02:00
socket . send ( { 'cmd' : 'inlineedit' , 'chunk' : chunk . getAttribute ( "n" ) , 'data' : chunk . innerText . replace ( /\u00a0/g , " " ) } ) ;
2021-08-23 08:34:27 +02:00
} else {
2021-08-24 00:52:45 +02:00
socket . send ( { 'cmd' : 'inlinedelete' , 'data' : chunk . getAttribute ( "n" ) } ) ;
2021-08-23 08:34:27 +02:00
}
}
2021-05-03 00:48:47 +02:00
//=================================================================//
// READY/RUNTIME
//=================================================================//
$ ( document ) . ready ( function ( ) {
2021-05-05 09:04:06 +02:00
// Bind UI references
2021-05-22 11:28:40 +02:00
connect _status = $ ( '#connectstatus' ) ;
button _newgame = $ ( '#btn_newgame' ) ;
2021-08-19 12:54:44 +02:00
button _rndgame = $ ( '#btn_rndgame' ) ;
2021-05-22 11:28:40 +02:00
button _save = $ ( '#btn_save' ) ;
button _saveas = $ ( '#btn_saveas' ) ;
button _savetofile = $ ( '#btn_savetofile' ) ;
2021-09-01 19:32:11 +02:00
button _download = $ ( '#btn_download' ) ;
2021-09-01 19:46:37 +02:00
button _downloadtxt = $ ( '#btn_downloadtxt' ) ;
2021-05-22 11:28:40 +02:00
button _load = $ ( '#btn_load' ) ;
button _loadfrfile = $ ( '#btn_loadfromfile' ) ;
button _import = $ ( "#btn_import" ) ;
2021-05-29 11:46:03 +02:00
button _importwi = $ ( "#btn_importwi" ) ;
2021-05-22 11:28:40 +02:00
button _impaidg = $ ( "#btn_impaidg" ) ;
button _settings = $ ( '#btn_settings' ) ;
button _format = $ ( '#btn_format' ) ;
2021-08-19 13:18:01 +02:00
button _mode = $ ( '#btnmode' )
button _mode _label = $ ( '#btnmode_label' )
2021-05-22 11:28:40 +02:00
button _send = $ ( '#btnsend' ) ;
button _actmem = $ ( '#btn_actmem' ) ;
button _actback = $ ( '#btn_actundo' ) ;
button _actretry = $ ( '#btn_actretry' ) ;
button _actwi = $ ( '#btn_actwi' ) ;
game _text = $ ( '#gametext' ) ;
input _text = $ ( '#input_text' ) ;
message _text = $ ( '#messagefield' ) ;
settings _menu = $ ( "#settingsmenu" ) ;
format _menu = $ ( '#formatmenu' ) ;
anote _menu = $ ( '#anoterowcontainer' ) ;
wi _menu = $ ( '#wimenu' ) ;
anote _input = $ ( '#anoteinput' ) ;
anote _labelcur = $ ( '#anotecur' ) ;
anote _slider = $ ( '#anotedepth' ) ;
popup = $ ( "#popupcontainer" ) ;
popup _title = $ ( "#popuptitletext" ) ;
popup _content = $ ( "#popupcontent" ) ;
popup _accept = $ ( "#btn_popupaccept" ) ;
popup _close = $ ( "#btn_popupclose" ) ;
aidgpopup = $ ( "#aidgpopupcontainer" ) ;
aidgpromptnum = $ ( "#aidgpromptnum" ) ;
aidg _accept = $ ( "#btn_aidgpopupaccept" ) ;
aidg _close = $ ( "#btn_aidgpopupclose" ) ;
saveaspopup = $ ( "#saveascontainer" ) ;
saveasinput = $ ( "#savename" ) ;
2021-08-19 12:54:44 +02:00
topic = $ ( "#topic" ) ;
2021-05-22 11:28:40 +02:00
saveas _accept = $ ( "#btn_saveasaccept" ) ;
saveas _close = $ ( "#btn_saveasclose" ) ;
loadpopup = $ ( "#loadcontainer" ) ;
loadcontent = $ ( "#loadlistcontent" ) ;
load _accept = $ ( "#btn_loadaccept" ) ;
load _close = $ ( "#btn_loadclose" ) ;
nspopup = $ ( "#newgamecontainer" ) ;
ns _accept = $ ( "#btn_nsaccept" ) ;
ns _close = $ ( "#btn_nsclose" ) ;
2021-08-19 12:54:44 +02:00
rspopup = $ ( "#rndgamecontainer" ) ;
rs _accept = $ ( "#btn_rsaccept" ) ;
rs _close = $ ( "#btn_rsclose" ) ;
2021-05-29 11:46:03 +02:00
seqselmenu = $ ( "#seqselmenu" ) ;
seqselcontents = $ ( "#seqselcontents" ) ;
2021-05-03 00:48:47 +02:00
2021-08-25 00:32:48 +02:00
// Connect to SocketIO server
socket = io . connect ( window . document . origin ) ;
2021-05-03 00:48:47 +02:00
socket . on ( 'from_server' , function ( msg ) {
2021-08-25 00:32:48 +02:00
if ( msg . cmd == "connected" ) {
2021-05-03 00:48:47 +02:00
// Connected to Server Actions
2021-09-01 00:22:30 +02:00
sman _allow _delete = msg . hasOwnProperty ( "smandelete" ) && msg . smandelete ;
sman _allow _rename = msg . hasOwnProperty ( "smanrename" ) && msg . smanrename ;
2021-08-23 08:34:27 +02:00
connected = true ;
2021-05-07 20:32:10 +02:00
connect _status . html ( "<b>Connected to KoboldAI Process!</b>" ) ;
connect _status . removeClass ( "color_orange" ) ;
connect _status . addClass ( "color_green" ) ;
2021-05-13 07:26:42 +02:00
// Reset Menus
2021-05-07 20:32:10 +02:00
settings _menu . html ( "" ) ;
2021-05-11 01:17:10 +02:00
format _menu . html ( "" ) ;
2021-05-13 07:26:42 +02:00
wi _menu . html ( "" ) ;
2021-08-23 08:34:27 +02:00
// Set up "Allow Editing"
$ ( 'body' ) . on ( 'input' , autofocus ) . on ( 'keydown' , 'chunk' , chunkOnKeyDown ) . on ( 'focusout' , 'chunk' , submitEditedChunk ) ;
$ ( '#allowediting' ) . prop ( 'checked' , allowedit ) . prop ( 'disabled' , false ) . change ( ) . on ( 'change' , function ( ) {
if ( allowtoggle ) {
2021-08-23 20:25:40 +02:00
allowedit = $ ( this ) . prop ( 'checked' )
$ ( "chunk" ) . attr ( 'contenteditable' , allowedit )
2021-08-23 08:34:27 +02:00
}
} ) ;
2021-05-03 00:48:47 +02:00
} else if ( msg . cmd == "updatescreen" ) {
2021-08-24 00:52:45 +02:00
_gamestarted = gamestarted ;
2021-08-19 13:18:01 +02:00
gamestarted = msg . gamestarted ;
if ( _gamestarted != gamestarted ) {
action _mode = 0 ;
changemode ( ) ;
}
2021-05-03 00:48:47 +02:00
// Send game content to Game Screen
2021-08-23 08:34:27 +02:00
if ( allowedit && document . activeElement . tagName == "CHUNK" ) {
chunk _conflict = true ;
}
2021-05-03 00:48:47 +02:00
game _text . html ( msg . data ) ;
2021-08-23 08:34:27 +02:00
// Make content editable if need be
$ ( 'chunk' ) . attr ( 'contenteditable' , allowedit ) ;
2021-05-04 15:56:48 +02:00
// Scroll to bottom of text
2021-08-23 08:34:27 +02:00
if ( newly _loaded ) {
2021-08-26 21:15:42 +02:00
scrollToBottom ( ) ;
2021-08-23 08:34:27 +02:00
}
newly _loaded = false ;
2021-08-24 17:24:29 +02:00
hideMessage ( ) ;
2021-08-24 01:19:36 +02:00
} else if ( msg . cmd == "scrolldown" ) {
2021-08-26 21:15:42 +02:00
scrollToBottom ( ) ;
2021-06-15 06:59:08 +02:00
} else if ( msg . cmd == "updatechunk" ) {
2021-08-26 01:22:35 +02:00
hideMessage ( ) ;
2021-06-15 06:59:08 +02:00
const { index , html , last } = msg . data ;
const existingChunk = game _text . children ( ` #n ${ index } ` )
const newChunk = $ ( html ) ;
if ( existingChunk . length > 0 ) {
// Update existing chunk
existingChunk . before ( newChunk ) ;
existingChunk . remove ( ) ;
} else {
// Append at the end
game _text . append ( newChunk ) ;
}
2021-08-25 01:02:52 +02:00
newChunk . attr ( 'contenteditable' , allowedit ) ;
hide ( [ $ ( '#curtain' ) ] ) ;
2021-06-15 06:59:08 +02:00
if ( last ) {
// Scroll to bottom of text if it's the last element
2021-08-26 21:15:42 +02:00
scrollToBottom ( ) ;
2021-06-15 06:59:08 +02:00
}
} else if ( msg . cmd == "removechunk" ) {
2021-08-26 01:22:35 +02:00
hideMessage ( ) ;
2021-08-25 00:32:48 +02:00
let index = msg . data ;
// Remove the chunk
game _text . children ( ` #n ${ index } ` ) . remove ( )
2021-08-25 01:02:52 +02:00
hide ( [ $ ( '#curtain' ) ] ) ;
2021-05-03 00:48:47 +02:00
} else if ( msg . cmd == "setgamestate" ) {
// Enable or Disable buttons
if ( msg . data == "ready" ) {
enableSendBtn ( ) ;
2021-08-23 08:34:27 +02:00
enableButtons ( [ button _actmem , button _actwi , button _actback , button _actretry ] ) ;
2021-05-03 00:48:47 +02:00
hideWaitAnimation ( ) ;
} else if ( msg . data == "wait" ) {
disableSendBtn ( ) ;
2021-08-23 08:34:27 +02:00
disableButtons ( [ button _actmem , button _actwi , button _actback , button _actretry ] ) ;
2021-05-03 00:48:47 +02:00
showWaitAnimation ( ) ;
} else if ( msg . data == "start" ) {
2021-05-29 11:46:03 +02:00
setStartState ( ) ;
2021-05-03 00:48:47 +02:00
}
} else if ( msg . cmd == "editmode" ) {
// Enable or Disable edit mode
if ( msg . data == "true" ) {
enterEditMode ( ) ;
} else {
exitEditMode ( ) ;
}
} else if ( msg . cmd == "setinputtext" ) {
2021-08-23 08:34:27 +02:00
// Set input box text for memory mode
if ( memorymode ) {
input _text . val ( msg . data ) ;
}
2021-05-03 00:48:47 +02:00
} else if ( msg . cmd == "memmode" ) {
// Enable or Disable memory edit mode
if ( msg . data == "true" ) {
enterMemoryMode ( ) ;
} else {
exitMemoryMode ( ) ;
}
} else if ( msg . cmd == "errmsg" ) {
// Send error message
errMessage ( msg . data ) ;
} else if ( msg . cmd == "texteffect" ) {
// Apply color highlight to line of text
newTextHighlight ( $ ( "#n" + msg . data ) )
2021-05-04 15:56:48 +02:00
} else if ( msg . cmd == "updatetemp" ) {
// Send current temp value to input
2021-05-07 20:32:10 +02:00
$ ( "#settemp" ) . val ( parseFloat ( msg . data ) ) ;
$ ( "#settempcur" ) . html ( msg . data ) ;
2021-05-04 15:56:48 +02:00
} else if ( msg . cmd == "updatetopp" ) {
2021-05-07 20:32:10 +02:00
// Send current top p value to input
$ ( "#settopp" ) . val ( parseFloat ( msg . data ) ) ;
$ ( "#settoppcur" ) . html ( msg . data ) ;
2021-08-19 14:47:57 +02:00
} else if ( msg . cmd == "updatetopk" ) {
// Send current top k value to input
$ ( "#settopk" ) . val ( parseFloat ( msg . data ) ) ;
$ ( "#settopkcur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "updatetfs" ) {
// Send current tfs value to input
$ ( "#settfs" ) . val ( parseFloat ( msg . data ) ) ;
$ ( "#settfscur" ) . html ( msg . data ) ;
2021-05-04 15:56:48 +02:00
} else if ( msg . cmd == "updatereppen" ) {
2021-05-07 20:32:10 +02:00
// Send current rep pen value to input
$ ( "#setreppen" ) . val ( parseFloat ( msg . data ) ) ;
$ ( "#setreppencur" ) . html ( msg . data ) ;
2021-05-04 15:56:48 +02:00
} else if ( msg . cmd == "updateoutlen" ) {
2021-05-07 20:32:10 +02:00
// Send current output amt value to input
$ ( "#setoutput" ) . val ( parseInt ( msg . data ) ) ;
$ ( "#setoutputcur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "updatetknmax" ) {
// Send current max tokens value to input
$ ( "#settknmax" ) . val ( parseInt ( msg . data ) ) ;
$ ( "#settknmaxcur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "updateikgen" ) {
// Send current max tokens value to input
$ ( "#setikgen" ) . val ( parseInt ( msg . data ) ) ;
$ ( "#setikgencur" ) . html ( msg . data ) ;
2021-05-04 15:56:48 +02:00
} else if ( msg . cmd == "setlabeltemp" ) {
// Update setting label with value from server
2021-05-07 20:32:10 +02:00
$ ( "#settempcur" ) . html ( msg . data ) ;
2021-05-04 15:56:48 +02:00
} else if ( msg . cmd == "setlabeltopp" ) {
// Update setting label with value from server
2021-05-07 20:32:10 +02:00
$ ( "#settoppcur" ) . html ( msg . data ) ;
2021-08-19 14:47:57 +02:00
} else if ( msg . cmd == "setlabeltopk" ) {
// Update setting label with value from server
$ ( "#settopkcur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "setlabeltfs" ) {
// Update setting label with value from server
$ ( "#settfscur" ) . html ( msg . data ) ;
2021-05-04 15:56:48 +02:00
} else if ( msg . cmd == "setlabelreppen" ) {
// Update setting label with value from server
2021-05-07 20:32:10 +02:00
$ ( "#setreppencur" ) . html ( msg . data ) ;
2021-05-04 15:56:48 +02:00
} else if ( msg . cmd == "setlabeloutput" ) {
// Update setting label with value from server
2021-05-07 20:32:10 +02:00
$ ( "#setoutputcur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "setlabeltknmax" ) {
// Update setting label with value from server
$ ( "#settknmaxcur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "setlabelikgen" ) {
// Update setting label with value from server
$ ( "#setikgencur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "updateanotedepth" ) {
2021-05-05 09:04:06 +02:00
// Send current Author's Note depth value to input
anote _slider . val ( parseInt ( msg . data ) ) ;
anote _labelcur . html ( msg . data ) ;
} else if ( msg . cmd == "setlabelanotedepth" ) {
// Update setting label with value from server
anote _labelcur . html ( msg . data ) ;
} else if ( msg . cmd == "getanote" ) {
// Request contents of Author's Note field
var txt = anote _input . val ( ) ;
socket . send ( { 'cmd' : 'anote' , 'data' : txt } ) ;
} else if ( msg . cmd == "setanote" ) {
// Set contents of Author's Note field
anote _input . val ( msg . data ) ;
2021-05-07 20:32:10 +02:00
} else if ( msg . cmd == "addsetting" ) {
// Add setting controls
addSetting ( msg . data ) ;
2021-05-11 01:17:10 +02:00
} else if ( msg . cmd == "addformat" ) {
// Add setting controls
addFormat ( msg . data ) ;
} else if ( msg . cmd == "updatefrmttriminc" ) {
// Update toggle state
2021-05-29 11:46:03 +02:00
$ ( "#frmttriminc" ) . prop ( 'checked' , msg . data ) . change ( ) ;
2021-05-11 01:17:10 +02:00
} else if ( msg . cmd == "updatefrmtrmblln" ) {
// Update toggle state
2021-05-29 11:46:03 +02:00
$ ( "#frmtrmblln" ) . prop ( 'checked' , msg . data ) . change ( ) ;
2021-05-11 01:17:10 +02:00
} else if ( msg . cmd == "updatefrmtrmspch" ) {
// Update toggle state
2021-05-29 11:46:03 +02:00
$ ( "#frmtrmspch" ) . prop ( 'checked' , msg . data ) . change ( ) ;
2021-05-11 01:17:10 +02:00
} else if ( msg . cmd == "updatefrmtadsnsp" ) {
// Update toggle state
2021-05-29 11:46:03 +02:00
$ ( "#frmtadsnsp" ) . prop ( 'checked' , msg . data ) . change ( ) ;
2021-05-11 01:17:10 +02:00
} else if ( msg . cmd == "allowtoggle" ) {
// Allow toggle change states to propagate
allowtoggle = msg . data ;
2021-05-11 06:27:34 +02:00
} else if ( msg . cmd == "popupshow" ) {
// Show/Hide Popup
popupShow ( msg . data ) ;
2021-09-01 00:22:30 +02:00
} else if ( msg . cmd == "hidepopupdelete" ) {
// Hide the dialog box that asks you to confirm deletion of a story
$ ( "#loadcontainerdelete" ) . removeClass ( "flex" ) . addClass ( "hidden" ) ;
hide ( [ $ ( ".saveasoverwrite" ) , $ ( ".popuperror" ) ] ) ;
} else if ( msg . cmd == "hidepopuprename" ) {
// Hide the story renaming dialog box
$ ( "#loadcontainerrename" ) . removeClass ( "flex" ) . addClass ( "hidden" ) ;
hide ( [ $ ( ".saveasoverwrite" ) , $ ( ".popuperror" ) ] ) ;
2021-05-11 06:27:34 +02:00
} else if ( msg . cmd == "addimportline" ) {
// Add import popup entry
addImportLine ( msg . data ) ;
} else if ( msg . cmd == "clearpopup" ) {
// Clear previous contents of popup
popup _content . html ( "" ) ;
2021-05-13 07:26:42 +02:00
} else if ( msg . cmd == "wimode" ) {
// Enable or Disable WI edit mode
if ( msg . data == "true" ) {
enterWiMode ( ) ;
} else {
exitWiMode ( ) ;
}
} else if ( msg . cmd == "addwiitem" ) {
// Add WI entry to WI Menu
addWiLine ( msg . data ) ;
} else if ( msg . cmd == "clearwi" ) {
// Clear previous contents of WI list
wi _menu . html ( "" ) ;
} else if ( msg . cmd == "requestwiitem" ) {
// Package WI contents and send back to server
returnWiList ( msg . data ) ;
2021-05-22 11:28:40 +02:00
} else if ( msg . cmd == "saveas" ) {
// Show Save As prompt
showSaveAsPopup ( ) ;
} else if ( msg . cmd == "hidesaveas" ) {
// Hide Save As prompt
hideSaveAsPopup ( ) ;
} else if ( msg . cmd == "buildload" ) {
// Send array of save files to load UI
buildLoadList ( msg . data ) ;
} else if ( msg . cmd == "askforoverwrite" ) {
// Show overwrite warning
2021-09-01 00:22:30 +02:00
show ( [ $ ( ".saveasoverwrite" ) ] ) ;
} else if ( msg . cmd == "popuperror" ) {
// Show error in the current dialog box
$ ( ".popuperror" ) . text ( msg . data ) ;
show ( [ $ ( ".popuperror" ) ] ) ;
2021-05-29 11:46:03 +02:00
} else if ( msg . cmd == "genseqs" ) {
// Parse generator sequences to UI
parsegenseqs ( msg . data ) ;
} else if ( msg . cmd == "hidegenseqs" ) {
// Collapse genseqs menu
hidegenseqs ( ) ;
} else if ( msg . cmd == "setlabelnumseq" ) {
// Update setting label with value from server
$ ( "#setnumseqcur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "updatenumseq" ) {
// Send current max tokens value to input
$ ( "#setnumseq" ) . val ( parseInt ( msg . data ) ) ;
$ ( "#setnumseqcur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "setlabelwidepth" ) {
// Update setting label with value from server
$ ( "#setwidepthcur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "updatewidepth" ) {
// Send current max tokens value to input
$ ( "#setwidepth" ) . val ( parseInt ( msg . data ) ) ;
$ ( "#setwidepthcur" ) . html ( msg . data ) ;
} else if ( msg . cmd == "updateuseprompt" ) {
// Update toggle state
$ ( "#setuseprompt" ) . prop ( 'checked' , msg . data ) . change ( ) ;
2021-08-19 13:18:01 +02:00
} else if ( msg . cmd == "updateadventure" ) {
// Update toggle state
$ ( "#setadventure" ) . prop ( 'checked' , msg . data ) . change ( ) ;
// Update adventure state
setadventure ( msg . data ) ;
2021-08-20 00:37:59 +02:00
} else if ( msg . cmd == "runs_remotely" ) {
hide ( [ button _loadfrfile , button _savetofile , button _import , button _importwi ] ) ;
2021-05-03 00:48:47 +02:00
}
2021-08-25 00:32:48 +02:00
} ) ;
2021-05-03 00:48:47 +02:00
socket . on ( 'disconnect' , function ( ) {
2021-08-23 08:34:27 +02:00
connected = false ;
2021-05-07 20:32:10 +02:00
connect _status . html ( "<b>Lost connection...</b>" ) ;
connect _status . removeClass ( "color_green" ) ;
connect _status . addClass ( "color_orange" ) ;
2021-05-03 00:48:47 +02:00
} ) ;
// Bind actions to UI buttons
button _send . on ( "click" , function ( ev ) {
dosubmit ( ) ;
} ) ;
2021-08-19 13:18:01 +02:00
button _mode . on ( "click" , function ( ev ) {
changemode ( ) ;
} ) ;
2021-05-03 00:48:47 +02:00
button _actretry . on ( "click" , function ( ev ) {
2021-08-25 20:42:37 +02:00
hideMessage ( ) ;
2021-05-03 00:48:47 +02:00
socket . send ( { 'cmd' : 'retry' , 'data' : '' } ) ;
2021-05-29 11:46:03 +02:00
hidegenseqs ( ) ;
2021-05-03 00:48:47 +02:00
} ) ;
button _actback . on ( "click" , function ( ev ) {
2021-08-25 20:42:37 +02:00
hideMessage ( ) ;
2021-05-03 00:48:47 +02:00
socket . send ( { 'cmd' : 'back' , 'data' : '' } ) ;
2021-05-29 11:46:03 +02:00
hidegenseqs ( ) ;
2021-05-03 00:48:47 +02:00
} ) ;
button _actmem . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'memory' , 'data' : '' } ) ;
} ) ;
2021-05-22 11:28:40 +02:00
button _savetofile . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'savetofile' , 'data' : '' } ) ;
2021-05-03 00:48:47 +02:00
} ) ;
2021-05-22 11:28:40 +02:00
button _loadfrfile . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'loadfromfile' , 'data' : '' } ) ;
2021-05-03 00:48:47 +02:00
} ) ;
2021-05-11 06:27:34 +02:00
button _import . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'import' , 'data' : '' } ) ;
} ) ;
2021-05-29 11:46:03 +02:00
button _importwi . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'importwi' , 'data' : '' } ) ;
} ) ;
2021-05-04 15:56:48 +02:00
button _settings . on ( "click" , function ( ev ) {
$ ( '#settingsmenu' ) . slideToggle ( "slow" ) ;
} ) ;
2021-05-11 01:17:10 +02:00
button _format . on ( "click" , function ( ev ) {
$ ( '#formatmenu' ) . slideToggle ( "slow" ) ;
} ) ;
2021-05-11 06:27:34 +02:00
popup _close . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'importcancel' , 'data' : '' } ) ;
2021-05-04 15:56:48 +02:00
} ) ;
2021-05-11 06:27:34 +02:00
popup _accept . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'importaccept' , 'data' : '' } ) ;
} ) ;
2021-05-13 07:26:42 +02:00
button _actwi . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'wi' , 'data' : '' } ) ;
} ) ;
2021-05-16 11:29:39 +02:00
button _impaidg . on ( "click" , function ( ev ) {
showAidgPopup ( ) ;
} ) ;
aidg _close . on ( "click" , function ( ev ) {
hideAidgPopup ( ) ;
} ) ;
aidg _accept . on ( "click" , function ( ev ) {
sendAidgImportRequest ( ) ;
} ) ;
2021-05-11 06:27:34 +02:00
2021-05-22 11:28:40 +02:00
button _save . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'saverequest' , 'data' : '' } ) ;
} ) ;
button _saveas . on ( "click" , function ( ev ) {
showSaveAsPopup ( ) ;
} ) ;
saveas _close . on ( "click" , function ( ev ) {
hideSaveAsPopup ( ) ;
socket . send ( { 'cmd' : 'clearoverwrite' , 'data' : '' } ) ;
} ) ;
saveas _accept . on ( "click" , function ( ev ) {
sendSaveAsRequest ( ) ;
} ) ;
2021-09-01 19:32:11 +02:00
button _download . on ( "click" , function ( ev ) {
window . open ( "/download" , "_blank" ) ;
} ) ;
2021-09-01 19:46:37 +02:00
button _downloadtxt . on ( "click" , function ( ev ) {
window . open ( "/download?format=plaintext" , "_blank" ) ;
} ) ;
2021-05-22 11:28:40 +02:00
button _load . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'loadlistrequest' , 'data' : '' } ) ;
} ) ;
load _close . on ( "click" , function ( ev ) {
hideLoadPopup ( ) ;
} ) ;
load _accept . on ( "click" , function ( ev ) {
2021-08-23 08:34:27 +02:00
newly _loaded = true ;
2021-05-22 11:28:40 +02:00
socket . send ( { 'cmd' : 'loadrequest' , 'data' : '' } ) ;
hideLoadPopup ( ) ;
} ) ;
button _newgame . on ( "click" , function ( ev ) {
showNewStoryPopup ( ) ;
} ) ;
ns _accept . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'newgame' , 'data' : '' } ) ;
hideNewStoryPopup ( ) ;
} ) ;
ns _close . on ( "click" , function ( ev ) {
hideNewStoryPopup ( ) ;
2021-08-19 12:54:44 +02:00
} ) ;
2021-09-01 19:05:24 +02:00
$ ( "#btn_dsclose" ) . on ( "click" , function ( ) {
$ ( "#loadcontainerdelete" ) . removeClass ( "flex" ) . addClass ( "hidden" ) ;
hide ( [ $ ( ".saveasoverwrite" ) , $ ( ".popuperror" ) ] ) ;
} ) ;
2021-09-01 19:10:21 +02:00
$ ( "#newsavename" ) . on ( "input" , function ( ev ) {
if ( $ ( this ) . val ( ) == "" ) {
disableButtons ( [ $ ( "#btn_rensaccept" ) ] ) ;
} else {
enableButtons ( [ $ ( "#btn_rensaccept" ) ] ) ;
}
hide ( [ $ ( ".saveasoverwrite" ) , $ ( ".popuperror" ) ] ) ;
} ) . on ( "keydown" , function ( ev ) {
2021-09-01 19:05:24 +02:00
if ( ev . which == 13 && $ ( this ) . val ( ) != "" ) {
submit ( ) ;
}
} ) ;
$ ( "#btn_rensclose" ) . on ( "click" , function ( ) {
$ ( "#loadcontainerrename" ) . removeClass ( "flex" ) . addClass ( "hidden" ) ;
hide ( [ $ ( ".saveasoverwrite" ) , $ ( ".popuperror" ) ] ) ;
} ) ;
2021-08-19 12:54:44 +02:00
button _rndgame . on ( "click" , function ( ev ) {
showRandomStoryPopup ( ) ;
} ) ;
rs _accept . on ( "click" , function ( ev ) {
socket . send ( { 'cmd' : 'rndgame' , 'data' : topic . val ( ) } ) ;
hideRandomStoryPopup ( ) ;
} ) ;
rs _close . on ( "click" , function ( ev ) {
hideRandomStoryPopup ( ) ;
2021-05-22 11:28:40 +02:00
} ) ;
2021-05-23 04:06:10 +02:00
anote _slider . on ( "input" , function ( ) {
socket . send ( { 'cmd' : 'anotedepth' , 'data' : $ ( this ) . val ( ) } ) ;
} ) ;
2021-05-22 11:28:40 +02:00
saveasinput . on ( "input" , function ( ) {
if ( saveasinput . val ( ) == "" ) {
disableButtons ( [ saveas _accept ] ) ;
} else {
enableButtons ( [ saveas _accept ] ) ;
}
2021-09-01 00:22:30 +02:00
hide ( [ $ ( ".saveasoverwrite" ) , $ ( ".popuperror" ) ] ) ;
2021-05-22 11:28:40 +02:00
} ) ;
2021-05-03 00:48:47 +02:00
// Bind Enter button to submit
input _text . keydown ( function ( ev ) {
if ( ev . which == 13 && ! shift _down ) {
do _clear _ent = true ;
dosubmit ( ) ;
} else if ( ev . which == 16 ) {
shift _down = true ;
}
} ) ;
2021-05-05 09:04:06 +02:00
// Enter to submit, but not if holding shift
2021-05-03 00:48:47 +02:00
input _text . keyup ( function ( ev ) {
if ( ev . which == 13 && do _clear _ent ) {
input _text . val ( "" ) ;
do _clear _ent = false ;
} else if ( ev . which == 16 ) {
shift _down = false ;
}
} ) ;
2021-05-16 11:29:39 +02:00
aidgpromptnum . keydown ( function ( ev ) {
if ( ev . which == 13 ) {
sendAidgImportRequest ( ) ;
}
} ) ;
2021-05-22 11:28:40 +02:00
saveasinput . keydown ( function ( ev ) {
if ( ev . which == 13 && saveasinput . val ( ) != "" ) {
sendSaveAsRequest ( ) ;
}
} ) ;
2021-05-03 00:48:47 +02:00
} ) ;