LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   JavaScript GUI For shelp.sh - Reading a File in JavaScript, Displayed on Linux Client (https://www.linuxquestions.org/questions/programming-9/javascript-gui-for-shelp-sh-reading-a-file-in-javascript-displayed-on-linux-client-4175735045/)

des_a 03-18-2024 09:11 PM

JavaScript GUI For shelp.sh - Reading a File in JavaScript, Displayed on Linux Client
 
Here is my code:

Code:

<HTML>
<HEAD>
<TITLE>Help Displayer</TITLE>
<SCRIPT LANGUAGE="javaScript">
<!-- Hide javascript
function help(topic, subtopic)
{
 const path = "/etc/settings/shelp/"
 const fr = new FileReader(path + topic + "/" + subtopic)
 fileReader.onload = function(event)
 {
  alert(fileReader.result)
 }
 inputElement.onchange = function(event)
 {
  fileReader.readAsText(event.target.files[0])
 }
}
-->
</SCRIPT>
</HEAD>
<BODY BGCOLOR="green">
<FONT COLOR="blue"><H1 ALIGN="center">Help Displayer</H1>
<FORM>
Help on which topic? <B>TOPIC</B>&nbsp;<INPUT NAME="subject1" TYPE="text">&nbsp;&nbsp;<B>SUBTOPIC</B>&nbsp;<INPUT NAME="subject2" TYPE="text"><BR>
<BR>
<INPUT NAME="submit" TYPE="button" VALUE="Help" onClick="help(this.subject1.value, this.subject2.value)"><BR>
<BR>
<INPUT NAME="reset" TYPE="reset">
</FORM>
</FONT>
</BODY>
</HTML>

I'm trying to create a GUI for my shelp.sh standard script command. Needing to use javascript in an HTML page, is part of my rules of my challenge right now, if I'm going to do it now. I don't want to have to install a server in order to do this. This does nothing on click of the help button. Please help me write the file out as an alert. If it's very, very simple, I'm ok with using other languages as well, as long as JavaScript and HTML integrates it together, and I understand what I'm doing. I will tie it in with the shell scripts, AFTER this works. Please help me. When I finish this, it will be used on my network, and shared via github a few different ways.

des_a 03-18-2024 09:15 PM

If this is impossible, just say so please. Also, I would prefer it's cross browser on Linux, but most of the time, it will probably use firefox. If it's also cross platform, and the thing would work on windows, even better. But I don't want it to get too complicated. The owner of the text files, is root, and they are 777 permissions, but could be changed, as long as it's at least readable by ugo.

des_a 03-18-2024 09:15 PM

I can also install the file into the settings directory, if I must.

michaelk 03-18-2024 09:25 PM

I am not sure it is possible to read a file from the client with a web browser. That would be a big security problem.

des_a 03-19-2024 01:18 AM

Too bad. I'm declaring it as impossible. Thank you though! It was a nice experiment, while it lasted!

NevemTeve 03-19-2024 02:21 PM

Maybe you could right click on your desktop and select `Create shortcut` from the context menu.

dugan 03-19-2024 03:44 PM

You need Electron (or something similar, like nwjs) for this.

des_a 03-20-2024 06:37 AM

I think node.js and electron are outside of the scope of what I'm doing. I'm only trying to create simple things that work on the web right now. I'm just marking it as impossible, and moving on. For this, since what I wanted to do is impossible, I might just use another tool to create a GUI. Later! Done for now. This would be useful to have, but it's not going to make or break me. Maybe as I need specifically the GUI more, I'll revisit this. I'll just keep working on other stuff for now. Thanks anyway though!


All times are GMT -5. The time now is 03:41 AM.