mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-12 02:32:10 +00:00
Fixes trimming and file browser.
Adds a option to stripped_input and stripped_multiline_input to not trim text. File browser uses these instead of input. File browser also has it's file listing fixed. Surprised it wasn't fixed sooner.
This commit is contained in:
@@ -81,14 +81,21 @@
|
|||||||
return text //only accepts the text if it has some non-spaces
|
return text //only accepts the text if it has some non-spaces
|
||||||
|
|
||||||
// Used to get a properly sanitized input, of max_length
|
// Used to get a properly sanitized input, of max_length
|
||||||
/proc/stripped_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN)
|
// no_trim is self explanatory but it prevents the input from being trimed if you intend to parse newlines or whitespace.
|
||||||
|
/proc/stripped_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE)
|
||||||
var/name = input(user, message, title, default) as text|null
|
var/name = input(user, message, title, default) as text|null
|
||||||
|
if(no_trim)
|
||||||
|
return copytext(html_encode(name), 1, max_length)
|
||||||
|
else
|
||||||
return trim(html_encode(name), max_length) //trim is "outside" because html_encode can expand single symbols into multiple symbols (such as turning < into <)
|
return trim(html_encode(name), max_length) //trim is "outside" because html_encode can expand single symbols into multiple symbols (such as turning < into <)
|
||||||
|
|
||||||
// Used to get a properly sanitized multiline input, of max_length
|
// Used to get a properly sanitized multiline input, of max_length
|
||||||
/proc/stripped_multiline_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN)
|
/proc/stripped_multiline_input(mob/user, message = "", title = "", default = "", max_length=MAX_MESSAGE_LEN, no_trim=FALSE)
|
||||||
var/name = input(user, message, title, default) as message|null
|
var/name = input(user, message, title, default) as message|null
|
||||||
return html_encode(trim(name, max_length))
|
if(no_trim)
|
||||||
|
return copytext(html_encode(name), 1, max_length)
|
||||||
|
else
|
||||||
|
return trim(html_encode(name), max_length)
|
||||||
|
|
||||||
//Filters out undesirable characters from names
|
//Filters out undesirable characters from names
|
||||||
/proc/reject_bad_name(t_in, allow_numbers=0, max_length=MAX_NAME_LEN)
|
/proc/reject_bad_name(t_in, allow_numbers=0, max_length=MAX_NAME_LEN)
|
||||||
|
|||||||
@@ -24,7 +24,7 @@
|
|||||||
open_file = params["name"]
|
open_file = params["name"]
|
||||||
if("PRG_newtextfile")
|
if("PRG_newtextfile")
|
||||||
. = 1
|
. = 1
|
||||||
var/newname = sanitize(input(usr, "Enter file name or leave blank to cancel:", "File rename"))
|
var/newname = stripped_input(usr, "Enter file name or leave blank to cancel:", "File rename", max_length=50)
|
||||||
if(!newname)
|
if(!newname)
|
||||||
return 1
|
return 1
|
||||||
if(!HDD)
|
if(!HDD)
|
||||||
@@ -69,7 +69,7 @@
|
|||||||
var/datum/computer_file/file = HDD.find_file_by_name(params["name"])
|
var/datum/computer_file/file = HDD.find_file_by_name(params["name"])
|
||||||
if(!file || !istype(file))
|
if(!file || !istype(file))
|
||||||
return 1
|
return 1
|
||||||
var/newname = sanitize(input(usr, "Enter new file name:", "File rename", file.filename))
|
var/newname = stripped_input(usr, "Enter new file name:", "File rename", file.filename, max_length=50)
|
||||||
if(file && newname)
|
if(file && newname)
|
||||||
file.filename = newname
|
file.filename = newname
|
||||||
if("PRG_edit")
|
if("PRG_edit")
|
||||||
@@ -84,7 +84,7 @@
|
|||||||
if(F.do_not_edit && (alert("WARNING: This file is not compatible with editor. Editing it may result in permanently corrupted formatting or damaged data consistency. Edit anyway?", "Incompatible File", "No", "Yes") == "No"))
|
if(F.do_not_edit && (alert("WARNING: This file is not compatible with editor. Editing it may result in permanently corrupted formatting or damaged data consistency. Edit anyway?", "Incompatible File", "No", "Yes") == "No"))
|
||||||
return 1
|
return 1
|
||||||
// 16384 is the limit for file length in characters. Currently, papers have value of 2048 so this is 8 times as long, since we can't edit parts of the file independently.
|
// 16384 is the limit for file length in characters. Currently, papers have value of 2048 so this is 8 times as long, since we can't edit parts of the file independently.
|
||||||
var/newtext = sanitize(html_decode(input(usr, "Editing file [open_file]. You may use most tags used in paper formatting:", "Text Editor", html_decode(F.stored_data)) as message|null), 16384)
|
var/newtext = stripped_multiline_input(usr, "Editing file [open_file]. You may use most tags used in paper formatting:", "Text Editor", html_decode(F.stored_data), 16384, TRUE)
|
||||||
if(!newtext)
|
if(!newtext)
|
||||||
return
|
return
|
||||||
if(F)
|
if(F)
|
||||||
|
|||||||
@@ -268,7 +268,7 @@
|
|||||||
|
|
||||||
if(href_list["write"])
|
if(href_list["write"])
|
||||||
var/id = href_list["write"]
|
var/id = href_list["write"]
|
||||||
var/t = stripped_multiline_input("Enter what you want to write:", "Write")
|
var/t = stripped_multiline_input("Enter what you want to write:", "Write", no_trim=TRUE)
|
||||||
if(!t)
|
if(!t)
|
||||||
return
|
return
|
||||||
var/obj/item/i = usr.get_active_held_item() //Check to see if he still got that darn pen, also check if he's using a crayon or pen.
|
var/obj/item/i = usr.get_active_held_item() //Check to see if he still got that darn pen, also check if he's using a crayon or pen.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -53,14 +53,17 @@
|
|||||||
{{else}}
|
{{else}}
|
||||||
<h2>Available files (local):</h2>
|
<h2>Available files (local):</h2>
|
||||||
<table>
|
<table>
|
||||||
<tr><th>File name
|
<tr>
|
||||||
<th>File type
|
<th>File name</th>
|
||||||
<th>File size (GQ)
|
<th>File type</th>
|
||||||
<th>Operations
|
<th>File size (GQ)</th>
|
||||||
|
<th>Operations</th>
|
||||||
|
</tr>
|
||||||
{{#each data.files}}
|
{{#each data.files}}
|
||||||
<tr><td>{{name}}
|
<tr>
|
||||||
<td>.{{type}}
|
<td>{{name}}</td>
|
||||||
<td>{{size}}GQ
|
<td>.{{type}}</td>
|
||||||
|
<td>{{size}}GQ</td>
|
||||||
<td>
|
<td>
|
||||||
<ui-button action='PRG_openfile' params='{"name": "{{name}}"}'>VIEW</ui-button>
|
<ui-button action='PRG_openfile' params='{"name": "{{name}}"}'>VIEW</ui-button>
|
||||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_deletefile' params='{"name": "{{name}}"}'>DELETE</ui-button>
|
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_deletefile' params='{"name": "{{name}}"}'>DELETE</ui-button>
|
||||||
@@ -69,24 +72,31 @@
|
|||||||
{{#if data.usbconnected}}
|
{{#if data.usbconnected}}
|
||||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_copytousb' params='{"name": "{{name}}"}'>EXPORT</ui-button>
|
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_copytousb' params='{"name": "{{name}}"}'>EXPORT</ui-button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</table>
|
</table>
|
||||||
{{#if data.usbconnected}}
|
{{#if data.usbconnected}}
|
||||||
<h2>Available files (portable device):</h2>
|
<h2>Available files (portable device):</h2>
|
||||||
<table>
|
<table>
|
||||||
<tr><th>File name
|
<tr>
|
||||||
<th>File type
|
<th>File name</th>
|
||||||
<th>File size (GQ)
|
<th>File type</th>
|
||||||
<th>Operations
|
<th>File size (GQ)</th>
|
||||||
|
<th>Operations</th>
|
||||||
|
</tr>
|
||||||
{{#each data.usbfiles}}
|
{{#each data.usbfiles}}
|
||||||
<tr><td>{{name}}
|
<tr>
|
||||||
<td>.{{type}}
|
<td>{{name}}</td>
|
||||||
<td>{{size}}GQ
|
<td>.{{type}}</td>
|
||||||
|
<td>{{size}}GQ</td>
|
||||||
<td>
|
<td>
|
||||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_usbdeletefile' params='{"name": "{{name}}"}'>DELETE</ui-button>
|
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_usbdeletefile' params='{"name": "{{name}}"}'>DELETE</ui-button>
|
||||||
{{#if data.usbconnected}}
|
{{#if data.usbconnected}}
|
||||||
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_copyfromusb' params='{"name": "{{name}}"}'>IMPORT</ui-button>
|
<ui-button state='{{undeletable ? "disabled" : null}}' action='PRG_copyfromusb' params='{"name": "{{name}}"}'>IMPORT</ui-button>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</table>
|
</table>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|||||||
Reference in New Issue
Block a user