Skip to content

Commit 8984402

Browse files
author
zhangyue0503
committed
20180710
1 parent 0064b5d commit 8984402

17 files changed

+302
-1
lines changed

.DS_Store

0 Bytes
Binary file not shown.

es6/promise/promise2-1.html

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
</head>
9+
<body>
10+
<script>
11+
new Promise(function(resolve,reject){
12+
reject();
13+
}).then(function(){
14+
alert(1);
15+
},function(){
16+
alert(2);
17+
});
18+
</script>
19+
</body>
20+
</html>

nodejs系列/2/1.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
今天心情真好

nodejs系列/2/1231

-1
This file was deleted.

nodejs系列/2/404.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
<style>
9+
10+
11+
</style>
12+
</head>
13+
<body>
14+
哥们,您找错位置了吧~~
15+
</body>
16+
</html>

nodejs系列/2/f.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var http = require('http'),
2+
fs = require('fs'),
3+
urlLib = require('url');
4+
5+
http.createServer(function(req,res){
6+
res.setHeader('Access-Control-Allow-Origin','*');
7+
8+
var json = urlLib.parse(req.url,true).query;
9+
// console.log(json);
10+
fs.writeFile(json.fname+'.html',json.inner,function(err){
11+
if(err){
12+
console.log(err);
13+
}else{
14+
console.log('生成成功....');
15+
res.write('生成成功');
16+
}
17+
res.end();
18+
});
19+
20+
}).listen(2729);
File renamed without changes.

nodejs系列/2/fs3.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
var http = require('http'),
2+
fs = require('fs'),
3+
urlLib = require('url'),
4+
querystring = require('querystring');
5+
6+
http.createServer(function (req, res) {
7+
res.setHeader('Access-Control-Allow-Origin', '*');
8+
9+
console.log(req.url);
10+
11+
var urlName = req.url;
12+
fs.readFile('.' + urlName, function (err, data) {
13+
if (err) {
14+
fs.readFile('./404.html', function (err, data) {
15+
if (err) console.log(err);
16+
res.write(data);
17+
res.end();
18+
});
19+
} else {
20+
res.write(data);
21+
res.end();
22+
}
23+
});
24+
25+
// if (req.url == '/index.html') {
26+
// fs.readFile('.' + req.url,function(err,data){
27+
// if(err)console.log(err);
28+
// res.write(data);
29+
// res.end();
30+
// });
31+
// }else{
32+
// fs.readFile('./404.html' ,function(err,data){
33+
// if(err)console.log(err);
34+
// res.write(data);
35+
// res.end();
36+
// });
37+
// }
38+
39+
40+
}).listen(2182);

nodejs系列/2/fs4.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var fs = require('fs');
2+
3+
fs.readFile('http://www.zyblog.net/post-279.html',function(err,data){
4+
if(err)console.log(err);
5+
6+
fs.writeFile('1.html',data,function(err){
7+
if(err)console.log(err);
8+
9+
});
10+
});

nodejs系列/2/index.html

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
<style>
9+
*{margin:0;padding:0;}
10+
11+
</style>
12+
</head>
13+
<body>
14+
正常页面index.html
15+
</body>
16+
</html>

nodejs系列/2/login.html

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
7+
<title>Document</title>
8+
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
9+
</head>
10+
<body>
11+
用户:<input type="text" id="user"><br/>
12+
密码:<input type="text" id="pass"><br/>
13+
<input type="button" value="注册" id="res">
14+
<input type="button" value="登录" id="login">
15+
<script>
16+
res.onclick = function(){
17+
$.ajax({
18+
type:'get',
19+
url:'http://localhost:2871/',
20+
data:{
21+
user:user.value,
22+
pass:pass.value
23+
},
24+
success:function(data){
25+
alert(data);
26+
}
27+
});
28+
};
29+
login.onclick = function(){
30+
$.ajax({
31+
type:'get',
32+
url:'http://localhost:2872/',
33+
data:{
34+
user:user.value,
35+
pass:pass.value
36+
},
37+
success:function(data){
38+
alert(data);
39+
}
40+
});
41+
};
42+
</script>
43+
</body>
44+
</html>

nodejs系列/2/login.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
var http = require('http'),
2+
urlLib = require('url');
3+
4+
var allDate = {};
5+
http.createServer(function(req,res){
6+
res.setHeader('Access-Control-Allow-Origin','*');
7+
8+
var json = urlLib.parse(req.url,true).query;
9+
// console.log(json);
10+
11+
if(allDate[json.user]){
12+
res.write('用户名已注册');
13+
}else{
14+
allDate[json.user] = json.pass;
15+
res.write('恭喜您,注册成功');
16+
}
17+
18+
// console.log(allDate);
19+
res.end();
20+
21+
}).listen(2871);
22+
23+
http.createServer(function(req,res){
24+
res.setHeader('Access-Control-Allow-Origin','*');
25+
var json = urlLib.parse(req.url,true).query;
26+
27+
if(allDate[json.user] == json.pass){
28+
res.write('登录成功');
29+
}else{
30+
res.write('用户名或密码错误');
31+
}
32+
res.end();
33+
}).listen(2872);

nodejs系列/2/rename.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var fs = require('fs');
2+
3+
fs.rename('./asdfasdf','ffff.txt',function(err){
4+
if(err){
5+
console.log('失败了:'+err);
6+
}else{
7+
console.log('修改成功');
8+
}
9+
});

nodejs系列/2/rj.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
var fs = require('fs');
2+
3+
fs.readFile('./save.txt', 'utf8', function (err, data) {
4+
if (err) {
5+
console.log(err);
6+
} else {
7+
// console.log(typeof data);
8+
var json = eval('(' + data + ')');
9+
console.log(typeof json);
10+
11+
json.a = 30;
12+
fs.writeFile('save.txt', JSON.stringify(json), function (err) {
13+
if (err) {
14+
console.log(err);
15+
} else {
16+
console.log('保存完成');
17+
}
18+
});
19+
20+
21+
}
22+
});

nodejs系列/2/save.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"a":30}

nodejs系列/2/song.html

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="UTF-8">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
8+
<title>Document</title>
9+
<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
10+
</head>
11+
12+
<body>
13+
<input type="text" id='songs'>
14+
<button id='btn'>搜索</button>
15+
<ul id="ul"></ul>
16+
<script>
17+
btn.onclick = function () {
18+
ul.innerHTML = '';
19+
$.ajax({
20+
url: 'http://myjavascript.cn:5213/myClevaly/addMp3',
21+
type: 'get',
22+
data: {
23+
user: 'Leo',
24+
mp3Name: songs.value
25+
},
26+
success: function (data) {
27+
28+
var jsonData = JSON.parse(data.data);
29+
var arrData = jsonData.result.songs;
30+
31+
for (var i = 0; i < arrData.length; i++) {
32+
var oLi = document.createElement('li');
33+
oLi.innerHTML = '<p>' + arrData[i].album.name + '</p>';
34+
oLi.innerHTML += '<img src="' + arrData[i].album.picUrl + '" width=200><br/>';
35+
oLi.innerHTML += '<audio controls src="' + arrData[i].audio + '"></audio><br/>';
36+
oLi.innerHTML += '<a href="' + arrData[i].page + '" target="_blank">' + arrData[
37+
i].page + '</a>';
38+
ul.appendChild(oLi);
39+
}
40+
41+
console.log(songs.value, ul.outerHTML);
42+
43+
$.ajax({
44+
url: 'http://localhost:2729/',
45+
type: 'get',
46+
data: {
47+
fname: songs.value,
48+
inner: ul.outerHTML
49+
},
50+
success: function (data) {
51+
alert(data);
52+
}
53+
});
54+
55+
}
56+
});
57+
};
58+
</script>
59+
</body>
60+
61+
</html>

nodejs系列/2/unlink.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
var fs = require('fs');
2+
3+
fs.unlink('./1231',function(err){
4+
if(err){
5+
console.log(err);
6+
}else{
7+
console.log('删除成功');
8+
}
9+
});

0 commit comments

Comments
 (0)