├── 02_tab.html
├── Map_07.html
├── README.md
├── Set_06.js
├── day_3.js
├── js_reduce.html
├── jsonp.js
├── scope.js
├── 从0开始
├── 01_day.html
├── 02_day.html
├── 02_days.html
├── 03_days.html
├── 04_day.html
├── 05_day.html
├── 05_days.html
├── 06_days.html
├── 07_time.html
├── 08_String.html
├── 09_move.html
├── 09_moves.html
├── 10_Index.html
├── 11.html
├── 11_day.html
├── 12_replace.html
├── 13.html
├── 14_day.html
├── image
│ ├── 0f000PC3L7v5WMl_8bcCX6.jpg
│ ├── 1.gif
│ ├── 1.jpg
│ ├── 2.gif
│ ├── 2.jpg
│ ├── 3.jpg
│ ├── 4.jpg
│ ├── 5.jpg
│ ├── bg.gif
│ ├── bpic_1.gif
│ ├── cloud.gif
│ ├── content.png
│ ├── content_bg.jpg
│ ├── lb1.jpg
│ ├── lb2.jpg
│ ├── lb3.jpg
│ ├── lb4.jpg
│ ├── lb5.jpg
│ ├── main.png
│ ├── mm.png
│ ├── nav.png
│ ├── rss.png
│ ├── taobao.jpg
│ ├── tianshi.gif
│ ├── tip1_c.gif
│ ├── tip1_f.gif
│ ├── tip1_h.gif
│ ├── top.png
│ ├── xiaoniao.gif
│ └── 百度换肤.png
├── images
│ ├── 01.jpg
│ ├── 02.jpg
│ ├── 03.jpg
│ ├── 04.jpg
│ ├── 05.jpg
│ ├── 1.png
│ ├── 2.png
│ ├── 3.png
│ ├── 4.png
│ ├── 5.png
│ ├── QQ图片20180709193807.png
│ ├── hungry.png
│ ├── hungry2.png
│ ├── low.png
│ ├── music_lie.png
│ ├── pass.png
│ ├── shop.png
│ ├── singer1.png
│ ├── singer2.png
│ ├── status.png
│ └── view.png
├── jq.html
├── rest.html
├── tools.js
└── 练习代码.html
├── 作用域_1.js
├── 冒泡.js
├── 去重_.js
├── 堆_2.js
├── 并集.html
├── 并集_06.html
├── 排序.html
├── 插入排序.html
├── 操作符_1.js
├── 栈_04.js
├── 求和_1.js
├── 进制.js
├── 选择排序.js
├── 队列_04.js
└── 队列_05.js
/02_tab.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Document
8 |
26 |
27 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
1
63 |
2
64 |
3
65 |
66 |
67 |
--------------------------------------------------------------------------------
/Map_07.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
52 |
53 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # JavaScript
2 | 数据结构
3 |
4 | 最近学习React感觉有点吃力 所以没太多时间更新 接着努力
5 |
6 | #最近时间可多了
7 |
8 | #自己比较喜欢原生js
9 |
--------------------------------------------------------------------------------
/Set_06.js:
--------------------------------------------------------------------------------
1 | function Set() {
2 | var items = {};
3 | this.has = function (value){
4 | //return value in items;
5 | return items.hasOwnProperty(value);
6 | }
7 | this.add = function (value){
8 | if(!this.has(value)){
9 | items[value] = value;
10 | return true;
11 | }
12 | return false;
13 | }
14 | this.remove = function (){
15 | if(this.has(value)){
16 | delete items[value];
17 | return true;
18 | }
19 | return false;
20 | }
21 | this.clear = function () {
22 | items = [];
23 | }
24 | this.print = function () {
25 | console.log(items);
26 | }
27 | this.size = function () {
28 | var count = 0;
29 | for(var prop in items){
30 | if(items.hasOwnProperty(prop)){
31 | ++count;
32 | }
33 | return count;
34 | }
35 | }
36 | this.values = function () {
37 | return Object.keys(items);
38 | }
39 | }
40 | var set = new Set();
41 | set.add(1);
42 | console.log(set.values()); //输出["1"]
43 | console.log(set.has(1)); //输出true
44 | console.log(set.size()); //输出1
--------------------------------------------------------------------------------
/day_3.js:
--------------------------------------------------------------------------------
1 | /*switch case使用*/
2 | var num = 4;
3 | switch(num){
4 | case 1:
5 | console.log("1");
6 | break;
7 | case 2:
8 | console.log("2");
9 | break;
10 | case 3:
11 | console.log("3");
12 | break;
13 | case 4:
14 | console.log("4");
15 | break;
16 | default:
17 | console.log("您不在我的范围内");
18 | }
19 | /*简单oop*/
20 | function Book(title,page,isBin){
21 | this.title = title;
22 | this.page = page;
23 | this.isBin = isBin;
24 | this.dbFun = function(){
25 | console.log("i am dbFun");
26 | }
27 | }
28 | let persion = new Book('hello',"10","js");
29 | console.log(persion.title)
30 | console.log(persion.page);
31 | console.log(persion.isBin)
32 |
33 | function printMatrix(myMatrix){
34 | for(var i=0;i
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
9 |
10 | 数组元素总和:
11 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/jsonp.js:
--------------------------------------------------------------------------------
1 | /*下载安装jsonp cnpm install jsonp*/
2 | /*自己建一个js文件*/
3 |
4 | import originJsonp from 'jsonp'
5 |
6 | export default function((url, data, option){
7 | url += (url.indexOf('?') < 0 ? '?' : '&') + param(data)
8 |
9 | /*使用promise*/
10 | return new Promise((resolve,rejects)=>{
11 | originJsonp(url, option, (err, data) => {
12 | if (!err) {
13 | resolve(data)
14 | } else {
15 | reject(err)
16 | }
17 | })
18 | })
19 | }
20 | /*拼接*/
21 | export function param(data) {
22 | let url = ''
23 | for (var k in data) {
24 | let value = data[k] !== undefined ? data[k] : ''
25 | url += '&' + k + '=' + encodeURIComponent(value)
26 | }
27 | return url ? url.substring(1) : ''
28 | }
29 | /*这是api.js*/
30 | import jsonp from '../common/js/jsonp'
31 | import {commonParams, options} from './config'
32 |
33 | export function getRecommend() {
34 | const url = 'https://c.y.qq.com/musichall/fcgi-bin/fcg_yqqhomepagerecommend.fcg'
35 | /*跟接口的数据保持一样*/
36 | const data = Object.assign({}, commonParams, {
37 | platform: 'h5',
38 | uin: 0,
39 | needNewCode: 1
40 | })
41 | return jsonp(url, data, options)
42 | }
43 | /*配置返回的ERR_OK值 config.js文件*/
44 | export const commonParams = {
45 | g_tk: 1928093487,
46 | inCharset: 'utf-8',
47 | outCharset: 'utf-8',
48 | notice: 0,
49 | format: 'jsonp'
50 | }
51 |
52 | export const options = {
53 | param: 'jsonpCallback'
54 | }
55 |
56 | export const ERR_OK = 0
57 |
58 | /*引入组件*/
59 | import { getRecommend } from '../../api/recommend'
60 | import { ERR_OK } from '../../api/config'
61 |
62 | export default{
63 | created(){
64 | this._getMsg();
65 | },
66 | methods: {
67 | _getMsg(){
68 | /*调用方法 封装的promise方法*/
69 | getRecommend().then((res)=>{
70 | if(res.code == ERR_OK){
71 | console.log(res.data);
72 | }
73 | })
74 | }
75 | }
76 | }
--------------------------------------------------------------------------------
/scope.js:
--------------------------------------------------------------------------------
1 | var arr = [];
2 | arr.number = 10;
3 | arr.test = function(){/* 对象下面的函数叫做方法 */
4 | alert(123)
5 | }
6 | var commit = [];
7 | commit.name = "XIn";/*commit下面的属性*/
8 | commit.showName = function(){/* commit下面的方法 */
9 | /*这个时候this指向的是showName这个函数*/
10 | alert(this.name);
11 | }
12 | commit.showName();/* 区分属性跟方法区别就在于加没加() */
13 | //arr.test();
14 | //alert(arr.number)
--------------------------------------------------------------------------------
/从0开始/01_day.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
44 |
45 |
--------------------------------------------------------------------------------
/从0开始/02_day.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
38 |
39 |
40 |
41 |
42 |
48 |
49 |
86 |
87 |
--------------------------------------------------------------------------------
/从0开始/02_days.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
26 |
41 |
42 |
--------------------------------------------------------------------------------
/从0开始/03_days.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
45 |
46 |
--------------------------------------------------------------------------------
/从0开始/04_day.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
49 |
50 |
--------------------------------------------------------------------------------
/从0开始/05_day.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
42 |
43 |
--------------------------------------------------------------------------------
/从0开始/05_days.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
15 |
16 |
17 |
18 |
19 |
22 |
47 |
48 |
--------------------------------------------------------------------------------
/从0开始/06_days.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
23 |
24 |
--------------------------------------------------------------------------------
/从0开始/07_time.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
9 |
38 |
39 |
--------------------------------------------------------------------------------
/从0开始/08_String.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
37 |
38 |
--------------------------------------------------------------------------------
/从0开始/09_move.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
18 |
19 |
20 |
21 |
22 | sss
23 |
24 |
34 |
35 |
--------------------------------------------------------------------------------
/从0开始/09_moves.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
56 |
57 |
58 |
59 |
60 |
61 | 
62 | 
63 | 
64 | 
65 | 
66 |
67 |
68 | 1
69 | 2
70 | 3
71 | 4
72 | 5
73 |
74 |
75 |
76 |
112 |
113 |
--------------------------------------------------------------------------------
/从0开始/10_Index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
15 |
16 |
17 |
18 |
19 | - 1
20 | - 2
21 | - 3
22 | - 4
23 |
24 |
25 |
59 |
60 |
--------------------------------------------------------------------------------
/从0开始/11.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
9 |
28 |
29 |
--------------------------------------------------------------------------------
/从0开始/11_day.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
13 |
14 |
--------------------------------------------------------------------------------
/从0开始/12_replace.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
18 |
19 |
--------------------------------------------------------------------------------
/从0开始/13.html:
--------------------------------------------------------------------------------
1 | import { Message } from 'element-ui'
2 | import restful from 'services/restful'
3 | import _ from 'lodash'
4 | import moment from 'moment'
5 | import utils from 'utils'
6 |
7 | async function readIdcard () {
8 | // 刚插上读卡器的时候,上面不能有身份证。否则第1步初始化端口会失败。
9 | // 每次读完,需要拿走身份证重新读。否则第2步鉴权会失败。
10 | // 有时候不停的第1步初始化端口失败,需要先空读一下读卡器,然后放身份证读。
11 |
12 | // 无论如何先关闭一次
13 | // await restful.csharpIdcard({ functionName: 'CloseComm' })
14 |
15 | // 1.初始化端口
16 | const SUCCESS_RET = '1'
17 | let portSn
18 | for (portSn = 1; portSn <= 16; portSn++) {
19 | let port = '100' + portSn
20 | let resp = await restful.csharpIdcard({
21 | functionName: 'InitComm',
22 | port
23 | })
24 | if (resp.status === SUCCESS_RET) {
25 | break
26 | }
27 | }
28 | if (portSn === 17) {
29 | Message.error({message: `初始化身份证读卡器失败`, showClose: true})
30 | // await restful.csharpIdcard({ functionName: 'CloseComm' })
31 | return
32 | }
33 |
34 | // 2.鉴权
35 | let resp = await restful.csharpIdcard({ functionName: 'Authenticate' })
36 | // if (resp.status !== SUCCESS_RET) {
37 | // Message.error({message: `鉴权失败。请尝试拿起身份证重新放下`, showClose: true})
38 | // await restful.csharpIdcard({ functionName: 'CloseComm' })
39 | // return
40 | // }
41 |
42 | // 3.读取
43 | resp = await restful.csharpIdcard({ functionName: 'ReadBaseInfos' })
44 | if (resp.status && resp.status !== SUCCESS_RET) {
45 | Message.error({message: `读取身份证读卡器失败,错误码:${resp.status}`, showClose: true})
46 | await restful.csharpIdcard({ functionName: 'CloseComm' })
47 | return
48 | }
49 | if (!resp.Name) {
50 | Message.error({message: `未读取到身份证信息`, showClose: true})
51 | // await restful.csharpIdcard({ functionName: 'CloseComm' })
52 | return
53 | }
54 |
55 | // 4.关闭
56 | await restful.csharpIdcard({ functionName: 'CloseComm' })
57 | return resp
58 | }
59 |
60 | let rfidConnected = false
61 | async function readRfidIsoO15693 () {
62 | const SUCCESS_RET = '0'
63 |
64 | // 1.初始化端口
65 | let portSn
66 | for (portSn = 1; portSn <= 16; portSn++) {
67 | let port = '100' + portSn
68 | await restful.csharpRfid({ functionName: 'rf_closeport' })
69 | let resp = await restful.csharpRfid({
70 | functionName: 'rf_init_com',
71 | port: `${portSn}`,
72 | baud: '19200'
73 | })
74 | if (resp.status === SUCCESS_RET) {
75 | break
76 | }
77 | }
78 | if (portSn === 17) {
79 | // Message.error({message: `RFID阅读器初始化失败`, showClose: true})
80 | throw new Error(`RFID阅读器初始化失败`)
81 | }
82 |
83 | // 点灯
84 | // rfidLight(RFID_LIGHT.GREEN)
85 |
86 | // 2.读取
87 | // utils.waitFor(500)
88 | let resp = await restful.csharpRfid({ functionName: 'ISO15693_Inventory' })
89 | if (resp.status && resp.status === '20') {
90 | // 没有检测到 rfid 时,返回值是20
91 | return []
92 | }
93 | if (resp.status && resp.status !== SUCCESS_RET) {
94 | // Message.error({message: `读取RFID失败,错误码:${resp.status}`, showClose: true})
95 | throw new Error(`读取RFID失败,错误码:${resp.status}`)
96 | }
97 |
98 | let rfid = resp.RFID.slice(2, 18)
99 | if (Number(rfid) === 0) {
100 | // 防止出现错误的rfid '00000000'
101 | return []
102 | }
103 | return [rfid]
104 | }
105 |
106 | async function batchReadRfidIsoO15693 () {
107 | const SUCCESS_RET = '0'
108 |
109 | // 1.初始化端口
110 | let portSn
111 | for (portSn = 1; portSn <= 16; portSn++) {
112 | let port = '100' + portSn
113 | await restful.csharpRfid({ functionName: 'rf_closeport' })
114 | let resp = await restful.csharpRfid({
115 | functionName: 'rf_init_com',
116 | port: `${portSn}`,
117 | baud: '19200'
118 | })
119 | if (resp.status === SUCCESS_RET) {
120 | break
121 | }
122 | }
123 | if (portSn === 17) {
124 | // Message.error({message: `RFID阅读器初始化失败`, showClose: true})
125 | throw new Error(`RFID阅读器初始化失败`)
126 | }
127 |
128 | // 点灯
129 | // rfidLight(RFID_LIGHT.GREEN)
130 |
131 | // 2.读取
132 | // utils.waitFor(500)
133 | let resp = await restful.csharpRfid({ functionName: 'ISO15693_Inventories' })
134 | console.info(resp)
135 | if (resp.status && resp.status === '20') {
136 | // 没有检测到 rfid 时,返回值是20
137 | return []
138 | }
139 | if (resp.status && resp.status !== SUCCESS_RET) {
140 | // Message.error({message: `读取RFID失败,错误码:${resp.status}`, showClose: true})
141 | throw new Error(`读取RFID失败,错误码:${resp.status}`)
142 | }
143 |
144 | let rfids = _.chain(resp.list)
145 | .map(rfid => rfid.slice(2, 18))
146 | .reject(rfid => Number(rfid) === 0)
147 | .value()
148 | return rfids
149 | }
150 |
151 | async function readRfid14443A () {
152 | const SUCCESS_RET = '0'
153 |
154 | // 1.初始化端口
155 | let portSn
156 | for (portSn = 1; portSn <= 16; portSn++) {
157 | let port = '100' + portSn
158 | await restful.csharpRfid({ functionName: 'rf_closeport' })
159 | // console.log('rf_closeport')
160 | let resp = await restful.csharpRfid({
161 | functionName: 'rf_init_com',
162 | port: `${portSn}`,
163 | baud: '19200'
164 | })
165 | // console.log('rf_init_com', `端口${port}`, resp.status)
166 | if (resp.status === SUCCESS_RET) {
167 | break
168 | }
169 | }
170 | if (portSn === 17) {
171 | // Message.error({message: `RFID阅读器初始化失败`, showClose: true})
172 | throw new Error(`RFID阅读器初始化失败`)
173 | }
174 |
175 | // 点灯
176 | // rfidLight(RFID_LIGHT.GREEN)
177 |
178 | // 2.读取
179 | let resp = await restful.csharpRfid({ functionName: 'rf_antenna_sta' })
180 | // console.log('rf_antenna_sta', resp.status)
181 | if (resp.status && resp.status !== SUCCESS_RET) {
182 | throw new Error(`rf_antenna_sta失败,错误码:${resp.status}`)
183 | }
184 | resp = await restful.csharpRfid({ functionName: 'rf_init_type' })
185 | // console.log('rf_init_type', resp.status)
186 | if (resp.status && resp.status !== SUCCESS_RET) {
187 | throw new Error(`rf_init_type失败,错误码:${resp.status}`)
188 | }
189 | resp = await restful.csharpRfid({ functionName: 'rf_request' })
190 | // console.log('rf_request', resp.status)
191 | // 没有检测到 rfid 时,返回值是20
192 | if (resp.status === '20') {
193 | // 此处必须返回,因为此处空读返回码 20 之后,下一步会继续报错,而此错误不想提示给用户。
194 | return []
195 | } else if (resp.status && resp.status !== SUCCESS_RET) {
196 | throw new Error(`rf_request失败,错误码:${resp.status}`)
197 | }
198 | resp = await restful.csharpRfid({ functionName: 'rf_anticoll' })
199 | // console.log('rf_anticoll', resp.status)
200 | if (resp.status && resp.status !== SUCCESS_RET) {
201 | throw new Error(`rf_anticoll失败,错误码:${resp.status}`)
202 | }
203 |
204 | return [resp.RFID]
205 | }
206 |
207 | async function rfidBeep () {
208 | // 哔一声
209 | await restful.csharpRfid({
210 | functionName: 'rf_beep',
211 | msec: '10'
212 | })
213 | }
214 |
215 | async function rfidWarnBeep () {
216 | // 哔一声
217 | for (let i = 0; i < 3; i++) {
218 | await rfidBeep()
219 | }
220 | }
221 |
222 | const RFID_LIGHT = {
223 | OFF: 0,
224 | RED: 1,
225 | GREEN: 2,
226 | YELLOW: 3
227 | }
228 | async function rfidLight (color) {
229 | await restful.csharpRfid({
230 | functionName: 'rf_light',
231 | color
232 | })
233 | }
234 |
235 | async function readHeartBeat () {
236 | await restful.csharpHeartBeat()
237 | }
238 |
239 | async function print (male, female) {
240 | await restful.csharpPrinter({
241 | 'printtimes': '1',
242 | 'femalename': female.name,
243 | 'malename': male.name,
244 | 'birthfemale': moment(female.birthday).format('YYYY-MM-DD'),
245 | 'birthmale': moment(male.birthday).format('YYYY-MM-DD'),
246 | 'cycletype': 'IVF'
247 | })
248 | }
249 |
250 | const FINGER_STATUS_SUCC = '0'
251 | async function _fingerRegister1 ({shouldCancle, msgHandler}) {
252 | while (!shouldCancle()) {
253 | let rsp = await restful.csharpFinger({
254 | functionName: 'FPRegister',
255 | acquireCount: 1
256 | })
257 | let finger1 = rsp.data
258 | if (finger1.status !== FINGER_STATUS_SUCC) {
259 | await utils.waitFor(500)
260 | continue
261 | }
262 | return finger1.FPTmp
263 | }
264 | // return Promise.reject(new Error('已取消'))
265 | }
266 |
267 | async function _fingerRegister2 ({shouldCancle, msgHandler}, tpl1) {
268 | while (!shouldCancle()) {
269 | let rsp = await restful.csharpFinger({
270 | functionName: 'FPRegister',
271 | acquireCount: 2,
272 | regTmp: tpl1
273 | })
274 | let finger2 = rsp.data
275 | if (finger2.status !== FINGER_STATUS_SUCC) {
276 | await utils.waitFor(500)
277 | continue
278 | }
279 | if (finger2.score < 60) {
280 | msgHandler({
281 | type: 'error',
282 | content: '请录入同一个手指'
283 | })
284 | }
285 | return finger2.FPTmp
286 | }
287 | // return Promise.reject(new Error('已取消'))
288 | }
289 |
290 | async function _fingerRegister3 ({shouldCancle, msgHandler}, tpl2) {
291 | while (!shouldCancle()) {
292 | let rsp = await restful.csharpFinger({
293 | functionName: 'FPRegister',
294 | acquireCount: 3,
295 | regTmp: tpl2
296 | })
297 | let finger3 = rsp.data
298 | if (finger3.status !== FINGER_STATUS_SUCC) {
299 | await utils.waitFor(500)
300 | continue
301 | }
302 | if (finger3.score < 60) {
303 | msgHandler({
304 | type: 'error',
305 | content: '请录入同一个手指'
306 | })
307 | }
308 | return finger3.FPTmp
309 | }
310 | // return Promise.reject(new Error('已取消'))
311 | }
312 |
313 | async function _fingerMerge (tpl1, tpl2, tpl3) {
314 | let rsp = await restful.csharpFinger({
315 | functionName: 'FPMerge',
316 | mergeTmp01: tpl1,
317 | mergeTmp02: tpl2,
318 | mergeTmp03: tpl3
319 | })
320 | let ret = rsp.data
321 | if (ret.status !== FINGER_STATUS_SUCC) {
322 | return Promise.reject(new Error('指纹合并错误'))
323 | }
324 | return ret
325 | }
326 |
327 | async function _fingerRegister ({shouldCancle, msgHandler}) {
328 | // 录制指纹前先终止一次。
329 | await fingerTerminate()
330 |
331 | // 获取第一枚指纹模板
332 | msgHandler({
333 | type: 'hint',
334 | content: '请录入第 1 次指纹,共需 3 次'
335 | })
336 | let tpl1 = await _fingerRegister1({shouldCancle, msgHandler})
337 | msgHandler({
338 | type: 'readed'
339 | })
340 |
341 | // 获取第二枚指纹模板。传入第一枚指纹供对比,防止两次不是同一个手指。
342 | msgHandler({
343 | type: 'hint',
344 | content: '请录入第 2 次指纹,共需 3 次'
345 | })
346 | let tpl2 = await _fingerRegister2({shouldCancle, msgHandler}, tpl1)
347 | msgHandler({
348 | type: 'readed'
349 | })
350 |
351 | // 获取第二枚指纹模板。传入第二枚指纹供对比
352 | msgHandler({
353 | type: 'hint',
354 | content: '请录入第 3 次指纹,共需 3 次'
355 | })
356 | let tpl3 = await _fingerRegister3({shouldCancle, msgHandler}, tpl2)
357 | msgHandler({
358 | type: 'readed'
359 | })
360 |
361 | let tpl = await _fingerMerge(tpl1, tpl2, tpl3)
362 | return tpl
363 | }
364 |
365 | function fingerRegisterCancelble ({msgHandler}) {
366 | let canceled = false
367 | let shouldCancle = () => canceled
368 |
369 | return {
370 | promise: _fingerRegister({shouldCancle, msgHandler}),
371 | cancel () {
372 | canceled = true
373 | fingerTerminate()
374 | }
375 | }
376 | }
377 |
378 | async function fingerTerminate () {
379 | return restful.csharpFinger({
380 | functionName: 'FPTerminate'
381 | })
382 | }
383 |
384 | async function _fingerMatch ({shouldCancle, msgHandler}, tpl) {
385 | while (!shouldCancle()) {
386 | let rsp = await restful.csharpFinger({
387 | functionName: 'FPMatch',
388 | compTmp: tpl
389 | })
390 | let matched = rsp.data
391 | if (matched.status !== FINGER_STATUS_SUCC) {
392 | await utils.waitFor(500)
393 | continue
394 | }
395 | if (matched.score < 60) {
396 | msgHandler({
397 | type: 'hint',
398 | content: `匹配度: ${matched.score}, 匹配失败`
399 | })
400 | continue
401 | }
402 | return matched.FPTmp
403 | }
404 | return Promise.reject(new Error('已取消'))
405 | }
406 |
407 | function fingerMatchCancelble ({msgHandler}, tpl) {
408 | let canceled = false
409 | let shouldCancle = () => canceled
410 |
411 | return {
412 | promise: _fingerMatch({shouldCancle, msgHandler}, tpl),
413 | cancel () {
414 | canceled = true
415 | fingerTerminate()
416 | }
417 | }
418 | }
419 |
420 | export default {
421 | readIdcard,
422 | // readRfid: readRfidIsoO15693,
423 | readRfid: batchReadRfidIsoO15693,
424 | // readRfid: readRfid14443A,
425 | rfidBeep,
426 | rfidWarnBeep,
427 | rfidLight,
428 | readHeartBeat,
429 | print,
430 | fingerRegister: fingerRegisterCancelble,
431 | fingerTerminate,
432 | fingerMatch: fingerMatchCancelble
433 | }
--------------------------------------------------------------------------------
/从0开始/14_day.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
第[49568]条 2016-07-7 22:51:52
108 |
×
109 |
110 |
111 |
112 | 普天同庆,天下大同!
113 |
114 |
115 |
116 |

117 |
118 |
不愿意透露姓名的吕先生
119 |
120 |
121 |
122 |
123 |
149 |
150 |
--------------------------------------------------------------------------------
/从0开始/image/0f000PC3L7v5WMl_8bcCX6.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/0f000PC3L7v5WMl_8bcCX6.jpg
--------------------------------------------------------------------------------
/从0开始/image/1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/1.gif
--------------------------------------------------------------------------------
/从0开始/image/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/1.jpg
--------------------------------------------------------------------------------
/从0开始/image/2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/2.gif
--------------------------------------------------------------------------------
/从0开始/image/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/2.jpg
--------------------------------------------------------------------------------
/从0开始/image/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/3.jpg
--------------------------------------------------------------------------------
/从0开始/image/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/4.jpg
--------------------------------------------------------------------------------
/从0开始/image/5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/5.jpg
--------------------------------------------------------------------------------
/从0开始/image/bg.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/bg.gif
--------------------------------------------------------------------------------
/从0开始/image/bpic_1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/bpic_1.gif
--------------------------------------------------------------------------------
/从0开始/image/cloud.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/cloud.gif
--------------------------------------------------------------------------------
/从0开始/image/content.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/content.png
--------------------------------------------------------------------------------
/从0开始/image/content_bg.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/content_bg.jpg
--------------------------------------------------------------------------------
/从0开始/image/lb1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/lb1.jpg
--------------------------------------------------------------------------------
/从0开始/image/lb2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/lb2.jpg
--------------------------------------------------------------------------------
/从0开始/image/lb3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/lb3.jpg
--------------------------------------------------------------------------------
/从0开始/image/lb4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/lb4.jpg
--------------------------------------------------------------------------------
/从0开始/image/lb5.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/lb5.jpg
--------------------------------------------------------------------------------
/从0开始/image/main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/main.png
--------------------------------------------------------------------------------
/从0开始/image/mm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/mm.png
--------------------------------------------------------------------------------
/从0开始/image/nav.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/nav.png
--------------------------------------------------------------------------------
/从0开始/image/rss.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/rss.png
--------------------------------------------------------------------------------
/从0开始/image/taobao.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/taobao.jpg
--------------------------------------------------------------------------------
/从0开始/image/tianshi.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/tianshi.gif
--------------------------------------------------------------------------------
/从0开始/image/tip1_c.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/tip1_c.gif
--------------------------------------------------------------------------------
/从0开始/image/tip1_f.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/tip1_f.gif
--------------------------------------------------------------------------------
/从0开始/image/tip1_h.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/tip1_h.gif
--------------------------------------------------------------------------------
/从0开始/image/top.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/top.png
--------------------------------------------------------------------------------
/从0开始/image/xiaoniao.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/xiaoniao.gif
--------------------------------------------------------------------------------
/从0开始/image/百度换肤.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/image/百度换肤.png
--------------------------------------------------------------------------------
/从0开始/images/01.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/01.jpg
--------------------------------------------------------------------------------
/从0开始/images/02.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/02.jpg
--------------------------------------------------------------------------------
/从0开始/images/03.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/03.jpg
--------------------------------------------------------------------------------
/从0开始/images/04.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/04.jpg
--------------------------------------------------------------------------------
/从0开始/images/05.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/05.jpg
--------------------------------------------------------------------------------
/从0开始/images/1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/1.png
--------------------------------------------------------------------------------
/从0开始/images/2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/2.png
--------------------------------------------------------------------------------
/从0开始/images/3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/3.png
--------------------------------------------------------------------------------
/从0开始/images/4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/4.png
--------------------------------------------------------------------------------
/从0开始/images/5.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/5.png
--------------------------------------------------------------------------------
/从0开始/images/QQ图片20180709193807.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/QQ图片20180709193807.png
--------------------------------------------------------------------------------
/从0开始/images/hungry.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/hungry.png
--------------------------------------------------------------------------------
/从0开始/images/hungry2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/hungry2.png
--------------------------------------------------------------------------------
/从0开始/images/low.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/low.png
--------------------------------------------------------------------------------
/从0开始/images/music_lie.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/music_lie.png
--------------------------------------------------------------------------------
/从0开始/images/pass.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/pass.png
--------------------------------------------------------------------------------
/从0开始/images/shop.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/shop.png
--------------------------------------------------------------------------------
/从0开始/images/singer1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/singer1.png
--------------------------------------------------------------------------------
/从0开始/images/singer2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/singer2.png
--------------------------------------------------------------------------------
/从0开始/images/status.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/status.png
--------------------------------------------------------------------------------
/从0开始/images/view.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GuangXinSZ/javascript-data-structure/c03d4a7c36df755010e46c74cbb8715c3d62a060/从0开始/images/view.png
--------------------------------------------------------------------------------
/从0开始/jq.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
128 |
129 |
--------------------------------------------------------------------------------
/从0开始/rest.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
42 |
43 |
--------------------------------------------------------------------------------
/从0开始/tools.js:
--------------------------------------------------------------------------------
1 | /**
2 | * [获取id]
3 | */
4 | function getEle(id){
5 | return document.getElementById(id);
6 | }
7 | /**
8 | * [getFirstNode description]
9 | * @param {[type]} ele [description]
10 | * @return {[type]} [description]
11 | */
12 | function getFirstNode(ele){
13 | var node = ele.firstElementChild || ele.firstChild;
14 | return node
15 | }
16 | /**
17 | * [getLastNode description]
18 | * @param {[type]} ele [description]
19 | * @return {[type]} [description]
20 | */
21 | function getLastNode(ele){
22 | var node = ele.lastElementChild || ele.lastChild;
23 | return node;
24 | }
25 | /**
26 | * [获取下一个兄弟节点]
27 | * @param {[type]} ele [description]
28 | * @return {[type]} [description]
29 | */
30 | function getNextNode(ele){
31 | return ele.nextElementSibling || ele.nextSibling;
32 | }
33 | /**
34 | * [获取上一个兄弟节点]
35 | * @param {[type]} ele [description]
36 | * @return {[type]} [description]
37 | */
38 | function getPrevNode(ele){
39 | /*兼容*/
40 | return ele.previousElementSibling || ele.previousSibling;
41 | }
42 |
43 | /**
44 | * [获取指定的兄弟节点元素 并返回]
45 | */
46 | function getEleOfIndex(ele,index){
47 | return ele.parentNode.children[index];
48 | }
49 | /**
50 | * [获取每一个子元素]
51 | */
52 | function getAllSiblingNode(ele){
53 | var newArr = [];
54 | var arr = ele.parentNode.children;
55 | for(var i=0;i {
22 | this.setState({
23 | theme: value ? 'dark' : 'light',
24 | });
25 | }
26 | toggle = () => {
27 | this.setState({
28 | collapsed: !this.state.collapsed,
29 | mode: this.state.collapsed ? 'inline' : 'vertical',
30 | });
31 | }
32 | clear = () => {
33 | this.setState({
34 | current: 'index',
35 | });
36 | }
37 | handleClick = (e, special) => {
38 | this.setState({
39 | current: e.key || special,
40 | });
41 | }
42 | render() {
43 | return (
44 |
45 |
46 |
47 |
53 | {this.state.theme === 'light' ? :
54 | }
55 | { this.state.theme === 'light' ? ruanmou : ruanmou }
56 |
85 |
86 |
92 |
93 |
94 |
95 |
96 |
97 |
98 | hello world
99 |
100 |
101 |
104 |
105 |
106 | );
107 | }
108 | }
109 | export default Container;
--------------------------------------------------------------------------------
/作用域_1.js:
--------------------------------------------------------------------------------
1 | /*constructor代表创建对象的指向 直接赋值可以不改变函数的指向*/
2 | var myVaribale = 'global';
3 | myOtherVar = 'global';
4 | function myFunction(){
5 | /*作用域*/
6 | var myVaribale = 'local';
7 | return myVaribale;
8 | }
9 | function myOtherFunction(){
10 | var myOtherVar = 'local';
11 | return myOtherVar;
12 | }
13 | console.log(myVaribale);
14 | console.log(myFunction());
15 |
16 | console.log(myOtherVar);
17 |
18 | console.log(myOtherFunction());
19 |
20 | console.log(myOtherVar);
21 |
--------------------------------------------------------------------------------
/冒泡.js:
--------------------------------------------------------------------------------
1 | function bubbleSort(arr) {
2 | var len = arr.length;
3 | for (var i = 0; i < len; i++) {
4 | for (var j = 0; j < len - 1 - i; j++) {
5 | if (arr[j] > arr[j+1]) { //相邻元素两两对比
6 | var temp = arr[j+1]; //元素交换
7 | arr[j+1] = arr[j];
8 | arr[j] = temp;
9 | }
10 | }
11 | }
12 | return arr;
13 | }
--------------------------------------------------------------------------------
/去重_.js:
--------------------------------------------------------------------------------
1 | var arr1 = [1,2,3,44,44,11,2,3,333,3,3];
2 | function removeRepeat(arr){
3 | var removeArr = [],obj = {};
4 | for(var i = 0, l = arr.length; i < l; i++){
5 | if(!obj[arr[i]]){
6 | removeArr.push(arr[i]);
7 | obj[arr[i]] = 1;
8 | }
9 | };
10 | return removeArr;
11 | }
12 | var singleArr = removeRepeat(arr1);
13 | console.log(singleArr); //[1, 2, 3, 44, 11, 333]
--------------------------------------------------------------------------------
/堆_2.js:
--------------------------------------------------------------------------------
1 |
2 | function Stack() {
3 | var items = [];
4 | this.push = function(element){
5 | items.push(element);
6 | };
7 | this.pop = function(){
8 | return items.pop();
9 | };
10 | this.peek = function(){
11 | return items[items.length-1];
12 | };
13 | this.isEmpty = function(){
14 | return items.length == 0;
15 | };
16 | this.size = function(){
17 | return items.length;
18 | };
19 | this.clear = function(){
20 | items = [];
21 | };
22 | this.print = function(){
23 | console.log(items.toString());
24 | };
25 | }
--------------------------------------------------------------------------------
/并集.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
114 |
115 |
--------------------------------------------------------------------------------
/并集_06.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
114 |
115 |
116 |
--------------------------------------------------------------------------------
/排序.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
63 |
64 |
--------------------------------------------------------------------------------
/插入排序.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
63 |
64 |
--------------------------------------------------------------------------------
/操作符_1.js:
--------------------------------------------------------------------------------
1 | var num = 0; //{1}
2 | num = num + 2;
3 | num = num * 3;
4 | num = num / 2;
5 | num++;
6 | num--;
7 | num += 1; //{2}
8 | num -= 2;
9 | num *= 3;
10 | num /= 2;
11 | num %= 3;
12 | console.log('num == 1 : ' + (num == 1)); // {3}
13 | console.log('num === 1 : ' + (num === 1));
14 | console.log('num != 1 : ' + (num != 1));
15 | console.log('num > 1 : ' + (num > 1));
16 | console.log('num < 1 : ' + (num < 1));
17 | console.log('num >= 1 : ' + (num >= 1));
18 | console.log('num <= 1 : ' + (num <= 1));
19 | console.log('true && false : ' + (true && false)); // {4}
20 | console.log('true || false : ' + (true || false));
21 | console.log('!true : ' + (!true));
--------------------------------------------------------------------------------
/栈_04.js:
--------------------------------------------------------------------------------
1 | function Stack(){
2 | /*首先定义一个数组*/
3 | var items = [];
4 | this.push = function (element){
5 | items.push(element);
6 | };
7 | /*删除并且return 顶部的数据*/
8 | this.pop = function (){
9 | return items.pop();
10 | };
11 | this.peek = function(){
12 | /*length-1 返回最后添加的数*/
13 | return items[items.length-1];
14 | };
15 | this.isEmpty = function(){
16 | return items.length == 0;
17 | };
18 | this.size = function(){
19 | return items.length;
20 | };
21 | this.clear = function(){
22 | items = [];
23 | };
24 | this.print = function(){
25 | console.log(items.toString());
26 | };
27 | }
28 | /*使用Stack*/
29 | var stack = new Stack();
30 | console.log(stack.isEmpty());/*true*/
31 | stack.push(5);
32 | stack.push(6);
33 | console.log(stack.peek());/*输出6 返回的是最后往里面添加的数值*/
34 | stack.push(7);
35 | console.log(stack.size());/*输出结果为3*/
36 | /*实现先进后出 后进先出的原理*/
37 | stack.pop();/*删除顶部的数并且返回*/
38 | stack.pop();
39 | console.log( stack.size());/*返回1*/
40 | stack.print();/*输出为5*/
--------------------------------------------------------------------------------
/求和_1.js:
--------------------------------------------------------------------------------
1 | var arrList = [];//定义的数组 tyoeof 是一个object
2 | arrList[0] = 1;//赋予2个值
3 | arrList[1] = 2;
4 | for(var i=3;i<20;i++){
5 | /*当前i=3 i-1就等于2 || i-2=1 所以得出下面*/
6 | arrList[i] = arrList[i-1] + arrList[i-2];
7 | }
8 | /*输出结果arrList[19]*/
9 | console.log(arrList);
--------------------------------------------------------------------------------
/进制.js:
--------------------------------------------------------------------------------
1 | function Stack(){
2 | /*首先定义一个数组*/
3 | var items = [];
4 | this.push = function (element){
5 | items.push(element);
6 | };
7 | /*删除并且return 顶部的数据*/
8 | this.pop = function (){
9 | return items.pop();
10 | };
11 | this.peek = function(){
12 | return items[items.length-1];
13 | };
14 | this.isEmpty = function(){
15 | return items.length == 0;
16 | };
17 | this.size = function(){
18 | return items.length;
19 | };
20 | this.clear = function(){
21 | items = [];
22 | };
23 | this.print = function(){
24 | console.log(items.toString());
25 | };
26 | }
27 | /*使用Stack*/
28 | var stack = new Stack();
29 | console.log(stack.isEmpty());/*true*/
30 | stack.push(5);
31 | stack.push(6);
32 | console.log(stack.peek());/*输出6 返回的是最后往里面添加的数值*/
33 | stack.push(7);
34 | console.log(stack.size());/*输出结果为3*/
35 | /*实现先进后出 后进先出的原理*/
36 | stack.pop();/*删除顶部的数并且返回*/
37 | stack.pop();
38 | console.log( stack.size());/*返回1*/
39 | stack.print();/*输出为5*/
40 |
41 | /*进制转换*/
42 |
43 | function divideBy2(number){
44 | var remStack = new Stack(),
45 | rem,
46 | bindaryString = '';
47 | while(number>0){
48 | /*取余数*/
49 | rem = Math.floor(number % 2);
50 |
51 | remStack.push(rem);
52 | /*取整*/
53 | number = Math.floor(number / 2);
54 | }
55 | while(!remStack.isEmpty()){
56 | bindaryString += remStack.pop().toString();
57 | }
58 | return bindaryString;
59 | }
60 | console.log(divideBy2(456));
61 | /*自定义转换*/
62 | function baseConverter(decNumber, base){
63 | var remStack = new Stack(),
64 | rem,
65 | baseString = '',
66 | digits = '0123456789ABCDEF'; //{6}
67 | while (decNumber > 0){
68 | rem = Math.floor(decNumber % base);
69 | remStack.push(rem);
70 | decNumber = Math.floor(decNumber / base);
71 | }
72 | while (!remStack.isEmpty()){
73 | baseString += digits[remStack.pop()]; //{7}
74 | }
75 | return baseString;
76 | }
--------------------------------------------------------------------------------
/选择排序.js:
--------------------------------------------------------------------------------
1 |
2 | function ArrayList(){
3 | var array = [];
4 | /* 通过构造函数的方法创建对象 */
5 | this.insert = function(item){
6 | /*实现push方法*/
7 | array.push(item)
8 | };
9 | /* join方法 */
10 | this.toString = function(){
11 | return array.join();
12 | }
13 | /*选择排序 基本思路 找到最小的一位放在第一个 以此类推*/
14 | this.selectionSort = function(){
15 | /* 获取长度 以好循环 */
16 | var length = array.length,
17 | /* 最小的那个参数 */
18 | indexMin;
19 | for(var i=0;i array[5] 接下来 循环过后: 内部循环得到了最小值 */
26 | /* 再次循环再次得到 */
27 | if(array[indexMin] > array[j]){
28 | indexMin = j
29 | }
30 | }
31 | /*待续 替换最新的值 新值替换老值*/
32 | if(i !== indexMin){
33 | swap(i,indexMin)
34 | }
35 | }
36 | }
37 | var swap = function (index1,index2){
38 | /* 实现替换的 */
39 | var aux = array[index1];
40 | /* 替换 */
41 | array[index1] = array[index2];
42 | /* 重新赋值 */
43 | array[index2] = aux;
44 | }
45 | }
46 | function createNonSortedArray(size){
47 | /* 函数里面调用了 new ArrayList */
48 | var array = new ArrayList();
49 | /* 实现5 4 3 2 1 */
50 | for(var i=size;i>0;i--){
51 | /*添加inser*/
52 | array.insert(i);
53 | }
54 | return array;
55 | }
56 | var array = createNonSortedArray(5);
57 | console.log(array.toString());//输出 54321
58 | /* 这个时候array 54321 */
59 |
60 | /* 运行 5>4>3>2>1 取到最小的值进行比较以此类推 输出结果 1<2<3<4<5 */
61 | array.selectionSort();
62 |
63 | console.log(array.toString())
64 |
--------------------------------------------------------------------------------
/队列_04.js:
--------------------------------------------------------------------------------
1 | /*队列*/
2 | function Queue(){
3 | var items = [];
4 | this.enqueue = function (element){
5 | /*添加一个值*/
6 | items.push(element);
7 | };
8 | this.dequeue = function (){
9 | /*删除第数组里面的第一个并且返回*/
10 | return items.unshift();
11 | };
12 | this.font = function (){
13 | /*返回第一个参数*/
14 | return items[0];
15 | };
16 | this.isEmpty = function(){
17 | /*判断数组是否为空*/
18 | return items.length ==0;
19 | };
20 | this.clear = function(){
21 | /*清空数组*/
22 | items = [];
23 | };
24 | this.size = function(){
25 | /*返回数组的长度*/
26 | return items.length;
27 | };
28 | this.print = function (){
29 | /*返回全部的结果*/
30 | console.log(items.toString())
31 | }
32 | }
33 | var queue = new Queue();
34 | queue.enqueue("1");
35 | queue.enqueue("2");
36 | /*实现先进先出 后进后出的效果*/
37 | queue.dequeue();
38 | queue.dequeue();
39 | queue.print();
--------------------------------------------------------------------------------
/队列_05.js:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Document
6 |
7 |
8 |
58 |
59 |
60 |
--------------------------------------------------------------------------------