CSS change to move options to below game text for mobile

This commit is contained in:
ebolam
2022-07-05 14:11:05 -04:00
parent cc3ccb7f36
commit 796a1dcf16
7 changed files with 138 additions and 68 deletions

View File

@@ -5978,9 +5978,9 @@ def popup_edit(data):
return
if session['popup_jailed_dir'] is None:
emit("popup_edit_file", {"file": data, "text": open(data, 'r').read()});
emit("popup_edit_file", {"file": data, "text": open(data, 'r', encoding='utf-8').read()});
elif session['popup_jailed_dir'] in data:
emit("popup_edit_file", {"file": data, "text": open(data, 'r').read()});
emit("popup_edit_file", {"file": data, "text": open(data, 'r', encoding='utf-8').read()});
else:
print("User is trying to delete files in your server outside the jail. Blocked. Jailed Dir: {} Requested Dir: {}".format(session['popup_jailed_dir'], data))
@@ -6036,7 +6036,6 @@ def file_popup(popup_title, starting_folder, return_event, upload=True, jailed=T
get_files_folders(starting_folder)
def get_files_folders(starting_folder):
import stat
session['current_folder'] = starting_folder
@@ -6110,7 +6109,6 @@ def get_files_folders(starting_folder):
#==================================================================#
@socketio.on('var_change')
def UI_2_var_change(data):
print(data)
classname = data['ID'].split("_")[0]
name = data['ID'][len(classname)+1:]
classname += "_settings"
@@ -6127,6 +6125,7 @@ def UI_2_var_change(data):
else:
print("Unknown Type {} = {}".format(name, type(getattr(koboldai_vars, name))))
print("Setting {} to {} as type {}".format(name, value, type(value)))
setattr(koboldai_vars, name, value)
#Now let's save except for story changes
@@ -6293,30 +6292,19 @@ def UI_2_relay(data):
#==================================================================#
# Test
#==================================================================#
def setup_context_for_thread():
pass
@bridged_kwarg()
def lua_print_threadid():
import threading
return threading.get_ident()
@app.route("/actions")
def show_actions():
return koboldai_vars.actions.actions
@app.route("/story")
def show_story():
return koboldai_vars.actions.to_json()
@app.route("/story_list")
def show_story_list():
return " ".join(koboldai_vars.story_list())
@app.route("/session")
def show_session():
print(dir(session))
return dict(session)
@app.route("/vars")
def show_vars():
json_data = {}
json_data['story_settings'] = json.loads(koboldai_vars.to_json("story_settings"))
json_data['model_settings'] = json.loads(koboldai_vars.to_json("model_settings"))
json_data['user_settings'] = json.loads(koboldai_vars.to_json("user_settings"))
json_data['system_settings'] = json.loads(koboldai_vars.to_json("system_settings"))
return json_data
#==================================================================#

View File

@@ -232,9 +232,9 @@ gensettingstf = [
"step": 1,
"default": 0,
"tooltip": "Turn this on if you are playing a Choose your Adventure model.",
"menu_path": "Story",
"classname": "story",
"name": "adventure"
#"menu_path": "Story",
#"classname": "story",
#"name": "adventure"
},
{
"uitype": "toggle",
@@ -246,9 +246,9 @@ gensettingstf = [
"step": 1,
"default": 0,
"tooltip": "This mode optimizes KoboldAI for chatting.",
"menu_path": "Story",
"classname": "story",
"name": "chatmode"
#"menu_path": "Story",
#"classname": "story",
#"name": "chatmode"
},
{
"uitype": "toggle",
@@ -461,9 +461,9 @@ gensettingsik =[{
"step": 1,
"default": 0,
"tooltip": "Turn this on if you are playing a Choose your Adventure model.",
"menu_path": "Story",
"classname": "story",
"name": "adventure"
#"menu_path": "Story",
#"classname": "story",
#"name": "adventure"
},
{
"uitype": "toggle",
@@ -475,9 +475,9 @@ gensettingsik =[{
"step": 1,
"default": 0,
"tooltip": "This mode optimizes KoboldAI for chatting.",
"menu_path": "Story",
"classname": "story",
"name": "chatmode"
#"menu_path": "Story",
#"classname": "story",
#"name": "chatmode"
},
{
"uitype": "toggle",

View File

@@ -39,7 +39,7 @@ def process_variable_changes(socketio, classname, name, value, old_value, debug_
@sio.event
def connect():
pass
sio.connect('http://localhost:5000/?rely=true')
sio.connect('ws://localhost:5000/?rely=true')
rely_clients[threading.get_ident()] = sio
#release no longer used clients
for thread in rely_clients:
@@ -60,10 +60,10 @@ class koboldai_vars(object):
def to_json(self, classname):
if classname == 'story_settings':
if 'story' in self._sessions:
return self._story_settings[self._sessions['story']].to_json()
else:
return self._story_settings['default'].to_json()
#if 'story' in self._sessions:
# return self._story_settings[self._sessions['story']].to_json()
#else:
return self._story_settings['default'].to_json()
return self.__dict__["_{}".format(classname)].to_json()
def load_story(self, story_name, json_data):
@@ -322,7 +322,7 @@ class story_settings(settings):
process_variable_changes(self.socketio, self.__class__.__name__.replace("_settings", ""), name, value, old_value)
#We want to automatically set gamesaved to false if something happens to the actions list (pins, redos, generations, text, etc)
#To do that we need to give the actions list a copy of this data so it can set the gamesaved variable as needed
if not new_variable:
if not new_variable and old_value != value:
if name == 'actions':
self.actions.story_settings = self
if self.tokenizer is not None:
@@ -336,6 +336,29 @@ class story_settings(settings):
self.memory_length = len(self.tokenizer.encode(self.memory))
elif name == 'prompt':
self.prompt_length = len(self.tokenizer.encode(self.prompt))
#Because we have seperate variables for action types, this syncs them
if name == 'actionmode':
if value == 0:
self.adventure = False
self.chatmode = False
elif value == 1:
self.adventure = True
self.chatmode = False
elif value == 2:
self.adventure = False
self.chatmode = True
elif name == 'adventure' and value == True:
self.chatmode = False
self.actionmode = 1
elif name == 'adventure' and value == False and self.chatmode == False:
self.actionmode = 0
elif name == 'chatmode' and value == True:
self.adventure = False
self.actionmode = 2
elif name == 'chatmode' and value == False and self.adventure == False:
self.actionmode = 0
class user_settings(settings):
local_only_variables = ['socketio']
@@ -372,7 +395,7 @@ class user_settings(settings):
class system_settings(settings):
local_only_variables = ['socketio', 'lua_state', 'lua_logname', 'lua_koboldbridge', 'lua_kobold', 'lua_koboldcore', 'regex_sl', 'acregex_ai', 'acregex_ui', 'comregex_ai', 'comregex_ui', 'sp']
no_save_variables = ['socketio']
no_save_variables = ['socketio', 'lua_state', 'lua_logname', 'lua_koboldbridge', 'lua_kobold', 'lua_koboldcore', 'sp']
settings_name = "system"
def __init__(self, socketio):
self.socketio = socketio

View File

@@ -427,20 +427,32 @@ body {
color: var(--text);
}
@media only screen and not (max-width: 768px) {
.main-grid {
transition: margin-left .5s;
display: grid;
height: 98vh;
margin-left: var(--flyout_menu_closed_width);
/* grid-template-areas: "menuicon gamescreen lefticon"
"menuicon actions lefticon"
"menuicon inputrow lefticon";*/
grid-template-areas: "menuicon gamescreen options lefticon"
"menuicon inputrow inputrow lefticon";
grid-template-columns: 30px auto fit-content(30%) 20px;
/* grid-template-rows: auto 40px 100px;*/
grid-template-rows: auto 100px;
}
}
@media only screen and (max-width: 768px) {
.main-grid {
transition: margin-left .5s;
display: grid;
height: 98vh;
margin-left: var(--flyout_menu_closed_width);
grid-template-areas: "menuicon gamescreen lefticon"
"menuicon mobile_options lefticon"
"menuicon inputrow lefticon";
grid-template-columns: 30px auto 20px;
grid-template-rows: auto min-content 100px;
}
}
@media only screen and not (max-width: 768px) {
.main-grid.pinned {
@@ -452,6 +464,7 @@ body {
.gamescreen {
background-color: var(--gamescreen_background);
color: white;
width: 100%;
grid-area: gamescreen;
display: flex;
flex-direction: column;
@@ -483,27 +496,60 @@ body {
color: var(--text_edit);
}
.sequence {
@media only screen and not (max-width: 768px) {
.sequence_area {
margin-top: 10px;
grid-area: options;
background-color: var(--gamescreen_background);
overflow-y: scroll;
}
}
table.sequence {
@media only screen and (max-width: 768px) {
.sequence_area {
margin-top: 5px;
grid-area: mobile_options;
background-color: var(--gamescreen_background);
overflow-y: hidden;
}
}
@media only screen and (max-width: 768px) {
.sequences {
width: 100%;
border: 0px;
border-spacing: 0;
display: flex;
flex-direction: row;
overflow-x: scroll;
scroll-snap-type: x mandatory;
}
}
tr.sequence {
@media only screen and not (max-width: 768px) {
.sequences {
width: 100%;
border: 0px;
border-spacing: 0;
display: flex;
flex-direction: column;
}
}
.sequence_row {
scroll-snap-align: start;
margin-top: 0px;
margin-bottom: 0px;
min-width: 100%;
display: grid;
grid-template-areas: "text icon";
grid-template-columns: auto 20px;
}
td.sequence {
.sequence {
border: 1px solid #959595;
border-radius: 5px;
grid-area: text;
padding: 0px;
background-color: var(--options_background);
-moz-transition: all 0.15s ease-in;
@@ -513,7 +559,11 @@ td.sequence {
white-space: pre-wrap;
}
td.sequence:hover {
.sequnce_icon {
grid-area: icon;
}
.sequence:hover {
filter: brightness(70%);
}

View File

@@ -84,23 +84,23 @@ function create_options(data) {
while (option_chunk.firstChild) {
option_chunk.removeChild(option_chunk.firstChild);
}
var table = document.createElement("table");
table.classList.add("sequence");
table.style = "border-spacing: 0;";
var table = document.createElement("div");
table.classList.add("sequences");
//Add Redo options
i=0;
for (item of data.value.options) {
if ((item['Previous Selection'])) {
var row = document.createElement("tr");
row.classList.add("sequence");
var textcell = document.createElement("td");
var row = document.createElement("div");
row.classList.add("sequence_row");
var textcell = document.createElement("span");
textcell.textContent = item.text;
textcell.classList.add("sequence");
textcell.setAttribute("option_id", i);
textcell.setAttribute("option_chunk", data.value.id);
var iconcell = document.createElement("td");
var iconcell = document.createElement("span");
iconcell.setAttribute("option_id", i);
iconcell.setAttribute("option_chunk", data.value.id);
iconcell.classList.add("sequnce_icon");
var icon = document.createElement("span");
icon.id = "Pin_"+i;
icon.classList.add("oi");
@@ -119,16 +119,17 @@ function create_options(data) {
i=0;
for (item of data.value.options) {
if (!(item.Edited) && !(item['Previous Selection'])) {
var row = document.createElement("tr");
row.classList.add("sequence");
var textcell = document.createElement("td");
var row = document.createElement("div");
row.classList.add("sequence_row");
var textcell = document.createElement("span");
textcell.textContent = item.text;
textcell.classList.add("sequence");
textcell.setAttribute("option_id", i);
textcell.setAttribute("option_chunk", data.value.id);
var iconcell = document.createElement("td");
var iconcell = document.createElement("span");
iconcell.setAttribute("option_id", i);
iconcell.setAttribute("option_chunk", data.value.id);
iconcell.classList.add("sequnce_icon");
var icon = document.createElement("span");
icon.id = "Pin_"+i;
icon.classList.add("oi");
@@ -222,7 +223,7 @@ function selected_preset(data) {
var elements_to_change = document.getElementsByClassName("var_sync_model_"+key);
for (item of elements_to_change) {
if (item.tagName.toLowerCase() === 'input') {
item.value = fix_text(value);
item.value = value;
} else {
item.textContent = fix_text(value);
}
@@ -268,6 +269,7 @@ function do_ai_busy(data) {
}
function var_changed(data) {
console.log(data);
//Special Case for Story Text
if ((data.classname == "actions") && (data.name == "Selected Text")) {
do_story_text_updates(data);
@@ -287,7 +289,14 @@ function var_changed(data) {
var elements_to_change = document.getElementsByClassName("var_sync_"+data.classname.replace(" ", "_")+"_"+data.name.replace(" ", "_"));
for (item of elements_to_change) {
if ((item.tagName.toLowerCase() === 'input') || (item.tagName.toLowerCase() === 'select')) {
item.value = fix_text(data.value);
if (item.getAttribute("type") == "checkbox") {
if (item.checked != data.value) {
//not sure why the bootstrap-toggle won't respect a standard item.checked = true/false, so....
item.parentNode.click();
}
} else {
item.value = fix_text(data.value);
}
} else {
item.textContent = fix_text(data.value);
}

View File

@@ -40,14 +40,14 @@
</div>
<!------------ Sequences --------------------->
<div id="action_count" class="var_sync_actions_Action_Count hidden"></div>
<div id="Select Options" class="sequence"></div>
<div id="Select Options" class="sequence_area"></div>
<!------------ Input Area--------------------->
<div class="inputrow" id="inputrow_container">
<textarea id="input_text" placeholder="Enter text here"></textarea>
<div class="statusbar_outer hidden">
<div class="statusbar_inner" style="width:0%">0%</div>
</div><br>
<button type="button" class="btn action_button submit var_sync_alt_system_aibusy" system_aibusy=False id="btnsend" onclick="socket.emit('submit', {'data': document.getElementById('input_text').value});">Submit</button>
<button type="button" class="btn action_button submit var_sync_alt_system_aibusy" system_aibusy=False id="btnsend" onclick="socket.emit('submit', {'data': document.getElementById('input_text').value});this.textContent = '';">Submit</button>
<button type="button" class="btn action_button submited var_sync_alt_system_aibusy" system_aibusy=False id="btnsend"><img src="static/thinking.gif" class="force_center"></button>
<button type="button" class="btn action_button back" onclick="socket.emit('back', {});"><span class="oi" data-glyph="action-undo"></span></button>
<button type="button" class="btn action_button redo" onclick="socket.emit('redo', {});"><span class="oi" data-glyph="action-redo"></span></button>

View File

@@ -27,7 +27,7 @@
<input type=checkbox id="{{ item['classname'] }}_{{ item['name'] }}" class="setting_item_input var_sync_{{ item['classname'] }}_{{ item['name'] }}"
data-size="mini" data-onstyle="success" data-toggle="toggle" onchange='socket.emit("var_change", {"ID": this.id, "value": this.checked});'>
{% elif item['uitype'] == "dropdown" %}
<select id="{{ item['classname'] }}_{{ item['name'] }}" class="settings_select var_sync_{{ item['classname'] }}_{{ item['name'] }}" onclick='socket.emit("var_change", {"ID": this.id, "value": this.value});'>
<select id="{{ item['classname'] }}_{{ item['name'] }}" class="settings_select var_sync_{{ item['classname'] }}_{{ item['name'] }}" onchange='socket.emit("var_change", {"ID": this.id, "value": this.value});'>
{% for option in item['children'] %}
<option value="{{ option['value'] }}">{{ option["text"] }}</option>
{% endfor %}