Skip to content

Commit 8c722e7

Browse files
committed
v0.2 released, writing and replying supported.
1 parent d2f935e commit 8c722e7

File tree

7 files changed

+196
-74
lines changed

7 files changed

+196
-74
lines changed

bbs_UI.js

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
function UI_register_func(){
22
$('#login-button').live('click',function(){
3-
var auth_code = $('input#auth-code-textbox').attr('value');
4-
$('#global-backdrop').show();
3+
var auth_code = $('input#auth-code-textbox').val();
4+
UI_show_backdrop();
55
getSession(auth_code, UI_session_retrieved);
66
});
77

@@ -55,9 +55,64 @@
5555
$('#notification').fadeOut();
5656
});
5757

58+
$('#reply-post-button').live('click', function(){
59+
getQuote($(this).attr('type'), UI_prepare_reply_post_modal);
60+
});
61+
5862
$('#post-button').live('click', function(){
5963
$('#write-post-window').show();
6064
});
65+
66+
$('#new-post-normal').live('click', UI_prepare_new_post_modal);
67+
68+
$('#publish-post-button').live('click', UI_write_post);
69+
}
70+
71+
function UI_prepare_new_post_modal(){
72+
$('#write-post-panel').attr('post-type', bbs_newpost_type);
73+
$('#write-post-title').val('');
74+
$('#write-post-content').val('');
75+
$('input:text[name=qmd-number]').val('');
76+
$('input:radio[name=qmd-type]').val('number');
77+
$('#write-post-board').text(bbs_current_path.board.name);
78+
$('#write-post-panel').modal('toggle');
79+
}
80+
81+
function UI_prepare_reply_post_modal(quote_content){
82+
$('#write-post-panel').attr('post-type', bbs_replypost_type);
83+
$('#write-post-title').val(quote_content.title);
84+
$('#write-post-content').val(quote_content.content);
85+
$('input:text[name=qmd-number]').val('');
86+
$('input:radio[name=qmd-type]').val('number');
87+
$('#write-post-board').text(bbs_current_path.board.name);
88+
$('#write-post-panel').modal('toggle');
89+
}
90+
91+
function UI_write_post(){
92+
var title = $('#write-post-title').val();
93+
var qmd_type = $('input:radio[name=qmd-type]:checked').val();
94+
var qmd_num = $('input:text[name=qmd-number]').val();
95+
if (qmd_num == '' || qmd_num == null){
96+
qmd_num = 0;
97+
}
98+
if (qmd_type == 'random') {
99+
qmd_num = -1;
100+
}
101+
var content = $('#write-post-content').val();
102+
//TODO: Add anonymouse code when pybbs is available.
103+
var anony = false;
104+
var type = $('#write-post-panel').attr('post-type');
105+
106+
UI_show_backdrop();
107+
writePost(type, title, content, qmd_num, anony, UI_update);
108+
}
109+
110+
function UI_hide_backdrop(){
111+
$('#global-backdrop').hide();
112+
}
113+
114+
function UI_show_backdrop(){
115+
$('#global-backdrop').show();
61116
}
62117

63118
function UI_session_retrieved(session){
@@ -66,7 +121,7 @@ function UI_session_retrieved(session){
66121
}
67122

68123
function UI_init() {
69-
$('#global-backdrop').show();
124+
UI_show_backdrop();
70125

71126
$('a#login-path').attr('href',bbs_server_addr + bbs_auth_path);
72127
$(document).attr("title", bbs_title + 'v' + bbs_version);
@@ -91,7 +146,7 @@ function UI_login_finished(result){
91146
$('#logged-navbar').hide();
92147
$('#logged-panel').hide();
93148
}
94-
$('#global-backdrop').hide();
149+
UI_hide_backdrop();
95150
}
96151

97152
function UI_logout(){
@@ -105,6 +160,7 @@ function UI_logout(){
105160
function UI_update(path, content){
106161
UI_subnavbar_update(path);
107162
UI_maindiv_update(path, content);
163+
UI_hide_backdrop();
108164
$('#logged-panel').show();
109165
}
110166

bbs_post.js

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
function getQuote(mode, callback_func){
2+
if (bbs_current_path.path_level < 3) {
3+
return null;
4+
}
5+
var data = {
6+
session : bbs_session,
7+
board : bbs_current_path.board.name,
8+
id : bbs_current_path.post.id,
9+
xid : bbs_current_path.post.xid,
10+
mode : mode
11+
};
12+
var request_settings = {
13+
url : bbs_server_addr + bbs_getquote_path,
14+
type: 'GET',
15+
data: data,
16+
dataType: 'text',
17+
cache: false
18+
};
19+
20+
var resp = $.ajax(request_settings);
21+
resp.success(function(response){
22+
callback_func(JSON.parse(response));
23+
});
24+
25+
resp.fail(function(jqXHR, textStatus){
26+
var msg = {
27+
type : 'error',
28+
content : 'network_error'
29+
};
30+
UI_notify_update(msg);
31+
});
32+
}
33+
34+
function writePost(type, title, content, qmd_id, anonym, callback_func){
35+
var data = {
36+
session : bbs_session,
37+
title : title,
38+
content: content + '\n\n' + bbs_send_source,
39+
signature_id : qmd_id,
40+
anonymous: (anonym ? 1 : 0)
41+
};
42+
if (type == bbs_newpost_type) {
43+
if (bbs_current_path.path_level != 2){
44+
return;
45+
}
46+
data.board = bbs_current_path.board.name;
47+
} else if (type == bbs_replypost_type) {
48+
if (bbs_current_path.path_level != 3){
49+
return;
50+
}
51+
data.board = bbs_current_path.board.name;
52+
data.re_id = bbs_current_path.post.id;
53+
data.re_xid = bbs_current_path.post.xid;
54+
}
55+
var request_settings = {
56+
url : bbs_server_addr + bbs_writepost_path,
57+
type: 'POST',
58+
data: data,
59+
dataType: 'text',
60+
cache: false
61+
};
62+
63+
var resp = $.ajax(request_settings);
64+
resp.success(function(response){
65+
var msg = {
66+
type : 'info',
67+
content : 'post_publish_success'
68+
};
69+
UI_hide_backdrop();
70+
view_board(bbs_current_path.board.name, -1, -1, callback_func, 'click');
71+
UI_notify_update(msg);
72+
});
73+
74+
resp.fail(function(jqXHR, textStatus){
75+
var msg = {
76+
type : 'error',
77+
content : 'network_error'
78+
};
79+
UI_hide_backdrop();
80+
view_board(bbs_current_path.board.name, -1, -1, callback_func, 'click');
81+
UI_notify_update(msg);
82+
});
83+
}
84+

change_log.txt

Lines changed: 0 additions & 48 deletions
This file was deleted.

config.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ var bbs_allboard_path = '/board/list';
88
var bbs_favboard_path = '/favboard/list';
99
var bbs_postlist_path = '/board/post_list';
1010
var bbs_viewpost_path = '/post/view';
11+
var bbs_getquote_path = '/post/quote';
12+
var bbs_writepost_path = '/post/new';
1113

1214
var bbs_favboard_type = 'FAVBOARD';
1315
var bbs_allboard_type = 'ALLBOARD';
16+
var bbs_newpost_type = 'NEWPOST';
17+
var bbs_replypost_type= 'REPLYPOST';
1418
var bbs_favboard_name = '收藏夹';
1519
var bbs_allboard_name = '所有版面';
1620
var bbs_error_session = 'SESSION_ERROR';
@@ -22,7 +26,8 @@ var bbs_msg = {
2226
board_reach_last : '已到达本版最后一页。',
2327
board_reach_first : '已到达本版第一页。',
2428
post_reach_last : '已到达本版最后一贴。',
25-
post_reach_first : '已到达本版第一帖。'
29+
post_reach_first : '已到达本版第一帖。',
30+
post_publish_success : '帖子发表成功。'
2631
},
2732
error : {
2833
zhname : '错误:',
@@ -42,5 +47,5 @@ var bbs_max_post_count = 999;
4247

4348
var bbs_session_cookie = 'bbs_session';
4449
var bbs_title = '9# BBS - Rowell ';
45-
var bbs_version = '0.1.3';
46-
50+
var bbs_version = '0.2.0';
51+
var bbs_send_source = '[Sent from Rowell v' + bbs_version + ']';

index.html

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -112,24 +112,24 @@ <h1>您尚未登录</h1>
112112
<li><a class='hide' id='post-nav-label'></a></li>
113113
<li class='pull-right'>
114114
<div class='btn-group hide' id='reply-button'>
115-
<button class='btn btn-large btn-success unimplemented'>回复 </button>
115+
<button class='btn btn-large btn-success' href='javascript:void(0)' id='reply-post-button' type='S'>回复 </button>
116116
<button class='btn btn-large btn-success dropdown-toggle' data-toggle='dropdown'>
117117
<span class='caret caret-white'></span>
118118
</button>
119119
<ul class='dropdown-menu'>
120-
<li><a href='javascript:void(0)' class='unimplemented'>普通模式(S)回复</a></li>
121-
<li><a href='javascript:void(0)' class='unimplemented'>R模式回复</a></li>
122-
<li><a href='javascript:void(0)' class='unimplemented'>A模式回复</a></li>
123-
<li><a href='javascript:void(0)' class='unimplemented'>N模式回复</a></li>
120+
<li><a href='javascript:void(0)' id='reply-post-button' type='S'>普通模式(S)回复</a></li>
121+
<li><a href='javascript:void(0)' id='reply-post-button' type='R'>R模式回复</a></li>
122+
<li><a href='javascript:void(0)' id='reply-post-button' type='A'>A模式回复</a></li>
123+
<li><a href='javascript:void(0)' id='reply-post-button' type='N'>N模式回复</a></li>
124124
</ul>
125125
</div>
126126
<div class='btn-group hide' id='post-button'>
127-
<button class='btn btn-large btn-danger' data-toggle='modal' href='#write-post-panel'>发帖</button>
127+
<button class='btn btn-large btn-danger' href='javascript:void(0)' id='new-post-normal'>发帖</button>
128128
<button class='btn btn-large btn-danger dropdown-toggle' data-toggle='dropdown'>
129129
<span class='caret'></span>
130130
</button>
131131
<ul class='dropdown-menu'>
132-
<li><a data-toggle='modal' href='#write-post-panel'>普通模式</a></li>
132+
<li><a href='javascript:void(0)' id='new-post-normal'>普通模式</a></li>
133133
<li><a href='javascript:void(0)' class='unimplemented'>Latex模式(X)</a></li>
134134
<li><a href='javascript:void(0)' class='unimplemented'>使用模板(T)</a></li>
135135
</ul>
@@ -203,18 +203,19 @@ <h3 id='post-panel-title'>发表新文章</h3>
203203
<br>
204204
<div class='write-post-option'>
205205
发表于<label id='write-post-board'><nobr>PC_Games</nobr></label>
206-
<input class='unimplemented anony-checkbox' type='checkbox' name='anonymous' value='0' />匿名
206+
<input class='unimplemented anony-checkbox' type='checkbox' name='anonymous' value='0' disabled='disabled' />匿名
207207
</div>
208208
</div>
209209
<div class='control-group'>
210210
内容:<textarea class='input-xlarge' id='write-post-content'></textarea>
211211
</div>
212212
<div class='write-post-option'>
213213
使用
214-
<input type='radio' class='radiobox' name='qmd-type' checked>随机签名档
215-
&nbsp;&nbsp;&nbsp;
216-
<input type='radio' class='radiobox' name='qmd-type'>
217-
<input type='text' class='short-text' name='qmd-number' value=''>
214+
<input type='radio' class='radiobox unimplemented' name='qmd-type' value='random' disabled='disabled' />
215+
随机签名档
216+
<input type='radio' class='radiobox' name='qmd-type' value='number' checked />
217+
218+
<input type='text' class='short-text' name='qmd-number' value='' />
218219
个签名档
219220
</div>
220221
</fieldset>
@@ -277,6 +278,7 @@ <h3 id='post-panel-title'>发表新文章</h3>
277278
<script src='bbs_login.js'></script>
278279
<script src='bbs_view.js'></script>
279280
<script src='bbs_UI.js'></script>
281+
<script src='bbs_post.js'></script>
280282

281283
<script type='text/javascript'>
282284
$(document).ready(function(){

readme.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,22 @@
1-
#Rowell v0.1.3
1+
#Rowell v0.2.0
22

33
##Introduction
44

55
Rowell is a pure front-end web UI for you-know-which bbs. The web terminal relies on pybbs developed by Henryhu as back-end data exchange interface, and
66
Bootstrap from Twitter as the front-end framework.
77

8-
Rowell is still being developed and has released its 0.0.4 version, which supports login/logout with session cookies, all boards listing and fav boards
9-
listing (sub-folders in favBoard are not supported yet), posts listing in boards, and a basic user interface.
8+
Rowell is still being developed and has released its 0.2.0 version, which supports the following functionals:
9+
10+
* Login/logout with session cookies
11+
12+
* All boards listing and fav boards listing (sub-folders in favBoard are not supported yet)
13+
14+
* Posts listing in boards
15+
16+
* Post reading
17+
18+
* Writing new posts in normal mode, reply posts in S/R/N/A modes. Anonymous posting is not supported yet, random qmd are is not supported yet.
19+
1020

1121
##How to Use it
1222

@@ -30,7 +40,7 @@ WE WILL NEVER BE RESPONSIBLE FOR IE USERS!!!
3040

3141
* CORS support when http error occurs, remove "retry" args in current functions, use the status code to detect error instead.(done in v0.1.2)
3242

33-
* Simple version of writing and replying posts.
43+
* Simple version of writing and replying posts.(done in v0.2.0)
3444

3545
* Add Google Analysis code. (done in v0.1.2)
3646

@@ -42,8 +52,23 @@ WE WILL NEVER BE RESPONSIBLE FOR IE USERS!!!
4252

4353
* Simple ASCII art interpreter.
4454

55+
* Random qmd and anonymous posting.
56+
57+
* Personal information viewing, searching and editing.
58+
59+
* Favboards management.
60+
4561
##Change Logs
4662

63+
####Version 0.2.0
64+
Release date: 06/15/2012
65+
66+
* Writing posts in normal mode are supported
67+
68+
* Replying in S/N/A/R modes are supported. Anonymous posting and random qmd are not supported for writing or replying yet.
69+
70+
* UI slightly adjusted.
71+
4772
####Version 0.1.3
4873
Release date: 06/14/2012
4974

0 commit comments

Comments
 (0)