my blog
 
<<返回UST Axis | feedback

If you like this site

在人人、非死不可、Twitter、空间、微博上分享此站吧。

也欢迎将此站设为浏览器首页,以方便你上网。

Browser compatibility

无法识别你的浏览器……也许是未开启JavaScript?
Tested OK, recommended:
Chrome | stable
Firefox | >= 3.6

Tested OK, but not recommended:
Opera | >=11
IE | 6, 7, 8

Untested, compatibility unknown:
IE | >=9
Safari | all

Not applicable:
IE | <=5.5

Changelog

26/09/11 开始写出第一行代码
16/10/11 初版测试版出炉。
23/10/11 正式版上线。上线前Update:课程网站widget、课程信息导入工具、按钮样式、浏览器检测;新的登录页。感谢周子旭等同学的feedback。
23/10/11 修正时间解析时将12:mmPM解析作24:mm的bug,感谢徐敏杰同学的feedback。修正手动添加课程在IE下不可用的bug,感谢某位不留名的同学的feedback。 03/02/12 新的课程信息导入器:直接输入StuID即可。

Acknowledgement

尽管整个站的程序基本上全是我自己写的,但是下列的文章/工具帮了我很大的忙。

JPEGmini(压缩JPEG的工具)
各浏览器下baseline区别
绝对定位元素的事件捕获
Addthis(收藏/分享网页的widget)
IE6下使用fixed定位
CSS渐变
IE下Button overpadding
Firefox下类似问题
JavaScript拖拽
禁止拖放对象文本被选择

当然,更要感谢的还有写成这一切的PHP语言,以及同样简洁易用的MySQL,和写这个我使用的Notepad++。索性再加上学校的ihome吧,虽然PHP4真的很苦逼。

Under the hood

UST Axis的结构包括一个骨架,以及直接复制粘贴就可以添加上去的widget们。作为深受WordPress毒害的一代少年,自然偏爱call_user_func函数。 这里有一个hello_world的sample widget,包含一些简单的说明:

<?php
/* 
your user's whole config will be saved in a variable $config (numeric/string/array is all ok). it will be passed to your functions.
everything below should be written in functions.
in any functions among them, returning $config will update config data.
*/

function hello_world_init($id,$config) { //this function will be called when the widget runs for the first time.
  echo 'You may need to configure first;';
  set_status($id,2); //update the status of the widget to "activated". otherwise hello_world_init will always be called and hello_world_display will never.
  return ('Hello World');
}

function hello_world_display($id,$config) { //this outputs the content displayed in the widget.
  echo $config;
  echo '<input type="button" value="Username_show" onclick="sendAjax(\'get\',\'ajax.php?id='.$id.'\',null,function(msg) { alert(msg); });" />';
}

function hello_world_config($id,$config) { //output the content in the config box. also dealing with the data user submitted from config box. one more thing to say: by using set_status you can refresh the whole page as well.
  if ( isset($_POST['display']) && $_POST['display']!='' ) {
    set_status($id, 2);
    echo 'Change accepted.';
    return $_POST['display'];
  }
  echo '<form action="config.php?id='.$id.'" method="post"><input type="text" name="display" /><input type="submit" /></form>';
}

function hello_world_ajax($id,$config) { //use this function to handle ajax requests. it is not needed if you're not going to make ajax requests.
  echo USER_NAME; //use this constant to get itsc username
}

?>

<<返回UST Axis | feedback