Monday, August 20

我的MBR爛掉了!!

剛虛驚了一場,還好只是MBR爛掉,重建就好了。

用開機光碟進入,打開console,取得root身份,進行如下操作:


#grub
grub> root (hd1,0)
grub> setup (hd0)
grub> quit
#reboot




Creative Commons License


This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 License.

Thursday, August 16

VI 設定

由於Ubuntu裝好之後,套件安裝的VI不含語法色彩顯示,必須加裝套件才行。程式碼如下:


sudo aptitude install vim-full

這樣就好了嗎?當然還沒,還必須修改設定檔。

sudo vi /etc/vim/vimrc

#在VI環境下輸入以下字元
:%s/\"syntax\ on/syntax\ on/g

:wq

大功告成!



Creative Commons License


This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 License.

Friend Links V2

對程式做了小變動。

主要變動如下:


  1. 加入<br/>
    function initialFriendType(f) {

    f.friendType.length = typeLength;

    for (var i = 0; i < typeLength; i ++ ) {

    f.friendType.options[i].value = i;

    f.friendType.options[i].text = friendType[i];

    }

    f.friendType.options[0].selected = true;

    }



  2. 使用HTML繪出兩個下拉式選單,在繪出空的下拉式選單之後,透過呼叫initialFriendType方法,將下拉式選單的值填入

    <form name="ff">好友分類

    <select onchange="changeFriend(this.value)" name="friendType">

    <option/>請選擇

    </select>
    好友暱稱

    <select onchange="goToAddress(this.value)" name="friendName">

    <option/>請選擇

    </select>

    </form>

    <script language="javascript">

    initialFriendType(document.ff);

    </script>



  3. 增加變數ty,用以指定陣列元素,日後可依個人喜好,配合好友分類更改排序。

    ty = 1;//配合好友分類陣列值。

    friend[ty].push(new Person("雅虎", "http://www.kimo.com.tw"));





如此一來,原程式碼定義好友分類的陣列即可派上用場,日後儘管加上類別即可,而不必再更動HTML碼。




Creative Commons License


This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 License.

Friday, August 3

Friend Links

移到這邊來之後,第一個遇上的問題是:用習慣了無名的好友功能。

網路上有解決之道,主要是某站去解析無名好友功能的程式碼,而後提供使用者隨意貼……。也幸好這邊可以自己增加外掛,所以貼些JavaScript倒不成問題。但是,我想要其他的好友也可以這樣選,有些好友使用無名,有些使用天空部落,有些使用樂多,怎麼辦呢?說不得,自己動手改一段了。

附上程式碼,修改方式應不致太難才是。

=====以下是程式碼=====

<script language="javascript">
function Person (nickname, address) {
this.nickname = nickname;
this.address = address;
}


friendType = new Array();
friend = new Array();
friend[0] = "";

//
// 更改的地方三
// 與更改的地方一相同
// 影響顯示的類別
// 附:好吧,其實這邊影響沒這麼大,主要是數字要對應得到。
//


friendType[0] = "請選擇";
friendType[1] = "東光國小";
friendType[2] = "中正國中";
friendType[3] = "東華補習班";
friendType[4] = "台北商專";
friendType[5] = "雲科二技";

typeLength = friendType.length;

//initial the 2nd. dimantion.
for (var i = 0; i < typeLength; i ++) {
friend[i] = new Array();
//friend[i][0] = friendType[i];
friend[i].push(new Person("請選擇", true));
}


//
// 更改的地方二
// 與上方的friendType的索引值需一樣
// 格式:暱稱 + 鏈結網址
// 餘此類推
//

//東光國小
friend[1].push(new Person("Das Kind", "http://ichbinkind.blogspot.com/"));

//中正國中
friend[2].push(new Person("DAS KIND", "http://ichbinkind.blogspot.com/"));

//東華補習班
friend[3].push(new Person("Kind", "http://ichbinkind.blogspot.com/"));

//台北商專
friend[4].push(new Person("Bear", "http://ichbinkind.blogspot.com/"));

//雲科二技
friend[5].push(new Person("DirtyBear", "http://ichbinkind.blogspot.com/"));


function goToAddress (address) {
//
if(address == true) {
return false;
} else {
window.open(address, "_blank");
}
}

function changeFriend(key) {
f = window.document.ff;
l = friend[key].length;
f.friendName.length = l;
for (var i = 0; i < l; i ++ ) {
f.friendName.options[i].value = friend[key][i].address;
f.friendName.options[i].text = friend[key][i].nickname;
}
f.friendName.options[0].selected = true;
}

function initialFriendType(f) {
f.friendType.length = typeLength;
for (var i = 0; i < typeLength; i ++ ) {
f.friendType.options[i].value = i;
f.friendType.options[i].text = friendType[i];
}
f.friendType.options[0].selected = true;
}
</script>

<form name="ff">好友分類
<select onchange="changeFriend(this.value)" name="friendType">
<!--顯示的類別

更改的地方一
依需求,加入自己需要的分類項瞥
VALUE依序編號即可

-->
<option value="0"/>請選擇
<option value="1"/>東光國小
<option value="2"/>中正國中
<option value="3"/>東華補習班
<option value="4"/>台北商專
<option value="5"/>雲科二技
</select><br/>好友暱稱
<select onchange="goToAddress(this.value)" name="friendName">
<option/>請選擇
</select>
</form>


=====以上是程式碼=====
程式碼參考自中華郵政及無名小站




Creative Commons License


This work is licensed under a
Creative Commons Attribution-Share Alike 3.0 License.