aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/css/index.less2
-rw-r--r--src/css/manage_dash.less12
-rw-r--r--src/css/manage_problem.less5
-rw-r--r--src/html/index.html26
-rw-r--r--src/html/manage_dash.html18
-rw-r--r--src/html/manage_problem.html19
-rw-r--r--src/html/manage_square.html5
-rw-r--r--src/js/com.js22
-rw-r--r--src/js/imc.js19
-rw-r--r--src/js/index.js32
-rw-r--r--src/js/manage.js174
-rw-r--r--src/js/mod.js57
-rw-r--r--src/js/notice.js30
-rw-r--r--src/js/square.js357
-rw-r--r--src/js/user.js81
-rw-r--r--src/pmod/pmod_test/css/manage.css4
-rw-r--r--src/pmod/pmod_test/css/manage.less7
-rw-r--r--src/pmod/pmod_test/css/view.css0
-rw-r--r--src/pmod/pmod_test/css/view.less0
-rw-r--r--src/pmod/pmod_test/html/manage.html144
-rw-r--r--src/pmod/pmod_test/html/view.html10
-rw-r--r--src/pmod/pmod_test/js/pmod_test.js317
-rw-r--r--src/pmod/pmod_test/py/__pycache__/pmod_test.cpython-33.pycbin0 -> 19948 bytes
-rw-r--r--src/pmod/pmod_test/py/pmod_test.py538
-rwxr-xr-xsrc/py/backend_server.py4
-rwxr-xr-xsrc/py/imc/blobclient.py38
-rwxr-xr-xsrc/py/imc/blobserver.py4
-rwxr-xr-xsrc/py/imc/proxy.py3
-rw-r--r--src/py/mod.py15
-rw-r--r--src/py/notice.py17
-rw-r--r--src/py/problem.py91
-rw-r--r--src/py/square.py41
-rwxr-xr-xsrc/py/tojauth.py5
-rw-r--r--src/sqmod/sqmod_test/css/index.css36
-rw-r--r--src/sqmod/sqmod_test/css/index.less43
-rw-r--r--src/sqmod/sqmod_test/css/manage.css0
-rw-r--r--src/sqmod/sqmod_test/css/manage.less3
-rw-r--r--src/sqmod/sqmod_test/html/IMSOHAPPY.jpgbin0 -> 52831 bytes
-rw-r--r--src/sqmod/sqmod_test/html/IMSOHAPPY.oggbin0 -> 1919144 bytes
-rw-r--r--src/sqmod/sqmod_test/html/JOMANDA.jpgbin0 -> 36987 bytes
-rw-r--r--src/sqmod/sqmod_test/html/JOMANDA.ju736
-rw-r--r--src/sqmod/sqmod_test/html/JOMANDA.oggbin0 -> 2469251 bytes
-rw-r--r--src/sqmod/sqmod_test/html/MOTHERSHIP.oggbin0 -> 2480363 bytes
-rw-r--r--src/sqmod/sqmod_test/html/MOTHERSHIP.pngbin0 -> 186901 bytes
-rw-r--r--src/sqmod/sqmod_test/html/Saucer-Bold.ttfbin0 -> 52384 bytes
-rw-r--r--src/sqmod/sqmod_test/html/Saucer-Light.ttfbin0 -> 54640 bytes
-rw-r--r--src/sqmod/sqmod_test/html/Saucer-Mono.ttfbin0 -> 50476 bytes
-rw-r--r--src/sqmod/sqmod_test/html/Saucer-Regular.ttfbin0 -> 55560 bytes
-rw-r--r--src/sqmod/sqmod_test/html/index.html10
-rw-r--r--src/sqmod/sqmod_test/html/light.pngbin0 -> 2618 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_0.pngbin0 -> 14954 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_1.pngbin0 -> 32903 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_10.pngbin0 -> 21688 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_11.pngbin0 -> 17865 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_12.pngbin0 -> 12937 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_2.pngbin0 -> 32115 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_3.pngbin0 -> 35166 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_4.pngbin0 -> 35076 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_5.pngbin0 -> 31602 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_6.pngbin0 -> 29979 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_7.pngbin0 -> 27447 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_8.pngbin0 -> 25898 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/_9.pngbin0 -> 23942 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_0.pngbin0 -> 49880 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_1.pngbin0 -> 46045 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_10.pngbin0 -> 64994 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_11.pngbin0 -> 65012 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_12.pngbin0 -> 65015 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_13.pngbin0 -> 63765 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_14.pngbin0 -> 56205 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_2.pngbin0 -> 48571 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_3.pngbin0 -> 52367 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_4.pngbin0 -> 52235 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_5.pngbin0 -> 52706 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_6.pngbin0 -> 53694 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_7.pngbin0 -> 57840 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_8.pngbin0 -> 62728 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/at_9.pngbin0 -> 64615 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_0.pngbin0 -> 32572 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_1.pngbin0 -> 40908 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_10.pngbin0 -> 50485 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_11.pngbin0 -> 49436 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_12.pngbin0 -> 46822 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_13.pngbin0 -> 29266 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_2.pngbin0 -> 41268 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_3.pngbin0 -> 41899 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_4.pngbin0 -> 41801 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_5.pngbin0 -> 41990 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_6.pngbin0 -> 46122 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_7.pngbin0 -> 48842 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_8.pngbin0 -> 51174 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/d_9.pngbin0 -> 50951 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_0.pngbin0 -> 46324 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_1.pngbin0 -> 42534 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_10.pngbin0 -> 70074 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_11.pngbin0 -> 74153 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_12.pngbin0 -> 75925 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_13.pngbin0 -> 77252 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_14.pngbin0 -> 75402 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_2.pngbin0 -> 42534 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_3.pngbin0 -> 44603 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_4.pngbin0 -> 45660 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_5.pngbin0 -> 46743 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_6.pngbin0 -> 48364 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_7.pngbin0 -> 49789 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_8.pngbin0 -> 54476 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/fect_9.pngbin0 -> 60911 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_0.pngbin0 -> 8214 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_1.pngbin0 -> 13598 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_10.pngbin0 -> 32218 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_11.pngbin0 -> 34150 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_12.pngbin0 -> 32117 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_13.pngbin0 -> 31203 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_14.pngbin0 -> 30132 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_2.pngbin0 -> 16929 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_3.pngbin0 -> 18963 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_4.pngbin0 -> 21349 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_5.pngbin0 -> 22957 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_6.pngbin0 -> 24257 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_7.pngbin0 -> 26567 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_8.pngbin0 -> 28303 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/mal_9.pngbin0 -> 29293 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/malpassed_0.pngbin0 -> 29817 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/malpassed_1.pngbin0 -> 29529 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/malpassed_2.pngbin0 -> 34082 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/malpassed_3.pngbin0 -> 43381 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/malpassed_4.pngbin0 -> 32258 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/malpassed_5.pngbin0 -> 33938 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/malpassed_6.pngbin0 -> 27065 bytes
-rwxr-xr-xsrc/sqmod/sqmod_test/html/mark/v.pngbin0 -> 35308 bytes
-rw-r--r--src/sqmod/sqmod_test/html/select.oggbin0 -> 578385 bytes
-rw-r--r--src/sqmod/sqmod_test/html/top.pngbin0 -> 14572 bytes
-rw-r--r--src/sqmod/sqmod_test/html/wave1.pngbin0 -> 681612 bytes
-rw-r--r--src/sqmod/sqmod_test/html/wave2.pngbin0 -> 41395 bytes
-rw-r--r--src/sqmod/sqmod_test/js/sqmod_test.js730
135 files changed, 3284 insertions, 371 deletions
diff --git a/src/css/index.less b/src/css/index.less
index 8d268ac..4cd496a 100644
--- a/src/css/index.less
+++ b/src/css/index.less
@@ -14,7 +14,7 @@ body{
left:0px;
opacity:0;
transition:opacity @fast;
- overflow-y:hidden;
+ overflow:hidden;
&.active{
height:41px;
diff --git a/src/css/manage_dash.less b/src/css/manage_dash.less
new file mode 100644
index 0000000..f45adb2
--- /dev/null
+++ b/src/css/manage_dash.less
@@ -0,0 +1,12 @@
+@import 'mixin.less';
+@import 'color.less';
+
+#index_page{
+ table.accesslist{
+ td.permission{
+ span.label{
+ margin-right:@SmallPad;
+ }
+ }
+ }
+}
diff --git a/src/css/manage_problem.less b/src/css/manage_problem.less
index ce7c5a4..bd00751 100644
--- a/src/css/manage_problem.less
+++ b/src/css/manage_problem.less
@@ -5,9 +5,4 @@
div.oper{
text-align:center;
}
- table.list{
- tr.item{
-
- }
- }
}
diff --git a/src/html/index.html b/src/html/index.html
index cbf096e..1d2855a 100644
--- a/src/html/index.html
+++ b/src/html/index.html
@@ -19,7 +19,6 @@
<script src="/codemirror-3.13/mode/javascript/javascript.js"></script>
<script src="/codemirror-3.13/mode/css/css.js"></script>
<script src="/codemirror-3.13/mode/htmlmixed/htmlmixed.js"></script>
-<script src="http://code.createjs.com/soundjs-0.4.1.min.js"></script>
<script src="/toj/js/imc.js" type="text/javascript"></script>
<script src="/toj/js/com.js" type="text/javascript"></script>
@@ -42,7 +41,6 @@ $(document).ready(function(){
com.conn_backend();
com.conn_callback.add(function(){
- user.ready();
notice.ready();
mod.ready();
index.ready();
@@ -52,17 +50,19 @@ $(document).ready(function(){
manage.ready();
stat.ready();
- j_win.on('resize',com.exheight);
- $(window).on('popstate',function(e){
- if(location.href != com.url_curr){
- com.url_prev = com.url_curr;
- com.url_curr = location.href;
- com.url_chg();
- }
- });
+ user.ready().done(function(){
+ j_win.on('resize',com.exheight);
+ $(window).on('popstate',function(e){
+ if(location.href != com.url_curr){
+ com.url_prev = com.url_curr;
+ com.url_curr = location.href;
+ com.url_chg();
+ }
+ });
- com.exheight();
- com.url_chg();
+ com.exheight();
+ com.url_chg();
+ });
});
});
</script>
@@ -97,7 +97,7 @@ $(document).ready(function(){
<li class="profile" style="display:none;"><a href="">個人</a></li>
<li class="square" style="display:none;"><a href="/toj/square/user/">方塊</a></li>
<li class="mail" style="display:none;"><a href="/toj/mail/inbox/">信箱</a></li>
- <li class="manage" style="display:none;"><a href="/toj/manage/square/">管理</a></li>
+ <li class="manage" style="display:none;"><a href="/toj/manage/dash/">管理</a></li>
<li class="stat"><a href="/toj/stat/">狀態</a></li>
<li><a href="#">關於</a></li>
</ul>
diff --git a/src/html/manage_dash.html b/src/html/manage_dash.html
new file mode 100644
index 0000000..86996ab
--- /dev/null
+++ b/src/html/manage_dash.html
@@ -0,0 +1,18 @@
+<link rel="stylesheet" href="/toj/css/manage_dash.css">
+
+<div class="row">
+ <div class="span3">
+
+ </div>
+ <div class="span6">
+ <table class="table accesslist">
+ <thead>
+ <tr>
+ <th class="span2">物件權限ID</th>
+ <th class="span4">權限</th>
+ </tr>
+ </thead>
+ <tbody></tbody>
+ </table>
+ </div>
+</div>
diff --git a/src/html/manage_problem.html b/src/html/manage_problem.html
index abad7a3..1ee7d47 100644
--- a/src/html/manage_problem.html
+++ b/src/html/manage_problem.html
@@ -12,6 +12,11 @@
<input name="title" type="text">
<label>題目模組</label>
<select name="pmod"></select>
+ <label>公開狀態</label>
+ <select name="hidden">
+ <option value=0>顯示</option>
+ <option value=1>隱藏</option>
+ </select>
</div>
</div>
</div>
@@ -30,6 +35,11 @@
<div class="span13">
<label>題目名稱</label>
<input name="title" type="text">
+ <label>公開狀態</label>
+ <select name="hidden">
+ <option value=0>顯示</option>
+ <option value=1>隱藏</option>
+ </select>
</div>
</div>
</div>
@@ -41,15 +51,16 @@
<div class="row">
<div class="span2 offset1 oper">
- <button class="btn create">建立題目</button>
+ <button class="btn create" style="display:none;">建立題目</button>
</div>
- <div class="span6">
+ <div class="span5">
<table class="table list">
<thead>
<tr>
<th class="span1">#</th>
- <th class="span3">題目名稱</th>
- <th class="span2"></th>
+ <th class="span2">題目名稱</th>
+ <th class="span1">公開狀態</th>
+ <th class="span1"></th>
</tr>
</thead>
<tbody></tbody>
diff --git a/src/html/manage_square.html b/src/html/manage_square.html
index 900e280..5db0460 100644
--- a/src/html/manage_square.html
+++ b/src/html/manage_square.html
@@ -69,14 +69,15 @@
<div class="row clearfix">
<div class="span2 offset1 oper">
- <button class="btn create">建立方塊</button>
+ <button class="btn create" style="display:none;">建立方塊</button>
</div>
<table class="span9 table table-hover list">
<thead>
<tr>
<th class="span1">#</th>
- <th class="span3">名稱</th>
+ <th class="span2">名稱</th>
<th class="span2">時間</th>
+ <th class="span1">公開狀態</th>
<th class="span2">分類</th>
<th class="span1"></th>
</tr>
diff --git a/src/js/com.js b/src/js/com.js
index f4f9612..3b162c2 100644
--- a/src/js/com.js
+++ b/src/js/com.js
@@ -1,5 +1,15 @@
'use strict'
+var ACCESSID_SQUAREMG = 4;
+var ACCESSID_PROBLEMMG = 6;
+
+var ACCESS_READ = 0x1;
+var ACCESS_WRITE = 0x2;
+var ACCESS_CREATE = 0x4;
+var ACCESS_DELETE = 0x8;
+var ACCESS_SETPER = 0x10;
+var ACCESS_EXECUTE = 0x20;
+
var WebSocketConnection = function(link,ws){
var that = this;
@@ -561,6 +571,13 @@ var com = new function(){
that.get_defaultimg = function(hash){
return 'http://www.gravatar.com/avatar/' + hash + '?f=y&d=identicon&s=256';
};
+ that.check_access = function(accessid,permission){
+ if((user.authmap[accessid].permission & permission) == permission){
+ return true;
+ }else{
+ return false;
+ }
+ };
that.create_codebox = function(j_div,mode,readonly){
var codebox;
@@ -584,6 +601,8 @@ var com = new function(){
codebox.getScrollerElement().style.width = '100%';
codebox.getScrollerElement().style.height = '100%';
+ j_div.data('codebox',codebox);
+
return codebox;
};
that.create_pagination = function(j_div,start,end,curr,step){
@@ -993,10 +1012,9 @@ var com = new function(){
if((cookie = that.get_cookie()).uid != undefined){
that.call_backend('core/user/','cookie_login',function(result){
if(that.is_callerr(result)){
- index.add_alert('','登入發生錯誤');
+ index.add_alert('','錯誤','登入失敗');
}else{
imc.Auth.change_current_iden(result.data.idendesc);
- user.uid = imc.Auth.get_current_iden().uid;
}
that.conn_callback.fire();
diff --git a/src/js/imc.js b/src/js/imc.js
index 8970ccf..ae81684 100644
--- a/src/js/imc.js
+++ b/src/js/imc.js
@@ -258,12 +258,31 @@ var imc = new function(){
cnode = walk_path(path,true);
cnode.name[func_name] = func;
};
+ that.unregister_call = function(path,func_name){
+ var cnode;
+
+ cnode = walk_path(path,true);
+ delete cnode.name[func_name];
+ }
that.register_filter = function(path,func){
var cnode;
cnode = walk_path(path,true);
cnode.filt.push(func);
};
+ that.unregister_filter = function(path,func){
+ var i;
+ var cnode;
+ var new_filt = new Array();
+
+ cnode = walk_path(path,true);
+ for(i = 0;i < cnode.filt.length;i++){
+ if(cnode.filt[i] != func){
+ new_filt.push(cnode.filt[i]);
+ }
+ }
+ cnode.filt.remove(func);
+ };
conn_retidmap[self_link] = {};
diff --git a/src/js/index.js b/src/js/index.js
index d6b36d3..f645d3d 100644
--- a/src/js/index.js
+++ b/src/js/index.js
@@ -112,20 +112,28 @@ var index = new function(){
}
});
- user.login_callback.add(function(){
+ user.datachg_callback.add(function(type){
+ var j_a;
var j_li;
- j_header.find('li.login').hide();
- j_header.find('li.register').hide();
- j_header.find('li.nickname').show();
- j_header.find('li.logout').show();
-
- j_li = j_menu.find('div.menu li.profile');
- j_li.find('a').attr('href','/toj/user:' + user.uid + '/main/');
- j_li.show();
- j_menu.find('div.menu li.square').show();
- j_menu.find('div.menu li.mail').show();
- j_menu.find('div.menu li.manage').show();
+ j_a = j_header.find('li.nickname > a');
+ j_a.text(user.nickname);
+ j_a.attr('href','/toj/user:' + user.uid + '/main/');
+ console.log(type);
+
+ if(type == 'login'){
+ j_header.find('li.login').hide();
+ j_header.find('li.register').hide();
+ j_header.find('li.nickname').show();
+ j_header.find('li.logout').show();
+
+ j_li = j_menu.find('div.menu li.profile');
+ j_li.find('a').attr('href','/toj/user:' + user.uid + '/main/');
+ j_li.show();
+ j_menu.find('div.menu li.square').show();
+ j_menu.find('div.menu li.mail').show();
+ j_menu.find('div.menu li.manage').show();
+ }
});
_change();
diff --git a/src/js/manage.js b/src/js/manage.js
index d631d0e..e3af1f9 100644
--- a/src/js/manage.js
+++ b/src/js/manage.js
@@ -3,15 +3,17 @@
var manage = new function(){
var that = this;
var j_index_page;
+
+ var manage_node = new vus.node('manage');
+ var dash_node = new vus.node('dash');
+ var square_node = new vus.node('square');
+ var problem_node = new vus.node('problem');
- that.ready = function(){
- var manage_node = new vus.node('manage');
- var square_node = new vus.node('square');
- var problem_node = new vus.node('problem');
-
- var j_tabnav_square;
- var j_tabnav_problem;
+ var j_tabnav_dash;
+ var j_tabnav_square;
+ var j_tabnav_problem;
+ that.ready = function(){
j_index_page = $('#index_page');
manage_node.url_chg = function(direct,url_upart,url_dpart,param){
@@ -19,17 +21,72 @@ var manage = new function(){
index.set_menu('管理');
index.clear_tabnav();
+ j_tabnav_dash = index.add_tabnav('儀表板','/toj/manage/dash/');
j_tabnav_square = index.add_tabnav('方塊','/toj/manage/square/');
j_tabnav_problem = index.add_tabnav('題目','/toj/manage/problem/');
-
- com.call_backend('core/user/','list_auth',function(result){
- console.log(result);
- });
}
return 'cont';
};
com.vus_root.child_set(manage_node);
+
+ dash_node.url_chg = function(direct,url_upart,url_dpart,param){
+ if(direct == 'in'){
+ j_tabnav_dash.active();
+
+ com.loadpage('/toj/html/manage_dash.html').done(function(){
+ var i;
+ var j_accesslist = j_index_page.find('table.accesslist');
+ var j_item;
+ var j_permission;
+ var accessid;
+ var authlist;
+ var autho;
+
+ authlist = new Array();
+ for(accessid in user.authmap){
+ authlist.push(user.authmap[accessid]);
+ }
+ authlist.sort(function(a,b){
+ return a.accessid - b.accessid;
+ });
+
+ for(i = 0;i < authlist.length;i++){
+ autho = authlist[i];
+
+ j_item = $('<tr><td class="accessid"></td><td class="permission"></td></tr>');
+ j_item.find('td.accessid').text(autho.accessid);
+ j_permission = j_item.find('td.permission');
+
+ if(com.check_access(autho.accessid,ACCESS_READ)){
+ j_permission.append($('<span class="label label-success">READ</span>'));
+ }
+ if(com.check_access(autho.accessid,ACCESS_WRITE)){
+ j_permission.append($('<span class="label label-warning">WRITE</span>'));
+ }
+ if(com.check_access(autho.accessid,ACCESS_CREATE)){
+ j_permission.append($('<span class="label label-info">CREATE</span>'));
+ }
+ if(com.check_access(autho.accessid,ACCESS_DELETE)){
+ j_permission.append($('<span class="label label-important">DELETE</span>'));
+ }
+ if(com.check_access(autho.accessid,ACCESS_SETPER)){
+ j_permission.append($('<span class="label label-inverse">SETPER</span>'));
+ }
+ if(com.check_access(autho.accessid,ACCESS_EXECUTE)){
+ j_permission.append($('<span class="label">EXECUTE</span>'));
+ }
+
+ j_accesslist.append(j_item);
+ }
+ });
+ }else if(direct == 'out'){
+
+ }
+
+ return 'cont';
+ };
+ manage_node.child_set(dash_node);
square_node.url_chg = function(direct,url_upart,url_dpart,param){
var j_create;
@@ -41,8 +98,9 @@ var manage = new function(){
var set_tagbox_cate;
var set_data;
- function _item_set(j_item,id,title,start_time,end_time,cateid,intro,logo,hidden){
+ function _item_set(j_item,id,title,hidden,start_time,end_time,cateid,intro,logo){
var i;
+ var j_hidden;
var j_cate;
var j_label;
@@ -55,6 +113,15 @@ var manage = new function(){
if(end_time != null){
j_item.find('td.time > div.end').text('└→' + com.get_timestring(end_time));
}
+
+ j_hidden = j_item.find('td.hid');
+ if(hidden == false){
+ j_hidden.text('公開');
+ j_hidden.removeClass('text-warning');
+ }else{
+ j_hidden.text('隱藏');
+ j_hidden.addClass('text-warning');
+ }
j_cate = j_item.find('td.cate');
j_cate.empty();
@@ -68,12 +135,12 @@ var manage = new function(){
set_data = {
'id':id,
'title':title,
+ 'hidden':hidden,
'start_time':start_time,
'end_time':end_time,
'cateid':cateid,
'intro':intro,
'logo':logo,
- 'hidden':hidden
};
j_set.modal('show');
@@ -88,10 +155,10 @@ var manage = new function(){
},id);
});
}
- function _item_create(id,title,start_time,end_time,cateid,intro,logo,hidden){
- var j_item = $('<tr class="item"><td class="id"></td><td class="title"><td class="time"><div class="time start"></div><div class="time end"></div</td></td><td class="cate"></td><td class="oper"><div class="btn-group"><button class="btn btn-small set"><i class="icon-cog"></i></button><button class="btn btn-small del"><i class="icon-trash"></i></button></div></td></tr>');
+ function _item_create(id,title,hidden,start_time,end_time,cateid,intro,logo){
+ var j_item = $('<tr class="item"><td class="id"></td><td class="title"><td class="time"><div class="time start"></div><div class="time end"></div</td><td class="hid"></td></td><td class="cate"></td><td class="oper"><div class="btn-group"><button class="btn btn-small set"><i class="icon-cog"></i></button><button class="btn btn-small del"><i class="icon-trash"></i></button></div></td></tr>');
- _item_set(j_item,id,title,start_time,end_time,cateid,intro,logo,hidden);
+ _item_set(j_item,id,title,hidden,start_time,end_time,cateid,intro,logo);
return j_item;
}
@@ -103,6 +170,7 @@ var manage = new function(){
if(com.is_callerr(result)){
index.add_alert('','警告','管理發生錯誤');
+ defer.reject(data);
}else{
defer.resolve(data);
}
@@ -157,24 +225,24 @@ var manage = new function(){
_item_set($(items[i]),sqo.sqid,
sqo.title,
+ sqo.hidden,
sqo.start_time,
sqo.end_time,
sqo.cateid,
sqo.intro,
- sqo.logo,
- sqo.hidden);
+ sqo.logo);
}
for(;i < data.length;i++){
sqo = data[i];
j_item = _item_create(sqo.sqid,
sqo.title,
+ sqo.hidden,
sqo.start_time,
sqo.end_time,
sqo.cateid,
sqo.intro,
- sqo.logo,
- sqo.hidden);
+ sqo.logo);
j_list.append(j_item);
}
for(;i < items.length;i++){
@@ -189,6 +257,7 @@ var manage = new function(){
if(direct == 'in'){
com.loadpage('/toj/html/manage_square.html').done(function(){
var j_catebox;
+ var j_button;
j_tabnav_square.active();
@@ -200,6 +269,14 @@ var manage = new function(){
create_tagbox_cate = j_catebox.tagbox({'words':[],'restrict':true,'duplicate':false});
j_catebox.find('input').attr('placeholder','+加入分類');
+ j_button = j_index_page.find('div.oper > button.create');
+ if(com.check_access(ACCESSID_SQUAREMG,ACCESS_CREATE)){
+ j_button.show();
+ }
+ j_index_page.find('div.oper > button.create').on('click',function(e){
+ j_create.modal('show');
+ });
+
j_create.find('[name="logo"]').on('change',function(e){
var url;
var j_logo = j_create.find('img.logo');
@@ -399,10 +476,6 @@ var manage = new function(){
set_tagbox_cate.clear();
});
- j_index_page.find('div.oper > button.create').on('click',function(e){
- j_create.modal('show');
- });
-
_update_list();
});
}
@@ -417,14 +490,25 @@ var manage = new function(){
var j_list;
var set_data;
- function _item_set(j_item,proid,title,pmodid){
+ function _item_set(j_item,proid,title,hidden,pmodid){
+ var j_hidden;
+
j_item.find('td.proid').text(proid);
j_item.find('td.title').text(title);
+ j_hidden = j_item.find('td.hid');
+ if(hidden == false){
+ j_hidden.text('公開');
+ j_hidden.removeClass('text-warning');
+ }else{
+ j_hidden.text('隱藏');
+ j_hidden.addClass('text-warning');
+ }
j_item.find('button.set').on('click',function(e){
set_data = {
'proid':proid,
'title':title,
+ 'hidden':hidden
};
j_set.modal('show');
@@ -439,10 +523,10 @@ var manage = new function(){
},proid);
});
}
- function _item_create(proid,title,pmodid){
- var j_item = $('<tr><td class="proid"></td><td class="title"></td><td class="oper"><div class="btn-group"><button class="btn btn-small set"><i class="icon-cog"></i></button><button class="btn btn-small del"><i class="icon-trash"></i></button></div></td></tr>')
+ function _item_create(proid,title,hidden,pmodid){
+ var j_item = $('<tr><td class="proid"></td><td class="title"></td><td class="hid"></td><td class="oper"><div class="btn-group"><button class="btn btn-small set"><i class="icon-cog"></i></button><button class="btn btn-small del"><i class="icon-trash"></i></button></div></td></tr>');
- _item_set(j_item,proid,title,pmodid);
+ _item_set(j_item,proid,title,hidden,pmodid);
return j_item;
}
@@ -457,6 +541,7 @@ var manage = new function(){
if(com.is_callerr(result)){
index.add_alert('','警告','管理發生錯誤');
+ defer.reject(data);
}else{
defer.resolve(data);
}
@@ -477,7 +562,7 @@ var manage = new function(){
j_list.empty();
for(i = 0;i < data.length;i++){
proo = data[i];
- j_item = _item_create(proo.proid,proo.title,proo.pmodid);
+ j_item = _item_create(proo.proid,proo.title,proo.hidden,proo.pmodid);
j_list.append(j_item);
}
}
@@ -488,11 +573,17 @@ var manage = new function(){
j_tabnav_problem.active();
com.loadpage('/toj/html/manage_problem.html').done(function(){
+ var j_button;
+
j_create = j_index_page.find('div.create');
j_set = j_index_page.find('div.set');
j_list = j_index_page.find('table.list > tbody');
- j_index_page.find('button.create').on('click',function(e){
+ j_button = j_index_page.find('div.oper > button.create');
+ if(com.check_access(ACCESSID_PROBLEMMG,ACCESS_CREATE)){
+ j_button.show();
+ }
+ j_button.on('click',function(e){
j_create.modal('show');
});
@@ -519,6 +610,13 @@ var manage = new function(){
j_create.find('button.submit').on('click',function(e){
var title = j_create.find('[name="title"]').val();
var pmodid = parseInt(j_create.find('[name="pmod"]').val());
+ var hidden = j_create.find('[name="hidden"]').val();
+
+ if(hidden == '0'){
+ hidden = false;
+ }else{
+ hidden = true;
+ }
com.call_backend('core/problem/','create_problem',function(result){
var data = result.data;
@@ -541,7 +639,7 @@ var manage = new function(){
index.add_alert('alert-success','成功','題目已建立');
_update_list();
}
- },title,pmodid);
+ },title,hidden,pmodid);
});
j_create.find('button.cancel').on('click',function(e){
j_create.modal('hide');
@@ -549,12 +647,24 @@ var manage = new function(){
j_set.on('show',function(e){
j_set.find('[name="title"]').val(set_data.title);
+ if(set_data.hidden == false){
+ j_set.find('[name="hidden"]').val(0);
+ }else{
+ j_set.find('[name="hidden"]').val(1);
+ }
});
j_set.on('hide',function(e){
j_set.find('input').val('');
});
j_set.find('button.submit').on('click',function(e){
var title = j_set.find('[name="title"]').val();
+ var hidden = j_set.find('[name="hidden"]').val();
+
+ if(hidden == '0'){
+ hidden = false;
+ }else{
+ hidden = true;
+ }
com.call_backend('core/problem/','set_problem',function(result){
var data = result.data;
@@ -577,7 +687,7 @@ var manage = new function(){
index.add_alert('alert-success','成功','題目已設定');
_update_list();
}
- },set_data.proid,title);
+ },set_data.proid,title,hidden);
});
j_set.find('button.cancel').on('click',function(e){
j_set.modal('hide');
diff --git a/src/js/mod.js b/src/js/mod.js
index e626ff9..db1c617 100644
--- a/src/js/mod.js
+++ b/src/js/mod.js
@@ -1,11 +1,13 @@
+'use strict'
+
var mod = new function(){
var that = this;
-
- that.curr_sqmod = null;
+ var sq_node = new vus.node('sq');
+ var pro_node = new vus.node('pro');
+ var curr_sqmod = null;
+ var curr_pmod = null;
that.ready = function(){
- var sq_node = new vus.node('sq');
-
sq_node.url_chg = function(direct,url_upart,url_dpart,param){
var sqid;
@@ -29,21 +31,60 @@ var mod = new function(){
$.getScript('/toj/sqmod/' + sqmodname + '/js/' + sqmodname + '.js',function(script,status,xhr){
var sqid_node;
- curr_sqmod = sqmodname;
-
sqid_node = new vus.node(sqid);
- eval(sqmodname + '(sqid_node);');
+ eval('curr_sqmod = new ' + sqmodname + '(sqid_node);');
sq_node.child_set(sqid_node);
});
}
},parseInt(sqid));
}else if(direct == 'out'){
- eval(curr_sqmod + '.unload()');
+ curr_sqmod.unload();
+ curr_sqmod = null;
}
return 'cont';
};
com.vus_root.child_set(sq_node);
+
+ pro_node.url_chg = function(direct,url_upart,url_dpart,param){
+ var proid;
+
+ if(direct == 'in'){
+ index.set_menu('題目');
+ index.clear_tabnav();
+
+ proid = url_dpart[0];
+ pro_node.child_delayset(proid);
+
+ com.call_backend('core/problem/','get_problem_info',function(result){
+ var data = result.data;
+ var pmodname;
+
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','開啓題目發生錯誤');
+ }else{
+ index.set_title(data.title);
+
+ pmodname = escape(data.pmodname);
+ $.getScript('/toj/pmod/' + pmodname + '/js/' + pmodname + '.js',function(script,status,xhr){
+ var proid_node;
+
+ proid_node = new vus.node(proid);
+ eval('curr_pmod = new ' + pmodname + '(parseInt(proid),proid_node);');
+
+ pro_node.child_set(proid_node);
+ });
+ }
+ },parseInt(proid));
+
+ }else if(direct == 'out'){
+ curr_pmod.unload();
+ curr_pmod = null;
+ }
+
+ return 'cont';
+ };
+ com.vus_root.child_set(pro_node);
};
}
diff --git a/src/js/notice.js b/src/js/notice.js
index 3b7dff1..f7a4f41 100644
--- a/src/js/notice.js
+++ b/src/js/notice.js
@@ -45,23 +45,25 @@ var notice = new function(){
});
});
- user.login_callback.add(function(){
- imc.Proxy.instance.register_call('core/notice/','update_notice',function(callback,unseen_count){
- _set_unseen_count(unseen_count);
- callback('Success');
- });
+ user.datachg_callback.add(function(type){
+ if(type == 'login'){
+ imc.Proxy.instance.register_call('core/notice/','update_notice',function(callback,unseen_count){
+ _set_unseen_count(unseen_count);
+ callback('Success');
+ });
- com.call_backend('core/notice/','get_unseen_count',function(result){
- var data = result.data;
+ com.call_backend('core/notice/','get_unseen_count',function(result){
+ var data = result.data;
- if(com.is_callerr(result)){
- index.add_alert('','警告','通知發生錯誤');
- }else{
- _set_unseen_count(data.unseen_count);
- }
- });
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','通知發生錯誤');
+ }else{
+ _set_unseen_count(data.unseen_count);
+ }
+ });
- j_noticetag.show();
+ j_noticetag.show();
+ }
});
};
};
diff --git a/src/js/square.js b/src/js/square.js
index 9b5f684..6e71acd 100644
--- a/src/js/square.js
+++ b/src/js/square.js
@@ -4,213 +4,222 @@ var square = new function(){
var j_catelist;
var j_indexlist;
- that.ready = function(){
- var square_node = new vus.node('square');
- var user_node = new vus.node('user');
- var index_node = new vus.node('index');
- var user_tabnav;
- var index_tabnav;
+ var square_node = new vus.node('square');
+ var user_node = new vus.node('user');
+ var index_node = new vus.node('index');
- function box_set(j_box,id,logo,title,start_time,end_time,intro,active){
- var j_oper;
+ function box_set(j_box,id,logo,title,start_time,end_time,intro,active){
+ var j_oper;
- j_box.attr('boxid',id);
+ j_box.attr('boxid',id);
- j_box.find('div.logo').css('background-image','url(\'' + logo + '\')');
- j_box.find('h5.title').text(title);
- j_box.find('p.intro').text(intro);
+ j_box.find('div.logo').css('background-image','url(\'' + logo + '\')');
+ j_box.find('h5.title').text(title);
+ j_box.find('p.intro').text(intro);
- if(start_time != null){
- j_box.find('div.start').text('┌─' + com.get_timestring(start_time));
- }
- if(end_time != null){
- j_box.find('div.end').text('└→' + com.get_timestring(end_time));
- }
+ if(start_time != null){
+ j_box.find('div.start').text('┌─' + com.get_timestring(start_time));
+ }
+ if(end_time != null){
+ j_box.find('div.end').text('└→' + com.get_timestring(end_time));
+ }
- j_oper = j_box.find('div.oper');
- j_oper.empty();
- if(active == null){
- j_oper.append('<button class="btn btn-primary join" data-loading-text="處理中">加入</button><a class="btn open">開啓</a>');
- j_oper.find('button.join').on('click',function(e){
- $(this).button('loading');
-
- com.call_backend('core/square/','join_square',function(result){
- var data = result.data;
-
- if(com.is_callerr(result)){
- if(data == 'Ereject'){
- index.add_alert('alert-error','拒絕','加入請求被拒絕');
- }else if(data == 'Eno_such_sqid'){
- index.add_alert('alert-error','錯誤','方塊不存在');
- }else{
- index.add_alert('alert-error','錯誤','操作方塊發生錯誤');
- }
+ j_oper = j_box.find('div.oper');
+ j_oper.empty();
+ if(active == null){
+ j_oper.append('<button class="btn btn-primary join" data-loading-text="處理中">加入</button><a class="btn open">開啓</a>');
+ j_oper.find('button.join').on('click',function(e){
+ $(this).button('loading');
+
+ com.call_backend('core/square/','join_square',function(result){
+ var data = result.data;
+
+ if(com.is_callerr(result)){
+ if(data == 'Ereject'){
+ index.add_alert('alert-error','拒絕','加入請求被拒絕');
+ }else if(data == 'Eno_such_sqid'){
+ index.add_alert('alert-error','錯誤','方塊不存在');
}else{
- box_update(id,logo,title,start_time,end_time,intro,data.active);
+ index.add_alert('alert-error','錯誤','操作方塊發生錯誤');
}
- },id);
- });
+ }else{
+ box_update(id,logo,title,start_time,end_time,intro,data.active);
+ }
+ },id);
+ });
+ }else{
+ if(active== true){
+ j_oper.append('<button class="btn btn-success quit" data-loading-text="處理中">退出</button><a class="btn open">開啓</a>');
}else{
- if(active== true){
- j_oper.append('<button class="btn btn-success quit" data-loading-text="處理中">退出</button><a class="btn open">開啓</a>');
- }else{
- j_oper.append('<button class="btn btn-warning quit" data-loading-text="處理中">取消申請</button><a class="btn open">開啓</a>');
- }
+ j_oper.append('<button class="btn btn-warning quit" data-loading-text="處理中">取消申請</button><a class="btn open">開啓</a>');
+ }
- j_oper.find('button.quit').on('click',function(e){
- $(this).button('loading');
+ j_oper.find('button.quit').on('click',function(e){
+ $(this).button('loading');
- com.call_backend('core/square/','quit_square',function(result){
- var data = result.data;
+ com.call_backend('core/square/','quit_square',function(result){
+ var data = result.data;
- if(com.is_callerr(result)){
- if(data == 'Eno_such_sqid'){
- index.add_alert('alert-error','錯誤','方塊不存在');
- }else{
- index.add_alert('alert-error','錯誤','操作方塊發生錯誤');
- }
+ if(com.is_callerr(result)){
+ if(data == 'Eno_such_sqid'){
+ index.add_alert('alert-error','錯誤','方塊不存在');
}else{
- box_update(id,logo,title,start_time,end_time,intro,null);
+ index.add_alert('alert-error','錯誤','操作方塊發生錯誤');
}
- },id);
- });
- }
-
- j_oper.find('a.open').attr('href','/toj/sq/' + id + '/');
+ }else{
+ box_update(id,logo,title,start_time,end_time,intro,null);
+ }
+ },id);
+ });
}
- function box_update(id,logo,title,start_time,end_time,intro,active){
- var i;
- var boxs;
- boxs = j_indexlist.find('[boxid="' + id + '"]');
- for(i = 0;i < boxs.length;i++){
- box_set($(boxs[i]),id,logo,title,start_time,end_time,intro,active);
- }
+ j_oper.find('a.open').attr('href','/toj/sq/' + id + '/');
+ }
+ function box_update(id,logo,title,start_time,end_time,intro,active){
+ var i;
+ var boxs;
+
+ boxs = j_indexlist.find('[boxid="' + id + '"]');
+ for(i = 0;i < boxs.length;i++){
+ box_set($(boxs[i]),id,logo,title,start_time,end_time,intro,active);
}
- function box_create(id,logo,title,start_time,end_time,intro,active){
- var j_box = $('<div class="span5 box"><div class="logo"></div><h5 class="title"></h5><div class="time start"></div><div class="time end"></div><p class="intro"></p><div class="btn-group oper"></div></div>');
+ }
+ function box_create(id,logo,title,start_time,end_time,intro,active){
+ var j_box = $('<div class="span5 box"><div class="logo"></div><h5 class="title"></h5><div class="time start"></div><div class="time end"></div><p class="intro"></p><div class="btn-group oper"></div></div>');
- box_set(j_box,id,logo,title,start_time,end_time,intro,active);
+ box_set(j_box,id,logo,title,start_time,end_time,intro,active);
- return j_box;
- }
- function catebox_set(j_box,cateid,catename){
- j_box.data('cateid',cateid);
- j_box.find('h3.catename').text(catename);
- }
- function catebox_create(cateid,catename){
- var j_box = $('<div class="catebox"><h3 class="catename"></h3><h4 class="run">進行中</h4><div class="clearfix boxlist run"></div><h4 class="pend">等待中</h4><div class="clearfix boxlist pend"></div><h4 class="past">已結束</h4><div class="clearfix boxlist past"></div>');
+ return j_box;
+ }
+ function catebox_set(j_box,cateid,catename){
+ j_box.data('cateid',cateid);
+ j_box.find('h3.catename').text(catename);
+ }
+ function catebox_create(cateid,catename){
+ var j_box = $('<div class="catebox"><h3 class="catename"></h3><h4 class="run">進行中</h4><div class="clearfix boxlist run"></div><h4 class="pend">等待中</h4><div class="clearfix boxlist pend"></div><h4 class="past">已結束</h4><div class="clearfix boxlist past"></div>');
- catebox_set(j_box,cateid,catename);
+ catebox_set(j_box,cateid,catename);
- return j_box;
- }
+ return j_box;
+ }
- function catelist_update(){
- var defer = $.Deferred();
+ function catelist_update(){
+ var defer = $.Deferred();
- com.call_backend('core/square/','list_category',function(result){
- var data = result.data;
+ com.call_backend('core/square/','list_category',function(result){
+ var data = result.data;
+
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','方塊目錄發生錯誤');
+ defer.reject();
+ }else{
+ defer.resolve(data);
+ }
+ });
+
+ return defer.promise();
+ }
+ function indexlist_update(catelist,joined){
+ var i;
+ var j_catebox;
+ var cateo;
+
+ j_catelist.empty();
+ j_indexlist.empty();
+ for(i = 0;i < catelist.length;i++){
+ cateo = catelist[i];
+
+ com.call_backend('core/square/','list_square',function(cateo){return function(result){
+ var i;
+ var data = result.data;
+ var show_list;
+ var sqo;
+ var logo;
+ var start_time;
+ var end_time;
+ var j_cate;
+ var j_box;
+ var j_run;
+ var j_pend;
+ var j_past;
+ var j_a;
if(com.is_callerr(result)){
index.add_alert('','警告','方塊目錄發生錯誤');
- defer.reject();
}else{
- defer.resolve(data);
- }
- });
-
- return defer.promise();
- }
- function indexlist_update(catelist,joined){
- var i;
- var j_catebox;
- var cateo;
-
- j_catelist.empty();
- j_indexlist.empty();
- for(i = 0;i < catelist.length;i++){
- cateo = catelist[i];
-
- com.call_backend('core/square/','list_square',function(cateo){return function(result){
- var i;
- var data = result.data;
- var sqo;
- var logo;
- var start_time;
- var end_time;
- var j_cate;
- var j_box;
- var j_run;
- var j_pend;
- var j_past;
- var j_a;
-
- if(com.is_callerr(result)){
- index.add_alert('','警告','方塊目錄發生錯誤');
- }else{
- if(data.length == 0){
- return;
+ show_list = new Array();
+ for(i = 0;i < data.length;i++){
+ sqo = data[i];
+ if((joined == false || sqo.active != null) && sqo.hidden == false){
+ show_list.push(sqo);
}
+ }
+ if(show_list.length == 0){
+ return;
+ }
- j_cate = $('<li><a href=""></a></li>');
- j_a = j_cate.find('a');
- j_a.text(cateo.catename);
- j_a.on('click',function(e){
- $(window).scrollTop(j_indexlist.find('[cateid="' + cateo.cateid + '"]').offset().top - 66);
- return false;
- });
- j_catelist.append(j_cate);
-
- j_catebox = catebox_create(cateo.cateid,cateo.catename);
- j_indexlist.append(j_catebox);
-
- j_run = j_catebox.find('div.run');
- j_pend = j_catebox.find('div.pend');
- j_past = j_catebox.find('div.past');
-
- for(i = 0;i < data.length;i++){
- sqo = data[i];
- if(joined == true && sqo.active == null){
- continue;
- }
-
- if((logo = sqo.logo) == ''){
- logo = com.get_defaultimg(sqo.sqid);
- }
-
- j_box = box_create(sqo.sqid,logo,sqo.title,sqo.start_time,sqo.end_time,sqo.intro,sqo.active);
-
- if(sqo.status == 1){
- j_pend.append(j_box);
- }else if(sqo.status == 2){
- j_run.append(j_box);
- }else if(sqo.status == 3){
- j_past.append(j_box);
- }
- }
-
- if(j_pend.children().length > 0){
- j_catebox.find('h4.pend').show();
- j_pend.show();
+ j_cate = $('<li><a href=""></a></li>');
+ j_a = j_cate.find('a');
+ j_a.text(cateo.catename);
+ j_a.on('click',function(e){
+ $(window).scrollTop(j_indexlist.find('[cateid="' + cateo.cateid + '"]').offset().top - 66);
+ return false;
+ });
+ j_catelist.append(j_cate);
+
+ j_catebox = catebox_create(cateo.cateid,cateo.catename);
+ j_indexlist.append(j_catebox);
+
+ j_run = j_catebox.find('div.run');
+ j_pend = j_catebox.find('div.pend');
+ j_past = j_catebox.find('div.past');
+
+ for(i = 0;i < show_list.length;i++){
+ sqo = show_list[i];
+ if((joined == true && sqo.active == null) || sqo.hidden == true){
+ continue;
}
- if(j_run.children().length > 0){
- j_catebox.find('h4.run').show();
- j_run.show();
+
+ if((logo = sqo.logo) == ''){
+ logo = com.get_defaultimg(sqo.sqid);
}
- if(j_past.children().length > 0){
- j_catebox.find('h4.past').show();
- j_past.show();
+
+ j_box = box_create(sqo.sqid,logo,sqo.title,sqo.start_time,sqo.end_time,sqo.intro,sqo.active);
+
+ if(sqo.status == 1){
+ j_pend.append(j_box);
+ }else if(sqo.status == 2){
+ j_run.append(j_box);
+ }else if(sqo.status == 3){
+ j_past.append(j_box);
}
+ }
+
+ if(j_pend.children().length > 0){
+ j_catebox.find('h4.pend').show();
+ j_pend.show();
}
- }}(cateo),cateo.cateid);
- }
- }
- function update(joined){
- catelist_update().done(function(catelist){
- indexlist_update(catelist,joined);
- });
+ if(j_run.children().length > 0){
+ j_catebox.find('h4.run').show();
+ j_run.show();
+ }
+ if(j_past.children().length > 0){
+ j_catebox.find('h4.past').show();
+ j_past.show();
+ }
+ }
+ }}(cateo),cateo.cateid);
}
+ }
+ function update(joined){
+ catelist_update().done(function(catelist){
+ indexlist_update(catelist,joined);
+ });
+ }
+
+ that.ready = function(){
+ var user_tabnav;
+ var index_tabnav;
j_index_page = $('#index_page');
diff --git a/src/js/user.js b/src/js/user.js
index 9a18a1a..73fdba0 100644
--- a/src/js/user.js
+++ b/src/js/user.js
@@ -3,15 +3,19 @@ var user = new function(){
var j_index_page;
that.uid = null;
+ that.authmap = null;
that.username = null;
that.nickname = null;
that.email = null;
that.avatar = null;
that.cover = null;
- that.login_callback = $.Callbacks();
+ that.datachg_callback = $.Callbacks();
+ that.authchg_callback = $.Callbacks();
that.ready = function(){
+ var defer = $.Deferred();
+
var uid;
var user_node_uid = null;
var j_tabnav_main;
@@ -33,9 +37,7 @@ var user = new function(){
document.cookie = 'hash=' + hash + ';path=/;expires=' + expire.toUTCString();
imc.Auth.change_current_iden(idendesc);
- _set_user_data(uid).done(function(){
- that.login_callback.fire();
- });
+ _set_user(uid);
};
function _logout(){
document.cookie = 'uid=;path=/;expires=Thu, 01 Jan 1970 00:00:00 GMT';
@@ -54,11 +56,30 @@ var user = new function(){
return defer.promise();
};
- function _set_user_data(uid){
+ function _get_user_authlist(uid){
var defer = $.Deferred();
- _get_user_info(uid).done(function(data){
- var j_a;
+ com.call_backend('core/user/','list_auth',function(result){
+ if(com.is_callerr(result)){
+ defer.reject(result.data);
+ }
+ defer.resolve(result.data);
+ });
+
+ return defer.promise();
+ }
+ function _set_user(uid){
+ var defer = $.Deferred();
+
+ $.when(_get_user_info(uid),_get_user_authlist(uid)).done(function(data,authlist){
+ var i;
+ var type;
+
+ if(that.username == null){
+ type = 'login';
+ }else{
+ type = 'set';
+ }
that.uid = data.uid;
that.username = data.username;
@@ -67,12 +88,16 @@ var user = new function(){
that.avatar = data.avatar;
that.cover = data.cover;
- j_a = $('#index_header li.nickname > a');
- j_a.text(that.nickname);
- j_a.attr('href','/toj/user:' + that.uid + '/main/');
+ user.authmap = new Object();
+ for(i = 0;i < authlist.length;i++){
+ user.authmap[authlist[i].accessid] = authlist[i];
+ }
+
+ that.datachg_callback.fire(type);
+ that.authchg_callback.fire();
defer.resolve();
- }).fail(function(data){
+ }).fail(function(){
defer.reject();
});
@@ -81,9 +106,11 @@ var user = new function(){
j_index_page = $('#index_page');
- if((uid = imc.Auth.get_current_iden().uid) != undefined){
- _set_user_data(uid).done(function(){
- that.login_callback.fire();
+ if((uid = imc.Auth.get_current_iden().uid) == undefined){
+ defer.resolve();
+ }else{
+ _set_user(uid).done(function(){
+ defer.resolve();
});
}
@@ -119,26 +146,6 @@ var user = new function(){
var j_menutag = $('#index_menutag');
var j_paneltag = $('#index_paneltag');
- function _tmp(y){
- var now = 0;
- var ay = 100;
-
- /*function __ani(){
- if(y <= now){
- $(window).scrollTop(y);
- return;
- }
- $(window).scrollTop(now);
-
- now = now + ay;
- ay = Math.max(5,ay * 0.86);
- setTimeout(__ani,10);
- }
-
- __ani();*/
- j_win.scrollTop(y);
- }
-
function _active(){
j_header.addClass('force');
j_header.addClass('active');
@@ -193,7 +200,7 @@ var user = new function(){
});
_active();
- _tmp(500);
+ j_win.scrollTop(500);
j_index_page.show();
j_index_page.css('visibility','visible');
});
@@ -294,7 +301,7 @@ var user = new function(){
index.add_alert('alert-error','失敗',errmsg,true);
set_defer.reject();
}else{
- _set_user_data(that.uid);
+ _set_user(that.uid);
set_defer.resolve();
}
},that.uid,j_nickname.val(),j_email.val(),j_avatar.val(),j_aboutme.val(),j_cover.val());
@@ -454,5 +461,7 @@ var user = new function(){
}
};
com.vus_root.child_set(logout_node);
+
+ return defer.promise();
};
};
diff --git a/src/pmod/pmod_test/css/manage.css b/src/pmod/pmod_test/css/manage.css
new file mode 100644
index 0000000..de9f049
--- /dev/null
+++ b/src/pmod/pmod_test/css/manage.css
@@ -0,0 +1,4 @@
+#index_page div.create_mode div.content,
+#index_page div.set_mode div.content {
+ height: 256px;
+}
diff --git a/src/pmod/pmod_test/css/manage.less b/src/pmod/pmod_test/css/manage.less
new file mode 100644
index 0000000..eebc931
--- /dev/null
+++ b/src/pmod/pmod_test/css/manage.less
@@ -0,0 +1,7 @@
+#index_page{
+ div.create_mode,div.set_mode{
+ div.content{
+ height:256px;
+ }
+ }
+}
diff --git a/src/pmod/pmod_test/css/view.css b/src/pmod/pmod_test/css/view.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/pmod/pmod_test/css/view.css
diff --git a/src/pmod/pmod_test/css/view.less b/src/pmod/pmod_test/css/view.less
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/pmod/pmod_test/css/view.less
diff --git a/src/pmod/pmod_test/html/manage.html b/src/pmod/pmod_test/html/manage.html
new file mode 100644
index 0000000..e3b1816
--- /dev/null
+++ b/src/pmod/pmod_test/html/manage.html
@@ -0,0 +1,144 @@
+<link href="/toj/pmod/pmod_test/css/manage.css" rel="stylesheet">
+
+<div class="modal hide fade medium_modal create_mode">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+ <h3>建立模式</h3>
+ </div>
+ <div class="modal-body container-fluid">
+ <div class="row-fluid">
+ <div class="span7">
+ <label>測試名稱</label>
+ <select name="testmode"></select>
+ </div>
+ </div>
+ <div class="row-fluid">
+ <div class="span13">
+ <label>題目內容</label>
+ <div class="content"></div>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button class="btn btn-primary submit">確定</button>
+ <button class="btn cancel">取消</button>
+ </div>
+</div>
+<div class="modal hide fade medium_modal set_mode">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+ <h3>設定模式</h3>
+ </div>
+ <div class="modal-body container-fluid">
+ <div class="row-fluid">
+ <div class="span7">
+ <label>測試名稱</label>
+ <select name="testmode"></select>
+ </div>
+ </div>
+ <div class="row-fluid">
+ <div class="span13">
+ <label>題目內容</label>
+ <div class="content"></div>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button class="btn btn-primary submit">確定</button>
+ <button class="btn cancel">取消</button>
+ </div>
+</div>
+
+<div class="modal hide fade medium_modal create_testmode">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+ <h3>建立測試</h3>
+ </div>
+ <div class="modal-body container-fluid">
+ <div class="row-fluid">
+ <div class="span7">
+ <label>測試名稱</label>
+ <input type="text" name="name">
+ <label>執行時間限制</label>
+ <input type="text" name="timelimit">
+ <label>記憶體限制</label>
+ <input type="text" name="memlimit">
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button class="btn btn-primary submit">確定</button>
+ <button class="btn cancel">取消</button>
+ </div>
+</div>
+<div class="modal hide fade medium_modal set_testmode">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
+ <h3>設定測試</h3>
+ </div>
+ <div class="modal-body container-fluid">
+ <div class="row-fluid">
+ <div class="span7">
+ <label>測試名稱</label>
+ <input type="text" name="name">
+ <label>執行時間限制</label>
+ <input type="text" name="timelimit">
+ <label>記憶體限制</label>
+ <input type="text" name="memlimit">
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button class="btn btn-primary submit">確定</button>
+ <button class="btn cancel">取消</button>
+ </div>
+</div>
+
+
+<div class="row">
+ <div class="span3">
+ sdfsdfs
+ </div>
+ <div class="span4">
+ <h3>模式</h3>
+ <button class="btn create_mode">建立模式</button>
+ <table class="table mode">
+ <thead>
+ <tr>
+ <th class="span1">#</th>
+ <th class="span2">測試名稱</th>
+ <th class="span1"></th>
+ </tr>
+ </thead>
+ <tbody></tbody>
+ </table>
+ </div>
+ <div class="span4">
+ <h3>測試</h3>
+ <button class="btn create_testmode">建立測試</button>
+ <table class="table testmode">
+ <thead>
+ <tr>
+ <th class="span1">#</th>
+ <th class="span2">測試名稱</th>
+ <th class="span1"></th>
+ </tr>
+ </thead>
+ <tbody></tbody>
+ </table>
+ </div>
+ <div class="span2">
+ <h3>測試資料</h3>
+ <button class="btn create_testdata">建立測試資料</button>
+ <table class="table testdata">
+ <thead>
+ <tr>
+ <th class="span1">#</th>
+ <th class="span1"></th>
+ </tr>
+ </thead>
+ <tbody></tbody>
+ </table>
+ </div>
+
+</div>
diff --git a/src/pmod/pmod_test/html/view.html b/src/pmod/pmod_test/html/view.html
new file mode 100644
index 0000000..80787a2
--- /dev/null
+++ b/src/pmod/pmod_test/html/view.html
@@ -0,0 +1,10 @@
+<link href="/toj/pmod/pmod_test/css/view.css" rel="stylesheet">
+
+<div class="row">
+ <div class="span3">
+
+ </div>
+ <div class="span10">
+ LaLaLala
+ </div>
+</div>
diff --git a/src/pmod/pmod_test/js/pmod_test.js b/src/pmod/pmod_test/js/pmod_test.js
new file mode 100644
index 0000000..1f8f848
--- /dev/null
+++ b/src/pmod/pmod_test/js/pmod_test.js
@@ -0,0 +1,317 @@
+'use strict'
+
+var pmod_test = function(proid,pro_node){
+ var that = this;
+ var j_index_page = $('#index_page');
+ var manage_node = new vus.node('manage');
+ var callpath = 'pro/' + proid + '/';
+
+ pro_node.url_chg = function(direct,url_upart,url_dpart,param){
+ if(direct == 'in'){
+ pro_node.child_set(manage_node);
+ }else if(direct == 'out'){
+ pro_node.child_del(manage_node);
+ }
+
+ return 'cont';
+ };
+ that.unload = function(){
+
+ };
+
+ manage_node.url_chg = function(direct,url_upart,url_dpart,param){
+ var j_create_mode;
+ var j_set_mode;
+ var j_create_testmode;
+ var j_set_testmode;
+ var j_mode_list;
+ var j_testmode_list;
+
+ var set_mode_id = null;
+ var set_testmode_id = null;
+ var set_testdata_id = null;
+
+ var testmode_idmap;
+
+ function _mode_set(j_item,modeid,testmodeid){
+ j_item.find('td.id').text(modeid);
+ j_item.find('td.testmode').text(testmode_idmap[testmodeid]);
+
+ j_item.find('button.set').off('click').on('click',function(e){
+ set_mode_id = modeid;
+ j_set_mode.modal('show');
+ });
+
+ if(modeid == 1){
+ j_item.find('button.del').remove();
+ }else{
+ j_item.find('button.del').off('click').on('click',function(e){
+ com.call_backend(callpath,'del_mode',function(result){
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','管理發生錯誤');
+ }else{
+ _update();
+ }
+ },modeid);
+ });
+ }
+ }
+ function _mode_create(modeid,testmodeid){
+ var j_item = $('<tr><td class="id"></td><td class="testmode"></td><td class="oper"><div class="btn-group"><button class="btn btn-small set"><i class="icon-cog"></i></button><button class="btn btn-small del"><i class="icon-trash"></i></button></div></td></tr>')
+
+ _mode_set(j_item,modeid,testmodeid);
+
+ return j_item;
+ }
+ function _mode_update(testmode_list){
+ com.call_backend(callpath,'list_mode',function(result){
+ var i;
+ var data = result.data;
+ var j_testmode;
+ var j_option;
+ var modeo;
+ var j_item;
+
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','管理發生錯誤');
+ }else{
+ j_testmode = j_create_mode.find('[name="testmode"]');
+ j_testmode.empty();
+ for(i = 0;i < testmode_list.length;i++){
+ j_option = $('<option></option>');
+ j_option.text(testmode_list[i].testmodename);
+ j_option.attr('value',testmode_list[i].testmodeid);
+ j_testmode.append(j_option);
+ }
+
+ j_testmode = j_set_mode.find('[name="testmode"]');
+ j_testmode.empty();
+ for(i = 0;i < testmode_list.length;i++){
+ j_option = $('<option></option>');
+ j_option.text(testmode_list[i].testmodename);
+ j_option.attr('value',testmode_list[i].testmodeid);
+ j_testmode.append(j_option);
+ }
+
+ j_mode_list.empty();
+ for(i = 0;i < data.length;i++){
+ modeo = data[i];
+
+ j_item = _mode_create(modeo.modeid,modeo.testmodeid);
+ j_mode_list.append(j_item);
+ }
+ }
+ });
+ }
+
+ function _testmode_set(j_item,testmodeid,testmodename){
+ j_item.find('td.id').text(testmodeid);
+ j_item.find('td.name').text(testmodename);
+
+ j_item.find('button.set').off('click').on('click',function(e){
+ set_testmode_id = testmodeid;
+ j_set_testmode.modal('show');
+ });
+ j_item.find('button.del').off('click').on('click',function(e){
+ com.call_backend(callpath,'del_testmode',function(result){
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','管理發生錯誤');
+ }else{
+ _update();
+ }
+ },testmodeid);
+ });
+ }
+ function _testmode_create(testmodeid,testmodename){
+ var j_item = $('<tr><td class="id"></td><td class="name"></td><td class="oper"><div class="btn-group"><button class="btn btn-small set"><i class="icon-cog"></i></button><button class="btn btn-small del"><i class="icon-trash"></i></button></div></td></tr>')
+
+ _testmode_set(j_item,testmodeid,testmodename);
+
+ return j_item;
+ }
+ function _testmode_update(){
+ var defer = $.Deferred();
+
+ com.call_backend(callpath,'list_testmode',function(result){
+ var i;
+ var data = result.data;
+ var testmodeo;
+ var j_item;
+
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','管理發生錯誤');
+ }else{
+ testmode_idmap = new Object();
+ j_testmode_list.empty();
+ for(i = 0;i < data.length;i++){
+ testmodeo = data[i];
+
+ testmode_idmap[testmodeo.testmodeid] = testmodeo.testmodename;
+
+ j_item = _testmode_create(testmodeo.testmodeid,testmodeo.testmodename);
+ j_testmode_list.append(j_item);
+ }
+
+ defer.resolve(data);
+ }
+ });
+
+ return defer.promise();
+ }
+ function _update(){
+ _testmode_update().done(_mode_update);
+ }
+
+ if(direct == 'in'){
+ com.loadpage('/toj/pmod/pmod_test/html/manage.html').done(function(){
+ j_mode_list = j_index_page.find('table.mode > tbody');
+ j_testmode_list = j_index_page.find('table.testmode > tbody');
+
+ j_create_mode = j_index_page.find('div.create_mode');
+ com.create_codebox(j_create_mode.find('div.content'),'text/html');
+
+ j_create_mode.on('shown',function(e){
+ j_create_mode.find('div.content').data('codebox').refresh();
+ });
+ j_create_mode.on('hide',function(e){
+ j_create_mode.find('div.content').data('codebox').setValue('');
+ });
+ j_create_mode.find('button.submit').on('click',function(e){
+ var content = j_create_mode.find('div.content').data('codebox').getValue();
+ var testmodeid = parseInt(j_create_mode.find('[name="testmode"]').val());
+
+ com.call_backend(callpath,'add_mode',function(result){
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','管理發生錯誤');
+ }else{
+ index.add_alert('alert-success','成功','模式已建立');
+ j_create_mode.modal('hide');
+
+ _update();
+ }
+ },content,testmodeid);
+ });
+ j_create_mode.find('button.cancel').on('click',function(e){
+ j_create_mode.modal('hide');
+ });
+
+ j_index_page.find('button.create_mode').on('click',function(e){
+ j_create_mode.modal('show');
+ });
+
+ j_set_mode = j_index_page.find('div.set_mode');
+ com.create_codebox(j_set_mode.find('div.content'),'text/html');
+
+ j_set_mode.on('show',function(e){
+ com.call_backend(callpath,'get_mode',function(result){
+ var data = result.data;
+
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','管理發生錯誤');
+ }else{
+ j_set_mode.find('div.content').data('codebox').setValue(data.content);
+ j_set_mode.find('[name="testmode"]').val(data.testmodeid);
+ }
+ },set_mode_id);
+ });
+ j_set_mode.on('shown',function(e){
+ j_set_mode.find('div.content').data('codebox').refresh();
+ });
+ j_set_mode.on('hide',function(e){
+ set_mode_id = null;
+ j_set_mode.find('div.content').data('codebox').setValue('');
+ });
+ j_set_mode.find('button.submit').on('click',function(e){
+ var content = j_set_mode.find('div.content').data('codebox').getValue();
+ var testmodeid = parseInt(j_set_mode.find('[name="testmode"]').val());
+
+ com.call_backend(callpath,'set_mode',function(result){
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','管理發生錯誤');
+ }else{
+ index.add_alert('alert-success','成功','模式已設定');
+ j_set_mode.modal('hide');
+
+ _update();
+ }
+ },set_mode_id,content,testmodeid);
+ });
+ j_set_mode.find('button.cancel').on('click',function(e){
+ j_set_mode.modal('hide');
+ });
+
+ j_create_testmode = j_index_page.find('div.create_testmode');
+ j_create_testmode.on('hide',function(e){
+ j_create_testmode.find('input').val('');
+ });
+ j_create_testmode.find('button.submit').on('click',function(e){
+ var name = j_create_testmode.find('[name="name"]').val();
+ var timelimit = parseInt(j_create_testmode.find('[name="timelimit"]').val());
+ var memlimit = parseInt(j_create_testmode.find('[name="memlimit"]').val());
+
+ com.call_backend(callpath,'add_testmode',function(result){
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','管理發生錯誤');
+ }else{
+ index.add_alert('alert-success','成功','測試已建立');
+ j_create_testmode.modal('hide');
+
+ _update();
+ }
+ },name,timelimit,memlimit);
+ });
+ j_create_testmode.find('button.cancel').on('click',function(e){
+ j_create_testmode.modal('hide');
+ });
+
+ j_set_testmode = j_index_page.find('div.set_testmode');
+ j_set_testmode.on('show',function(e){
+ com.call_backend(callpath,'get_testmode',function(result){
+ var data = result.data;
+
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','管理發生錯誤');
+ }else{
+ j_set_testmode.find('[name="name"]').val(data.testmodename);
+ j_set_testmode.find('[name="timelimit"]').val(data.timelimit);
+ j_set_testmode.find('[name="memlimit"]').val(data.memlimit);
+ }
+ },set_testmode_id);
+ });
+ j_set_testmode.on('hide',function(e){
+ set_testmode_id = null;
+ });
+ j_set_testmode.find('button.submit').on('click',function(e){
+ var name = j_set_testmode.find('[name="name"]').val();
+ var timelimit = parseInt(j_set_testmode.find('[name="timelimit"]').val());
+ var memlimit = parseInt(j_set_testmode.find('[name="memlimit"]').val());
+
+ com.call_backend(callpath,'set_testmode',function(result){
+ var data = result.data;
+
+ if(com.is_callerr(result)){
+ index.add_alert('','警告','管理發生錯誤');
+ }else{
+ index.add_alert('alert-success','成功','測試已設定');
+ j_set_testmode.modal('hide');
+
+ }
+ },set_testmode_id,name,timelimit,memlimit);
+
+ });
+ j_set_testmode.find('button.cancel').on('click',function(e){
+ j_set_testmode.modal('hide');
+ });
+
+ j_index_page.find('button.create_testmode').on('click',function(e){
+ j_create_testmode.modal('show');
+ });
+
+ _update();
+ });
+ }
+
+ return 'cont';
+ };
+
+};
diff --git a/src/pmod/pmod_test/py/__pycache__/pmod_test.cpython-33.pyc b/src/pmod/pmod_test/py/__pycache__/pmod_test.cpython-33.pyc
new file mode 100644
index 0000000..427ec82
--- /dev/null
+++ b/src/pmod/pmod_test/py/__pycache__/pmod_test.cpython-33.pyc
Binary files differ
diff --git a/src/pmod/pmod_test/py/pmod_test.py b/src/pmod/pmod_test/py/pmod_test.py
new file mode 100644
index 0000000..baa5151
--- /dev/null
+++ b/src/pmod/pmod_test/py/pmod_test.py
@@ -0,0 +1,538 @@
+from tojauth import TOJAuth
+from asyncdb import AsyncDB
+import mod
+import com
+import imc.async
+from imc.proxy import Proxy
+import config
+from problem import Problem
+
+class pmod_test(Problem):
+ _pmod_name = 'pmod_test'
+
+ def __init__(self, mod_idendesc, get_link_fn, proid):
+ self._proid = proid
+ self._idendesc = mod_idendesc
+ self.get_link = get_link_fn
+
+ self._proinfo = mod.ProblemMg.get_problem_info_by_proid(self._proid)
+ self._accessid = mod.ProblemMg.get_accessid_by_proid(self._proid)
+
+ self.db = AsyncDB(config.MOD_DBNAME, config.MOD_DBUSER,
+ config.MOD_DBPASSWORD)
+
+ self._reg_path = 'pro/' + str(self._proid) + '/'
+
+ Proxy.instance.register_call(
+ self._reg_path, 'add_mode', self.add_mode)
+ Proxy.instance.register_call(
+ self._reg_path, 'del_mode', self.del_mode)
+ Proxy.instance.register_call(
+ self._reg_path, 'set_mode', self.set_mode)
+ Proxy.instance.register_call(
+ self._reg_path, 'get_mode', self.get_mode)
+ Proxy.instance.register_call(
+ self._reg_path, 'list_mode', self.list_mode)
+ Proxy.instance.register_call(
+ self._reg_path, 'add_testmode', self.add_testmode)
+ Proxy.instance.register_call(
+ self._reg_path, 'del_testmode', self.del_testmode)
+ Proxy.instance.register_call(
+ self._reg_path, 'set_testmode', self.set_testmode)
+ Proxy.instance.register_call(
+ self._reg_path, 'get_testmode', self.get_testmode)
+ Proxy.instance.register_call(
+ self._reg_path, 'list_testmode', self.list_testmode)
+ Proxy.instance.register_call(
+ self._reg_path, 'set_testdata', self.set_testdata)
+ Proxy.instance.register_call(
+ self._reg_path, 'get_testdata', self.get_testdata)
+
+ def unload(self, force):
+ Proxy.instance.unregister_call(
+ self._reg_path, 'add_mode')
+ Proxy.instance.unregister_call(
+ self._reg_path, 'del_mode')
+ Proxy.instance.unregister_call(
+ self._reg_path, 'set_mode')
+ Proxy.instance.unregister_call(
+ self._reg_path, 'get_mode')
+ Proxy.instance.unregister_call(
+ self._reg_path, 'list_mode')
+ Proxy.instance.unregister_call(
+ self._reg_path, 'add_testmode')
+ Proxy.instance.unregister_call(
+ self._reg_path, 'del_testmode')
+ Proxy.instance.unregister_call(
+ self._reg_path, 'set_testmode')
+ Proxy.instance.unregister_call(
+ self._reg_path, 'get_testmode')
+ Proxy.instance.unregister_call(
+ self._reg_path, 'set_testdata')
+ Proxy.instance.unregister_call(
+ self._reg_path, 'get_testdata')
+
+ @staticmethod
+ @TOJAuth.check_access(mod.ProblemMg._accessid, TOJAuth.ACCESS_CREATE)
+ def create_problem_data(proid):
+ db = AsyncDB(config.MOD_DBNAME, config.MOD_DBUSER,
+ config.MOD_DBPASSWORD)
+
+ cur = db.cursor()
+ sqlstr = ('INSERT INTO "PMOD_TEST_MODE" ("proid", "modeid", '
+ '"content", "testmodeid") VALUES (%s, %s, %s, %s);')
+ sqlarr = (proid, 1, '', None)
+ cur.execute(sqlstr, sqlarr)
+
+ @staticmethod
+ @TOJAuth.check_access(mod.ProblemMg._accessid, TOJAuth.ACCESS_DELETE)
+ def delete_problem_data(proid):
+ db = AsyncDB(config.MOD_DBNAME, config.MOD_DBUSER,
+ config.MOD_DBPASSWORD)
+
+ cur = db.cursor()
+ sqlstr = ('DELETE FROM "PMOD_TEST_MODE" WHERE "proid" = %s;')
+ sqlarr = (proid, )
+ cur.execute(sqlstr, sqlarr)
+
+ sqlstr = ('DELETE FROM "PMOD_TEST_TESTMODE" WHERE "proid" = %s;')
+ sqlarr = (proid, )
+ cur.execute(sqlstr, sqlarr)
+
+ sqlstr = ('DELETE FROM "PMOD_TEST_TESTDATA" WHERE "proid" = %s;')
+ sqlarr = (proid, )
+ cur.execute(sqlstr, sqlarr)
+
+ @imc.async.caller
+ def add_mode(self, content, testmodeid):
+ if(
+ (content != None and type(content) != str) or
+ (testmodeid != None and type(testmodeid) != int)
+ ):
+ return 'Eparameter'
+
+ if testmodeid != None and not self._does_testmodeid_exist(testmodeid):
+ return 'Etestmodeid'
+
+ self._add_mode(None, content, testmodeid)
+
+ return 'Success'
+
+ def _add_mode(self, modeid, content, testmodeid):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqltab = ('INSERT INTO "PMOD_TEST_MODE" (')
+ sqlcol = ('"proid", "content", "testmodeid"')
+ sqlval = (') VALUES (%s, %s, %s')
+ sqlend = (');')
+ sqlarr = [self._proid, content, testmodeid]
+
+ if modeid != None:
+ sqlcol = sqlcol + ', "modeid"'
+ sqlval = sqlval + ', %s'
+ sqlarr.append(modeid)
+
+ sqlstr = sqltab + sqlcol + sqlval + sqlend
+ cur.execute(sqlstr, sqlarr)
+
+ @imc.async.caller
+ def del_mode(self, modeid):
+ if(
+ type(modeid) != int
+ ):
+ return 'Eparameter'
+
+ if modeid == 1 or not self._does_modeid_exist(modeid):
+ return 'Emodeid'
+
+ self._del_mode(modeid)
+
+ return 'Success'
+
+ def _del_mode(self, modeid):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('DELETE FROM "PMOD_TEST_MODE" WHERE "proid" = %s AND '
+ '"modeid" = %s;')
+ sqlarr = (self._proid, modeid)
+ cur.execute(sqlstr, sqlarr)
+
+ @imc.async.caller
+ def set_mode(self, modeid, content, testmodeid):
+ if(
+ type(modeid) != int or
+ (content != None and type(content) != str) or
+ (testmodeid != None and type(testmodeid) != int)
+ ):
+ return 'Eparameter'
+
+ if not self._does_modeid_exist(modeid):
+ return 'Emodeid'
+
+ if testmodeid != None and not self._does_testmodeid_exist(testmodeid):
+ return 'Etestmodeid'
+
+ self._set_mode(modeid, content, testmodeid)
+
+ return 'Success'
+
+ def _set_mode(self, modeid, content, testmodeid):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('UPDATE "PMOD_TEST_MODE" SET "content" = %s, '
+ '"testmodeid" = %s WHERE "proid" = %s AND "modeid" = %s;')
+ sqlarr = (content, testmodeid, self._proid, modeid)
+ cur.execute(sqlstr, sqlarr)
+
+ @imc.async.caller
+ def get_mode(self, modeid):
+ if(
+ type(modeid) != int
+ ):
+ return 'Eparameter'
+
+ mode = self._get_mode_by_modeid(modeid)
+
+ if mode == None:
+ return 'Emodeid'
+
+ return mode
+
+ @imc.async.caller
+ def list_mode(self):
+ mode_list = self._list_mode()
+
+ return mode_list
+
+ def _list_mode(self):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('SELECT "modeid", "testmodeid" FROM "PMOD_TEST_MODE" '
+ 'WHERE "proid" = %s ORDER BY "modeid" ASC;')
+ sqlarr = (self._proid, )
+ cur.execute(sqlstr, sqlarr)
+
+ mode_list = []
+ for data in cur:
+ obj = {}
+ obj['modeid'] = data[0]
+ obj['testmodeid'] = data[1]
+
+ mode_list.append(obj)
+
+ return mode_list
+
+ @imc.async.caller
+ def add_testmode(self, testmodename, timelimit, memlimit):
+ if(
+ type(testmodename) != str or
+ (timelimit != None and type(timelimit) != int) or
+ (memlimit != None and type(memlimit) != int)
+ ):
+ return 'Eparameter'
+
+ if timelimit != None and timelimit < 0:
+ return 'Etimelimit'
+ if memlimit != None and memlimit < 0:
+ return 'Ememlimit'
+
+ self._add_testmode(testmodename, timelimit, memlimit)
+
+ return 'Success'
+
+ def _add_testmode(self, testmodename, timelimit, memlimit):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('INSERT INTO "PMOD_TEST_TESTMODE" ("proid", "testmodename", '
+ '"timelimit", "memlimit") VALUES (%s, %s, %s, %s);')
+ sqlarr = (self._proid, testmodename, timelimit, memlimit)
+ cur.execute(sqlstr, sqlarr)
+
+ @imc.async.caller
+ def del_testmode(self, testmodeid):
+ if(
+ type(testmodeid) != int
+ ):
+ return 'Eparameter'
+
+ if not self._does_testmodeid_exist(testmodeid):
+ return 'Etestmodeid'
+
+ self._del_testmode(testmodeid)
+
+ return 'Success'
+
+ def _del_testmode(self, testmodeid):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('DELETE FROM "PMOD_TEST_TESTMODE" WHERE "proid" = %s AND '
+ '"testmodeid" = %s;')
+ sqlarr = (self._proid, testmodeid)
+ cur.execute(sqlstr, sqlarr)
+
+ sqlstr = ('DELETE FROM "PMOD_TEST_TESTDATA" WHERE "proid" = %s AND '
+ '"testmodeid" = %s;')
+ sqlarr = (self._proid, testmodeid)
+ cur.execute(sqlstr, sqlarr)
+
+ @imc.async.caller
+ def set_testmode(self, testmodeid, testmodename, timelimit, memlimit):
+ if(
+ type(testmodeid) != int or
+ type(testmodename) != str or
+ (timelimit != None and type(timelimit) != int) or
+ (memlimit != None and type(memlimit) != int)
+ ):
+ return 'Eparameter'
+
+ if not self._does_testmodeid_exist(testmodeid):
+ return 'Etestmodeid'
+
+ if timelimit != None and timelimit < 0:
+ return 'Etimelimit'
+ if memlimit != None and memlimit < 0:
+ return 'Ememlimit'
+
+ self._set_testmode(testmodeid, testmodename, timelimit, memlimit)
+
+ return 'Success'
+
+ def _set_testmode(self, testmodeid, testmodename, timelimit, memlimit):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('UPDATE "PMOD_TEST_TESTMODE" SET "testmodename" = %s, '
+ '"timelimit" = %s, "memlimit" = %s WHERE "proid" = %s AND '
+ '"testmodeid" = %s;')
+ sqlarr = (testmodename, timelimit, memlimit, self._proid, testmodeid)
+ cur.execute(sqlstr, sqlarr)
+
+ @imc.async.caller
+ def get_testmode(self, testmodeid):
+ if(
+ type(testmodeid) != int
+ ):
+ return 'Eparameter'
+
+ if not self._does_testmodeid_exist(testmodeid):
+ return 'Etestmodeid'
+
+ testmode = self._get_testmode(testmodeid)
+
+ return testmode
+
+ def _get_testmode(self, testmodeid):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('SELECT "testmodeid", "testmodename", "timelimit", '
+ '"memlimit" FROM "PMOD_TEST_TESTMODE" WHERE "proid" = %s AND '
+ '"testmodeid" = %s;')
+ sqlarr = (self._proid, testmodeid)
+ cur.execute(sqlstr, sqlarr)
+
+ testmode = None
+ for data in cur:
+ testmode = {}
+ testmode['testmodeid'] = data[0]
+ testmode['testmodename'] = data[1]
+ testmode['timelimit'] = data[2]
+ testmode['memlimit'] = data[3]
+
+ return testmode
+
+ @imc.async.caller
+ def list_testmode(self):
+ testmode_list = self._list_testmode()
+
+ return testmode_list
+
+ def _list_testmode(self):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('SELECT "testmodeid", "testmodename", "timelimit", '
+ '"memlimit" FROM "PMOD_TEST_TESTMODE" WHERE "proid" = %s '
+ 'ORDER BY "testmodeid" ASC;')
+ sqlarr = (self._proid, )
+ cur.execute(sqlstr, sqlarr)
+
+ testmode_list = []
+ for data in cur:
+ obj = {}
+ obj['testmodeid'] = data[0]
+ obj['testmodename'] = data[1]
+ obj['timelimit'] = data[2]
+ obj['memlimit'] = data[3]
+
+ testmode_list.append(obj)
+
+ return testmode_list
+
+ @imc.async.caller
+ def set_testdata(self, testmodeid, testdata):
+ if(
+ type(testmodeid) != int or
+ type(testdata) != list
+ ):
+ return 'Eparameter'
+
+ for test in testdata:
+ if type(test) != list:
+ return 'Eparameter'
+ if(
+ 'testid' not in test or
+ type(test['testid']) != int or
+ 'timelimit' not in test or
+ type(test['timelimit']) != int or
+ 'memlimit' not in test or
+ type(test['memlimit']) != int or
+ 'subtask' not in test or
+ type(test['subtask']) != int
+ ):
+ return 'Eparameter'
+
+ if test['timelimit'] != None and test['timelimit'] < 0:
+ return 'Etimelimit'
+ if test['memlimit'] != None and test['memlimit'] < 0:
+ return 'Ememlimit'
+
+ if not self._does_testmodeid_exist(testmodeid):
+ return 'Etestmodeid'
+
+ self._set_testdata(testmodeid, testdata)
+
+ return 'Success'
+
+ def _set_testdata(self, testmodeid, testdata):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('DELETE FROM "PMOD_TEST_TESTDATA" WHERE "proid" = %s AND '
+ '"testmodeid" = %s;')
+ sqlarr = (self._proid, testmodeid)
+ cur.execute(sqlstr, sqlarr)
+
+ if len(testdata) == 0:
+ return
+
+ sqltab = ('INSERT INTO "PMOD_TEST_TESTDATA" ("proid", "testmodeid", '
+ '"order", "testid", "timelimit", "memlimit", "subtask") '
+ 'VALUES')
+ sqlval = ()
+ sqlend = (';')
+ sqlarr = []
+
+ cnt = 0
+ for test in testdata:
+ if cnt == 0:
+ sqlval = sqlval + ' '
+ else:
+ sqlval = sqlval + ', '
+
+ cnt = cnt + 1
+ sqlval = sqlval + '(%s, %s, %s, %s, %s, %s, %s)'
+ sqlarr.append(self._proid)
+ sqlarr.append(testmodeid)
+ sqlarr.append(cnt)
+ sqlarr.append(test['testid'])
+ sqlarr.append(test['timelimit'])
+ sqlarr.append(test['memlimit'])
+ sqlarr.append(test['subtask'])
+
+ sqlstr = sqltab + sqlval + sqlend
+ cur.execute(sqlstr, sqlarr)
+
+ @imc.async.caller
+ def get_testdata(self, testmodeid):
+ if(
+ type(testmodeid) != int
+ ):
+ return 'Eparameter'
+
+ if not self._does_testmodeid_exist(testmodeid):
+ return 'Etestmodeid'
+
+ testdata = self._get_testdata(testmodeid)
+
+ return testdata
+
+ def _get_testdata(self, testmodeid):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('SELECT "order", "testid", "timelimit", "memlimit", '
+ '"subtask" FROM "PMOD_TEST_TESTDATA" WHERE "proid" = %s AND '
+ '"testmodeid" = %s ORDER BY "order" ASC;')
+ sqlarr = (self._proid, testmodeid)
+ cur.execute(sqlstr, sqlarr)
+
+ testdata = []
+ for data in cur:
+ obj = {}
+ obj['order'] = data[0]
+ obj['testid'] = data[1]
+ obj['timelimit'] = data[2]
+ obj['memlimit'] = data[3]
+ obj['subtask'] = data[4]
+
+ testdata.append(obj)
+
+ return testdata
+
+ def _does_modeid_exist(self, modeid):
+ mode = self._get_mode_by_modeid(modeid)
+
+ return mode != None
+
+ def _get_mode_by_modeid(self, modeid):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('SELECT "proid", "modeid", "content", "testmodeid" FROM '
+ '"PMOD_TEST_MODE" WHERE "proid" = %s AND "modeid" = %s;')
+ sqlarr = (self._proid, modeid)
+ cur.execute(sqlstr, sqlarr)
+
+ mode = None
+ for data in cur:
+ mode = {}
+ mode['proid'] = data[0]
+ mode['modeid'] = data[1]
+ mode['content'] = data[2]
+ mode['testmodeid'] = data[3]
+
+ return mode
+
+ def _does_testmodeid_exist(self, testmodeid):
+ testmode_info = self._get_testmode_info(testmodeid)
+
+ return testmode_info != None
+
+ def _get_testmode_info(self, testmodeid):
+ TOJAuth.check_access_func(self._accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('SELECT "proid", "testmodeid", "testmodename", "timelimit",'
+ ' "memlimit" FROM "PMOD_TEST_TESTMODE" WHERE "proid" = %s '
+ 'AND "testmodeid" = %s;')
+ sqlarr = (self._proid, testmodeid)
+ cur.execute(sqlstr, sqlarr)
+
+ testmode_info = None
+ for data in cur:
+ testmode_info = {}
+ testmode_info['proid'] = data[0]
+ testmode_info['testmodeid'] = data[1]
+ testmode_info['testmodename'] = data[2]
+ testmode_info['timelimit'] = data[3]
+ testmode_info['memlimit'] = data[4]
+
+ return testmode_info
+
diff --git a/src/py/backend_server.py b/src/py/backend_server.py
index 6d0ceec..7042d41 100755
--- a/src/py/backend_server.py
+++ b/src/py/backend_server.py
@@ -52,8 +52,8 @@ class BackendWorker(tornado.tcpserver.TCPServer):
self._client_linkmap = {}
def start(self):
- sys.stdout = self._log
- sys.stderr = self._log
+ #sys.stdout = self._log
+ #sys.stderr = self._log
sock_port = random.randrange(4096,8192)
self.sock_addr = ('10.8.0.6',sock_port)
diff --git a/src/py/imc/blobclient.py b/src/py/imc/blobclient.py
index f4879af..8a7baea 100755
--- a/src/py/imc/blobclient.py
+++ b/src/py/imc/blobclient.py
@@ -129,14 +129,13 @@ class BlobClient:
if not sta:
# TODO:
# pend operation when client can't imc call server
- return None
- if ret is None:
- return True
- elif not ret:
+ pass
+ elif ret == 'up_to_date':
+ pass
+ elif ret == 'no_exist':
self._cachetable.del_blob(blobname)
if cacherev:
self.del_real_blob(''.join([blobname, '_', str(cacherev)]))
- return None
else:
info = ret['info']
rev = info['rev']
@@ -145,14 +144,9 @@ class BlobClient:
sta, ret = self._server_call('recv_update_result', blobname,
rst, rev, True)
- if not sta:
- pass
- # TODO:
if 'Success' == ret:
self.update_blob(blobname, info)
- return True
-
- return False
+ break
def commit(self, commit_info, force_flag, blobhandle):
filekey = None
@@ -205,28 +199,26 @@ class BlobClient:
def open(self, container, blobname, flag):
if container not in self._containers:
raise Exception("this container isn't open")
- blob = container + '_' + blobname
- is_existent = self.update(blob)
- if is_existent is None:
+ blob = ''.join([container, '_', blobname])
+ self.update(blob)
+ info = self._cachetable.get_blob_info(blob)
+ if info is None:
if (not flag & self.BlobHandle.WRITE or
not flag & self.BlobHandle.CREATE):
- raise Exception("the blob doesn't exist, so you must "
- "add a create flag")
- elif not is_existent:
- pass
- try:
- info = self._cachetable.get_blob_info(blob)
- if info is None:
+ raise ValueError("the blob doesn't exist, so you must "
+ "add a create flag")
+ else:
info = {'container': container,
'rev': 0,
'metadata': '',
'size': None,
'commit_time': None}
+ try:
handle = self.BlobHandle(blob, info, flag, self)
- except:
+ except ValueError:
raise
else:
- blob += '_' + str(handle.get_rev())
+ blob = ''.join(blob, '_', str(handle.get_rev()))
self._opencounts[blob] += 1
return handle
diff --git a/src/py/imc/blobserver.py b/src/py/imc/blobserver.py
index 73bc143..b876833 100755
--- a/src/py/imc/blobserver.py
+++ b/src/py/imc/blobserver.py
@@ -131,14 +131,14 @@ class BlobServer:
def check_blob(self, client, blobname, cacherev):
rev = self._blobtable.get_blob_info(blobname, 'rev')
if rev is None:
- return False
+ return 'no_exist'
elif cacherev < rev:
result = self.send_blob(client, blobname)
response = {'filekey': result.filekey,
'info': self._blobtable.get_blob_info(blobname)}
return response
else:
- return None
+ return 'up_to_date'
@imc.async.caller
def recv_update_result(self, client, blobname, result,
diff --git a/src/py/imc/proxy.py b/src/py/imc/proxy.py
index ecc08da..5846bd2 100755
--- a/src/py/imc/proxy.py
+++ b/src/py/imc/proxy.py
@@ -333,6 +333,9 @@ class Proxy:
except KeyError:
return __ret((False,'Enoexist'))
+ #except Exception:
+ # return __ret((False,'Einternal'))
+
if Auth.get_current_idendesc() == idendesc:
result = func(*param)
diff --git a/src/py/mod.py b/src/py/mod.py
index e67a9e6..af24577 100644
--- a/src/py/mod.py
+++ b/src/py/mod.py
@@ -8,9 +8,9 @@ import importlib.machinery
mod = sys.modules[__name__]
mod_list = {}
-class SqmodFinder(MetaPathFinder):
+class ModFinder(MetaPathFinder):
def find_module(fullname,path):
- if not fullname.startswith('sqmod/'):
+ if not fullname.startswith('/srv/'):
return None
return importlib.machinery.SourceFileLoader(fullname,fullname + '.py')
@@ -26,10 +26,13 @@ def unload(name):
del mod_list[name]
def load_sqmod(sqmodname):
- print(sqmodname)
-
- instance = import_module(''.join(['sqmod/',sqmodname,'/py/',sqmodname]))
+ instance = import_module(''.join(['/srv/py/sqmod/',sqmodname,'/py/',sqmodname]))
return getattr(instance,sqmodname)
-sys.meta_path.append(SqmodFinder)
+def load_pmod(pmodname):
+ instance = import_module(''.join(['/srv/http/toj/pmod/',pmodname,'/py/',pmodname]))
+
+ return getattr(instance,pmodname)
+
+sys.meta_path.append(ModFinder)
diff --git a/src/py/notice.py b/src/py/notice.py
index de2e2d8..564aa96 100644
--- a/src/py/notice.py
+++ b/src/py/notice.py
@@ -25,6 +25,16 @@ class Notice:
Proxy.instance.register_call(
'core/notice/', 'get_unseen_count', self.get_unseen_count)
+ def unload(self):
+ Proxy.instance.unregister_call(
+ 'core/notice/', 'list_notice')
+ Proxy.instance.unregister_call(
+ 'core/notice/', 'read_notice')
+ Proxy.instance.unregister_call(
+ 'core/notice/', 'del_notice')
+ Proxy.instance.unregister_call(
+ 'core/notice/', 'get_unseen_count')
+
@TOJAuth.check_access(_accessid, TOJAuth.ACCESS_EXECUTE)
def send_notice(self, uid, title, content, noticemod_path, metadata):
cur = self.db.cursor()
@@ -78,6 +88,8 @@ class Notice:
self._del_notice(noticeid)
self.notify_client(notice['uid'])
+ return 'Success'
+
@TOJAuth.check_access(_accessid, TOJAuth.ACCESS_EXECUTE)
def _del_notice(self, noticeid):
cur = self.db.cursor()
@@ -141,6 +153,8 @@ class Notice:
with TOJAuth.change_current_iden(self._idendesc):
self.set_notice_unread(noticeid, False)
+ return 'Success'
+
@TOJAuth.check_access(_accessid, TOJAuth.ACCESS_EXECUTE)
def set_notice_unread(self, noticeid, unread):
cur = self.db.cursor()
@@ -233,6 +247,3 @@ class Notice:
return ret
- def unload():
- pass
-
diff --git a/src/py/problem.py b/src/py/problem.py
index 443408a..b202f8c 100644
--- a/src/py/problem.py
+++ b/src/py/problem.py
@@ -19,6 +19,8 @@ class ProblemMg:
self.get_link = get_link_fn
self._pmod_list = {}
+ Proxy.instance.register_filter('pro/', self.pmod_filter)
+
Proxy.instance.register_call(
'core/problem/', 'create_problem', self.create_problem)
Proxy.instance.register_call(
@@ -28,19 +30,30 @@ class ProblemMg:
Proxy.instance.register_call(
'core/problem/', 'list_problem', self.list_problem)
Proxy.instance.register_call(
+ 'core/problem/', 'get_problem_info', self.get_problem_info)
+ Proxy.instance.register_call(
'core/problem/', 'list_pmod', self.list_pmod)
def unload(self):
+ Proxy.instance.unregister_filter('pro/',self.pmod_filter)
+
Proxy.instance.unregister_call(
'core/problem/', 'create_problem')
- Proxy.instance.register_call(
+ Proxy.instance.unregister_call(
'core/problem/', 'delete_problem')
Proxy.instance.unregister_call(
'core/problem/', 'set_problem')
Proxy.instance.unregister_call(
'core/problem/', 'list_problem')
Proxy.instance.unregister_call(
- 'core/problem/', 'list_problem')
+ 'core/problem/', 'get_problem_info')
+ Proxy.instance.unregister_call(
+ 'core/problem/', 'list_pmod')
+
+ def pmod_filter(self, res_path, dst_func):
+ proid = int(res_path[0])
+ with TOJAuth.change_current_iden(self._idendesc):
+ self.load_problem(proid)
@TOJAuth.check_access(_accessid, TOJAuth.ACCESS_EXECUTE)
def load_problem(self, proid):
@@ -48,7 +61,7 @@ class ProblemMg:
return self._pmod_list[proid]
proinfo = self.get_problem_info_by_proid(proid)
- pmodname = self.proinfo['pmodname']
+ pmodname = proinfo['pmodname']
pmod = mod.load_pmod(pmodname)
self._pmod_list[proid] = pmod(self._idendesc, self.get_link, proid)
@@ -61,9 +74,10 @@ class ProblemMg:
del self._pmod_list[proid]
@imc.async.caller
- def create_problem(self, title, pmodid):
+ def create_problem(self, title, hidden, pmodid):
if(
type(title) != str or
+ type(hidden) != bool or
type(pmodid) != int
):
return 'Eparameter'
@@ -77,6 +91,8 @@ class ProblemMg:
return 'Epmodid'
proid = self._create_problem(title, pmodid)
+ self._set_problem_hidden(proid, hidden)
+
return {'proid': proid}
@TOJAuth.check_access(_accessid, TOJAuth.ACCESS_CREATE)
@@ -107,10 +123,10 @@ class ProblemMg:
TOJAuth.ACCESS_ALL
)
- # pmodname = self.get_pmodname_by_pmodid(pmodid)
- # pmod = mod.load_pmod(pmodname)
+ pmodname = self.get_pmodname_by_pmodid(pmodid)
+ pmod = mod.load_pmod(pmodname)
- # pmod.create_problem_data(proid)
+ pmod.create_problem_data(proid)
return proid
@@ -132,14 +148,14 @@ class ProblemMg:
accessid = self.get_accessid_by_proid(proid)
TOJAuth.check_access_func(accessid, TOJAuth.ACCESS_DELETE)
- # proinfo = self.get_problem_info_by_proid(proid)
- # pmodname = proinfo['pmodname']
- # pmod = mod.load_pmod(pmodname)
+ proinfo = self.get_problem_info_by_proid(proid)
+ pmodname = proinfo['pmodname']
+ pmod = mod.load_pmod(pmodname)
with TOJAuth.change_current_iden(self._idendesc):
self.unload_problem(proid)
- # pmod.delete_problem_data(proid)
+ pmod.delete_problem_data(proid)
TOJAuth.instance.del_access(accessid)
@@ -149,10 +165,11 @@ class ProblemMg:
cur.execute(sqlstr, sqlarr)
@imc.async.caller
- def imc_set_problem(self, proid, title):
+ def imc_set_problem(self, proid, title, hidden):
if(
type(proid) != int or
- type(title) != str
+ type(title) != str or
+ type(hidden) != bool
):
return 'Eparameter'
@@ -165,6 +182,7 @@ class ProblemMg:
return 'Eproid'
self.set_problem(proid, title)
+ self._set_problem_hidden(proid, hidden)
return 'Success'
@@ -186,8 +204,8 @@ class ProblemMg:
@TOJAuth.check_access(_accessid, TOJAuth.ACCESS_EXECUTE)
def _list_problem(self):
cur = self.db.cursor()
- sqlstr = ('SELECT "proid", "title", "pmodid" FROM "PROBLEM" ORDER BY '
- '"proid" ASC;')
+ sqlstr = ('SELECT "proid", "title", "hidden", "pmodid" FROM "PROBLEM" '
+ 'ORDER BY "proid" ASC;')
cur.execute(sqlstr)
problem_list = []
@@ -195,7 +213,8 @@ class ProblemMg:
obj = {}
obj['proid'] = data[0]
obj['title'] = data[1]
- obj['pmodid'] = data[2]
+ obj['hidden'] = data[2]
+ obj['pmodid'] = data[3]
problem_list.append(obj)
@@ -233,6 +252,26 @@ class ProblemMg:
return pmod_list
+ def _set_problem_hidden(self, proid, hidden):
+ accessid = self.get_accessid_by_proid(proid)
+ TOJAuth.check_access_func(accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('UPDATE "PROBLEM" SET "hidden" = %s WHERE "proid" = %s;')
+ sqlarr = (hidden, proid)
+ cur.execute(sqlstr, sqlarr)
+
+ if hidden == True:
+ TOJAuth.instance.set_access_list(
+ accessid, TOJAuth.ROLEID_GUEST, TOJAuth.ACCESS_READ)
+ TOJAuth.instance.set_access_list(
+ accessid, TOJAuth.ROLEID_USER_GROUP, TOJAuth.ACCESS_READ)
+ else:
+ TOJAuth.instance.del_access_list(
+ accessid, TOJAuth.ROLEID_GUEST)
+ TOJAuth.instance.del_access_list(
+ accessid, TOJAuth.ROLEID_USER_GROUP)
+
def get_accessid_by_proid(self, proid):
cur = self.db.cursor()
sqlstr = ('SELECT "accessid" FROM "PROBLEM" WHERE "proid" = %s;')
@@ -247,8 +286,8 @@ class ProblemMg:
def get_problem_info_by_proid(self, proid):
cur = self.db.cursor()
- sqlstr = ('SELECT "proid", "title", "pmodid" FROM "PROBLEM" WHERE '
- '"proid" = %s;')
+ sqlstr = ('SELECT "proid", "title", "hidden", "pmodid" FROM "PROBLEM" '
+ 'WHERE "proid" = %s;')
sqlarr = (proid, )
cur.execute(sqlstr, sqlarr)
@@ -257,9 +296,10 @@ class ProblemMg:
ret = {}
ret['proid'] = data[0]
ret['title'] = data[1]
- ret['pmodid'] = data[2]
+ ret['hidden'] = data[2]
+ ret['pmodid'] = data[3]
- # ret['pmodname'] = self.get_pmodname_by_pmodid(obj['pmodid'])
+ ret['pmodname'] = self.get_pmodname_by_pmodid(ret['pmodid'])
return ret
@@ -269,7 +309,16 @@ class ProblemMg:
return pro_info != None
def get_pmodname_by_pmodid(self, pmodid):
- return 'ABC'
+ cur = self.db.cursor()
+ sqlstr = ('SELECT "pmodname" FROM "PMOD" WHERE "pmodid" = %s;')
+ sqlarr = (pmodid, )
+ cur.execute(sqlstr, sqlarr)
+
+ pmodname = None
+ for data in cur:
+ pmodname = data[0]
+
+ return pmodname
def does_pmodid_exist(self, pmodid):
pmodname = self.get_pmodname_by_pmodid(pmodid)
diff --git a/src/py/square.py b/src/py/square.py
index 159120b..6ce0d85 100644
--- a/src/py/square.py
+++ b/src/py/square.py
@@ -135,17 +135,18 @@ class SquareMg:
if not self.does_sqmodid_exist(sqmodid):
return 'Eno_such_sqmodid'
- sqid = self._create_square(title, hidden, sqmodid, intro, logo)
+ sqid = self._create_square(title, sqmodid, intro, logo)
self._set_square_category(sqid, category)
+ self._set_square_hidden(sqid, hidden)
return {'sqid': sqid}
@TOJAuth.check_access(_accessid, TOJAuth.ACCESS_CREATE)
- def _create_square(self, title, hidden, sqmodid, intro, logo):
+ def _create_square(self, title, sqmodid, intro, logo):
cur = self.db.cursor()
sqlstr = ('INSERT INTO "SQUARE" ("title", "hidden", "sqmodid", '
'"intro", "logo", "accessid") VALUES (%s, %s, %s, %s, '
'%s, %s) RETURNING "sqid";')
- sqlarr = (title, hidden, sqmodid, intro, logo, 0)
+ sqlarr = (title, False, sqmodid, intro, logo, 0)
cur.execute(sqlstr, sqlarr)
sqid = None
@@ -269,21 +270,21 @@ class SquareMg:
if not self.does_cateid_exist(cateid):
return 'Eno_such_cateid'
- self.set_square(sqid, title, start_time, end_time, hidden, intro, logo)
+ self.set_square(sqid, title, start_time, end_time, intro, logo)
self._set_square_category(sqid, category)
+ self._set_square_hidden(sqid, hidden)
return 'Success'
- def set_square(self, sqid, title, start_time, end_time, hidden, intro,
- logo):
+ def set_square(self, sqid, title, start_time, end_time, intro, logo):
accessid = self.get_accessid_by_sqid(sqid)
TOJAuth.check_access_func(accessid, TOJAuth.ACCESS_WRITE)
cur = self.db.cursor()
sqlstr = ('UPDATE "SQUARE" SET "title" = %s, "start_time" = %s, '
- '"end_time" = %s, "hidden" = %s, "intro" = %s, "logo" = %s '
+ '"end_time" = %s, "intro" = %s, "logo" = %s '
'WHERE "sqid" = %s;')
- sqlarr = (title, start_time, end_time, hidden, intro, logo, sqid)
+ sqlarr = (title, start_time, end_time, intro, logo, sqid)
cur.execute(sqlstr, sqlarr)
@imc.async.caller
@@ -428,8 +429,8 @@ class SquareMg:
sq_accessid = self.get_accessid_by_sqid(sqid)
TOJAuth.check_access_func(sq_accessid, TOJAuth.ACCESS_WRITE)
- if category == {}:
- category = {0}
+ if category == []:
+ category = [0]
cur = self.db.cursor()
sqlstr = ('UPDATE "SQUARE" SET "cateid" = %s WHERE "sqid" = %s;')
@@ -555,6 +556,26 @@ class SquareMg:
sqlarr = (uid, sqid)
cur.execute(sqlstr, sqlarr)
+ def _set_square_hidden(self, sqid, hidden):
+ accessid = self.get_accessid_by_sqid(sqid)
+ TOJAuth.check_access_func(accessid, TOJAuth.ACCESS_WRITE)
+
+ cur = self.db.cursor()
+ sqlstr = ('UPDATE "SQUARE" SET "hidden" = %s WHERE "sqid" = %s')
+ sqlarr = (hidden, sqid)
+ cur.execute(sqlstr, sqlarr)
+
+ if hidden == True:
+ TOJAuth.instance.set_access_list(
+ accessid, TOJAuth.ROLEID_GUEST, TOJAuth.ACCESS_READ)
+ TOJAuth.instance.set_access_list(
+ accessid, TOJAuth.ROLEID_USER_GROUP, TOJAuth.ACCESS_READ)
+ else:
+ TOJAuth.instance.del_access_list(
+ accessid, TOJAuth.ROLEID_GUEST)
+ TOJAuth.instance.del_access_list(
+ accessid, TOJAuth.ROLEID_USER_GROUP)
+
def get_square_info_by_sqid(self, sqid):
cur = self.db.cursor()
sqlstr = ('SELECT "sqid", "title", "start_time", "end_time", '
diff --git a/src/py/tojauth.py b/src/py/tojauth.py
index 3446efb..7d19526 100755
--- a/src/py/tojauth.py
+++ b/src/py/tojauth.py
@@ -23,7 +23,10 @@ class TOJAuth(Auth):
ROLEID_MOD = 2
ROLEID_GUEST = 99
- ROLEID_SQUARE_ADMIN_GROUP = 101
+ ROLEID_SQUARE_ADMIN_GROUP = 101
+ ROLEID_PROBLEM_ADMIN_GROUP = 102
+
+ ROLEID_USER_GROUP = 201
_accessid = 1
diff --git a/src/sqmod/sqmod_test/css/index.css b/src/sqmod/sqmod_test/css/index.css
new file mode 100644
index 0000000..64d7015
--- /dev/null
+++ b/src/sqmod/sqmod_test/css/index.css
@@ -0,0 +1,36 @@
+@font-face {
+ font-family: Saucer-Regular;
+ src: url('/toj/sqmod/sqmod_test/html/Saucer-Regular.ttf');
+}
+@font-face {
+ font-family: Saucer-Bold;
+ src: url('/toj/sqmod/sqmod_test/html/Saucer-Bold.ttf');
+}
+@font-face {
+ font-family: Saucer-Mono;
+ src: url('/toj/sqmod/sqmod_test/html/Saucer-Mono.ttf');
+}
+#index_page div.stage {
+ width: 100%;
+ position: absolute;
+ top: 41px;
+ left: 0px;
+ font-family: Saucer-Regular;
+}
+#index_page div.stage div.box {
+ margin: 0px auto 0px auto;
+ position: relative;
+}
+#index_page div.stage div.box span.fps {
+ color: #D9D9D9;
+ font-size: 12px;
+}
+#index_page div.stage div.box canvas.stage {
+ position: absolute;
+ top: 0px;
+ left: 0px;
+}
+#index_page div.stage div.box div.butt {
+ position: absolute;
+ cursor: pointer;
+}
diff --git a/src/sqmod/sqmod_test/css/index.less b/src/sqmod/sqmod_test/css/index.less
new file mode 100644
index 0000000..6b9c590
--- /dev/null
+++ b/src/sqmod/sqmod_test/css/index.less
@@ -0,0 +1,43 @@
+@font-face {
+ font-family:Saucer-Regular;
+ src:url('/toj/sqmod/sqmod_test/html/Saucer-Regular.ttf');
+}
+@font-face {
+ font-family:Saucer-Bold;
+ src:url('/toj/sqmod/sqmod_test/html/Saucer-Bold.ttf');
+}
+@font-face {
+ font-family:Saucer-Mono;
+ src:url('/toj/sqmod/sqmod_test/html/Saucer-Mono.ttf');
+}
+
+#index_page{
+ div.stage{
+ width:100%;
+ position:absolute;
+ top:41px;
+ left:0px;
+ font-family:Saucer-Regular;
+
+ div.box{
+ margin:0px auto 0px auto;
+ position:relative;
+
+ span.fps{
+ color:#D9D9D9;
+ font-size:12px;
+ }
+
+ canvas.stage{
+ position:absolute;
+ top:0px;
+ left:0px;
+ }
+
+ div.butt{
+ position:absolute;
+ cursor:pointer;
+ }
+ }
+ }
+}
diff --git a/src/sqmod/sqmod_test/css/manage.css b/src/sqmod/sqmod_test/css/manage.css
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/src/sqmod/sqmod_test/css/manage.css
diff --git a/src/sqmod/sqmod_test/css/manage.less b/src/sqmod/sqmod_test/css/manage.less
new file mode 100644
index 0000000..b2736ad
--- /dev/null
+++ b/src/sqmod/sqmod_test/css/manage.less
@@ -0,0 +1,3 @@
+#index_page{
+
+}
diff --git a/src/sqmod/sqmod_test/html/IMSOHAPPY.jpg b/src/sqmod/sqmod_test/html/IMSOHAPPY.jpg
new file mode 100644
index 0000000..de34d3f
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/IMSOHAPPY.jpg
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/IMSOHAPPY.ogg b/src/sqmod/sqmod_test/html/IMSOHAPPY.ogg
new file mode 100644
index 0000000..dfd0180
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/IMSOHAPPY.ogg
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/JOMANDA.jpg b/src/sqmod/sqmod_test/html/JOMANDA.jpg
new file mode 100644
index 0000000..45cbdc4
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/JOMANDA.jpg
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/JOMANDA.ju b/src/sqmod/sqmod_test/html/JOMANDA.ju
new file mode 100644
index 0000000..021a5b8
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/JOMANDA.ju
@@ -0,0 +1,736 @@
+#title=JOMANDA
+#dif=3
+#lev=10
+j=JOMANDA.jpg
+m=JOMANDA.mp3
+d=905
+t=195
+#start#
+0 t=195
+0 32
+1000 64
+2000 512
+3000 1024
+3500 32768
+4500 1
+5500 8
+6500 4096
+6750 256
+7000 1024
+7500 32768
+8000 32
+9000 64
+10000 512
+11000 1024
+11500 32768
+12500 1
+13500 8
+14500 4096
+14750 256
+15000 1024
+16000 32
+17000 64
+18000 512
+19000 1024
+19500 32768
+20500 1
+21500 8
+22500 4096
+23000 1024
+23500 32768
+25000 64
+26000 512
+27000 1024
+28000 32
+29000 64
+30000 512
+30500 4096
+31000 1024
+31500 32768
+32000 32
+33000 64
+34000 512
+35000 1024
+35500 32768
+36500 1
+37500 8
+38500 4096
+38750 256
+39000 1024
+39500 32768
+40000 32
+41000 64
+42000 512
+43000 1024
+43500 32768
+44500 1
+45500 8
+46500 4096
+46750 256
+47000 1024
+48000 32
+49000 64
+50000 512
+51000 1024
+52000 32
+53000 64
+54000 512
+55000 1024
+56000 32
+57000 64
+58000 512
+59000 1024
+60000 32
+60750 16
+61500 8
+64000 49152
+64500 48
+65000 192
+65500 768
+66000 8
+66500 4096
+67000 2048
+67500 8192
+68000 49152
+68500 48
+69000 192
+69500 768
+70000 4
+70500 3
+71000 2048
+71500 4096
+72000 49152
+72500 32
+73000 8
+73500 272
+74000 128
+74500 2
+75000 1024
+75500 4096
+76000 32768
+76500 512
+77000 2048
+77500 1
+78000 256
+78500 1024
+79000 4
+79500 2
+80000 49152
+80500 48
+81000 192
+81500 768
+82000 8
+82500 4096
+83000 2048
+83500 8192
+84000 49152
+84500 48
+85000 192
+85500 768
+86000 4
+86500 3
+87000 1024
+87500 2048
+88000 49152
+88500 32
+89000 8
+89500 272
+90000 128
+90500 2
+91000 1024
+91500 4096
+92000 16384
+92500 1
+93000 4
+93500 256
+94000 8
+94500 2
+95000 2048
+95500 8192
+96000 49152
+96500 48
+97000 192
+97500 768
+98000 8
+98500 4096
+99000 2048
+99500 8192
+100000 49152
+100500 48
+101000 192
+101500 768
+102000 4
+102500 3
+103000 2048
+103500 4096
+104000 49152
+104500 32
+105000 8
+105500 272
+106000 128
+106500 2
+107000 1024
+107500 4096
+108000 32768
+108500 512
+109000 2048
+109500 1
+110000 256
+110500 1024
+111000 4
+111500 2
+112000 49152
+112500 48
+113000 192
+113500 768
+114000 8
+114500 4096
+115000 2048
+115500 8192
+116000 49152
+116500 48
+117000 192
+117500 768
+118000 4
+118500 3
+119000 1024
+119500 2048
+120000 49152
+120500 32
+121000 8
+121500 272
+122000 128
+122500 2
+123000 1024
+123500 4096
+124000 16416
+124750 516
+125500 32769
+126250 384
+127000 2064
+128000 t=160
+128000 24672
+130000 38544
+132000 t=140
+132000 26976
+134000 t=120
+134000 38544
+136000 t=90
+136000 26976
+136500 6
+137000 16
+137250 512
+137500 128
+137750 1024
+138250 96
+138750 36864
+139000 9
+139500 256
+139750 2048
+140000 24576
+140500 6
+141000 t=115
+141000 16
+141250 512
+141500 128
+141750 1024
+142250 96
+142750 36864
+143000 9
+143500 256
+143750 2048
+144000 t=135
+144000 24576
+144500 6
+145000 16
+145250 512
+145500 128
+145750 1024
+146250 96
+146750 36864
+147000 t=145
+147000 9
+147500 256
+147750 2048
+148000 24576
+148500 6
+149000 t=155
+149000 16
+149250 512
+149500 128
+149750 1024
+150250 96
+150750 36864
+151000 t=180
+151000 9
+151500 256
+151750 2048
+152000 24576
+152500 6
+153000 t=205
+153000 16
+153250 512
+153500 128
+153750 1024
+154250 96
+154750 36864
+155000 9
+155500 256
+155750 2048
+156000 24576
+156500 6
+157000 t=220
+157000 16
+157250 512
+157500 128
+157750 1024
+158250 96
+158750 36864
+159000 9
+159500 256
+159750 2048
+160000 t=260
+160000 24576
+161000 16
+162000 6
+163000 128
+164000 t=260
+164000 1536
+165000 4096
+166000 96
+167000 32768
+168000 t=300
+168000 136
+168500 4
+169000 2
+169500 1
+170000 16
+170500 256
+171000 4096
+171500 8192
+172000 16384
+172500 32768
+173000 2048
+173500 128
+174000 8
+174500 4
+175000 2
+175500 1
+176000 16
+176500 256
+177000 4096
+177500 8192
+178000 16384
+178500 32768
+179000 2048
+179500 128
+180000 8
+180500 4
+181000 2
+181500 1
+182000 16
+182500 256
+183000 4096
+183500 8192
+184000 16384
+184500 32768
+185000 2048
+185500 128
+186000 1056
+188000 t=195
+188000 520
+188750 260
+189500 32769
+190250 2064
+191000 1056
+191500 576
+192000 4096
+192750 8
+193500 8192
+194250 4
+195000 512
+195250 32
+195500 1024
+195750 64
+196000 4096
+196750 8
+197500 1
+198250 32768
+199000 32
+199250 512
+199500 64
+199750 1024
+200000 4096
+200750 2048
+201500 16
+202250 8
+202750 32768
+203000 256
+203250 512
+203500 1024
+204000 4096
+204750 128
+205500 1
+206250 2048
+207000 528
+207500 33792
+208000 4096
+208750 8
+209500 8192
+210250 4
+211000 512
+211250 32
+211500 1024
+211750 64
+212000 4096
+212750 8
+213500 1
+214250 32768
+215000 32
+215250 512
+215500 64
+215750 1024
+216000 4096
+216750 16384
+217500 2
+218250 8
+219000 1
+219500 64
+219750 256
+220000 32768
+220750 512
+221500 2
+222250 2048
+223000 33
+223500 33792
+224000 4096
+224750 8
+225500 8192
+226250 4
+227000 512
+227250 32
+227500 1024
+227750 64
+228000 4096
+228750 8
+229500 1
+230250 32768
+231000 32
+231250 512
+231500 64
+231750 1024
+232000 4096
+232750 2048
+233500 16
+234250 8
+234750 32768
+235000 256
+235250 512
+235500 1024
+236000 4096
+236750 128
+237500 1
+238250 2048
+239000 528
+239500 33792
+240000 4096
+240750 8
+241500 8192
+242250 4
+243000 512
+243250 32
+243500 1024
+243750 64
+244000 4096
+244750 8
+245500 1
+246250 32768
+247000 32
+247250 512
+247500 64
+247750 1024
+248000 4096
+248750 16384
+249500 2
+250250 8
+251000 1
+251500 64
+251750 256
+252000 32768
+252750 512
+253500 2
+254250 2048
+255000 17652
+256000 32768
+257000 1
+257500 256
+258000 8
+258500 2048
+259000 64
+259500 128
+260000 16
+260500 32
+261000 1024
+261500 4
+262000 256
+262500 512
+263000 16384
+263500 64
+264000 4096
+264500 16
+265000 2048
+265500 8
+266000 4
+266500 32
+267000 1024
+267500 8192
+268000 4096
+268500 32768
+269000 256
+269500 2048
+270000 32
+270500 4
+271000 8192
+271500 1024
+272000 4096
+272250 1
+272500 32768
+272750 8
+273250 512
+273500 16
+274000 16384
+274250 4
+274500 8192
+274750 2
+275250 1024
+275500 128
+276000 4096
+276500 32768
+277000 1
+277500 8
+278000 16384
+278250 4
+278500 8192
+278750 2
+279250 1024
+279500 128
+280000 2304
+280750 32769
+281500 24
+282250 8196
+283000 16896
+283500 1056
+284750 129
+285500 33024
+286250 2064
+287000 514
+287500 16448
+292000 20480
+292500 16
+292750 8
+293000 128
+293500 8448
+294250 4
+295000 512
+295250 32
+295500 1024
+295750 64
+296000 20480
+296500 16
+296750 8
+297000 128
+297500 257
+298250 32768
+298500 6
+299000 32
+299250 512
+299500 64
+299750 1024
+300000 20480
+300750 2048
+301500 17
+302250 8
+302750 32768
+303000 256
+303250 512
+303500 1024
+304000 4096
+304750 128
+305500 1
+306250 2048
+307000 528
+307500 33792
+308000 20480
+308500 256
+308750 8
+309000 128
+309500 8193
+310250 4
+311000 512
+311250 32
+311500 1024
+311750 64
+312000 20480
+312500 16
+312750 8
+313000 128
+313500 8193
+314250 32768
+314500 2304
+315000 32
+315250 512
+315500 64
+315750 1024
+316000 4100
+316750 16384
+317500 146
+318250 8
+319000 1
+319500 64
+319750 256
+320000 36864
+320750 516
+321500 130
+322250 1040
+323000 2080
+323500 320
+324000 36864
+325000 9
+325500 8192
+326000 16
+326250 4
+327000 2560
+327250 32
+327500 1024
+327750 64
+328000 4096
+328750 8
+329000 128
+329500 1
+330000 16
+330250 32768
+331000 16416
+331250 512
+331500 64
+331750 1024
+332000 4096
+332750 2048
+333000 128
+333500 16
+334000 8192
+334250 8
+334750 32768
+335000 16640
+335250 512
+335500 1024
+336000 4096
+336750 128
+337000 64
+337500 1
+338000 8192
+338250 2048
+339000 16912
+339500 33792
+340000 4096
+340750 8
+341000 128
+341500 8192
+342000 256
+342250 4
+343000 2560
+343250 32
+343500 1024
+343750 64
+344000 4096
+344750 8
+345000 128
+345500 1
+346000 16
+346250 32768
+347000 2080
+347250 512
+347500 64
+347750 1024
+348000 4096
+348750 16384
+349000 128
+349500 2
+350000 16
+350250 8
+351000 5
+351500 64
+351750 256
+352000 32768
+352500 8192
+352750 512
+353500 4098
+354250 2048
+355000 17652
+356000 40960
+357000 1
+357500 768
+358000 8
+358500 18432
+359000 64
+359500 32896
+360000 16
+360500 8224
+361000 1024
+361500 4
+362000 256
+362500 514
+363000 16384
+363500 64
+364000 36864
+364500 16
+365000 2048
+365500 136
+366000 4
+366500 34
+367000 1024
+367500 8704
+368000 4096
+368500 32832
+369000 256
+369500 2048
+370000 32
+370500 132
+371000 8192
+371500 1024
+372000 4096
+372250 1
+372500 32768
+372750 8
+373250 512
+373500 272
+374000 16384
+374250 4
+374500 8224
+374750 2
+375250 1024
+375500 2176
+376000 4096
+376500 32832
+377000 1
+377500 8
+378000 16384
+378250 4
+378500 8224
+378750 2
+379250 512
+379500 1152
+380000 2304
+380750 32769
+381500 24
+382250 8196
+382500 64
+383000 16896
+383500 1056
+384500 4096
+384750 129
+385500 33024
+386250 2064
+386500 8
+387000 514
+387500 16448
+388000 13348 \ No newline at end of file
diff --git a/src/sqmod/sqmod_test/html/JOMANDA.ogg b/src/sqmod/sqmod_test/html/JOMANDA.ogg
new file mode 100644
index 0000000..aa73566
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/JOMANDA.ogg
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/MOTHERSHIP.ogg b/src/sqmod/sqmod_test/html/MOTHERSHIP.ogg
new file mode 100644
index 0000000..415e4e8
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/MOTHERSHIP.ogg
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/MOTHERSHIP.png b/src/sqmod/sqmod_test/html/MOTHERSHIP.png
new file mode 100644
index 0000000..a8b68a1
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/MOTHERSHIP.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/Saucer-Bold.ttf b/src/sqmod/sqmod_test/html/Saucer-Bold.ttf
new file mode 100644
index 0000000..2578072
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/Saucer-Bold.ttf
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/Saucer-Light.ttf b/src/sqmod/sqmod_test/html/Saucer-Light.ttf
new file mode 100644
index 0000000..12b56a1
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/Saucer-Light.ttf
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/Saucer-Mono.ttf b/src/sqmod/sqmod_test/html/Saucer-Mono.ttf
new file mode 100644
index 0000000..93c28a4
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/Saucer-Mono.ttf
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/Saucer-Regular.ttf b/src/sqmod/sqmod_test/html/Saucer-Regular.ttf
new file mode 100644
index 0000000..c57de44
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/Saucer-Regular.ttf
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/index.html b/src/sqmod/sqmod_test/html/index.html
new file mode 100644
index 0000000..7e36bae
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/index.html
@@ -0,0 +1,10 @@
+<link href="/toj/sqmod/sqmod_test/css/index.css" rel="stylesheet">
+
+<div class="stage" exheight=true extop=47px>
+ <div class="box">
+ <canvas class="stage bottom"></canvas>
+ <canvas class="stage main"></canvas>
+ <canvas class="stage top"></canvas>
+ <span class="fps"></span>
+ </div>
+</div>
diff --git a/src/sqmod/sqmod_test/html/light.png b/src/sqmod/sqmod_test/html/light.png
new file mode 100644
index 0000000..081db45
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/light.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_0.png b/src/sqmod/sqmod_test/html/mark/_0.png
new file mode 100755
index 0000000..e85d8b5
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_0.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_1.png b/src/sqmod/sqmod_test/html/mark/_1.png
new file mode 100755
index 0000000..fb0d796
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_1.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_10.png b/src/sqmod/sqmod_test/html/mark/_10.png
new file mode 100755
index 0000000..c02f102
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_10.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_11.png b/src/sqmod/sqmod_test/html/mark/_11.png
new file mode 100755
index 0000000..f02783a
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_11.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_12.png b/src/sqmod/sqmod_test/html/mark/_12.png
new file mode 100755
index 0000000..5df4794
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_12.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_2.png b/src/sqmod/sqmod_test/html/mark/_2.png
new file mode 100755
index 0000000..acf85a3
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_2.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_3.png b/src/sqmod/sqmod_test/html/mark/_3.png
new file mode 100755
index 0000000..4f3066e
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_3.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_4.png b/src/sqmod/sqmod_test/html/mark/_4.png
new file mode 100755
index 0000000..a64f0df
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_4.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_5.png b/src/sqmod/sqmod_test/html/mark/_5.png
new file mode 100755
index 0000000..01eb708
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_5.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_6.png b/src/sqmod/sqmod_test/html/mark/_6.png
new file mode 100755
index 0000000..8d6ea4a
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_6.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_7.png b/src/sqmod/sqmod_test/html/mark/_7.png
new file mode 100755
index 0000000..51a59f1
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_7.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_8.png b/src/sqmod/sqmod_test/html/mark/_8.png
new file mode 100755
index 0000000..22899ae
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_8.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/_9.png b/src/sqmod/sqmod_test/html/mark/_9.png
new file mode 100755
index 0000000..6cbcbc6
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/_9.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_0.png b/src/sqmod/sqmod_test/html/mark/at_0.png
new file mode 100755
index 0000000..732028d
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_0.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_1.png b/src/sqmod/sqmod_test/html/mark/at_1.png
new file mode 100755
index 0000000..93eb8d7
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_1.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_10.png b/src/sqmod/sqmod_test/html/mark/at_10.png
new file mode 100755
index 0000000..3866a91
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_10.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_11.png b/src/sqmod/sqmod_test/html/mark/at_11.png
new file mode 100755
index 0000000..764a06d
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_11.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_12.png b/src/sqmod/sqmod_test/html/mark/at_12.png
new file mode 100755
index 0000000..6fd2815
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_12.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_13.png b/src/sqmod/sqmod_test/html/mark/at_13.png
new file mode 100755
index 0000000..f6f413b
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_13.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_14.png b/src/sqmod/sqmod_test/html/mark/at_14.png
new file mode 100755
index 0000000..e8db012
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_14.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_2.png b/src/sqmod/sqmod_test/html/mark/at_2.png
new file mode 100755
index 0000000..4c7b86a
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_2.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_3.png b/src/sqmod/sqmod_test/html/mark/at_3.png
new file mode 100755
index 0000000..3277405
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_3.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_4.png b/src/sqmod/sqmod_test/html/mark/at_4.png
new file mode 100755
index 0000000..28b4881
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_4.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_5.png b/src/sqmod/sqmod_test/html/mark/at_5.png
new file mode 100755
index 0000000..48f32c6
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_5.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_6.png b/src/sqmod/sqmod_test/html/mark/at_6.png
new file mode 100755
index 0000000..71b1da3
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_6.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_7.png b/src/sqmod/sqmod_test/html/mark/at_7.png
new file mode 100755
index 0000000..63e0135
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_7.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_8.png b/src/sqmod/sqmod_test/html/mark/at_8.png
new file mode 100755
index 0000000..e3003bd
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_8.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/at_9.png b/src/sqmod/sqmod_test/html/mark/at_9.png
new file mode 100755
index 0000000..a321679
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/at_9.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_0.png b/src/sqmod/sqmod_test/html/mark/d_0.png
new file mode 100755
index 0000000..54921ec
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_0.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_1.png b/src/sqmod/sqmod_test/html/mark/d_1.png
new file mode 100755
index 0000000..ffc0e0b
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_1.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_10.png b/src/sqmod/sqmod_test/html/mark/d_10.png
new file mode 100755
index 0000000..aff0e0a
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_10.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_11.png b/src/sqmod/sqmod_test/html/mark/d_11.png
new file mode 100755
index 0000000..5060fe4
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_11.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_12.png b/src/sqmod/sqmod_test/html/mark/d_12.png
new file mode 100755
index 0000000..f91cdb5
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_12.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_13.png b/src/sqmod/sqmod_test/html/mark/d_13.png
new file mode 100755
index 0000000..519345d
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_13.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_2.png b/src/sqmod/sqmod_test/html/mark/d_2.png
new file mode 100755
index 0000000..5717732
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_2.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_3.png b/src/sqmod/sqmod_test/html/mark/d_3.png
new file mode 100755
index 0000000..01dfe39
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_3.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_4.png b/src/sqmod/sqmod_test/html/mark/d_4.png
new file mode 100755
index 0000000..7f63431
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_4.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_5.png b/src/sqmod/sqmod_test/html/mark/d_5.png
new file mode 100755
index 0000000..3d5d7fd
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_5.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_6.png b/src/sqmod/sqmod_test/html/mark/d_6.png
new file mode 100755
index 0000000..0e32a04
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_6.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_7.png b/src/sqmod/sqmod_test/html/mark/d_7.png
new file mode 100755
index 0000000..2735d0c
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_7.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_8.png b/src/sqmod/sqmod_test/html/mark/d_8.png
new file mode 100755
index 0000000..108fe90
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_8.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/d_9.png b/src/sqmod/sqmod_test/html/mark/d_9.png
new file mode 100755
index 0000000..6b01f02
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/d_9.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_0.png b/src/sqmod/sqmod_test/html/mark/fect_0.png
new file mode 100755
index 0000000..a768871
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_0.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_1.png b/src/sqmod/sqmod_test/html/mark/fect_1.png
new file mode 100755
index 0000000..4fc0ee8
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_1.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_10.png b/src/sqmod/sqmod_test/html/mark/fect_10.png
new file mode 100755
index 0000000..1c4ecff
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_10.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_11.png b/src/sqmod/sqmod_test/html/mark/fect_11.png
new file mode 100755
index 0000000..735e6b3
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_11.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_12.png b/src/sqmod/sqmod_test/html/mark/fect_12.png
new file mode 100755
index 0000000..f10eb35
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_12.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_13.png b/src/sqmod/sqmod_test/html/mark/fect_13.png
new file mode 100755
index 0000000..6c80276
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_13.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_14.png b/src/sqmod/sqmod_test/html/mark/fect_14.png
new file mode 100755
index 0000000..a70a193
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_14.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_2.png b/src/sqmod/sqmod_test/html/mark/fect_2.png
new file mode 100755
index 0000000..6c798b8
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_2.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_3.png b/src/sqmod/sqmod_test/html/mark/fect_3.png
new file mode 100755
index 0000000..b79ebb4
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_3.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_4.png b/src/sqmod/sqmod_test/html/mark/fect_4.png
new file mode 100755
index 0000000..b0a6cff
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_4.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_5.png b/src/sqmod/sqmod_test/html/mark/fect_5.png
new file mode 100755
index 0000000..3b1a7af
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_5.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_6.png b/src/sqmod/sqmod_test/html/mark/fect_6.png
new file mode 100755
index 0000000..c1ee7c1
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_6.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_7.png b/src/sqmod/sqmod_test/html/mark/fect_7.png
new file mode 100755
index 0000000..1589ae0
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_7.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_8.png b/src/sqmod/sqmod_test/html/mark/fect_8.png
new file mode 100755
index 0000000..30f5724
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_8.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/fect_9.png b/src/sqmod/sqmod_test/html/mark/fect_9.png
new file mode 100755
index 0000000..9d8cc1d
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/fect_9.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_0.png b/src/sqmod/sqmod_test/html/mark/mal_0.png
new file mode 100755
index 0000000..479a504
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_0.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_1.png b/src/sqmod/sqmod_test/html/mark/mal_1.png
new file mode 100755
index 0000000..13732e0
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_1.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_10.png b/src/sqmod/sqmod_test/html/mark/mal_10.png
new file mode 100755
index 0000000..a408199
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_10.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_11.png b/src/sqmod/sqmod_test/html/mark/mal_11.png
new file mode 100755
index 0000000..a29646d
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_11.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_12.png b/src/sqmod/sqmod_test/html/mark/mal_12.png
new file mode 100755
index 0000000..0e2f74b
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_12.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_13.png b/src/sqmod/sqmod_test/html/mark/mal_13.png
new file mode 100755
index 0000000..c2da60c
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_13.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_14.png b/src/sqmod/sqmod_test/html/mark/mal_14.png
new file mode 100755
index 0000000..5cb6b59
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_14.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_2.png b/src/sqmod/sqmod_test/html/mark/mal_2.png
new file mode 100755
index 0000000..cffca20
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_2.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_3.png b/src/sqmod/sqmod_test/html/mark/mal_3.png
new file mode 100755
index 0000000..7a21be4
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_3.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_4.png b/src/sqmod/sqmod_test/html/mark/mal_4.png
new file mode 100755
index 0000000..4d27a9c
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_4.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_5.png b/src/sqmod/sqmod_test/html/mark/mal_5.png
new file mode 100755
index 0000000..7444c93
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_5.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_6.png b/src/sqmod/sqmod_test/html/mark/mal_6.png
new file mode 100755
index 0000000..95689f2
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_6.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_7.png b/src/sqmod/sqmod_test/html/mark/mal_7.png
new file mode 100755
index 0000000..9e5f998
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_7.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_8.png b/src/sqmod/sqmod_test/html/mark/mal_8.png
new file mode 100755
index 0000000..cb0aa83
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_8.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/mal_9.png b/src/sqmod/sqmod_test/html/mark/mal_9.png
new file mode 100755
index 0000000..0dc0f58
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/mal_9.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/malpassed_0.png b/src/sqmod/sqmod_test/html/mark/malpassed_0.png
new file mode 100755
index 0000000..55622a9
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/malpassed_0.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/malpassed_1.png b/src/sqmod/sqmod_test/html/mark/malpassed_1.png
new file mode 100755
index 0000000..d3d5831
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/malpassed_1.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/malpassed_2.png b/src/sqmod/sqmod_test/html/mark/malpassed_2.png
new file mode 100755
index 0000000..0709370
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/malpassed_2.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/malpassed_3.png b/src/sqmod/sqmod_test/html/mark/malpassed_3.png
new file mode 100755
index 0000000..55dc2f9
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/malpassed_3.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/malpassed_4.png b/src/sqmod/sqmod_test/html/mark/malpassed_4.png
new file mode 100755
index 0000000..faf3c87
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/malpassed_4.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/malpassed_5.png b/src/sqmod/sqmod_test/html/mark/malpassed_5.png
new file mode 100755
index 0000000..5153f4f
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/malpassed_5.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/malpassed_6.png b/src/sqmod/sqmod_test/html/mark/malpassed_6.png
new file mode 100755
index 0000000..0ae496b
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/malpassed_6.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/mark/v.png b/src/sqmod/sqmod_test/html/mark/v.png
new file mode 100755
index 0000000..6afa6a5
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/mark/v.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/select.ogg b/src/sqmod/sqmod_test/html/select.ogg
new file mode 100644
index 0000000..b0d45ba
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/select.ogg
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/top.png b/src/sqmod/sqmod_test/html/top.png
new file mode 100644
index 0000000..7b74492
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/top.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/wave1.png b/src/sqmod/sqmod_test/html/wave1.png
new file mode 100644
index 0000000..74d3e36
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/wave1.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/html/wave2.png b/src/sqmod/sqmod_test/html/wave2.png
new file mode 100644
index 0000000..ca6a741
--- /dev/null
+++ b/src/sqmod/sqmod_test/html/wave2.png
Binary files differ
diff --git a/src/sqmod/sqmod_test/js/sqmod_test.js b/src/sqmod/sqmod_test/js/sqmod_test.js
new file mode 100644
index 0000000..cf95ca9
--- /dev/null
+++ b/src/sqmod/sqmod_test/js/sqmod_test.js
@@ -0,0 +1,730 @@
+'use strict'
+
+var sqmod_test = function(sq_node){
+ var that = this;
+ var index_node = new vus.node('index');
+ var j_index_page = $('#index_page');
+
+ sq_node.url_chg = function(direct,url_upart,url_dpart,param){
+ if(direct == 'in'){
+ if(url_dpart.length == 0){
+ com.url_update('/toj/' + url_upart.join('/') + '/index/');
+ return 'stop';
+ }
+ }
+
+ return 'cont';
+ }
+
+ index_node.url_chg = function(direct,url_upart,url_dpart,param){
+ if(direct == 'in'){
+ com.loadpage('/toj/sqmod/sqmod_test/html/index.html').done(function(){
+ test();
+ });
+ }
+
+ return 'cont';
+ };
+ sq_node.child_set(index_node);
+
+ that.unload = function(){
+
+ };
+
+
+
+
+ function test(){
+ var i;
+ var j;
+ var st;
+ var j_div;
+ var j_box;
+ var j_fps;
+ var j_stage_bottom;
+ var j_stage;
+ var j_stage_top;
+ var ctx_bottom;
+ var eng_bottom;
+ var ctx;
+ var eng;
+ var ctx_top;
+ var eng_top;
+
+ var butts;
+ var keymap = {'4':[0,0],'5':[0,1],'6':[0,2],'7':[0,3],
+ 'R':[1,0],'T':[1,1],'Y':[1,2],'U':[1,3],
+ 'F':[2,0],'G':[2,1],'H':[2,2],'J':[2,3],
+ 'V':[3,0],'B':[3,1],'N':[3,2],'M':[3,3]};
+
+ var audio;
+ var ab_select;
+ var ab_song2;
+ var ab_song3;
+ var ab_song4;
+
+ var i_top = new Image();
+ var i_light = new Image();
+ var i_wave1 = new Image();
+ var i_cover2 = new Image();
+ var i_cover3 = new Image();
+ var i_cover4 = new Image();
+
+ var i_marks = new Array();
+
+
+
+ function _load(){
+ var i;
+ var image;
+
+ function _load_audio(filename,callback){
+ var xhr = new XMLHttpRequest();
+ xhr.open('GET','/toj/sqmod/sqmod_test/html/' + filename,true);
+ xhr.responseType = 'arraybuffer';
+ xhr.onload = function(){
+ audio.decodeAudioData(xhr.response,callback);
+ }
+ xhr.send();
+ }
+
+ i_top.src = '/toj/sqmod/sqmod_test/html/top.png';
+ i_light.src = '/toj/sqmod/sqmod_test/html/light.png';
+ i_wave1.src = '/toj/sqmod/sqmod_test/html/wave1.png';
+ i_cover2.src = '/toj/sqmod/sqmod_test/html/IMSOHAPPY.jpg';
+ i_cover3.src = '/toj/sqmod/sqmod_test/html/JOMANDA.jpg';
+ i_cover4.src = '/toj/sqmod/sqmod_test/html/MOTHERSHIP.png';
+
+ for(i = 0;i < 15;i++){
+ image = new Image();
+ image.src = '/toj/sqmod/sqmod_test/html/mark/mal_' + i + '.png';
+ i_marks.push(image);
+ }
+ for(i = 0;i < 7;i++){
+ image = new Image();
+ image.src = '/toj/sqmod/sqmod_test/html/mark/malpassed_' + i + '.png';
+ i_marks.push(image);
+ }
+
+ window.AudioContext = window.AudioContext || window.webkitAudioContext;
+
+ audio = new AudioContext();
+
+ _load_audio('select.ogg',function(buffer){
+ ab_select = buffer;
+ });
+ _load_audio('IMSOHAPPY.ogg',function(buffer){
+ ab_song2 = buffer;
+ });
+ _load_audio('JOMANDA.ogg',function(buffer){
+ ab_song3 = buffer;
+ });
+ _load_audio('MOTHERSHIP.ogg',function(buffer){
+ ab_song4 = buffer;
+ });
+ }
+
+ function _scale(){
+ var i;
+ var j;
+ var w;
+ var h;
+ var sw;
+ var sh;
+ var ratio;
+
+ w = j_div.width();
+ h = j_div.height();
+
+ if(w * 3 >= h * 4){
+ sw = h * 4 / 3;
+ sh = h;
+ }else{
+ sw = w;
+ sh = w * 3 / 4;
+ }
+
+ ratio = sw / 1920;
+ for(i = 0;i < 4;i++){
+ for(j = 0;j < 4;j++){
+ butts[i][j].css('top',(32 + i * 352) * ratio);
+ butts[i][j].css('left',(272 + j * 352) * ratio);
+ butts[i][j].width(320 * ratio);
+ butts[i][j].height(320 * ratio);
+ }
+ }
+
+ j_box.width(sw);
+ j_box.height(sh);
+ j_stage_bottom.attr('width',sw);
+ j_stage_bottom.attr('height',sh);
+ j_stage.attr('width',sw);
+ j_stage.attr('height',sh);
+ j_stage_top.attr('width',sw);
+ j_stage_top.attr('height',sh);
+ ctx_bottom.scale(sw / 1920,sh / 1440);
+ ctx.scale(sw / 1920,sh / 1440);
+ ctx_top.scale(sw / 1920,sh / 1440);
+ }
+
+ var wave1_off = 0;
+ var wave2_off = -1920;
+ function _wave(){
+ wave1_off -= 4;
+ if(wave1_off < -i_wave1.width){
+ wave1_off = -(wave1_off + i_wave1.width);
+ }
+ wave2_off -= 3;
+ if(wave2_off < -i_wave1.width){
+ wave2_off = -(wave2_off + i_wave1.width);
+ }
+
+ eng_bottom.add_draw(function(ctx){
+ ctx.drawImage(i_wave1,wave1_off,1440 - i_wave1.height);
+ ctx.drawImage(i_wave1,wave1_off + i_wave1.width,1440 - i_wave1.height);
+ ctx.drawImage(i_wave1,wave2_off,1440 - i_wave1.height);
+ ctx.drawImage(i_wave1,wave2_off + i_wave1.width,1440 - i_wave1.height);
+ });
+
+ eng_bottom.add_work(_wave);
+ }
+
+ var lights;
+ function _top(){
+ eng_top.add_draw(function(ctx){
+ var i;
+ var j;
+
+ for(i = 0;i < 4;i++){
+ for(j = 0;j < 4;j++){
+ if(butts[i][j].touch == true){
+ ctx.drawImage(i_light,butts[i][j].x,butts[i][j].y);
+ }
+ }
+ }
+
+ ctx.drawImage(i_top,0,0);
+ });
+ eng_top.add_work(_top);
+ }
+
+ function _pro(){
+ var curr_song = null;
+ var start_cd = null;
+
+ function __draw(){
+ eng.add_draw(function(ctx){
+ var title;
+
+ function _draw_pro(i,j,title,cover){
+ var x,y;
+
+ x = butts[i][j].x;
+ y = butts[i][j].y;
+
+ if(cover != undefined){
+ ctx.drawImage(cover,x + 8,y + 8,304,304);
+ }else{
+ ctx.fillStyle = '#1C1C1C';
+ ctx.font = '40px Saucer-Bold';
+ ctx.fillText(title,x + 32,y + 290);
+ }
+ }
+
+ _draw_pro(0,0,'A+B Problem');
+ _draw_pro(0,1,'I\'m so happy',i_cover2);
+ _draw_pro(0,2,'JOMANDA',i_cover3);
+ _draw_pro(0,3,'Mother Ship',i_cover4);
+
+ ctx.fillStyle = '#1C1C1C';
+ ctx.font = '60px Saucer-Regular';
+ if(curr_song != null){
+ if(start_cd == null){
+ start_cd = eng.ts;
+ }
+
+ ctx.fillText('BACK',1002,1344);
+ ctx.fillText('START',1360,1344);
+
+ ctx.font = '48px Saucer-Regular';
+ ctx.fillText(new Number(60 - ((eng.ts - start_cd) / 1000)).toFixed(2),1360,1244);
+
+ title = curr_song;
+ }else{
+ ctx.fillText('PREV',1002,1344);
+ ctx.fillText('NEXT',1360,1344);
+
+ title = 'SELECT PROBLEM';
+ }
+
+ ctx.rotate(Math.PI / 2);
+ ctx.font = '100px Saucer-Regular';
+ ctx.fillText(title,32,-100);
+ });
+
+ eng.add_work(__draw);
+ }
+
+ butts[0][1].on('click',function(e){
+ _audio_play(ab_song2);
+ curr_song = 'I\'m so happy';
+ });
+ butts[0][2].on('click',function(e){
+ _audio_play(ab_song3);
+ curr_song = 'JOMANDA';
+ });
+ butts[0][3].on('click',function(e){
+ _audio_play(ab_song4);
+ curr_song = 'Mother Ship';
+ });
+
+ butts[3][2].on('click',function(e){
+ if(curr_song != null){
+ _audio_play(ab_select);
+ start_cd = null;
+ curr_song = null;
+ }
+ });
+ butts[3][3].on('click',function(e){
+ _test();
+ });
+
+
+ __draw();
+ }
+
+ function _test(){
+ var timemap = new Array();
+ var st = null;
+ var curr = 0;
+ var poslist = new Array();
+ var last_touch;
+
+ var curr_combo = 0;
+ var score = {
+ 'perfect':0,
+ 'great':0,
+ 'good':0,
+ 'badd':0,
+ 'miss':0,
+ 'max_combo':0
+ };
+
+ function __judge(time){
+ var ret;
+
+ time = Math.abs(time);
+
+ if(time > 500){
+ score.miss += 1;
+ ret = 4;
+ }else if(time > 200){
+ score.bad += 1;
+ ret = 3;
+ }else if(time > 100){
+ score.good += 1;
+ ret = 2;
+ }else if(time > 50){
+ score.great += 1;
+ ret = 1;
+ }else{
+ score.perfect += 1;
+ ret = 0;
+ }
+
+ if(ret <= 4){
+ curr_combo += 1;
+ score.max_combo = Math.max(score.max_combo,curr_combo);
+ }else{
+ curr_combo = 0;
+ }
+
+ return ret;
+ }
+ function __play(){
+ var i;
+ var j;
+ var ct;
+ var map;
+ var poss;
+ var pos;
+ var row;
+ var col;
+ var time;
+ var next_poslist;
+
+ ct = eng.ts - st;
+
+ map = timemap[curr];
+ if((ct + 509) >= map.time){
+ poss = map.pos;
+ for(i = 0;i < poss.length;i++){
+ poslist.push({'judge':-1,'time':map.time,'pos':poss[i]});
+ }
+
+ curr += 1;
+ if(curr >= timemap.length){
+ return;
+ }
+ }
+
+ next_poslist = new Array();
+ for(i = 0;i < poslist.length;i++){
+ pos = poslist[i];
+ time = ct - pos.time;
+ if(time >= 500){
+ if(pos.judge == -1){
+ pos.judge = __judge(time);
+ }
+ continue;
+ }
+
+ if(Math.abs(time) < 50 && pos.judge == -1){
+ pos.judge = __judge(time);
+ }
+
+ row = pos.pos[0];
+ col = pos.pos[1];
+ if(butts[row][col].touch == true && last_touch[row][col] == false){
+ pos.judge = __judge(time);
+ }
+
+ next_poslist.push(pos);
+ }
+ poslist = next_poslist;
+
+ for(i = 0;i < 4;i++){
+ for(j = 0;j < 4;j++){
+ last_touch[i][j] = butts[i][j].touch;
+ }
+ }
+
+ eng.add_work(__play);
+ }
+ function __drawmark(ctx,x,y,time){
+ var image = i_marks[Math.floor(time / 36.36364)];
+ ctx.drawImage(image,x + 8,y + 8,304,304);
+ }
+ function __draw(ctx){
+ var i;
+ var j;
+ var pos;
+ var row;
+ var col;
+ var time;
+
+ ctx.fillStyle = '#C3C3C3';
+ for(i = 0;i < poslist.length;i++){
+ pos = poslist[i];
+
+ time = (eng.ts - st) - pos.time;
+ if(time >= -509 && time < 291){
+ row = pos.pos[0];
+ col = pos.pos[1];
+ __drawmark(ctx,butts[row][col].x,butts[row][col].y,time + 509);
+ }
+ }
+ eng.add_draw(__draw,10);
+ }
+
+ function __combo(){
+ var last_combo = curr_combo;
+ var ani_st = -1;
+
+ function ___draw(ctx){
+ var m;
+ var move = 0;
+
+ if(curr_combo != last_combo && ani_st == -1){
+ ani_st = eng.ts;
+ }
+
+ if(ani_st != -1){
+ if((move = eng.beat_ease(150,10,eng.ts - ani_st)) == null){
+ ani_st = -1;
+ }else{
+ ctx.transform(1,0,0,1,0,-move);
+ }
+ }
+
+ ctx.fillStyle = '#D9D9D9';
+ ctx.font = '300px Saucer-Mono';
+ m = ctx.measureText(curr_combo);
+ ctx.fillText(curr_combo,272 + 352 * 3 - 64 - m.width,32 + 352 * 2 - 64);
+
+ ctx.font = '60px Saucer-Mono';
+ m = ctx.measureText('combo');
+ ctx.fillText('combo',272 + 352 * 3 - 64 - m.width,32 + 352 * 2 + 64);
+
+ last_combo = curr_combo;
+
+ eng.add_draw(___draw,0);
+ }
+
+ eng.add_draw(___draw,0);
+ }
+
+ $.get('/toj/sqmod/sqmod_test/html/JOMANDA.ju',function(data){
+ var i;
+ var j;
+ var k;
+ var lines;
+ var line;
+ var parts;
+
+ var tpb;
+ var lbeat;
+ var beat;
+ var map;
+
+ var ltime;
+ var time;
+ var pos;
+
+ lines = data.split('\n');
+
+ //Find start
+ for(i = 0;i < lines.length;i++){
+ line = lines[i];
+ if(line == '#start#'){
+ i++;
+ break;
+ }
+ }
+
+ //Read beatmap
+ tpb = 0;
+ lbeat = 0;
+ ltime = 570;
+ for(;i < lines.length;i++){
+ if((line = lines[i]) == ''){
+ continue;
+ }
+
+ parts = line.split(' ');
+ beat = parts[0];
+ time = ltime + (beat - lbeat) * tpb / 1000;
+ if(parts[1].charAt(0) == 't'){
+ tpb = 60000 / parseInt(parts[1].split('=')[1]);
+ }else{
+ map = parseInt(parts[1]);
+ pos = new Array();
+ for(j = 0;j < 4;j++){
+ for(k = 0;k < 4;k++){
+ if((map & 1) == 1){
+ pos.push([j,k]);
+ }
+ map = map >> 1;
+ }
+ }
+
+ timemap.push({'time':time,'pos':pos});
+ }
+
+ lbeat = beat;
+ ltime = time;
+ }
+
+ last_touch = new Array(4);
+ for(i = 0;i < 4;i++){
+ last_touch[i] = new Array(4);
+ for(j = 0;j < 4;j++){
+ last_touch[i][j] = butts[i][j].touch;
+ }
+ }
+
+ j_stage_bottom.css('background-color','#1C1C1C');
+
+ st = eng.ts;
+ _audio_play(ab_song3,1);
+ eng.add_work(__play);
+ eng.add_draw(__draw,10);
+ __combo();
+ });
+ }
+
+ function _ani(){
+ var et = new Date().getTime();
+ j_fps.text(Math.floor(1 / (et - st) * 1000));
+ st = et;
+
+ window.requestAnimationFrame(_ani);
+
+ eng_bottom.update();
+ eng.update();
+ eng_top.update();
+ }
+
+ var g_out;
+ function _audio(){
+ g_out = audio.createGain();
+ g_out.connect(audio.destination);
+ g_out.gain.value = 0.2;
+ }
+ var curr_src = null;
+ function _audio_play(buffer,delay){
+ var src = audio.createBufferSource();
+ var delay = audio.createDelay();
+
+ if(curr_src != null){
+ curr_src.stop(0);
+ }
+
+
+ src.buffer = buffer;
+ if(delay != undefined){
+ delay.delayTime.value = delay;
+ delay.connect(g_out);
+ src.connect(delay);
+ }else{
+ src.connect(g_out);
+ }
+ src.start(0);
+
+ curr_src = src;
+ }
+
+ $(window).on('resize',function(e){
+ _scale();
+ });
+ $(window).on('keydown',function(e){
+ var chr = String.fromCharCode(e.keyCode);
+ var pos;
+
+ if((pos = keymap[chr]) != undefined){
+ butts[pos[0]][pos[1]].touch = true;
+ }
+ });
+ $(window).on('keyup',function(e){
+ var chr = String.fromCharCode(e.keyCode);
+ var pos;
+
+ if((pos = keymap[chr]) != undefined){
+ butts[pos[0]][pos[1]].touch = false;
+ }
+ });
+
+ j_div = j_index_page.find('div.stage');
+ j_box = j_div.find('div.box');
+ j_fps = j_box.find('span.fps');
+ j_stage_bottom = j_box.find('canvas.bottom');
+ j_stage = j_box.find('canvas.main');
+ j_stage_top = j_box.find('canvas.top');
+
+ ctx_bottom = j_stage_bottom[0].getContext('2d');
+ ctx = j_stage[0].getContext('2d');
+ ctx_top = j_stage_top[0].getContext('2d');
+
+ butts = new Array(3);
+ for(i = 0;i < 4;i++){
+ butts[i] = new Array(3);
+ for(j = 0;j < 4;j++){
+ butts[i][j] = $('<div class="butt"></div>')
+ butts[i][j].data('row',i);
+ butts[i][j].data('col',j);
+ butts[i][j].x = 272 + (j * 352);
+ butts[i][j].y = 32 + (i * 352);
+ butts[i][j].touch = false;
+
+ j_box.append(butts[i][j]);
+ }
+ }
+
+ lights = new Array(3);
+ for(i = 0;i < 4;i++){
+ lights[i] = new Array(3);
+ for(j = 0;j < 4;j++){
+ lights[i][j] = 0;
+
+ butts[i][j].on('mousedown',function(e){
+ lights[$(this).data('row')][$(this).data('col')] = 1;
+ });
+ butts[i][j].on('mouseup',function(e){
+ lights[$(this).data('row')][$(this).data('col')] = 0;
+ });
+ }
+ }
+
+ _scale();
+ _load();
+
+ eng_bottom = new engine(ctx_bottom);
+ //eng_bottom.add_work(_wave);
+ eng = new engine(ctx);
+ eng.add_work(_test);
+ eng_top = new engine(ctx_top);
+ eng_top.add_work(_top);
+
+
+ eng_top.update();
+ ctx.fillStyle = '#1C1C1C';
+ ctx.font = '100px Saucer-Regular';
+ ctx.fillText('LOADING...',272 + 352 + 32,272 + 353 + 32);
+
+ setTimeout(function(){
+ _audio();
+ _audio_play(ab_select);
+
+ st = new Date().getTime();
+ window.requestAnimationFrame(_ani);
+ },2000);
+ }
+};
+
+var engine = function(ctx){
+ var that = this;
+ var workq = new Array();
+ var drawq = new Array();
+ var st = null;
+
+ that.ts = new Date().getTime();
+
+ that.add_work = function(work){
+ workq.push({'work':work});
+ };
+ that.add_draw = function(draw,z){
+ if(z == undefined){
+ z = 0;
+ }
+ drawq.push({'z':z,'draw':draw});
+ };
+ that.update = function(){
+ var i;
+ var worktq;
+ var drawtq;
+
+ that.ts = new Date().getTime() - st;
+
+ worktq = workq.slice(0);
+ workq = new Array();
+ for(i = 0;i < worktq.length;i++){
+ worktq[i].work();
+ }
+
+ drawtq = drawq.slice(0);
+ drawq = new Array();
+ drawtq.sort(function(a,b){
+ return a.z - b.z;
+ });
+ if(drawtq.length > 0){
+ ctx.clearRect(0,0,1920,1440);
+ }
+ for(i = 0;i < drawtq.length;i++){
+ ctx.save();
+ drawtq[i].draw(ctx);
+ ctx.restore();
+ }
+ };
+
+ that.beat_ease = function(dur,max,off){
+ if(off > dur){
+ return null;
+ }
+
+ if(off * 2 < dur){
+ return max * (off * 2 / dur);
+ }else{
+ return max * (2 - off * 2 / dur);
+ }
+ }
+};