#!/mod/bin/jimsh

package require cgi
source /mod/webif/lib/setup
require plugin

jqplugin enadis tabsupport filetree
jscss script.js style.css
header

set file [cgi_get file -]
set backdesc [cgi_get backdesc "Back to diagnostics"]
set backlink [cgi_get backlink "/diag/diag.jim"]
if {$file ne "-"} {
	puts "<script type=text/javascript>forcefile = '$file';</script>"
}

puts {

<fieldset class=cleft>
<legend>File Editor</legend>

<div id=msg class=blood style="padding-bottom: 0.7em">
Use the <i>Open</i> button below to begin.
</div>

<textarea cols=120 rows=20 id=editor
class="ui-widget ui-corner-all"></textarea>

<br>
<button class=xeditactive id=open>Open</button>
<button class=editactive id=save>Save</button>
<button class=editactive id=revert>Revert</button>
<button class=xeditactive id=create>Create File</button>
<button class=editactive id=executable>Make Executable</button>

<div id=result class="blood hidden" />

</fieldset>

<div class=cleft>
}
puts "<button id=back dst=\"$backlink\">$backdesc</button>"
puts {
</div>

<div id=qedit class=cleft style="margin-top: 1em">
<fieldset>
<legend> Commonly edited files </legend>
<ul>
	<li><a href=# class=qfile>/mod/etc/anacrontab</a></li>
	<li><a href=# class=qfile>/mod/var/spool/cron/crontabs/root</a></li>
	<li><a href=# class=qfile>/mod/webif/html/css/EXTRA.css</a></li>
}

proc quickedit {file} {
	puts "<li><a href=# class=qfile>$file</a></li>"
}

eval_plugins quickedit

puts {
</ul>
</fieldset>
</div>

<div id=chooserd>
	<i>Humax Filesystem</i>
	<div id=chooser></div>
</div>

<div id=createf title="Create new file" style="display: none">
	<form id=createf_form>
	<table border=0>
	<tr>
	<th>
		<label for="createf_name">
			<b>Filename</b>
		</label>
	</th>
	<td>
		<input type=text name="createf_name"
		    id="createf_name"
		    value="/mod/" size=70 maxlength=255
		    class="text ui-widget-content ui-corner-all">
	</td>
	</tr>
	</table>
	</form>
</div>

}

footer

