Ascheriit

about me

A little something about me.

twitter

found on

[Ff13-2] Chromie - Time Labyrinth Breaker

- - posted in jQuery, javascriptMVC | Comments

簡介

  • ff13-2裡面有個時鐘小遊戲,影片參考
  • 說穿了就是一個排列組合遊戲,比起其他小遊戲這個難度高很多,所以網路上有一些人寫了程式專門解這個小遊戲。其實有很多解答版本,但是都不太好用,UI也…。乾脆自己寫一個!
  • 有參考某個flash實做,不過我用純html5+js實現。js核心是jquery1.7.1,框架是javascriptMVC。

命名

Chromie = 克羅米

克羅米是魔獸世界WoW中擁有時間穿梭能力的種族-青銅龍族中的一員。 克羅米@wow wiki

實做

[javascriptMVC] Forum 問答

- - posted in javascriptMVC | Comments

如何手動觸發model update? 讓’{model} updated’可以被想要接受的人接收

1
modelInstanceVariable.updated({});

可以讓view自動聽model更新自己改變自己嗎?

不行。你應該用controller去更新view。

如何除錯./js

1
2
3
4
5
6
7
./js -d  ##開啟Rhino javascript debugger

##之後針對要除錯的js下load

load('steal/pluginifyjs')
steal.build.pluginify('alive/gundam',{});
## 記得設中斷點

[javascriptMVC] Class Init

- - posted in javascriptmvc | Comments

1
2
3
4
5
6
7
8
9
10
11
12
13
14
$.Controller('Alive',{
  //static init
  init: function(){
      steal.dev.log('The class init will be invoked whenever you declare a class');
  }
},{
  init: function(){
      steal.dev.log('The instance init will be invoked whenever you declare a new instance');
  }
});

/*Console: The class init will be invoked whenever you declare a class */
new alive(element);
/*Console: The instance init will be invoked whenever you declare a new instance */

[Javascript] Final誤我一生 - Js未來保留字

- - posted in javascript | Comments

問題

Rhino javascript debugger一直有一段敘述過不了

1
var utc_current = self.options.begin + (self.options.final - self.options.begin)*offset/$('#homura').width();

可是明明真實的瀏覽器跑起來都正常運作,用jsfiddle的jslint看也沒問題: jsfiddle說的

真相

online jslint看, 突然想起來final好像是js保留字不能直接拿來當key, 實際上會因為瀏覽器有沒有處理而定。

JS保留字

  • abstract else instanceof super
  • boolean enum int switch
  • break export interface synchronized
  • byte extends let this
  • case false long throw
  • catch final native thishrows
  • char finally new transient
  • class float null true
  • const for package try
  • continue function private typeof
  • debugger goto protected var
  • default if public void
  • debuggerlete implements return volatile
  • do import short while
  • double in static with

[javascriptMVC] stealJS - Steal Anything

- - posted in javascriptmvc | Comments

steal is a function that loads scripts, css, and other resources into your application.

steal(FILE_or_FUNCTION, ...)

Quick Walkthrough

Add a script tag that loadssteal/steal.js and add the path to the first file to load in the query string like:

<script type=‘text/javascript’

 src='../steal/steal.js?myapp/myapp.js'>

</script>

[Table Game] 桌遊大賽賽前研究

- - posted in tablegame | Comments

玩過得項目

卡卡頌十周年紀念版 (德文版)

矮人礦坑 1+2 – 中文版

閃靈快手

水瓶座

Dixit 3說書人–奧德賽擴充

雄偉競技場 – 中文版

  • 外部網誌介紹
  • 賭博版的牌七,這樣說好像不太有趣,不過這遊戲我也只玩過一次就沒碰了。

沒玩過得項目

諜影危機

[Git] 心得(1) Submodule, Bitbucket

- - posted in github | Comments

Bitbucker

偶然間發現這個github的競爭者Bitbucket推出了無限免費私有倉庫+無限硬碟空間,

title: “[git] 心得(1) Submodule, Bitbucker” date: 2012-02-15 23:32 comments: true

categories: git,github

Bitbucker

偶然間發現這個github的競爭者Bitbucker推出了無限免費私有倉庫+無限硬碟空間,

origin/master 於是有了一個想法:把不能說得project放到bitbucker,把好玩的open source放在github,兩者透過submodule互通! 畢竟工作上要用到大量的open source project,每次更新都要cp實在很累人。 在大部分專案都在github,而且他的介面也真的很好用的狀況下,在github上開repo還是有必要得! 而且還要能夠隨時跟原作者的repo同步!

Git submodule

要達成這個目的還是得先了解一下submodule的用法, 以下是學到的事情。

本地端起submodule

cd my_existing_repo
git add submodule git@github.com:alivedise/lab.git
git submodule init #啟動submodule
git submodule update #把submodule內容抓回本地端
git commit -a -m 'commited with submodule lab added!' #commit submodule的設定回自己的git remote

別人更新他的repo時

git submodule update
#確認是你想要得內容
git commit -a -m 'commited with submodule lab updated.' #commit submodule新的版本號回去自己的git remote

問題來了,如果別人的repo你自己會作修改該怎麼辦?

我的作法:直接fork回自己的repo,將submodule重新指向自己的repo,自己來維護這份repo。

別人跟自己同時都有更新repo時

很簡單,利用add remote->fetch->merge->commit

cd my_forked_submodule
git add remote upstream git@github.com:alivedise/lab.git
git fetch upstream
git merge origin master

Reference

[Octopress] 重來懶人包

- - posted in octopress, ubuntu | Comments

在ubuntu上架設octopress環境的懶人包:

Git

略過

rvm/ruby系列

事前準備

apt-get install libssl-dev
apt-get install libtool
sudo apt-get install libyaml-0-2 libyaml-dev

開始

bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer) echo ‘[[ -s “$HOME/.rvm/scripts/rvm” ]] && . “$HOME/.rvm/scripts/rvm” # Load RVM function’ >> ~/.bash_profile source ~/.bash_profile rvm pkg install openssl rvm pkg install iconv rvm install 1.9.2 -C —with-openssl-dir=$HOME/.rvm/usr,—with-iconv-dir=$HOME/.rvm/usr rvm rubygems latest rvm use 1.9.2 —default rvm reload gem install bundler

Octopress

git clone git://github.com/imathis/octopress.git octopress cd octopress yes bundle install rake setup_github_pages git@github.com:alivedise/alivedise.github.com.git git pull

完成!

讓vim支援octopress語法

安裝pathogen

(https://github.com/tpope/vim-pathogen)

安裝vim-octopress

(https://github.com/vim-scripts/vim-octopress)

[HTML] 多行tooltip(title)

- - posted in w3c | Comments

html原生tooltip(title屬性)顯示多行的方法:

1
<span title="123&#13;456">test3</span>

殘念得是很難得的firefox有bug,多行會變成空白字元…. IE跟Chrome是正常的。

jsfiddle

[jQuery] SlickGrid API列表

- - posted in jquery, slickgrid | Comments

Grid options

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
    var defaults = {
        headerHeight: 25,                //header高度
        rowHeight: 25,                   //列高
        defaultColumnWidth: 80,          //預設欄位寬度
        enableAddRow: false,             //可否新增列
        leaveSpaceForNewRows: false,     //是否預留新列空間
        editable: false,                 //是否可編輯
        autoEdit: true,                  //?
        enableCellNavigation: true,      //是否可用上下左右
        enableColumnReorder: true,       //欄位是否可換位
        asyncEditorLoading: false,
        asyncEditorLoadDelay: 100,
        forceFitColumns: false,
        enableAsyncPostRender: false,
        asyncPostRenderDelay: 60,
        autoHeight: false,
        editorLock: Slick.GlobalEditorLock,
        showHeaderRow: false,
        headerRowHeight: 25,
        showTopPanel: false,
        topPanelHeight: 25,
        formatterFactory: null,
        editorFactory: null,
        cellFlashingCssClass: "flashing",
        selectedCellCssClass: "selected",
        multiSelect: true,
        enableTextSelectionOnCells: false,
        dataItemColumnValueExtractor: null
    };

Column options

1
2
3
4
5
6
       name: "",
        resizable: true,
        sortable: false,
        minWidth: 30,
        rerenderOnResize: false,
        headerCssClass: null

Grid callback

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
       "onScroll":                     new Slick.Event(),
        "onSort":                       new Slick.Event(),
        "onHeaderContextMenu":          new Slick.Event(),
        "onHeaderClick":                new Slick.Event(),
        "onMouseEnter":                 new Slick.Event(),
        "onMouseLeave":                 new Slick.Event(),
        "onClick":                      new Slick.Event(),
        "onDblClick":                   new Slick.Event(),
        "onContextMenu":                new Slick.Event(),
        "onKeyDown":                    new Slick.Event(),
        "onAddNewRow":                  new Slick.Event(),
        "onValidationError":            new Slick.Event(),
        "onViewportChanged":            new Slick.Event(),
        "onColumnsReordered":           new Slick.Event(),
        "onColumnsResized":             new Slick.Event(),
        "onCellChange":                 new Slick.Event(),
        "onBeforeEditCell":             new Slick.Event(),
        "onBeforeCellEditorDestroy":    new Slick.Event(),
        "onBeforeDestroy":              new Slick.Event(),
        "onActiveCellChanged":          new Slick.Event(),
        "onActiveCellPositionChanged":  new Slick.Event(),
        "onDragInit":                   new Slick.Event(),
        "onDragStart":                  new Slick.Event(),
        "onDrag":                       new Slick.Event(),
        "onDragEnd":                    new Slick.Event(),
        "onSelectedRowsChanged":        new Slick.Event(),

Grid API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
        // Methods
        "registerPlugin":               registerPlugin,
        "unregisterPlugin":             unregisterPlugin,
        "getColumns":                   getColumns,
        "setColumns":                   setColumns,
        "getColumnIndex":               getColumnIndex,
        "updateColumnHeader":           updateColumnHeader,
        "setSortColumn":                setSortColumn,
        "autosizeColumns":              autosizeColumns,
        "getOptions":                   getOptions,
        "setOptions":                   setOptions,
        "getData":                      getData,
        "getDataLength":                getDataLength,
        "getDataItem":                  getDataItem,
        "setData":                      setData,
        "getSelectionModel":            getSelectionModel,
        "setSelectionModel":            setSelectionModel,
        "getSelectedRows":              getSelectedRows,
        "setSelectedRows":              setSelectedRows,

      "render":                       render,
        "invalidate":                   invalidate,
        "invalidateRow":                invalidateRow,
        "invalidateRows":               invalidateRows,
        "invalidateAllRows":            invalidateAllRows,
        "updateCell":                   updateCell,
        "updateRow":                    updateRow,
        "getViewport":                  getVisibleRange,
        "getRenderedRange":             getRenderedRange,
        "resizeCanvas":                 resizeCanvas,
        "updateRowCount":               updateRowCount,
        "scrollRowIntoView":            scrollRowIntoView,
        "getCanvasNode":                getCanvasNode,

        "getCellFromPoint":             getCellFromPoint,
        "getCellFromEvent":             getCellFromEvent,
        "getActiveCell":                getActiveCell,
        "setActiveCell":                setActiveCell,
        "getActiveCellNode":            getActiveCellNode,
        "getActiveCellPosition":        getActiveCellPosition,
        "resetActiveCell":              resetActiveCell,
        "editActiveCell":               makeActiveCellEditable,
        "getCellEditor":                getCellEditor,
        "getCellNode":                  getCellNode,
        "getCellNodeBox":               getCellNodeBox,
        "canCellBeSelected":            canCellBeSelected,
        "canCellBeActive":              canCellBeActive,
        "navigatePrev":                 navigatePrev,
        "navigateNext":                 navigateNext,
        "navigateUp":                   navigateUp,
        "navigateDown":                 navigateDown,
        "navigateLeft":                 navigateLeft,
        "navigateRight":                navigateRight,
        "gotoCell":                     gotoCell,
        "getTopPanel":                  getTopPanel,
        "showTopPanel":                 showTopPanel,
        "hideTopPanel":                 hideTopPanel,
        "showHeaderRowColumns":         showHeaderRowColumns,
        "hideHeaderRowColumns":         hideHeaderRowColumns,
        "getHeaderRow":                 getHeaderRow,
        "getHeaderRowColumn":           getHeaderRowColumn,
        "getGridPosition":              getGridPosition,
        "flashCell":                    flashCell,
        "addCellCssStyles":             addCellCssStyles,
        "setCellCssStyles":             setCellCssStyles,
        "removeCellCssStyles":          removeCellCssStyles,

        "destroy":                      destroy,

DataView API

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
        "beginUpdate":      beginUpdate,
        "endUpdate":        endUpdate,
        "setPagingOptions": setPagingOptions,
        "getPagingInfo":    getPagingInfo,
        "getItems":         getItems,
        "setItems":         setItems,
        "setFilter":        setFilter,
        "sort":             sort,
        "fastSort":         fastSort,
        "reSort":           reSort,
        "groupBy":          groupBy,
        "setAggregators":   setAggregators,
        "collapseGroup":    collapseGroup,
        "expandGroup":      expandGroup,
        "getGroups":        getGroups,
        "getIdxById":       getIdxById,
        "getRowById":       getRowById,
        "getItemById":      getItemById,
        "getItemByIdx":     getItemByIdx,
        "setRefreshHints":  setRefreshHints,
        "setFilterArgs":    setFilterArgs,
        "refresh":          refresh,
        "updateItem":       updateItem,
        "insertItem":       insertItem,
        "addItem":          addItem,
        "deleteItem":       deleteItem,

        // data provider methods
        "getLength":        getLength,
        "getItem":          getItem,
        "getItemMetadata":  getItemMetadata,

        // events
        "onRowCountChanged":    onRowCountChanged,
        "onRowsChanged":        onRowsChanged,
        "onPagingInfoChanged":  onPagingInfoChanged