slight js to update cursor pos upon save
This commit is contained in:
parent
83ec9e831f
commit
6716a76094
23
note.php
23
note.php
|
@ -78,7 +78,12 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
header("Location: note.php?title=" . $title);
|
||||
$noteurl = "Location: note.php?title=" . $title;
|
||||
if (isset($_POST['cursorpos']))
|
||||
{
|
||||
$noteurl .= '&cursorpos=' . $_POST['cursorpos'];
|
||||
}
|
||||
header($noteurl);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
@ -130,17 +135,29 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
||||
<meta charset="UTF-8">
|
||||
<link rel="stylesheet" type="text/css" href="style.css">
|
||||
<script>
|
||||
function updatecursorpos()
|
||||
{
|
||||
cursorpos.value = document.getElementsByTagName("textarea")[0].selectionStart;
|
||||
}
|
||||
function setcursorpos()
|
||||
{
|
||||
params = new URLSearchParams(window.location.search);
|
||||
document.getElementsByTagName("textarea")[0].selectionStart = params.get("cursorpos");
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<body onload="setcursorpos()">
|
||||
<!-- editor -->
|
||||
<div <?php if(isset($_GET['preview'])) echo 'hidden'; ?>>
|
||||
<form action="note.php" method="POST">
|
||||
<form onsubmit="updatecursorpos()" action="note.php" method="POST">
|
||||
<div>
|
||||
<input type="submit" name="home" value="home" accesskey="h">
|
||||
<input type="submit" name="save" value="save" accesskey="s">
|
||||
<input type="submit" name="preview" value="preview" accesskey="p">
|
||||
<input type="submit" name="download" value="download" accesskey="d">
|
||||
<input type="submit" name="delete" value="delete">
|
||||
<input hidden name="cursorpos" id="cursorpos">
|
||||
<input hidden name="lastchanged" value="<?php echo $lastchanged; ?>">
|
||||
<input autocomplete="off" class="title" name="title" value="<?php echo $title; ?>">
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue