# ccdom

> ```coffeescript helper = require './helper' pop_msg_node = require './pop-node' R = require './r' yes_no = require './yes-no' ccdom = require 'ccdom' select_friends = require './select-friends'

Latest version **0.0.31** (published 2014-05-21) · BSD license · 0 weekly downloads

## Install

```sh
npm install ccdom
pnpm add ccdom
yarn add ccdom
bun add ccdom
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.31 |
| Published | 2014-05-21 |
| First published | 2013-09-05 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | seobyeongky |

## Links

- npm: https://www.npmjs.com/package/ccdom
- npm.io page: https://npm.io/package/ccdom

## Dependencies (1)

- [coffee-script](https://npm.io/package/coffee-script.md) ~1.6.3

## Recent versions

- 0.0.31 (latest) — 2014-05-21
- 0.0.30 — 2014-05-21
- 0.0.29 — 2014-05-21
- 0.0.28 — 2014-04-09
- 0.0.26 — 2013-10-31
- 0.0.25 — 2013-10-31
- 0.0.24 — 2013-10-31
- 0.0.23 — 2013-10-28
- 0.0.22 — 2013-10-28
- 0.0.21 — 2013-10-25
- 0.0.20 — 2013-10-24
- 0.0.19 — 2013-10-16
- 0.0.18 — 2013-10-14
- 0.0.17 — 2013-10-14
- 0.0.16 — 2013-10-07
- … 14 more at https://npm.io/package/ccdom/versions

## README

# 주의사항: repeat에는 배열이 사용되는데, 배열의 element는 object여야함... 그래야 $index 속성이 추가됨.

# 주의사항2: scope간 prototype으로 상속이 이루어짐... 그래서 child scope에서 root scope의 객체를 액세스가 가능하지만, 대입하면 child scope만의 객체로서 만들어지고 root scope의 객체는 영향받지 않음

# lobby scene example!!

# modules
```coffeescript
helper = require './helper'
pop_msg_node = require './pop-node'
R = require './r'
yes_no = require './yes-no'
ccdom = require 'ccdom'
select_friends = require './select-friends'

module.exports = (cb_remote) ->
	template =
		type: 'scene'
		controller: 'AppCtrl'
		children: [
			type: 'layer_color'
			controller: 'LayerCtrl'
			color: '{{this.white}}'
			children: [
				{
					# main title
					type: 'label'
					font_size: 75
					text: '알까기 게임...!'
					anchor: '0 0'
					color: '149 149 79 255'
				}
				{
					# announcments
					type: 'node'
					pos: '0 {{this.win_size.height}}'
					anchor: '0 1'
					repeat: {
						bind: 'item in ann_items'
						template: {
							type: 'label'
							font_size: 30
							text: '{{this.item.text}}'
							pos: '0 {{this.item.$index * -35}}'
							anchor: '0 1'
							color: '{{this.black}}'
						}
					}
				}
				{
					# main menu
					type: 'menu'
					pos: '{{this.win_size.width}} 0'
					anchor: '1 0'
					children: [
						{
							type: 'label_item'
							show: '{{this.conn}}'
							text: '친구와 한 판 한다'
							callback: '{{this.matchWithFriend}}'
							pos: '0 200'
							anchor: '1 0'
							color: '{{this.menu_color}}'
							font_size: 45
						}
						{
							type: 'label_item'
							text: '다른 게임을 한다'
							callback: '{{this.another_game}}'
							pos: '0 100'
							anchor: '1 0'
							color: '{{this.menu_color}}'
							font_size: 45
						}
						{
							type: 'label_item'
							text: '그만한다'
							callback: '{{this.end_game}}'
							pos: '0 0'
							anchor: '1 0'
							color: '{{this.menu_color}}'
							font_size: 45
						}
					]
				}
			]
		]

	ctrlers =
		AppCtrl: ($scope) ->
			$scope.font_name = 'Arial'
			$scope.win_size = director.getWinSize()
			$scope.black = '0 0 0 255'
			$scope.white = '255 255 255 255'
			$scope.menu_color = '73 62 32 255'
			$scope.conn = false
			$scope.ann_items = []
			$scope.end_game = ->
				director.end()
			$scope.another_game = ->
				__jsc__.selectGame()

		LayerCtrl: ($scope) ->
#			$scope.pop_node = pop_msg_node [$scope.win_size.width/2, $scope.win_size.height - 150]
#			@addChild $scope.pop_node
#			$scope.pop_node.push_msg (CurrentUser?.name or '아무개') + '님 반갑습니다'

			$scope.$watch 'this.conn', ->
				$scope.$update()
			$scope.$watch 'this.ann_items', ->
				$scope.$update()

			cb_remote (remote) ->
				$scope.$apply ->
					$scope.conn = true
					$scope.matchWithFriend = ->
						select_friends cb_remote, (res, friend_id) ->
							if res
								remote.req_match_with friend_id, (err) ->
									unless err
	#									pop_node.push_msg '대국이 곧 시작됩니다. 접속 중 입니다', 3
									else
	#									pop_node.push_msg err, 3

				remote.req_annouce (item) ->
					$scope.$apply ->
						$scope.ann_items.push item

	scene = ccdom template, ctrlers
	director.replaceScene scene

	scene.handlers = {}
	scene.handlers.req_match_with = ( user, cb ) ->
		yes_no user.name + '님이 대국을 원하십니다.', cb		
	
	scene
```

---
_Source: https://npm.io/package/ccdom · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
