From 08268860601f61e0d0d0829e673a7189b7db134e Mon Sep 17 00:00:00 2001 From: raylu Date: Fri, 5 Aug 2011 02:05:49 -0700 Subject: add on the page --- main.go | 1 + static/script.js | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index a64aeb4..a278f26 100644 --- a/main.go +++ b/main.go @@ -128,6 +128,7 @@ func add(w http.ResponseWriter, r *http.Request) { http.Error(w, err.String(), http.StatusInternalServerError) return } + w.Write([]byte("1")) } func main() { diff --git a/static/script.js b/static/script.js index 4766387..a958a44 100644 --- a/static/script.js +++ b/static/script.js @@ -139,15 +139,38 @@ function search(query) { } function add(id, title) { + var user = $('#user').val(); params = { 'pid': pid, 'yid': id, 'title': title, - 'user': $('#user').val() + 'user': user } $.getJSON('/add/', params, function(data) { - alert(data); + if (data != 1) + return; + $('article').append('\ +
\ + \ +
' + user + '
\ +
×
\ +
\ +
\ + ' + id + '\ +
\ + \ +
\ + Play\ + Pause\ + Stop\ +
\ +
\ + '); + ids.push(id); + drawBar(id); } ); } -- cgit v1.2.3