233 |
234 |
235 |
236 |
237 |
--------------------------------------------------------------------------------
/gulpfile.babel.js:
--------------------------------------------------------------------------------
1 | /**
2 | * gulp 自动化配置默认文件
3 | * 执行: gulp --watch
4 | */
5 |
6 | import gulp from 'gulp'; // 获取 gulp
7 | import yargs from 'yargs'; // node.js 命令行框架
8 | import requireDir from 'require-dir'; // 包含文件
9 | import del from 'del'; // 清除文件
10 | // import copy from 'copy'; // 复制文件
11 | // import rev from 'gulp-rev'; //
12 | // import revReplace from 'gulp-rev-replace'; //
13 | // import useref from 'gulp-useref'; //
14 | // import filter from 'gulp-filter'; //
15 | // import csso from 'gulp-csso'; //
16 | import gulpSequence from 'gulp-sequence'; // 设置 gulp task 的顺序
17 | import gulpif from 'gulp-if'; // gulp 判断语句
18 | import livereload from 'gulp-livereload'; // 浏览器热更新
19 | import util from 'gulp-util'; // 命令行输出
20 | import concat from 'gulp-concat'; // 字符串拼接(合并文件)
21 | import webpack from 'webpack'; // 构建
22 | import gulpWebpack from 'webpack-stream'; // 基于流的构建
23 | import plumber from 'gulp-plumber'; // 处理文件信息流
24 | import named from 'vinyl-named'; // 文件命名
25 | import rename from 'gulp-rename'; // 文件重命名
26 | import htmlmin from 'gulp-htmlmin'; // html 压缩
27 | import htmlReplace from 'gulp-html-replace'; // html 文件对合并文件后的替换处理插件
28 | import uglify from 'gulp-uglify'; // js 压缩
29 | import minifyCSS from 'gulp-minify-css'; // css 压缩
30 | import imagemin from 'gulp-imagemin'; // 图片压缩
31 | import liveserver from 'gulp-live-server'; // 启动服务器
32 |
33 |
34 |
35 | // npm install ... --save-dev
36 |
37 | // 对命令行参数进行解析
38 | const args = yargs
39 | // 生产环境,默认关闭
40 | .option('production', {
41 | boolean: true,
42 | default: false,
43 | describe: 'min all scripts'
44 | })
45 | // 监听开发环境中的文件,自动更新
46 | .option('watch', {
47 | boolean: true,
48 | default: false,
49 | describe: 'min all files'
50 | })
51 | // 输出命令行执行日志
52 | .option('verbose', {
53 | boolean: true,
54 | default: false,
55 | describe: 'log'
56 | })
57 | // 压缩
58 | .option('sourcemaps', {
59 | describe: 'force the creation of sourcemaps'
60 | })
61 | // 服务器端口
62 | .option('port', {
63 | string: true,
64 | default: 8080,
65 | describe: 'server port'
66 | })
67 | .argv;
68 |
69 | // default task
70 | gulp.task('default', ['build']);
71 |
72 | // 设置 gulp task 的顺序
73 | gulp.task('build', gulpSequence('clean', 'pages', 'styles', 'images', 'scripts', ['browser', 'serve']));
74 |
75 | // 清空指定文件夹里的文件(清除旧部署文件)
76 | gulp.task('clean', () => {
77 | return del(['server/public', 'server/views']);
78 | });
79 |
80 | // 处理模板 views 信息
81 | gulp.task('pages', () => {
82 | return gulp.src('app/**/*.ejs')
83 | // 文件存放路径
84 | .pipe(gulp.dest('server'))
85 | // 热更新,若命令行中有 watch 这个参数才执行
86 | .pipe(gulpif(args.watch, livereload()));
87 | });
88 |
89 | // 处理 css 文件
90 | gulp.task('styles', () => {
91 | return gulp.src('app/**/*.css')
92 | // 压缩文件
93 | .pipe(minifyCSS())
94 | // 文件存放路径
95 | .pipe(gulp.dest('server/public'))
96 | // 热更新,若命令行中有 watch 这个参数才执行
97 | .pipe(gulpif(args.watch, livereload()));
98 | });
99 |
100 | // 图片处理
101 | gulp.task('images', function() {
102 | return gulp.src('app/**/*.{png,jpg,jpeg,gif,webp,svg,ico}')
103 | // 压缩图片
104 | // .pipe(imagemin({
105 | // progressive: true
106 | // }))
107 | // 文件存放路径
108 | .pipe(gulp.dest('server/public'))
109 | // 热更新,若命令行中有 watch 这个参数才执行
110 | .pipe(gulpif(args.watch, livereload()));
111 | });
112 |
113 | // 处理 js 代码
114 | gulp.task('scripts', () => {
115 | return gulp.src('app/**/*.js')
116 | .pipe(plumber({
117 | errorHandle: function() {}
118 | }))
119 | .pipe(named())
120 | .pipe(gulpWebpack({
121 | module: {
122 | loaders: [{
123 | test: /\.js$/,
124 | loader: 'babel'
125 | }]
126 | }
127 | }), null, (err, stats) => {
128 | log(`Finished '${colors.cyan('scripts')}'`, stats.toString({
129 | chunks: false
130 | }))
131 | })
132 | .pipe(gulp.dest('server/public/js'))
133 | .pipe(rename({
134 | basename: 'cp',
135 | extname: '.min.js'
136 | }))
137 | .pipe(uglify({ compress: { properties: false }, output: { 'quote_keys': true } }))
138 | .pipe(gulp.dest('server/public/js'))
139 | .pipe(gulpif(args.watch, livereload()))
140 | });
141 |
142 | // 在 html 中替换调用的 js代码,以及压缩 html
143 | // 例如: a.html 调用了 a.js b.js,然后 a.js b.js在前面被合并成 c.min.js,这个 task 的作用就是将 a.html 中改成调用 c.min.js
144 | // gulp.task('htmlmin', function() {
145 | // let options = {
146 | // // 压缩HTML
147 | // collapseWhitespace: true,
148 | // // 压缩页面JS
149 | // minifyJS: true,
150 | // // 压缩页面CSS
151 | // minifyCSS: true,
152 | // // 省略布尔属性的值
153 | // collapseBooleanAttributes: false
154 | // };
155 |
156 | // return gulp.src('../**/*.{htm,html,ejs}')
157 | // .pipe(htmlReplace({
158 | // 'cpjs': '/js/cp.min.js',
159 | // }))
160 | // .pipe(htmlmin(options))
161 | // // 文件存放路径
162 | // .pipe(gulp.dest('server/public'))
163 | // // 热更新,若命令行中有 watch 这个参数才执行
164 | // .pipe(gulpif(args.watch, livereload()));
165 | // });
166 |
167 | // 浏览器热更新监听,当 前者变化时,启动后面的任务
168 | gulp.task('browser', (cb) => {
169 | if (!args.watch) {
170 | return cb();
171 | }
172 |
173 | // 热更新
174 | gulp.watch(['app/**/*.js'], ['scripts']);
175 | gulp.watch(['app/**/*.css'], ['styles']);
176 | gulp.watch(['app/**/*.ejs'], ['pages']);
177 | });
178 |
179 | // 处理服务器的脚本
180 | gulp.task('serve', (cb) => {
181 | // 若命令行不处于监听状态,返回
182 | // if (!args.watch) {
183 | // return cb();
184 | // }
185 |
186 | // 创建一个服务器并启动
187 | var server = liveserver.new(['--harmony', 'server/bin/www']);
188 | server.start();
189 |
190 | // 热更新
191 | gulp.watch(['server/public/**/*.js', 'server/public/**/*.css', 'server/views/*.ejs'], (file) => {
192 | server.notify.apply(server, [file]);
193 | });
194 |
195 | // 需要重启服务器才能更新
196 | gulp.watch(['server/routes/**/*.js', 'server/app.js'], () => {
197 | server.start.bind(server)();
198 | });
199 | });
200 |
--------------------------------------------------------------------------------
/npm-debug.log:
--------------------------------------------------------------------------------
1 | 0 info it worked if it ends with ok
2 | 1 verbose cli [ 'D:\\nodejs\\node.exe',
3 | 1 verbose cli 'D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
4 | 1 verbose cli 'install',
5 | 1 verbose cli 'babrl-plugins-transform-decorators-legacy',
6 | 1 verbose cli '--save-dev' ]
7 | 2 info using npm@3.10.10
8 | 3 info using node@v6.10.3
9 | 4 silly loadCurrentTree Starting
10 | 5 silly install loadCurrentTree
11 | 6 silly install readLocalPackageData
12 | 7 silly fetchPackageMetaData babrl-plugins-transform-decorators-legacy
13 | 8 silly fetchNamedPackageData babrl-plugins-transform-decorators-legacy
14 | 9 silly mapToRegistry name babrl-plugins-transform-decorators-legacy
15 | 10 silly mapToRegistry using default registry
16 | 11 silly mapToRegistry registry https://registry.npmjs.org/
17 | 12 silly mapToRegistry data Result {
18 | 12 silly mapToRegistry raw: 'babrl-plugins-transform-decorators-legacy',
19 | 12 silly mapToRegistry scope: null,
20 | 12 silly mapToRegistry escapedName: 'babrl-plugins-transform-decorators-legacy',
21 | 12 silly mapToRegistry name: 'babrl-plugins-transform-decorators-legacy',
22 | 12 silly mapToRegistry rawSpec: '',
23 | 12 silly mapToRegistry spec: 'latest',
24 | 12 silly mapToRegistry type: 'tag' }
25 | 13 silly mapToRegistry uri https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy
26 | 14 verbose request uri https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy
27 | 15 verbose request no auth needed
28 | 16 info attempt registry request try #1 at 22:45:48
29 | 17 verbose request id 626b38689cff1976
30 | 18 http request GET https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy
31 | 19 http 404 https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy
32 | 20 verbose headers { 'content-type': 'application/json',
33 | 20 verbose headers 'cache-control': 'max-age=0',
34 | 20 verbose headers 'content-length': '2',
35 | 20 verbose headers 'accept-ranges': 'bytes',
36 | 20 verbose headers date: 'Sun, 02 Jul 2017 14:45:52 GMT',
37 | 20 verbose headers via: '1.1 varnish',
38 | 20 verbose headers age: '0',
39 | 20 verbose headers connection: 'keep-alive',
40 | 20 verbose headers 'x-served-by': 'cache-nrt6125-NRT',
41 | 20 verbose headers 'x-cache': 'MISS',
42 | 20 verbose headers 'x-cache-hits': '0',
43 | 20 verbose headers 'x-timer': 'S1499006752.809881,VS0,VE715',
44 | 20 verbose headers vary: 'Accept-Encoding' }
45 | 21 silly get cb [ 404,
46 | 21 silly get { 'content-type': 'application/json',
47 | 21 silly get 'cache-control': 'max-age=0',
48 | 21 silly get 'content-length': '2',
49 | 21 silly get 'accept-ranges': 'bytes',
50 | 21 silly get date: 'Sun, 02 Jul 2017 14:45:52 GMT',
51 | 21 silly get via: '1.1 varnish',
52 | 21 silly get age: '0',
53 | 21 silly get connection: 'keep-alive',
54 | 21 silly get 'x-served-by': 'cache-nrt6125-NRT',
55 | 21 silly get 'x-cache': 'MISS',
56 | 21 silly get 'x-cache-hits': '0',
57 | 21 silly get 'x-timer': 'S1499006752.809881,VS0,VE715',
58 | 21 silly get vary: 'Accept-Encoding' } ]
59 | 22 silly fetchPackageMetaData Error: Registry returned 404 for GET on https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy
60 | 22 silly fetchPackageMetaData at makeError (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:302:12)
61 | 22 silly fetchPackageMetaData at CachingRegistryClient. (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:280:14)
62 | 22 silly fetchPackageMetaData at Request._callback (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:210:14)
63 | 22 silly fetchPackageMetaData at Request.self.callback (D:\nodejs\node_modules\npm\node_modules\request\request.js:187:22)
64 | 22 silly fetchPackageMetaData at emitTwo (events.js:106:13)
65 | 22 silly fetchPackageMetaData at Request.emit (events.js:191:7)
66 | 22 silly fetchPackageMetaData at Request. (D:\nodejs\node_modules\npm\node_modules\request\request.js:1048:10)
67 | 22 silly fetchPackageMetaData at emitOne (events.js:96:13)
68 | 22 silly fetchPackageMetaData at Request.emit (events.js:188:7)
69 | 22 silly fetchPackageMetaData at IncomingMessage. (D:\nodejs\node_modules\npm\node_modules\request\request.js:969:12)
70 | 22 silly fetchPackageMetaData error for babrl-plugins-transform-decorators-legacy { Error: Registry returned 404 for GET on https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy
71 | 22 silly fetchPackageMetaData at makeError (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:302:12)
72 | 22 silly fetchPackageMetaData at CachingRegistryClient. (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:280:14)
73 | 22 silly fetchPackageMetaData at Request._callback (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:210:14)
74 | 22 silly fetchPackageMetaData at Request.self.callback (D:\nodejs\node_modules\npm\node_modules\request\request.js:187:22)
75 | 22 silly fetchPackageMetaData at emitTwo (events.js:106:13)
76 | 22 silly fetchPackageMetaData at Request.emit (events.js:191:7)
77 | 22 silly fetchPackageMetaData at Request. (D:\nodejs\node_modules\npm\node_modules\request\request.js:1048:10)
78 | 22 silly fetchPackageMetaData at emitOne (events.js:96:13)
79 | 22 silly fetchPackageMetaData at Request.emit (events.js:188:7)
80 | 22 silly fetchPackageMetaData at IncomingMessage. (D:\nodejs\node_modules\npm\node_modules\request\request.js:969:12)
81 | 22 silly fetchPackageMetaData pkgid: 'babrl-plugins-transform-decorators-legacy',
82 | 22 silly fetchPackageMetaData statusCode: 404,
83 | 22 silly fetchPackageMetaData code: 'E404' }
84 | 23 silly rollbackFailedOptional Starting
85 | 24 silly rollbackFailedOptional Finishing
86 | 25 silly runTopLevelLifecycles Finishing
87 | 26 silly install printInstalled
88 | 27 verbose stack Error: Registry returned 404 for GET on https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy
89 | 27 verbose stack at makeError (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:302:12)
90 | 27 verbose stack at CachingRegistryClient. (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:280:14)
91 | 27 verbose stack at Request._callback (D:\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:210:14)
92 | 27 verbose stack at Request.self.callback (D:\nodejs\node_modules\npm\node_modules\request\request.js:187:22)
93 | 27 verbose stack at emitTwo (events.js:106:13)
94 | 27 verbose stack at Request.emit (events.js:191:7)
95 | 27 verbose stack at Request. (D:\nodejs\node_modules\npm\node_modules\request\request.js:1048:10)
96 | 27 verbose stack at emitOne (events.js:96:13)
97 | 27 verbose stack at Request.emit (events.js:188:7)
98 | 27 verbose stack at IncomingMessage. (D:\nodejs\node_modules\npm\node_modules\request\request.js:969:12)
99 | 28 verbose statusCode 404
100 | 29 verbose pkgid babrl-plugins-transform-decorators-legacy
101 | 30 verbose cwd E:\Web\Project-2\lottery
102 | 31 error Windows_NT 10.0.14393
103 | 32 error argv "D:\\nodejs\\node.exe" "D:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "babrl-plugins-transform-decorators-legacy" "--save-dev"
104 | 33 error node v6.10.3
105 | 34 error npm v3.10.10
106 | 35 error code E404
107 | 36 error 404 Registry returned 404 for GET on https://registry.npmjs.org/babrl-plugins-transform-decorators-legacy
108 | 37 error 404
109 | 38 error 404 'babrl-plugins-transform-decorators-legacy' is not in the npm registry.
110 | 39 error 404 You should bug the author to publish it (or use the name yourself!)
111 | 40 error 404 Note that you can also install from a
112 | 41 error 404 tarball, folder, http url, or git url.
113 | 42 verbose exit [ 1, true ]
114 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "lottery",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "devDependencies": {
12 | "babel-core": "^6.25.0",
13 | "babel-loader": "^7.1.0",
14 | "babel-polyfill": "^6.23.0",
15 | "babel-preset-env": "^1.5.2",
16 | "babel-preset-es2015": "^6.24.1",
17 | "connect-livereload": "^0.6.0",
18 | "del": "^3.0.0",
19 | "gulp": "^3.9.1",
20 | "gulp-concat": "^2.6.1",
21 | "gulp-html-replace": "^1.6.2",
22 | "gulp-htmlmin": "^3.0.0",
23 | "gulp-if": "^2.0.2",
24 | "gulp-imagemin": "^3.3.0",
25 | "gulp-live-server": "0.0.30",
26 | "gulp-livereload": "^3.8.1",
27 | "gulp-minify-css": "^1.2.4",
28 | "gulp-plumber": "^1.1.0",
29 | "gulp-rename": "^1.2.2",
30 | "gulp-sequence": "^0.4.6",
31 | "gulp-uglify": "^3.0.0",
32 | "gulp-util": "^3.0.8",
33 | "jquery": "^3.2.1",
34 | "require-dir": "^0.3.2",
35 | "vinyl-named": "^1.1.0",
36 | "webpack": "^3.0.0",
37 | "webpack-stream": "^3.2.0",
38 | "yargs": "^8.0.2"
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/resource/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/.DS_Store
--------------------------------------------------------------------------------
/resource/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets":["es2015"],
3 | "plugins":["transform-decorators-legacy"]
4 | }
5 |
--------------------------------------------------------------------------------
/resource/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 |
5 | # Runtime data
6 | pids
7 | *.pid
8 | *.seed
9 |
10 | # Directory for instrumented libs generated by jscoverage/JSCover
11 | lib-cov
12 |
13 | # Coverage directory used by tools like istanbul
14 | coverage
15 |
16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17 | .grunt
18 |
19 | # node-waf configuration
20 | .lock-wscript
21 |
22 | # Compiled binary addons (http://nodejs.org/api/addons.html)
23 | build/Release
24 |
25 | # Dependency directory
26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
27 | node_modules
28 |
--------------------------------------------------------------------------------
/resource/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., [http://fsf.org/]
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 | {description}
294 | Copyright (C) 2017 快乐动起来
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | {signature of Ty Coon}, 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------
/resource/README.md:
--------------------------------------------------------------------------------
1 | #cp-lessons
2 |
--------------------------------------------------------------------------------
/resource/app/css/reset.css:
--------------------------------------------------------------------------------
1 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,audio,canvas,details,figcaption,figure,footer,header,hgroup,mark,menu,meter,nav,output,progress,section,summary,time,video{margin:0;padding:0}fieldset,img{border:0}address,caption,cite,code,dfn,em,th,var,optgroup{font-style:normal;font-weight:normal}ins{text-decoration:none}li{list-style:none}table{font-size:inherit;font:100%;border-collapse:collapse;border-spacing:0}caption,th{text-align:left}h1,h2,h3,h4,h5,h6{font-size:100%}q:before,q:after{content:''}abbr,acronym{border:0;font-variant:normal}legend{color:#000}input,button,textarea,select,optgroup,option{font-family:inherit;font-size:inherit;font-style:inherit;font-weight:inherit}input,button,textarea,select{margin:0;*font-size:100%;line-height:1.2}a img,img{-ms-interpolation-mode:bicubic}sub,sup{vertical-align:baseline}article,aside,dialog,figure,footer,header,hgroup,nav,section,blockquote{display:block}pre{white-space:pre-wrap;word-wrap:break-word}
2 |
--------------------------------------------------------------------------------
/resource/app/js/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/.DS_Store
--------------------------------------------------------------------------------
/resource/app/js/class/.DS_Store:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/class/.DS_Store
--------------------------------------------------------------------------------
/resource/app/js/class/lesson1.js:
--------------------------------------------------------------------------------
1 | function test(){
2 | // for(let i=1;i<3;i++){
3 | // console.log(i);
4 | // }
5 | // console.log(i);
6 | let a = 1;
7 | // let a = 2;
8 | }
9 |
10 | function last(){
11 | const PI=3.1415926;
12 | const k={
13 | a:1
14 | }
15 | k.b=3;
16 | console.log(PI,k);
17 | }
18 |
19 |
20 | // test();
21 | last();
22 |
--------------------------------------------------------------------------------
/resource/app/js/class/lesson10.js:
--------------------------------------------------------------------------------
1 | {
2 | let list = new Set();
3 | list.add(5);
4 | list.add(7);
5 |
6 | console.log('size',list.size);
7 | }
8 |
9 | {
10 | let arr = [1,2,3,4,5];
11 | let list = new Set(arr);
12 |
13 | console.log('size',list.size);
14 | }
15 |
16 | {
17 | let list = new Set();
18 | list.add(1);
19 | list.add(2);
20 | list.add(1);
21 |
22 | console.log('list',list);
23 |
24 | let arr=[1,2,3,1,'2'];
25 | let list2=new Set(arr);
26 |
27 | console.log('unique',list2);
28 | }
29 |
30 | {
31 | let arr=['add','delete','clear','has'];
32 | let list=new Set(arr);
33 |
34 | console.log('has',list.has('add'));
35 | console.log('delete',list.delete('add'),list);
36 | list.clear();
37 | console.log('list',list);
38 | }
39 |
40 | {
41 | let arr=['add','delete','clear','has'];
42 | let list=new Set(arr);
43 |
44 | for(let key of list.keys()){
45 | console.log('keys',key);
46 | }
47 | for(let value of list.values()){
48 | console.log('value',value);
49 | }
50 | for(let [key,value] of list.entries()){
51 | console.log('entries',key,value);
52 | }
53 |
54 | list.forEach(function(item){console.log(item);})
55 | }
56 |
57 |
58 | {
59 | let weakList=new WeakSet();
60 |
61 | let arg={};
62 |
63 | weakList.add(arg);
64 |
65 | // weakList.add(2);
66 |
67 | console.log('weakList',weakList);
68 | }
69 |
70 | {
71 | let map = new Map();
72 | let arr=['123'];
73 |
74 | map.set(arr,456);
75 |
76 | console.log('map',map,map.get(arr));
77 | }
78 |
79 | {
80 | let map = new Map([['a',123],['b',456]]);
81 | console.log('map args',map);
82 | console.log('size',map.size);
83 | console.log('delete',map.delete('a'),map);
84 | console.log('clear',map.clear(),map);
85 | }
86 |
87 | {
88 | let weakmap=new WeakMap();
89 |
90 | let o={};
91 | weakmap.set(o,123);
92 | console.log(weakmap.get(o));
93 | }
94 |
--------------------------------------------------------------------------------
/resource/app/js/class/lesson11.js:
--------------------------------------------------------------------------------
1 | {
2 | let obj={
3 | time:'2017-03-11',
4 | name:'net',
5 | _r:123
6 | };
7 |
8 | let monitor=new Proxy(obj,{
9 | // 拦截对象属性的读取
10 | get(target,key){
11 | return target[key].replace('2017','2018')
12 | },
13 | // 拦截对象设置属性
14 | set(target,key,value){
15 | if(key==='name'){
16 | return target[key]=value;
17 | }else{
18 | return target[key];
19 | }
20 | },
21 | // 拦截key in object操作
22 | has(target,key){
23 | if(key==='name'){
24 | return target[key]
25 | }else{
26 | return false;
27 | }
28 | },
29 | // 拦截delete
30 | deleteProperty(target,key){
31 | if(key.indexOf('_')>-1){
32 | delete target[key];
33 | return true;
34 | }else{
35 | return target[key]
36 | }
37 | },
38 | // 拦截Object.keys,Object.getOwnPropertySymbols,Object.getOwnPropertyNames
39 | ownKeys(target){
40 | return Object.keys(target).filter(item=>item!='time')
41 | }
42 | });
43 |
44 | console.log('get',monitor.time);
45 |
46 | monitor.time='2018';
47 | monitor.name='mukewang';
48 | console.log('set',monitor.time,monitor);
49 |
50 | console.log('has','name' in monitor,'time' in monitor);
51 |
52 | // delete monitor.time;
53 | // console.log('delete',monitor);
54 | //
55 | // delete monitor._r;
56 | // console.log('delete',monitor);
57 | console.log('ownKeys',Object.keys(monitor));
58 |
59 | }
60 |
61 | {
62 | let obj={
63 | time:'2017-03-11',
64 | name:'net',
65 | _r:123
66 | };
67 |
68 | console.log('Reflect get',Reflect.get(obj,'time'));
69 | Reflect.set(obj,'name','mukewang');
70 | console.log(obj);
71 | console.log('has',Reflect.has(obj,'name'));
72 | }
73 |
--------------------------------------------------------------------------------
/resource/app/js/class/lesson12.js:
--------------------------------------------------------------------------------
1 | {
2 | // 基本定义和生成实例
3 | class Parent{
4 | constructor(name='mukewang'){
5 | this.name=name;
6 | }
7 | }
8 | let v_parent=new Parent('v');
9 | console.log('构造函数和实例',v_parent);
10 | }
11 |
12 | {
13 | // 继承
14 | class Parent{
15 | constructor(name='mukewang'){
16 | this.name=name;
17 | }
18 | }
19 |
20 | class Child extends Parent{
21 |
22 | }
23 |
24 | console.log('继承',new Child());
25 | }
26 |
27 | {
28 | // 继承传递参数
29 | class Parent{
30 | constructor(name='mukewang'){
31 | this.name=name;
32 | }
33 | }
34 |
35 | class Child extends Parent{
36 | constructor(name='child'){
37 | super(name);
38 | this.type='child';
39 | }
40 | }
41 |
42 | console.log('继承传递参数',new Child('hello'));
43 | }
44 |
45 | {
46 | // getter,setter
47 | class Parent{
48 | constructor(name='mukewang'){
49 | this.name=name;
50 | }
51 |
52 | get longName(){
53 | return 'mk'+this.name
54 | }
55 |
56 | set longName(value){
57 | this.name=value;
58 | }
59 | }
60 |
61 | let v=new Parent();
62 | console.log('getter',v.longName);
63 | v.longName='hello';
64 | console.log('setter',v.longName);
65 | }
66 |
67 | {
68 | // 静态方法
69 | class Parent{
70 | constructor(name='mukewang'){
71 | this.name=name;
72 | }
73 |
74 | static tell(){
75 | console.log('tell');
76 | }
77 | }
78 |
79 | Parent.tell();
80 |
81 | }
82 |
83 | {
84 | // 静态属性
85 | class Parent{
86 | constructor(name='mukewang'){
87 | this.name=name;
88 | }
89 |
90 | static tell(){
91 | console.log('tell');
92 | }
93 | }
94 |
95 | Parent.type='test';
96 |
97 | console.log('静态属性',Parent.type);
98 |
99 |
100 | }
101 |
--------------------------------------------------------------------------------
/resource/app/js/class/lesson13.js:
--------------------------------------------------------------------------------
1 | {
2 | // 基本定义
3 | let ajax=function(callback){
4 | console.log('执行');
5 | setTimeout(function () {
6 | callback&&callback.call()
7 | }, 1000);
8 | };
9 | ajax(function(){
10 | console.log('timeout1');
11 | })
12 | }
13 |
14 | {
15 | let ajax=function(){
16 | console.log('执行2');
17 | return new Promise(function(resolve,reject){
18 | setTimeout(function () {
19 | resolve()
20 | }, 1000);
21 | })
22 | };
23 |
24 | ajax().then(function(){
25 | console.log('promise','timeout2');
26 | })
27 | }
28 |
29 | {
30 | let ajax=function(){
31 | console.log('执行3');
32 | return new Promise(function(resolve,reject){
33 | setTimeout(function () {
34 | resolve()
35 | }, 1000);
36 | })
37 | };
38 |
39 | ajax()
40 | .then(function(){
41 | return new Promise(function(resolve,reject){
42 | setTimeout(function () {
43 | resolve()
44 | }, 2000);
45 | });
46 | })
47 | .then(function(){
48 | console.log('timeout3');
49 | })
50 | }
51 |
52 | {
53 | let ajax=function(num){
54 | console.log('执行4');
55 | return new Promise(function(resolve,reject){
56 | if(num>5){
57 | resolve()
58 | }else{
59 | throw new Error('出错了')
60 | }
61 | })
62 | }
63 |
64 | ajax(6).then(function(){
65 | console.log('log',6);
66 | }).catch(function(err){
67 | console.log('catch',err);
68 | });
69 |
70 | ajax(3).then(function(){
71 | console.log('log',3);
72 | }).catch(function(err){
73 | console.log('catch',err);
74 | });
75 | }
76 |
--------------------------------------------------------------------------------
/resource/app/js/class/lesson14.js:
--------------------------------------------------------------------------------
1 | {
2 | let arr=['hello','world'];
3 | let map=arr[Symbol.iterator]();
4 | console.log(map.next());
5 | console.log(map.next());
6 | console.log(map.next());
7 | }
8 |
9 | {
10 | let obj={
11 | start:[1,3,2],
12 | end:[7,9,8],
13 | [Symbol.iterator](){
14 | let self=this;
15 | let index=0;
16 | let arr=self.start.concat(self.end);
17 | let len=arr.length;
18 | return {
19 | next(){
20 | if(index3}));
42 | console.log([1,2,3,4,5,6].findIndex(function(item){return item>3}));
43 | }
44 |
45 | {
46 | console.log('number',[1,2,NaN].includes(1));
47 | console.log('number',[1,2,NaN].includes(NaN));
48 | }
49 |
--------------------------------------------------------------------------------
/resource/app/js/class/lesson7.js:
--------------------------------------------------------------------------------
1 | {
2 | function test(x, y = 'world'){
3 | console.log('默认值',x,y);
4 | }
5 | test('hello');
6 | test('hello','kill');
7 | }
8 |
9 | {
10 | let x='test';
11 | function test2(x,y=x){
12 | console.log('作用域',x,y);
13 | }
14 | test2('kill');
15 | }
16 |
17 | {
18 | function test3(...arg){
19 | for(let v of arg){
20 | console.log('rest',v);
21 | }
22 | }
23 | test3(1,2,3,4,'a');
24 | }
25 |
26 | {
27 | console.log(...[1,2,4]);
28 | console.log('a',...[1,2,4]);
29 | }
30 |
31 | {
32 | let arrow = v => v*2;
33 | let arrow2 = () => 5;
34 | console.log('arrow',arrow(3));
35 | console.log(arrow2());
36 |
37 | }
38 |
39 | {
40 | function tail(x){
41 | console.log('tail',x);
42 | }
43 | function fx(x){
44 | return tail(x)
45 | }
46 | fx(123)
47 | }
48 |
--------------------------------------------------------------------------------
/resource/app/js/class/lesson8.js:
--------------------------------------------------------------------------------
1 | {
2 | // 简洁表示法
3 | let o=1;
4 | let k=2;
5 | let es5={
6 | o:o,
7 | k:k
8 | };
9 | let es6={
10 | o,
11 | k
12 | };
13 | console.log(es5,es6);
14 |
15 | let es5_method={
16 | hello:function(){
17 | console.log('hello');
18 | }
19 | };
20 | let es6_method={
21 | hello(){
22 | console.log('hello');
23 | }
24 | };
25 | console.log(es5_method.hello(),es6_method.hello());
26 | }
27 |
28 | {
29 | // 属性表达式
30 | let a='b';
31 | let es5_obj={
32 | a:'c',
33 | b:'c'
34 | };
35 |
36 | let es6_obj={
37 | [a]:'c'
38 | }
39 |
40 | console.log(es5_obj,es6_obj);
41 |
42 | }
43 |
44 | {
45 | // 新增API
46 | console.log('字符串',Object.is('abc','abc'),'abc'==='abc');
47 | console.log('数组',Object.is([],[]),[]===[]);
48 |
49 | console.log('拷贝',Object.assign({a:'a'},{b:'b'}));
50 |
51 | let test={k:123,o:456};
52 | for(let [key,value] of Object.entries(test)){
53 | console.log([key,value]);
54 | }
55 | }
56 |
57 | {
58 | // 扩展运算符
59 | // let {a,b,...c}={a:'test',b:'kill',c:'ddd',d:'ccc'};
60 | // c={
61 | // c:'ddd',
62 | // d:'ccc'
63 | // }
64 | }
65 |
--------------------------------------------------------------------------------
/resource/app/js/class/lesson9.js:
--------------------------------------------------------------------------------
1 | {
2 | // 声明
3 | let a1=Symbol();
4 | let a2=Symbol();
5 | console.log(a1===a2);
6 | let a3=Symbol.for('a3');
7 | let a4=Symbol.for('a3');
8 | console.log(a3===a4);
9 | }
10 |
11 | {
12 | let a1=Symbol.for('abc');
13 | let obj={
14 | [a1]:'123',
15 | 'abc':345,
16 | 'c':456
17 | };
18 | console.log('obj',obj);
19 |
20 | for(let [key,value] of Object.entries(obj)){
21 | console.log('let of',key,value);
22 | }
23 |
24 | Object.getOwnPropertySymbols(obj).forEach(function(item){
25 | console.log(obj[item]);
26 | })
27 |
28 | Reflect.ownKeys(obj).forEach(function(item){
29 | console.log('ownkeys',item,obj[item]);
30 | })
31 | }
32 |
--------------------------------------------------------------------------------
/resource/app/js/class/test.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/class/test.js
--------------------------------------------------------------------------------
/resource/app/js/index.js:
--------------------------------------------------------------------------------
1 | import 'babel-polyfill';
2 | import Lottery from './lottery';
3 |
--------------------------------------------------------------------------------
/resource/app/js/lottery.js:
--------------------------------------------------------------------------------
1 | import './lottery/base.js';
2 | import './lottery/timer.js';
3 | import './lottery/calculate.js';
4 | import './lottery/interface.js';
5 |
--------------------------------------------------------------------------------
/resource/app/js/lottery/base.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/lottery/base.js
--------------------------------------------------------------------------------
/resource/app/js/lottery/calculate.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/lottery/calculate.js
--------------------------------------------------------------------------------
/resource/app/js/lottery/interface.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/lottery/interface.js
--------------------------------------------------------------------------------
/resource/app/js/lottery/timer.js:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/js/lottery/timer.js
--------------------------------------------------------------------------------
/resource/app/views/error.ejs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/AliceGB/lottery/22731653705cd39c849b362cbc949d28905e324b/resource/app/views/error.ejs
--------------------------------------------------------------------------------
/resource/app/views/index.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | ES6实战
7 |
8 |
9 |
10 |
16 |
17 |
18 |
19 |