Browse Source

采用DedeConfirm改写window.confirm

tags/6.2.0
tianya 2 months ago
parent
commit
9f5205c384
14 changed files with 200 additions and 91 deletions
  1. +4
    -37
      src/admin/js/key.js
  2. +39
    -0
      src/admin/js/main.js
  3. +0
    -4
      src/admin/templets/diy_edit.htm
  4. +36
    -8
      src/admin/templets/feedback_main.htm
  5. +22
    -19
      src/admin/templets/freelist_main.htm
  6. +5
    -2
      src/admin/templets/mychannel_edit.htm
  7. +15
    -8
      src/admin/templets/stepselect_main.htm
  8. +6
    -3
      src/admin/templets/templets_default.htm
  9. +40
    -0
      src/static/web/js/style.js
  10. +5
    -1
      src/user/templets/content_list.htm
  11. +5
    -1
      src/user/templets/content_sg_list.htm
  12. +8
    -3
      src/user/templets/mypay.htm
  13. +4
    -2
      src/user/templets/operation.htm
  14. +11
    -3
      src/user/templets/pm-main.htm

+ 4
- 37
src/admin/js/key.js View File

@@ -15,46 +15,13 @@ function noselAll()
}
}
}
function delkey()
{
if (window.confirm("您确定要删除选定的关键字吗")) {
document.form3.dopost.value = 'del';
document.form3.submit();
}
}
function diskey()
{
if (window.confirm("您确定要禁用选定的关键字吗")) {
document.form3.dopost.value = 'dis';
document.form3.submit();
}
}
function enakey()
{
if (window.confirm("您确定要启用选定的关键字吗")) {
document.form3.dopost.value = 'ena';
document.form3.submit();
}
}
function urlkey()
{
if (window.confirm("您确定要更新选定的关键字的网址吗")) {
document.form3.dopost.value = 'url';
document.form3.submit();
}
}
function rankey()
{
if (window.confirm("您确定要改变选定的关键字的频率吗")) {
document.form3.dopost.value = 'ran';
document.form3.submit();
}
}
//批量删除搜多关键字
function delall()
{
if (window.confirm("您确定要删除选定的关键字吗")) {
DedeConfirm("您确定要删除选定的关键字吗?").then((v)=>{
document.form3.dopost.value = 'delall';
document.form3.submit();
}
}).catch((e)=>{
console.log(e)
});
}

+ 39
- 0
src/admin/js/main.js View File

@@ -511,6 +511,45 @@ function guid() {
}
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
}
var _DedeConfirmFuncs = {};
var _DedeConfirmFuncsClose = {};
function __DedeConfirmRun(modalID) {
_DedeConfirmFuncs[modalID]();
}
function __DedeConfirmRunClose(modalID) {
_DedeConfirmFuncsClose[modalID]();
}
function DedeConfirm(content="",title="确认提示") {
let modalID = guid();
return new Promise((resolve, reject) => {
_DedeConfirmFuncs[modalID] = ()=>{
resolve("success");
CloseModal(`DedeModal${modalID}`);
}
_DedeConfirmFuncsClose[modalID] = ()=>{
reject("cancel");
CloseModal(`DedeModal${modalID}`);
}

let footer = `<button type="button" class="btn btn-outline-success btn-sm" onClick="__DedeConfirmRunClose(\'${modalID}\')">取消</button> <button type="button" class="btn btn-success btn-sm" onClick="__DedeConfirmRun(\'${modalID}\')">确定</button>`;
let modal = `<div id="DedeModal${modalID}" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="DedeModalLabel${modalID}">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"><div class="modal-header">
<h6 class="modal-title" id="DedeModalLabel${modalID}">${title}</h6>`;
modal += `<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span>&times;</span>
</button>`;
modal += `</div><div class="modal-body">${content}</div><div class="modal-footer">${footer}</div></div></div></div>`;
$("body").append(modal)
$("#DedeModal" + modalID).modal({
backdrop: 'static',
show: true
});
$("#DedeModal" + modalID).on('hidden.bs.modal', function (e) {
$("#DedeModal" + modalID).remove();
})
})
}
//函数会返回一个modalID,通过这个id可自已定义一些方法,这里用到了一个展开语法https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Spread_syntax
function ShowMsg(content, ...args) {
title = "系统提示";


+ 0
- 4
src/admin/templets/diy_edit.htm View File

@@ -18,10 +18,6 @@
}
return true;
}
function DelNote(gourl) {
if (!window.confirm("您确认要删除这条记录吗")) { return false; }
location.href = gourl;
}
</script>
</head>
<body>


+ 36
- 8
src/admin/templets/feedback_main.htm View File

@@ -45,23 +45,51 @@
}
function delFeedback() {
var qstr = getCheckboxItem();
if (qstr == "") ShowMsg("您没选中任何文档");
else if (window.confirm('您确定要删除这些评论吗')) location.href = "feedback_main.php?job=del&fid=" + qstr;
if (qstr == "") {
ShowMsg("您没选中任何文档");
return
};
DedeConfirm("您确定要删除这些评论吗?").then((v)=>{
location.href = "feedback_main.php?job=del&fid=" + qstr
}).catch((e)=>{
console.log(e)
});
}
function delFeedbackIP() {
var qstr = getCheckboxItem();
if (qstr == "") ShowMsg("您没选中任何文档");
else if (window.confirm('您确定要删除这些评论吗')) location.href = "feedback_main.php?job=delall&fid=" + qstr;
if (qstr == "") {
ShowMsg("您没选中任何文档");
return;
};
DedeConfirm("您确定要删除这些评论吗?").then((v)=>{
location.href = "feedback_main.php?job=delall&fid=" + qstr;
}).catch((e)=>{
console.log(e)
});
}
function checkFeedback() {
var qstr = getCheckboxItem();
if (qstr == "") ShowMsg("您没选中任何文档");
else location.href = "feedback_main.php?job=check&fid=" + qstr;
if (qstr == "") {
ShowMsg("您没选中任何文档");
return;
};
DedeConfirm("您确定要删除这些评论吗?").then((v)=>{
location.href = "feedback_main.php?job=check&fid=" + qstr;
}).catch((e)=>{
console.log(e)
});
}
function editFeedback() {
var qstr = getCheckboxItem();
if (qstr == "") ShowMsg("您没选中任何文档");
else location.href = "feedback_edit.php?job=edit&fid=" + qstr;
if (qstr == "") {
ShowMsg("您没选中任何文档");
return;
}
DedeConfirm("您确定要删除这些评论吗?").then((v)=>{
location.href = "feedback_edit.php?job=edit&fid=" + qstr;
}).catch((e)=>{
console.log(e)
});
}
</script>
</head>


+ 22
- 19
src/admin/templets/freelist_main.htm View File

@@ -12,8 +12,8 @@
<script src="js/main.js"></script>
<script>
var pageno = 1;
var totalrow = <?php echo $totalRow;?>;
var pagesize = <?php echo $pagesize;?>;
var totalrow = parseInt('<?php echo $totalRow;?>');
var pagesize = parseInt('<?php echo $pagesize;?>');
var orderby = '<?php echo $orderby?>';
var addget = "<?php echo $addget?>";
//加载列表
@@ -43,24 +43,27 @@
}
//删除
function DelNote(nid) {
if (!window.confirm("您确认要删除这条记录吗")) { return false; }
var listArea = $Obj('rslist');
totalrow = totalrow - 1;
var pagenum = Math.ceil(totalrow / pagesize);
if (pagenum <= pageno) pageno = pagenum;
var errMsg = "网络通信出错<br>[<a href=\"javascript:LoadPage('" + pageno + "')\">点击此重新加载列表</a>]";
fetch("freelist_main.php?dopost=del&aid=" + nid + "&pageno=" + pageno).then(resp=>{
if (resp.ok) {
return resp.text()
}
throw new Error(errMsg);
}).then((d)=>{
listArea.innerHTML = d;
}).catch((error) => {
listArea.innerHTML = errMsg;
});
DedeConfirm("您确认要删除这条记录吗?").then((v)=>{
var listArea = $Obj('rslist');
totalrow = totalrow - 1;
var pagenum = Math.ceil(totalrow / pagesize);
if (pagenum <= pageno) pageno = pagenum;
var errMsg = "网络通信出错<br>[<a href=\"javascript:LoadPage('" + pageno + "')\">点击此重新加载列表</a>]";
fetch("freelist_main.php?dopost=del&aid=" + nid + "&pageno=" + pageno).then(resp=>{
if (resp.ok) {
return resp.text()
}
throw new Error(errMsg);
}).then((d)=>{
listArea.innerHTML = d;
}).catch((error) => {
listArea.innerHTML = errMsg;
});

ReloadPageNum(pageno);
ReloadPageNum(pageno);
}).catch((e)=>{
console.log(e)
});
}
//重新加载分页列表
function ReloadPageNum(startnum) {


+ 5
- 2
src/admin/templets/mychannel_edit.htm View File

@@ -300,8 +300,11 @@
}
//删除
function DelNote(gourl) {
if (!window.confirm("您确认要删除这个字段吗")) { return false; }
location.href = gourl;
DedeConfirm("您确认要删除这个字段吗?").then((v)=>{
location.href = gourl;
}).catch((e)=>{
console.log(e)
});
}
function ShowObj(objname) {
var obj = document.getElementById(objname);


+ 15
- 8
src/admin/templets/stepselect_main.htm View File

@@ -94,13 +94,16 @@
});
}
function DelType() {
if (window.confirm("您确实要删除这个分类吗") == false) return false;
var id = GetSelType();
if (id == 0) {
ShowMsg("必须选择一个类别");
return false;
}
location.href = 'stepselect_main.php?action=del&id=' + id;
DedeConfirm("您确实要删除这个分类吗?").then((v)=>{
var id = GetSelType();
if (id == 0) {
ShowMsg("必须选择一个类别");
return false;
}
location.href = 'stepselect_main.php?action=del&id=' + id;
}).catch((e)=>{
console.log(e)
});
}
function CloseTWin() {
$DE('edsta').innerHTML = loadhtml;
@@ -123,7 +126,11 @@
}
}
function DelSel() {
if (window.confirm("您确实要删除这些分类吗")) document.form1.submit();
DedeConfirm("您确实要删除这些分类吗?").then((v)=>{
document.form1.submit();
}).catch((e)=>{
console.log(e)
});
}
function ChangePage2(sobj) {
var nv = sobj.options[sobj.selectedIndex].value;


+ 6
- 3
src/admin/templets/templets_default.htm View File

@@ -9,9 +9,12 @@
<link rel="stylesheet" href="../static/web/css/admin.css">
<script>
function DelTpl(filename) {
if (window.confirm('您确定要删除这篇文档吗')) location = 'tpl.php?action=del&acdir=<?php echo $acdir;?>&filename=' +
filename;
else return false;
DedeConfirm("您确实要删除这个模板吗?").then((v)=>{
location = 'tpl.php?action=del&acdir=<?php echo $acdir;?>&filename=' +
filename;
}).catch((e)=>{
console.log(e)
});
}
</script>
</head>


+ 40
- 0
src/static/web/js/style.js View File

@@ -29,6 +29,46 @@ function guid() {
}
return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
}

var _DedeConfirmFuncs = {};
var _DedeConfirmFuncsClose = {};
function __DedeConfirmRun(modalID) {
_DedeConfirmFuncs[modalID]();
}
function __DedeConfirmRunClose(modalID) {
_DedeConfirmFuncsClose[modalID]();
}
function DedeConfirm(content="",title="确认提示") {
let modalID = guid();
return new Promise((resolve, reject) => {
_DedeConfirmFuncs[modalID] = ()=>{
resolve("success");
CloseModal(`DedeModal${modalID}`);
}
_DedeConfirmFuncsClose[modalID] = ()=>{
reject("cancel");
CloseModal(`DedeModal${modalID}`);
}

let footer = `<button type="button" class="btn btn-outline-success btn-sm" onClick="__DedeConfirmRunClose(\'${modalID}\')">取消</button> <button type="button" class="btn btn-success btn-sm" onClick="__DedeConfirmRun(\'${modalID}\')">确定</button>`;
let modal = `<div id="DedeModal${modalID}" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="DedeModalLabel${modalID}">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content"><div class="modal-header">
<h6 class="modal-title" id="DedeModalLabel${modalID}">${title}</h6>`;
modal += `<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span>&times;</span>
</button>`;
modal += `</div><div class="modal-body">${content}</div><div class="modal-footer">${footer}</div></div></div></div>`;
$("body").append(modal)
$("#DedeModal" + modalID).modal({
backdrop: 'static',
show: true
});
$("#DedeModal" + modalID).on('hidden.bs.modal', function (e) {
$("#DedeModal" + modalID).remove();
})
})
}
//函数会返回一个modalID,通过这个id可自已定义一些方法,这里用到了一个展开语法:https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Operators/Spread_syntax
function ShowMsg(content, ...args) {
title = "系统提示";


+ 5
- 1
src/user/templets/content_list.htm View File

@@ -17,7 +17,11 @@
location = "archives_do.php?dopost=edit&channelid=" + channelid + "&aid=" + aid;
}
function delArc(aid) {
if (window.confirm('您确定要删除这篇文档吗')) location = "archives_do.php?aid=" + aid + "&dopost=delArc";
DedeConfirm("您确定要删除这篇文档吗?").then((v)=>{
location = "archives_do.php?aid=" + aid + "&dopost=delArc";
}).catch((e)=>{
console.log(e)
});
}
</script>
</head>


+ 5
- 1
src/user/templets/content_sg_list.htm View File

@@ -17,7 +17,11 @@
location = "archives_do.php?dopost=edit&channelid=" + channelid + "&aid=" + aid;
}
function delArc(aid) {
if (window.confirm('您确定要删除这篇文档吗')) location = "archives_do.php?aid=" + aid + "&dopost=delArc";
DedeConfirm("您确定要删除这篇文档吗?").then((v)=>{
location = "archives_do.php?aid=" + aid + "&dopost=delArc";
}).catch((e)=>{
console.log(e)
});
}
</script>
</head>


+ 8
- 3
src/user/templets/mypay.htm View File

@@ -68,6 +68,9 @@
//获得选中文件的文件名
function GetCheckfolderItem() {
var allSel = '';
if (typeof document.form1.deleteid == "undefined") {
return '';
}
if (document.form1.deleteid.value) return document.form1.deleteid.value;
for (i = 0; i < document.form1.deleteid.length; i++) {
if (document.form1.deleteid[i].checked) {
@@ -82,12 +85,14 @@
function DoSubmit() {
var selid = GetCheckfolderItem();
if (selid == '') {
alert("您没选中任何信息");
ShowMsg("您没选中任何信息");
return false;
}
if (window.confirm("您确定要删除这些消息吗")) {
DedeConfirm("您确定要删除这些消息吗?").then((v)=>{
location = "mypay.php?dopost=del&ids=" + selid;
}
}).catch((e)=>{
console.log(e)
});
}
</script>
</body>

+ 4
- 2
src/user/templets/operation.htm View File

@@ -82,9 +82,11 @@
ShowMsg("您没选中任何信息");
return false;
}
if (window.confirm("您确定要删除这些消息吗")) {
DedeConfirm("您确定要删除这些消息吗?").then((v)=>{
location = "operation.php?dopost=del&ids=" + selid;
}
}).catch((e)=>{
console.log(e)
});
}
</script>
</body>

+ 11
- 3
src/user/templets/pm-main.htm View File

@@ -44,15 +44,23 @@
}
return allSel;
}
//删除操作
function DoSubmit(myfolder) {
var selid = GetCheckfolderItem();
if (selid == '') {
ShowMsg("您没选中任何信息");
return false;
}
if (window.confirm("您确定要删除这些消息吗")) {
location = "pm.php?dopost=del&ids=" + selid + "&folder=" + myfolder;
}
DedeConfirm("您确定要删除这些消息吗?").then((v)=>{
$.get("pm.php?dopost=remove&ids=" + selid + "&folder=" + myfolder,function (data) {
let result = JSON.parse(data);
if (result.code === 200) {
location.reload();
}
})
}).catch((e)=>{
console.log(e)
});
}
</script>
</head>


Loading…
Cancel
Save