Open xgqfrms opened 5 years ago
https://codepen.io/webgeeker/pen/JmPXaN
https://browsersync.io/docs/command-line#start
https://github.com/Browsersync/browser-sync
# Start Browsersync from a config file with overriding flags
$ browser-sync start --config 'conf/browser-sync.js' --port 4000
"scripts": {
"dev": "start http://localhost:8888/pages/index.html && npm start",
"html": "browser-sync start --server --files './build/*.*' --port 8888",
"app": "npm run build && start http://localhost:8888/pages/index.html && npm run html",
"json-open": "start http://localhost:3000",
"json-db": "json-server --watch api/db.json"
},
http://localhost:3000/build/pages/index.html http://localhost:8888/build/pages/index.html
https://zzk.cnblogs.com/s?w=blog%3Axgqfrms%20zip
# all files in folder
$ zip -r auth-mamage.zip auth-mamage/*
Q: how to disable form submit action refresh page?
https://teamtreehouse.com/community/how-to-disable-submit-form
https://www.w3schools.com/html/html_forms.asp
A:
e.preventDefault();
&return false;
const showPasswordModal = (title = `修改密码`) => {
console.log(`password has been modified!`);
let formDOM = formGenerator(`password`);
layer.open({
title: `<h3>${title}</h3>`,
content: `<div class="form-box">${formDOM}</div>`,
area: ["50%", "70%"],
type: 1,
btn: ["关闭"],
yes: function(index, layero){
let submitBtn = document.querySelector(`button[type="submit"]`),
restButton = document.querySelector(`button[type="reset"]`);
submitBtn.addEventListener(`click`, function(e) {
// e.target
e.preventDefault();
});
layui.use('form', function() {
let form = layui.form;
form.on('submit(formDemo)', function(data){
console.log(`json =`, JSON.stringify(data.field));
// http://10.1.5.202/deploy/http/sign/changepassword?{"old_password":"hongk","new_password":"123456"}
return false;
});
});
setTimeout(() => {
// success
layer.close(index);
}, 1000);
},
btn2: function(index, layero){
layer.close(index);
},
});
};
<!DOCTYPE html>
<html>
<body>
<h2>HTML Forms</h2>
<form action="">
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form>
<p>If you click the "Submit" button, the form-data will be sent to a page called "/action_page.php".</p>
<script>
let submitBtn = document.querySelector(`input[type="submit"]`);
submitBtn.addEventListener(`click`, function(e) {
// e.target
e.preventDefault();
});
</script>
</body>
</html>
https://www.w3schools.com/html/tryit.asp?filename=tryhtml_form_submit
const getNowTimeStamps = (filename = `速览`, extension = `pdf`, debug = false) => {
let result = ``,
date = new Date(),
name = filename,// "stock 速览" => "stock_速览" ??? Regex
yyyy = ``,
MM = ``,
dd = ``,
hh = ``,
mm = ``,
ss = ``;
yyyy = date.getFullYear();
MM = date.getMonth() + 1;// 1 => 01 (zero padding)???
dd = date.getDate();
hh = date.getHours();
mm = date.getMinutes();// 1 => 01 (zero padding)???
ss = date.getSeconds();
result = `${name}_${yyyy}${MM}${dd}${hh}${mm}${ss}.${extension}`;
return result;
};
how to get download progress in js?
https://stackoverflow.com/questions/18126406/how-can-i-get-the-progress-of-a-downloading-script https://stackoverflow.com/questions/16690740/how-to-show-loading-status-in-percentage-for-ajax-response https://stackoverflow.com/questions/18323152/get-download-progress-in-node-js-with-request
https://www.w3schools.com/howto/howto_js_progressbar.asp https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_progressbar_3
https://ourcodeworld.com/articles/read/56/how-to-get-the-progress-of-an-upload-or-download-with-jquery-ajax https://zinoui.com/blog/ajax-request-progress-bar https://coderwall.com/p/je3uww/get-progress-of-an-ajax-request
webpack.DllPlugin
?https://webpack.js.org/plugins/dll-plugin/
https://github.com/cd-dongzi/vue-project/issues/7
https://docs.mongodb.com/manual/mongo/
$ mongo --help
# default port 27017
$ mongo
# port
$ mongo --port 28015
$ help
$ show databases
$ use local
$ show tabels
$ whoami
# net user "user name"
$ net user "xgqfrms"
$ wmic useraccount list full
$ wmic useraccount list full >"%userprofile%\Desktop\UserAccountDetails.txt"
https://www.windows-commandline.com/current-logged-in-user-name-command/
https://www.tenforums.com/tutorials/3443-view-user-account-details-windows-10-a.html
$ net user administrator
https://www.lifewire.com/net-user-command-2618097
https://www.layui.com/doc/modules/form.html#onselect
https://www.layui.com/doc/element/form.html#select
form.render("select");
let jsonObj = {};
const editProject = () => {
let reset = document.querySelector(`button[type="reset"]`);
layui.use("form", function() {
let form = layui.form,
layer = layui.layer;
// init select
form.render("select");
form.on('submit(formDemo)', function(data) {
let {
user_name,
role,
password,
email,
} = data.field;
let query_obj = {
user_name,
role,
password
};
// filter
if (email) {
query_obj.email = email;
}
let url = `${fetchIP}/http/sign/updateuser?${encodeURIComponent(JSON.stringify(query_obj))}`;
getDatas(url).then(json => {
// loading
let loadingIndex = layer.load(1, {
time: 1*1000,
});
let resetButton = document.querySelector(`button[type="reset"]`);
setTimeout(() => {
layer.close(loadingIndex);
if (json.success) {
layer.close(modalIndex);
swal({
title: "修改服务成功!",
text: `${json.message !== null ? json.message : "3 秒后自动关闭!"}`,
icon: "success",
// button: "关闭",
buttons: false,
timer: 3000,
});
resetButton.click();
loadList();
} else {
swal({
title: "修改服务失败!",
text: `${json.message !== null ? json.message : "3 秒后自动关闭!"}`,
icon: "error",
// button: "关闭",
buttons: false,
timer: 3000,
});
}
}, 1000);
// reset
reset.click();
}).catch(err => console.log(`error`, err));
return false;
});
let {
user_name,
role,
// password,
email,
// role_desc,
} = jsonObj;
let input_name = document.querySelector(`input[name="user_name"]`),
input_role = document.querySelector(`select[name="role"]`),
input_email = document.querySelector(`input[name="email"]`);
input_name.value = `${user_name}`;
input_name.setAttribute(`disabled`, `disabled`);
// input_name.setAttribute(`readonly`, `readonly`);
input_email.value = `${email}`;
input_role.value = `${role}`;
// update select
form.render("select");
});
};
<div class="layui-form-item">
<label class="layui-form-label" title="服务器 IP">服务器 IP</label>
<div class="layui-input-block">
<input type="text" name="server_ip" required lay-verify="required" placeholder="请输入服务器 IP" autocomplete="on" class="layui-input" value="${ip}">
</div>
</div>
async & delay bug
form.render("select");
// select default value
reset.addEventListener(`click`, () => {
// re-render
setTimeout(() => {
// async & delay bug
input_role.value = `${role}`;
form.render("select");
}, 100);
});
vue 2.x api & basic demos
https://vuejs.org/v2/api/index.html#v-on
http://www.runoob.com/vue2/vue-start.html
https://cli.vuejs.org/config/#baseurl
https://www.npmjs.com/package/better-scroll