From d76441e80ad0af2ef28a3adaa3fa7e916e722511 Mon Sep 17 00:00:00 2001 From: Hironsan Date: Mon, 13 Aug 2018 14:19:57 +0900 Subject: [PATCH] Refactor seq2seq.js --- app/db.sqlite3 | Bin 241664 -> 241664 bytes app/server/static/bundle/seq2seq.js | 2 +- app/server/static/js/seq2seq.js | 124 ++++++++++--------- app/server/templates/annotation/seq2seq.html | 10 +- 4 files changed, 69 insertions(+), 67 deletions(-) diff --git a/app/db.sqlite3 b/app/db.sqlite3 index 0df78685148b925f5c083eb5f212c67adf986067..10fc26ffdd8240e8be386e11634646d0610ea450 100644 GIT binary patch delta 1901 zcma)-Z;0Du9LMwIN&jTp{L*W={=ep`Hw(vQ$oEn#dTc%K>UOPO z#i5i<+#5w@qc0-t&6L~rN_MldBK{dV1Q`l4d?DM^d*KU}`43B9sGv_Wx89^{2g!#d z{J!5O`F)dL4z3Fa*M-9gR6mlu7u8P}Po(3kKKKw`hgHbJ0Vu;XgoMk&Cqi3TZH`KZ z1Wz)A??LwVU2N3LMT1yJc5sdjH!jH!qi`d;gUf8U2f%@4LbxRxD)qYV5F zU%+Q@4nBhSpaVa__wX%z4Hw`yXu{iY65fQP&0w(tBOZ(p4!aDw9C8_SDcbL!MX|<( zU+=gboC_?6G0$&mqT)a4x2huD-l=lpNp2e|;tc4v?-hK&q4NpM{cERH?3p4Nl zOu^ltx3b63AHpM!kuT$N)TQJy?b5v;U&=jBx=gr?yNtPvx{SCSwqH7hUZjifuzhQ2 zJPr-o%$MO1ZRYdvEL7=zEWkWG0Xyj9-Ud?~=26DMr~}DC+QEo}l!K&$goC()n1iST z+GidOx8695_KG;;v25R$bV2@8zQV`+=luKp5#PtYIq#3&x;N-K?y;Jx_%k6>o{cZKZwz<5llAJ+ES?b!F{cW{duvKN%$`fLi z(_Pzqf7{$(TcXPb$y-Dzk92K~{6Y*m@)s%dHERM%GTZ>wIly}wUnsv)a+i?+9r zq_)%i_|4x0yLu6Ara>$D$sCa_P0~y<^&_BC@FvqMLawnwv>Oi%^9;9$oUw*KZW>eWvT4! zVG;j#Wl!ZvX`xct17{SLEBaYzGw>(0>D>4M+>sOJoRI@~6T>hpbQt&xI<4Sg_6qoU z#5vOepIKv3aa>3-LxB#4^KcsW(;2h~MR*Lh!e$82!F~x|33P;ah1Y}yVJjW-=K}}E zM2?w3{a-aAW4dl;x^LN7c(9QnkxuJ|Zm8>7rqQzC;If>IBZ57Z#u2+c wf*V=-EMqWOrnXL{@tjE0SZCOV delta 433 zcmXv~OGsN$6ujr1mppH1?z|X7Z2bhQlz>nbaVaXLAm~C7p*x?8Mv;oy2tpUNNa?O9 zSzMPYepaQ40Yj)C(2WR!y0VRkpit;S8whR`>TN+do0&7rnKRQDYWhOWR#9TE`V}QI z-fHaGii0hD!7}3bfHCwStj^S~DyfxhUGpd9s|s_w)O|x%rLQu?ZKOkkRz<4tvX@jU z-t^udiQ3#sx;ReZ>}FGUx;BWsz&#GJk3DQ7k6Zl470z*r6a2}BJPrMQhn}WRZt9<~ zkBKasS;|0`yuY!fq-$n9X}fE7CwUyfjCL02xxB0fj|FmP^zn~jwi@Z7mf~p{JfX~Qa3Q3H@!y9zq1%jr&f~haB vtf {\n this.items[this.cur]['labels'].push(response.data)\n })\n\n this.newTodo = ''\n },\n\n removeTodo: function (todo) {\n var doc_id = this.items[this.cur].id;\n _http_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].delete(`docs/${doc_id}/annotations/${todo.id}`).then(response => {\n this.items[this.cur]['labels'].splice(this.items[this.cur]['labels'].indexOf(todo), 1)\n });\n },\n\n editTodo: function (todo) {\n this.beforeEditCache = todo.text\n this.editedTodo = todo\n },\n\n doneEdit: function (todo) {\n if (!this.editedTodo) {\n return\n }\n this.editedTodo = null\n todo.text = todo.text.trim()\n if (!todo.text) {\n this.removeTodo(todo)\n }\n var doc_id = this.items[this.cur].id;\n _http_js__WEBPACK_IMPORTED_MODULE_2__[\"default\"].put(`docs/${doc_id}/annotations/${todo.id}`, todo).then(response => {\n console.log(response)\n });\n },\n\n cancelEdit: function (todo) {\n this.editedTodo = null\n todo.text = this.beforeEditCache\n }\n },\n created: function () {\n this.submit();\n }\n});\n\n//# sourceURL=webpack:///./static/js/seq2seq.js?"); +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var vue__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! vue */ \"./node_modules/vue/dist/vue.esm.js\");\n/* harmony import */ var _mixin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mixin */ \"./static/js/mixin.js\");\n/* harmony import */ var _http__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./http */ \"./static/js/http.js\");\n\n\n\n\nvue__WEBPACK_IMPORTED_MODULE_0__[\"default\"].use(__webpack_require__(/*! vue-shortkey */ \"./node_modules/vue-shortkey/dist/index.js\"));\n\n\nconst vm = new vue__WEBPACK_IMPORTED_MODULE_0__[\"default\"]({\n el: '#mail-app',\n delimiters: ['[[', ']]'],\n data: {\n newTodo: '',\n editedTodo: null,\n },\n mixins: [_mixin__WEBPACK_IMPORTED_MODULE_1__[\"default\"]],\n directives: {\n 'todo-focus': function(el, binding) {\n if (binding.value) {\n el.focus();\n }\n },\n },\n\n methods: {\n addTodo() {\n const value = this.newTodo && this.newTodo.trim();\n if (!value) {\n return;\n }\n\n const docId = this.docs[this.pageNumber].id;\n const payload = {\n text: value,\n };\n _http__WEBPACK_IMPORTED_MODULE_2__[\"default\"].post(`docs/${docId}/annotations/`, payload).then((response) => {\n this.annotations[this.pageNumber].push(response.data);\n });\n\n this.newTodo = '';\n },\n\n removeTodo(todo) {\n const docId = this.docs[this.pageNumber].id;\n _http__WEBPACK_IMPORTED_MODULE_2__[\"default\"].delete(`docs/${docId}/annotations/${todo.id}`).then((response) => {\n const index = this.annotations[this.pageNumber].indexOf(todo);\n this.annotations[this.pageNumber].splice(index, 1);\n });\n },\n\n editTodo(todo) {\n this.beforeEditCache = todo.text;\n this.editedTodo = todo;\n },\n\n doneEdit(todo) {\n if (!this.editedTodo) {\n return;\n }\n this.editedTodo = null;\n todo.text = todo.text.trim();\n if (!todo.text) {\n this.removeTodo(todo);\n }\n const docId = this.docs[this.pageNumber].id;\n _http__WEBPACK_IMPORTED_MODULE_2__[\"default\"].put(`docs/${docId}/annotations/${todo.id}`, todo).then((response) => {\n console.log(response);\n });\n },\n\n cancelEdit(todo) {\n this.editedTodo = null;\n todo.text = this.beforeEditCache;\n },\n },\n});\n\n\n//# sourceURL=webpack:///./static/js/seq2seq.js?"); /***/ }) diff --git a/app/server/static/js/seq2seq.js b/app/server/static/js/seq2seq.js index eb1a4337..705d4717 100644 --- a/app/server/static/js/seq2seq.js +++ b/app/server/static/js/seq2seq.js @@ -1,73 +1,75 @@ import Vue from 'vue'; +import annotationMixin from './mixin'; +import HTTP from './http'; + Vue.use(require('vue-shortkey')); -import annotationMixin from './mixin.js'; -import HTTP from './http.js'; -var vm = new Vue({ - el: '#mail-app', - delimiters: ['[[', ']]'], - data: { - newTodo: '', - editedTodo: null - }, - mixins: [annotationMixin], - directives: { - 'todo-focus': function (el, binding) { - if (binding.value) { - el.focus() - } - } +const vm = new Vue({ + el: '#mail-app', + delimiters: ['[[', ']]'], + data: { + newTodo: '', + editedTodo: null, + }, + mixins: [annotationMixin], + directives: { + 'todo-focus': function(el, binding) { + if (binding.value) { + el.focus(); + } }, - methods: { - addTodo: function () { - var value = this.newTodo && this.newTodo.trim() - if (!value) { - return - } + }, - var doc_id = this.items[this.cur].id; - var payload = {text: value} - HTTP.post(`docs/${doc_id}/annotations/`, payload).then(response => { - this.items[this.cur]['labels'].push(response.data) - }) + methods: { + addTodo() { + const value = this.newTodo && this.newTodo.trim(); + if (!value) { + return; + } - this.newTodo = '' - }, + const docId = this.docs[this.pageNumber].id; + const payload = { + text: value, + }; + HTTP.post(`docs/${docId}/annotations/`, payload).then((response) => { + this.annotations[this.pageNumber].push(response.data); + }); - removeTodo: function (todo) { - var doc_id = this.items[this.cur].id; - HTTP.delete(`docs/${doc_id}/annotations/${todo.id}`).then(response => { - this.items[this.cur]['labels'].splice(this.items[this.cur]['labels'].indexOf(todo), 1) - }); - }, + this.newTodo = ''; + }, - editTodo: function (todo) { - this.beforeEditCache = todo.text - this.editedTodo = todo - }, + removeTodo(todo) { + const docId = this.docs[this.pageNumber].id; + HTTP.delete(`docs/${docId}/annotations/${todo.id}`).then((response) => { + const index = this.annotations[this.pageNumber].indexOf(todo); + this.annotations[this.pageNumber].splice(index, 1); + }); + }, - doneEdit: function (todo) { - if (!this.editedTodo) { - return - } - this.editedTodo = null - todo.text = todo.text.trim() - if (!todo.text) { - this.removeTodo(todo) - } - var doc_id = this.items[this.cur].id; - HTTP.put(`docs/${doc_id}/annotations/${todo.id}`, todo).then(response => { - console.log(response) - }); - }, + editTodo(todo) { + this.beforeEditCache = todo.text; + this.editedTodo = todo; + }, + + doneEdit(todo) { + if (!this.editedTodo) { + return; + } + this.editedTodo = null; + todo.text = todo.text.trim(); + if (!todo.text) { + this.removeTodo(todo); + } + const docId = this.docs[this.pageNumber].id; + HTTP.put(`docs/${docId}/annotations/${todo.id}`, todo).then((response) => { + console.log(response); + }); + }, - cancelEdit: function (todo) { - this.editedTodo = null - todo.text = this.beforeEditCache - } + cancelEdit(todo) { + this.editedTodo = null; + todo.text = this.beforeEditCache; }, - created: function () { - this.submit(); - } -}); \ No newline at end of file + }, +}); diff --git a/app/server/templates/annotation/seq2seq.html b/app/server/templates/annotation/seq2seq.html index 14e1a340..b7d33797 100644 --- a/app/server/templates/annotation/seq2seq.html +++ b/app/server/templates/annotation/seq2seq.html @@ -1,8 +1,8 @@ {% extends "annotation/annotation_base.html" %} {% load static %} {% block annotation-area %}
-
-
- [[ items[cur].text ]] +
+
+ [[ docs[pageNumber].text ]]
@@ -15,9 +15,9 @@ v-model="newTodo" @keyup.enter="addTodo"> -
+
    -
  • +