68 lines
1.7 KiB
PHP
68 lines
1.7 KiB
PHP
<?php
|
|
global $c;
|
|
$strFile = "site.js";
|
|
$strContent = "";
|
|
|
|
UserAuth::requirePermission("admin");
|
|
|
|
if (file_exists($strFile))
|
|
$strContent = file_get_contents($strFile);
|
|
|
|
if (Request::posts("content"))
|
|
{
|
|
$strContent = Request::getPosted("content");
|
|
file_put_contents($strFile, $strContent);
|
|
}
|
|
?>
|
|
|
|
<style>
|
|
textarea {
|
|
font-family: monospace;
|
|
}
|
|
</style>
|
|
|
|
<form method="post">
|
|
<div class="navbar navbar-expand bg-body-tertiary d-flex px-3 sticky-top">
|
|
<div class="container justify-content-between">
|
|
<div class="navbar-nav d-inline-flex align-items-center">
|
|
<span class="navbar-brand"><?= $strFile; ?></span>
|
|
|
|
<a class="btn btn-outline-success text-nowrap" onclick="fnSave();"><i class="fa fa-fw fa-save"></i> Save</a>
|
|
</div>
|
|
|
|
<div class="navbar-nav d-inline-flex">
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<?php /**/ ?>
|
|
<div class="container my-5">
|
|
<div class="row">
|
|
<textarea
|
|
class="form-control border-0 shadow-none"
|
|
name="content"
|
|
placeholder="Enter content here..."
|
|
oninput="fnResize(this);"
|
|
autocomplete="off"
|
|
autocorrect="off"
|
|
autocapitalize="off"
|
|
spellcheck="false"><?= $strContent; ?></textarea>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
|
|
<script>
|
|
$(function() {
|
|
fnSave = function() {
|
|
$("form").first().submit();
|
|
};
|
|
|
|
fnResize = function(x) {
|
|
x.style.height = "auto";
|
|
x.style.height = x.scrollHeight + "px";
|
|
};
|
|
|
|
fnResize($("textarea").first()[0]);
|
|
});
|
|
</script>
|