mirror of
				https://scm.univ-tours.fr/22107988t/rappaurio-sae501_502.git
				synced 2025-11-04 04:55:22 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			209 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
			
		
		
	
	
			209 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			Markdown
		
	
	
	
	
	
<!--
 | 
						|
http://stackshare.io/continuous-integration
 | 
						|
-->
 | 
						|
[](https://www.npmjs.com/package/cejs)
 | 
						|
[](https://www.npmjs.com/package/cejs)
 | 
						|
[](https://snyk.io/test/github/kanasimi/CeJS?targetFile=package.json)
 | 
						|
[](https://github.com/kanasimi/CeJS/actions)
 | 
						|
<!--
 | 
						|
[](https://travis-ci.com/kanasimi/CeJS)
 | 
						|
[](https://ci.appveyor.com/project/kanasimi/cejs)
 | 
						|
[](https://circleci.com/gh/kanasimi/CeJS)
 | 
						|
[](https://scrutinizer-ci.com/g/kanasimi/CeJS/)
 | 
						|
 | 
						|
[](https://snyk.io/test/npm/cejs)
 | 
						|
[](https://david-dm.org/kanasimi/CeJS)
 | 
						|
-->
 | 
						|
 | 
						|
# [Colorless echo](http://lyrics.meicho.com.tw/) JavaScript kit
 | 
						|
The project aims to develop a JavaScript module framework that is simple to use with some interesting features.
 | 
						|
本計畫目標是建立一個簡單上手的 JavaScript 程式庫架構。<!-- toolkit -->
 | 
						|
 | 
						|
## Web page usage / browser 運行方式
 | 
						|
<!--
 | 
						|
https://github.com/highlightjs/highlight.js/blob/master/SUPPORTED_LANGUAGES.md
 | 
						|
-->
 | 
						|
```html
 | 
						|
<script type="text/JavaScript" src="path/to/ce.js">
 | 
						|
	// { "run" : "module name or callback" }
 | 
						|
</script>
 | 
						|
```
 | 
						|
 | 
						|
```javascript
 | 
						|
// Insert from browser console
 | 
						|
var cejs_node = document.createElement("script");
 | 
						|
cejs_node.setAttribute('src', 'https://kanasimi.github.io/CeJS/ce.js');
 | 
						|
cejs_node.setAttribute('type', 'text/javascript');
 | 
						|
document.head.appendChild(cejs_node);
 | 
						|
if (!window.CeL) window.CeL = { initializer : function() { CeL.run('interact.DOM', initialization); } };
 | 
						|
function initialization() {}
 | 
						|
```
 | 
						|
 | 
						|
```javascript
 | 
						|
// CeL.run( 'module.name', function callback() { /* ... */ } );
 | 
						|
CeL.run([ 'data.math', 'application.debug.log' ], function() {
 | 
						|
	CeL.assert([ CeL.GCD(4, 6), 2 ]);
 | 
						|
});
 | 
						|
```
 | 
						|
 | 
						|
## Node.js usage / node.js 運行方式
 | 
						|
 | 
						|
### Node.js lazy installation. Node.js 環境最新版本懶人配置法
 | 
						|
<code>[npm](https://www.npmjs.com/package/cejs)</code> 安裝的可能不是最新版本,這裡示範的是最新版本的安裝方法。
 | 
						|
 | 
						|
不囉嗦,已經做過的步驟可以跳過:
 | 
						|
1. 請先安裝 [node.js](https://nodejs.org/) 與 [7-Zip](https://en.wikipedia.org/wiki/7-Zip)
 | 
						|
2. 下載 GitHub repository 安裝檔 [GitHub.updater.node.js](https://raw.githubusercontent.com/kanasimi/gh-updater/master/GitHub.updater.node.js)
 | 
						|
3. 在[命令行界面](https://zh.wikipedia.org/wiki/%E5%91%BD%E4%BB%A4%E8%A1%8C%E7%95%8C%E9%9D%A2)下,進到 GitHub repository 安裝檔(`GitHub.updater.node.js`)所在的目錄,執行命令以下載 CeJS 程式庫:
 | 
						|
 | 
						|
   ```bash
 | 
						|
   node GitHub.updater.node.js
 | 
						|
   ```
 | 
						|
 | 
						|
4. CeJS 程式庫應該已經解壓縮,並且放在安裝檔所在目錄的 CeJS-master 目錄下,可以開始試用:
 | 
						|
 | 
						|
   ```bash
 | 
						|
   node
 | 
						|
   ```
 | 
						|
   ```javascript
 | 
						|
   // or: require('./CeJS-master/_for include/node.loader.js');
 | 
						|
   require('./_CeL.loader.nodejs.js');
 | 
						|
   var cejs = require("cejs");
 | 
						|
   CeL.run([ 'data.math', 'application.debug.log' ]);
 | 
						|
   CeL.assert([ CeL.GCD(4, 6), 2 ]);
 | 
						|
   ```
 | 
						|
 | 
						|
5. 每次要更新到最新 CeJS 程式庫時,只要重新執行一次 GitHub repository 安裝檔即可。
 | 
						|
 | 
						|
### Installation via npm 安裝
 | 
						|
<!-- NodeICO badges -->
 | 
						|
[](https://nodei.co/npm/cejs/)
 | 
						|
<!-- [](https://nodei.co/npm/cejs/) -->
 | 
						|
 | 
						|
1. First, go to [nodejs.org](https://nodejs.org/), download the runtime environment and [install the node.js package](https://nodejs.org/en/download/package-manager/). 請先安裝 [node.js](https://nodejs.org/)。
 | 
						|
2. Then, install the CeJS library: 接著安裝 CeJS library:
 | 
						|
   ```bash
 | 
						|
   $ npm install cejs
 | 
						|
   ```
 | 
						|
* 請注意:採用 `npm` 安裝的可能不是最新版,尚未加入最新功能。建議下載最新版本壓縮檔,解開後配置;而不是直接執行 `npm install` 安裝舊版的程式庫。
 | 
						|
 | 
						|
### Installation via GitHub latest version 一般正常安裝方法
 | 
						|
鑒於更新頻繁,有些功能可能最新版本才具備;若是執行的程式採用了新功能,將會發生嚴重錯誤。此時您可直接到 GitHub 下載最新版本壓縮檔,解開後配置。
 | 
						|
 | 
						|
Since the frequent updates of the code, some features may work at the latest version only; it's recommended download the latest version at GitHub, and then configure the library.
 | 
						|
 | 
						|
#### Using a setup script:
 | 
						|
For using the alpha version of CeJS, you can set `{ "dependencies": {"cejs": "github:kanasimi/cejs"}}` in the package.json, or use a setup script:
 | 
						|
1. Install node.js, wget/curl and [7-Zip](https://en.wikipedia.org/wiki/7-Zip). e.g.,
 | 
						|
 | 
						|
   ```bash
 | 
						|
   yum -y install nodejs wget p7zip
 | 
						|
   ```
 | 
						|
 | 
						|
2. fetch CeJS updater script. e.g.,
 | 
						|
 | 
						|
   ```bash
 | 
						|
   cd /tmp
 | 
						|
   mkdir CeJS && cd CeJS
 | 
						|
   wget "https://raw.githubusercontent.com/kanasimi/gh-updater/master/GitHub.updater.node.js" || curl -O https://raw.githubusercontent.com/kanasimi/gh-updater/master/GitHub.updater.node.js
 | 
						|
   # This script will download + extract CeJS library at ./CeJS-master.
 | 
						|
   node GitHub.updater.node.js
 | 
						|
   ```
 | 
						|
 | 
						|
3. See [GitHub.updater.node.js](https://raw.githubusercontent.com/kanasimi/gh-updater/master/GitHub.updater.node.js) for automatic updating configuration.
 | 
						|
 | 
						|
<!--
 | 
						|
Using git:
 | 
						|
git clone --single-branch --depth 1 https://github.com/kanasimi/CeJS.git
 | 
						|
# for update:
 | 
						|
# https://stackoverflow.com/questions/2866358/git-checkout-only-files-without-repository
 | 
						|
# https://stackoverflow.com/questions/6941889/is-it-safe-to-shallow-clone-with-depth-1-create-commits-and-pull-updates-aga
 | 
						|
# https://stackoverflow.com/questions/41075972/how-to-update-a-git-shallow-clone
 | 
						|
git fetch --depth 1; git reset --hard origin/master
 | 
						|
git clean -dfx
 | 
						|
-->
 | 
						|
 | 
						|
#### To setup the loader as a split file:
 | 
						|
1. Copy the loader file, <code>[_CeL.loader.nodejs.js](https://github.com/kanasimi/CeJS/tree/master/_for%20include/_CeL.loader.nodejs.js)</code> to the target directory (e.g., the same as the script file).
 | 
						|
2. Create the repository_path_list_file, <code>[_repository_path_list.txt](https://github.com/kanasimi/CeJS/blob/master/_for%20include/_repository_path_list.sample.txt)</code> in the same directory.
 | 
						|
3. Set the path list to search the library base: Write to the repository_path_list_file (`_repository_path_list.txt`), one path per line.
 | 
						|
4. to use in a script file:
 | 
						|
 | 
						|
   ```javascript
 | 
						|
   //global.use_cejs_mudule = true;
 | 
						|
   require('./_CeL.loader.nodejs.js');
 | 
						|
   ```
 | 
						|
 | 
						|
#### To setup the loader inside a single script file:
 | 
						|
1. Copy all codes of [_CeL.loader.nodejs.js](https://github.com/kanasimi/CeJS/tree/master/_for%20include/_CeL.loader.nodejs.js) to the front of the script.
 | 
						|
2. Set the CeL_path_list to the paths to search the library base, split by '|'. See also [node.demo.js](https://github.com/kanasimi/CeJS/blob/master/_test%20suite/misc/node.demo.js).
 | 
						|
 | 
						|
 | 
						|
### Execution
 | 
						|
Let's try it:
 | 
						|
```bash
 | 
						|
$ node
 | 
						|
```
 | 
						|
```javascript
 | 
						|
// Load CeJS library.
 | 
						|
require('cejs');
 | 
						|
 | 
						|
// Load modules.
 | 
						|
// CeL.run( 'module.name', function callback() { /* ... */ } );
 | 
						|
CeL.run([ 'data.math', 'application.debug.log' ]);
 | 
						|
 | 
						|
// Running codes.
 | 
						|
CeL.assert(CeL.GCD(48, 64) === 16);
 | 
						|
CeL.assert([ "2³⋅13⋅80611⋅82217",
 | 
						|
		CeL.factorize(689269837048).toString() ], 'factorize');
 | 
						|
```
 | 
						|
 | 
						|
## Features and examples 特點
 | 
						|
For further introduction, please see the [wiki](https://github.com/kanasimi/CeJS/wiki).
 | 
						|
進一步介紹請參閱本計畫之 [wiki](https://github.com/kanasimi/CeJS/wiki)。
 | 
						|
<!-- TODO: screenshot data:image/png;base64, -->
 | 
						|
 | 
						|
### 中西曆轉換
 | 
						|
Live demo: [紀年轉換工具](https://kanasimi.github.io/CeJS/_test%20suite/era.htm).
 | 
						|
 | 
						|
[](https://kanasimi.github.io/CeJS/_test%20suite/era.htm)
 | 
						|
 | 
						|
### 直式四則運算
 | 
						|
直式四則運算 (elementary arithmetic),即直式加減乘除、長除法。
 | 
						|
 | 
						|

 | 
						|

 | 
						|

 | 
						|

 | 
						|
 | 
						|
### ES6 shim
 | 
						|
See [compatibility.js](https://github.com/kanasimi/CeJS/blob/master/data/code/compatibility.js) and [native.js](https://github.com/kanasimi/CeJS/blob/master/data/native.js).
 | 
						|
 | 
						|
## Demo 線上示範
 | 
						|
* The [live demo page](https://kanasimi.github.io/CeJS/_test%20suite/demo.htm) usually takes 10 to 20 seconds to load.
 | 
						|
* 由於頻寬不足,加上載入時須做初始化,本功能示範頁面在載入時得稍微等一下。
 | 
						|
[](https://kanasimi.github.io/CeJS/_test%20suite/demo.htm)
 | 
						|
* [GitHub Pages](https://kanasimi.github.io/CeJS/) 在線演示。
 | 
						|
 | 
						|
## Requirements and dependencies
 | 
						|
* 本 library 須使用新一點的瀏覽器/執行環境。
 | 
						|
* 本 library 將使用到 global 變數 ```CeL```。
 | 
						|
 | 
						|
## Concepts 模組概念
 | 
						|
詳細請參閱[概念介紹頁](http://lyrics.meicho.com.tw/reviews/review.pl?seg=CeJS)。
 | 
						|
 | 
						|
## Contact 聯絡我們
 | 
						|
Contact us at [GitHub](https://github.com/kanasimi/CeJS/issues).
 | 
						|
 | 
						|
(This document is written by [GitHub Flavored Markdown](https://help.github.com/categories/writing-on-github/).)
 | 
						|
 | 
						|
[](http://lyrics.meicho.com.tw/)
 | 
						|
 | 
						|
<!--
 | 
						|
Markdown comment: need check under github and npmjs
 | 
						|
http://stackoverflow.com/questions/4823468/comments-in-markdown
 | 
						|
https://github.com/tiimgreen/github-cheat-sheet/blob/master/README.zh-tw.md
 | 
						|
 | 
						|
try: README.wiki
 | 
						|
-->
 |