bugfix: setting focus if /new opened
This commit is contained in:
+10
-10
@@ -10,19 +10,21 @@ var hash = function (input) {
|
||||
}
|
||||
|
||||
var $ = function(id){ return document.getElementById(id); }
|
||||
var $draft = $("draft");
|
||||
var $action = $("action");
|
||||
var $preview = $("preview");
|
||||
var $password = $("password");
|
||||
var $plain_password = $("plain-password");
|
||||
var $input_elems = $("input-elems");
|
||||
var $dashed_line = $("dashed-line");
|
||||
var iosDetected = navigator.userAgent.match("(iPad|iPod|iPhone)");
|
||||
var timer = null;
|
||||
var timerDelay = iosDetected ? 800 : 400;
|
||||
var show = function(elem) { elem.style.display = "block" }
|
||||
var $draft, $action, $preview, $password, $plain_password, $input_elems, $dashed_line, updatePreview;
|
||||
|
||||
var updatePreview = function(){
|
||||
function loadPage() {
|
||||
$draft = $("draft");
|
||||
$action = $("action");
|
||||
$preview = $("preview");
|
||||
$password = $("password");
|
||||
$plain_password = $("plain-password");
|
||||
$input_elems = $("input-elems");
|
||||
$dashed_line = $("dashed-line");
|
||||
updatePreview = function(){
|
||||
clearTimeout(timer);
|
||||
var content = $draft.value;
|
||||
var delay = Math.min(timerDelay, timerDelay * (content.length / 400));
|
||||
@@ -32,8 +34,6 @@ var updatePreview = function(){
|
||||
$preview.innerHTML = marked(content);
|
||||
}, delay);
|
||||
};
|
||||
|
||||
function loadPage() {
|
||||
if($action){
|
||||
if($action.value == "update") updatePreview(); else $draft.value = "";
|
||||
$draft.onkeyup = updatePreview;
|
||||
|
||||
Reference in New Issue
Block a user