From 246528966650304afe62a6aa2fd04fdc2d80e1fe Mon Sep 17 00:00:00 2001 From: shaoying Date: Thu, 25 Oct 2018 09:29:51 +0800 Subject: [PATCH] mac add check_argument --- Makefile | 2 +- etc/dotsfile/.vimrc | 5 ++--- src/contexts/nfs/nfs.go | 2 ++ usr/library/base.js | 23 +++++++++++++++-------- usr/template/common/base.tmpl | 3 ++- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 8b1557c7..4b4c5b29 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ build: go build $(BENCH) run: - etc/run.sh + etc/run.sh 2>var/error.log win64: GOARCH=amd64 GOOS=windows go build $(BENCH) diff --git a/etc/dotsfile/.vimrc b/etc/dotsfile/.vimrc index 39d72364..f7b0d55b 100644 --- a/etc/dotsfile/.vimrc +++ b/etc/dotsfile/.vimrc @@ -8,6 +8,8 @@ "加载插件"{{{ call plug#begin() Plug 'vim-scripts/tComment' +Plug 'gcmt/taboo.vim' +Plug 'vim-scripts/tComment' Plug 'tpope/vim-fugitive' Plug 'airblade/vim-gitgutter' Plug 'vim-airline/vim-airline' @@ -15,9 +17,6 @@ Plug 'vim-airline/vim-airline-themes' Plug 'ntpeters/vim-better-whitespace' Plug 'easymotion/vim-easymotion' -Plug 'gcmt/taboo.vim' -set sessionoptions+=tabpages,globals - Plug 'vim-scripts/taglist.vim' let g:Tlist_WinWidth=45 let g:Tlist_Exit_OnlyWindow=1 diff --git a/src/contexts/nfs/nfs.go b/src/contexts/nfs/nfs.go index 7904ec3e..c661cea4 100644 --- a/src/contexts/nfs/nfs.go +++ b/src/contexts/nfs/nfs.go @@ -131,6 +131,8 @@ func dir(m *ctx.Message, name string, level int, deep bool, fields []string) { case "filename": m.Add("append", "filename", filename) case "is_dir": + f, e := os.Stat(filename) + m.Assert(e) m.Add("append", "is_dir", f.IsDir()) case "size": m.Add("append", "size", f.Size()) diff --git a/usr/library/base.js b/usr/library/base.js index 27c7e0f3..e5dbe21d 100644 --- a/usr/library/base.js +++ b/usr/library/base.js @@ -63,14 +63,27 @@ function send_command(form, cb) { typeof(cb) == "function" && cb(msg) }) } +function check_argument(form, target) { + for (var i = 0; i < form.length-1; i++) { + if (form[i] == target) { + if (form[i+1].type == "button") { + form[i+1].click() + } else { + form[i+1].focus() + } + return false + } + } + send_command(form) +} function onaction(event, action) { switch (action) { case "click": if (event.target.nodeName == "INPUT") { if (event.altKey) { - console.log("fuck") var board = document.querySelector("#clipboard") event.target.value = board.value + check_argument(event.target.form, event.target) } } break @@ -80,13 +93,7 @@ function onaction(event, action) { case "input": switch (event.key) { case "Enter": - var form = event.target.form - for (var i = 0; i < form.length; i++) { - if (form[i] == event.target) { - continue - } - (i == form.length-1)? send_command(form): form[i+1].focus() - } + check_argument(event.target.form, event.target) break case "Escape": event.target.value = "" diff --git a/usr/template/common/base.tmpl b/usr/template/common/base.tmpl index 1e9396b9..880ba7ee 100644 --- a/usr/template/common/base.tmpl +++ b/usr/template/common/base.tmpl @@ -97,13 +97,14 @@ {{if eq $form_type "upload"}} method="POST" action="/upload" enctype="multipart/form-data" {{end}} + onsubmit="onaction(event,'submit')" > {{range $index, $input := option . "inputs"}}
{{$type := index $input "type"}} {{if eq $type "button"}} - + {{else if eq $type "submit"}} {{else if eq $type "file"}}