From 00639fe8cc014ccebfd1bae585526f8745bf9a38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=99=E8=BF=B0=E3=80=81=E5=88=AB=E7=A6=BB?= <2449271624@qq.com> Date: Fri, 8 Sep 2023 18:13:44 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/admin/js/album.js | 85 +++++------ src/admin/js/global.js | 63 +++++--- src/admin/js/main.js | 216 +++++++++++++++++----------- src/admin/templets/catalog_main.htm | 21 --- src/admin/templets/index.htm | 12 +- src/static/web/css/admin.css | 3 - src/static/web/js/user.album.js | 68 +++++---- 7 files changed, 240 insertions(+), 228 deletions(-) diff --git a/src/admin/js/album.js b/src/admin/js/album.js index a483dd0b..0d54b2d5 100644 --- a/src/admin/js/album.js +++ b/src/admin/js/album.js @@ -39,55 +39,38 @@ function delAlbPicOld(picfile, pid) { $Obj('galleryedit').removeChild(tgobj); }); } -(function() { - var nForm = null; - var nFrame = null; - var picnameObj = null; - var vImg = null; - function GetWinPos(w, h) { - var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX; - var dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY; - var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; - var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; - var systemZoom = width / window.screen.availWidth; - var left = (width - w) / 2 / systemZoom + dualScreenLeft; - var top = (height - h) / 2 / systemZoom + dualScreenTop; - return { left: left, top: top }; +function seePicNewAlb(f, imgdid, frname, hpos, acname) { + var newobj = null; + if (f.value == '') return; + vImg = $Obj(imgdid); + picnameObj = document.getElementById('picname'); + nFrame = $Nav() == 'IE' ? eval('document.frames.' + frname) : $Obj(frname); + nForm = f.form; + //修改form的action等参数 + if (nForm.detachEvent) nForm.detachEvent("onsubmit", checkSubmitAlb); + else nForm.removeEventListener("submit", checkSubmitAlb, false); + nForm.action = 'archives_do.php'; + nForm.target = frname; + nForm.dopost.value = 'uploadLitpic'; + nForm.submit(); + picnameObj.value = ''; + newobj = $Obj('uploadwait'); + if (!newobj) { + newobj = document.createElement("div"); + newobj.id = 'uploadwait'; + newobj.style.position = 'absolute'; + newobj.className = 'uploadwait'; + newobj.style.width = 120; + newobj.style.height = 20; + newobj.style.top = hpos; + newobj.style.left = 100; + document.body.appendChild(newobj); + newobj.innerHTML = ''; } - function SeePicNew(f, imgdid, frname, hpos, acname) { - var newobj = null; - if (f.value == '') return; - vImg = $Obj(imgdid); - picnameObj = document.getElementById('picname'); - nFrame = $Nav() == 'IE' ? eval('document.frames.' + frname) : $Obj(frname); - nForm = f.form; - //修改form的action等参数 - if (nForm.detachEvent) nForm.detachEvent("onsubmit", checkSubmit); - else nForm.removeEventListener("submit", checkSubmit, false); - nForm.action = 'archives_do.php'; - nForm.target = frname; - nForm.dopost.value = 'uploadLitpic'; - nForm.submit(); - picnameObj.value = ''; - newobj = $Obj('uploadwait'); - if (!newobj) { - newobj = document.createElement("div"); - newobj.id = 'uploadwait'; - newobj.style.position = 'absolute'; - newobj.className = 'uploadwait'; - newobj.style.width = 120; - newobj.style.height = 20; - newobj.style.top = hpos; - newobj.style.left = 100; - newobj.style.display = 'block'; - document.body.appendChild(newobj); - newobj.innerHTML = ''; - } - newobj.style.display = 'block'; - //提交后还原form的action等参数 - nForm.action = acname; - nForm.dopost.value = 'save'; - nForm.target = ''; - nForm.litpic.disabled = true; - } -}); \ No newline at end of file + newobj.style.display = 'block'; + //提交后还原form的action等参数 + nForm.action = acname; + nForm.dopost.value = 'save'; + nForm.target = ''; + nForm.litpic.disabled = true; +} \ No newline at end of file diff --git a/src/admin/js/global.js b/src/admin/js/global.js index 6a25726c..b58e7557 100644 --- a/src/admin/js/global.js +++ b/src/admin/js/global.js @@ -1,25 +1,42 @@ -(function() { - var BROWSER = {}; - var USERAGENT = navigator.userAgent.toLowerCase(); - browserVersion({'firefox':'','chrome':'','opera':'','safari':'','maxthon':'','mozilla':'','webkit':''}); - if (BROWSER.safari) { - BROWSER.firefox = true; - } - BROWSER.opera = BROWSER.opera ? opera.version() : 0; - function browserVersion(types) { - var other = 1; - for (i in types) { - var v = types[i] ? types[i] : i; - if (USERAGENT.indexOf(v) != -1) { - var re = new RegExp(v + '(\\/|\\s)([\\d\\.]+)', 'ig'); - var matches = re.exec(USERAGENT); - var ver = matches != null ? matches[2] : 0; - other = ver !== 0 ? 0 : other; - } else { - var ver = 0; - } - eval('BROWSER.' + i + '= ver'); +var BROWSER = {}; +var USERAGENT = navigator.userAgent.toLowerCase(); +browserVersion({'firefox':'','chrome':'','opera':'','safari':'','maxthon':'','mozilla':'','webkit':''}); +if (BROWSER.safari) { + BROWSER.firefox = true; +} +BROWSER.opera = BROWSER.opera ? opera.version() : 0; +function browserVersion(types) { + var other = 1; + for (i in types) { + var v = types[i] ? types[i] : i; + if (USERAGENT.indexOf(v) != -1) { + var re = new RegExp(v + '(\\/|\\s)([\\d\\.]+)', 'ig'); + var matches = re.exec(USERAGENT); + var ver = matches != null ? matches[2] : 0; + other = ver !== 0 ? 0 : other; + } else { + var ver = 0; } - BROWSER.other = other; + eval('BROWSER.' + i + '= ver'); + } + BROWSER.other = other; +} +function LoadSuns(ctid, tid) { + if ($DE(ctid).innerHTML.length < 10) { + $DE('img' + tid).className = 'fa fa-minus-square'; + fetch('catalog_do.php?dopost=GetSunLists&cid=' + tid).then(resp => resp.text()).then((d) => { + $DE(ctid).innerHTML = d; + }); + } else { + showHide(ctid, tid); + } +} +function showHide(objname, tid) { + if ($DE(objname).style.display == "none") { + $DE('img' + tid).className = 'fa fa-minus-square'; + $DE(objname).style.display = BROWSER.firefox ? "" : "block"; + } else { + $DE('img' + tid).className = 'fa fa-plus-square'; + $DE(objname).style.display = "none"; } -}); \ No newline at end of file +} \ No newline at end of file diff --git a/src/admin/js/main.js b/src/admin/js/main.js index f059aab1..f5fc9e49 100644 --- a/src/admin/js/main.js +++ b/src/admin/js/main.js @@ -1,3 +1,53 @@ +var nForm = null; +var nFrame = null; +var picnameObj = null; +var vImg = null; +function GetWinPos(w, h) { + var dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX; + var dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY; + var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width; + var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height; + var systemZoom = width / window.screen.availWidth; + var left = (width - w) / 2 / systemZoom + dualScreenLeft; + var top = (height - h) / 2 / systemZoom + dualScreenTop; + return { left: left, top: top }; +} +function SeePicNew(f, imgdid, frname, hpos, acname) { + var newobj = null; + if (f.value == '') return; + vImg = $Obj(imgdid); + picnameObj = document.getElementById('picname'); + nFrame = $Nav() == 'IE' ? eval('document.frames.' + frname) : $Obj(frname); + nForm = f.form; + //修改form的action等参数 + if (nForm.detachEvent) nForm.detachEvent("onsubmit", checkSubmit); + else nForm.removeEventListener("submit", checkSubmit, false); + nForm.action = 'archives_do.php'; + nForm.target = frname; + nForm.dopost.value = 'uploadLitpic'; + nForm.submit(); + picnameObj.value = ''; + newobj = $Obj('uploadwait'); + if (!newobj) { + newobj = document.createElement("div"); + newobj.id = 'uploadwait'; + newobj.style.position = 'absolute'; + newobj.className = 'uploadwait'; + newobj.style.width = 120; + newobj.style.height = 20; + newobj.style.top = hpos; + newobj.style.left = 100; + newobj.style.display = 'block'; + document.body.appendChild(newobj); + newobj.innerHTML = ''; + } + newobj.style.display = 'block'; + //提交后还原form的action等参数 + nForm.action = acname; + nForm.dopost.value = 'save'; + nForm.target = ''; + nForm.litpic.disabled = true; +} function SelectMedia(fname) { var pos = GetWinPos(800,600); window.open("./dialog/select_media.php?f=" + fname + "&noeditor=yes", "popUpFlashWin", "scrollbars=yes,resizable=yes,statebar=no,width=800,height=600,left=" + pos.left + ", top=" + pos.top); @@ -200,7 +250,6 @@ function LoadQuickDiv(e, surl, oname, w, h) { fetch(surl).then(resp => resp.text()).then((d) => { newobj.innerHTML = d; }); - } function ShowCatMap(e, obj, cid, targetId, oldvalue) { LoadQuickDiv(e, 'archives_do.php?dopost=getCatMap&targetid=' + targetId + '&channelid=' + cid + '&oldvalue=' + oldvalue + '&rnd=' + Math.random(), 'getCatMap', '700px', '500px'); @@ -330,91 +379,105 @@ function CloseModal(modalID) { }) } //获取缩略图 -$(function() { - var litpicImgSrc = ""; - var litpicImg = ""; - var currentCID = 0; - var mdlCropperID = ""; - var pubAt = 0; - var optCropper = { - preview: ".pv", - crop: function(e) { - $("#cropWidth").text(Math.round(e.detail.height)); - $("#cropHeight").text(Math.round(e.detail.width)); - if ($(this).cropper("getCroppedCanvas")) { - var dataUrl = $(this).cropper("getCroppedCanvas").toDataURL(); - litpicImg = dataUrl; - $("#litPic").attr("src", litpicImg); - } - }, - aspectRatio: 4 / 3, - //拖动截取缩略图后,截取的缩略图更新到imageItems中 - cropend: function(data) { - //这里的id要单独取出来 +var litpicImgSrc = ""; +var litpicImg = ""; +var mdlCropperID = ""; +var optCropper = { + preview: ".pv", + crop: function(e) { + $("#cropWidth").text(Math.round(e.detail.height)); + $("#cropHeight").text(Math.round(e.detail.width)); + if ($(this).cropper("getCroppedCanvas")) { var dataUrl = $(this).cropper("getCroppedCanvas").toDataURL(); litpicImg = dataUrl; - $("#litPic").attr("src", litpicImg); - $("#litpic_b64").val(litpicImg); + $("#litPic").attr("src", litpicImg); } - } - var cropperAspectRatio = { - 0: 16 / 9, - 1: 4 / 3, - 2: 1 / 1, - 3: 2 / 3, - 4: NaN, - } - function setAspectRatio(ar) { - var opts = optCropper; - opts.aspectRatio = cropperAspectRatio[ar]; - $("#cropImg" + mdlCropperID).cropper('destroy').cropper(opts); - } - function okImage(modalID) { - uploadImage(litpicImg); + }, + aspectRatio: 4 / 3, + cropend: function(data) { + var dataUrl = $(this).cropper("getCroppedCanvas").toDataURL(); + litpicImg = dataUrl; $("#litPic").attr("src", litpicImg); - CloseModal('GKModal' + modalID); - } - function useDefault(modalID) { - uploadImage(litpicImgSrc); - $("#litPic").attr("src", litpicImgSrc); - CloseModal('GKModal' + modalID); - } - function uploadImage(litpicImgSrc) { - const formData = new FormData() - formData.append('litpic_b64', litpicImgSrc); - fetch('archives_do.php?dopost=upload_base64_image', { - method: 'POST', - body: formData - }) - .then(r => { - if (r.ok) { - return r.json() - } - throw new Error(errMsg); - }) - .then(d => { - if (d.code == 200) { - $("#picname").val(d.data.image_url); - } - }).catch((error) => { - alert("上传缩略图错误"); - }); + $("#litpic_b64").val(litpicImg); } +} +var cropperAspectRatio = { + 0: 16 / 9, + 1: 4 / 3, + 2: 1 / 1, + 3: 2 / 3, + 4: NaN, +} +function setAspectRatio(ar) { + var opts = optCropper; + opts.aspectRatio = cropperAspectRatio[ar]; + $("#cropImg" + mdlCropperID).cropper('destroy').cropper(opts); +} +function okImage(modalID) { + uploadImage(litpicImg); + $("#litPic").attr("src", litpicImg); + CloseModal('GKModal' + modalID); +} +function useDefault(modalID) { + uploadImage(litpicImgSrc); + $("#litPic").attr("src", litpicImgSrc); + CloseModal('GKModal' + modalID); +} +function uploadImage(litpicImgSrc) { + const formData = new FormData() + formData.append('litpic_b64', litpicImgSrc); + fetch('archives_do.php?dopost=upload_base64_image', { + method: 'POST', + body: formData + }) + .then(r => { + if (r.ok) { + return r.json() + } + throw new Error(errMsg); + }) + .then(d => { + if (d.code == 200) { + $("#picname").val(d.data.image_url); + } + }).catch((error) => { + alert("上传缩略图错误"); + }); +} +function SetThumb(srcURL) { + var footer = "

使用原图确定

"; + var optButton = `

`; + mdlCropperID = ShowMsg('

宽度:px,高度:px

' + optButton + '
', { + footer: footer, + noClose: false, + title: '图片裁剪', + }); + setTimeout(function() { + $("#cropImg" + mdlCropperID).cropper(optCropper); + }, 500); +} +$(document).ready(function() { + $("#togglemenu").click(function() { + if ($("body").attr("class") == "showmenu") { + $("body").attr("class", "hidemenu"); + $(this).html(''); + } else { + $("body").attr("class", "showmenu"); + $(this).html(''); + } + }); $("#btnClearAll").click(function(event) { litpicImgSrc = ""; litpicImg = ""; $("#picname").val(litpicImg); $("#litPic").attr("src", "/static/web/img/thumbnail.jpg"); }) - //添加图片 $("#iptAddImages").change(function(event) { var files = event.target.files; for (var i = 0, f; f = files[i]; i++) { - //如果不是图片忽略 if (!f.type.match('image.*')) { continue; } - //将图片渲染到浏览器 var reader = new FileReader(); reader.onload = (function(theFile) { return function(e) { @@ -431,21 +494,6 @@ $(function() { } $("#iptAddImages").val(""); }); - //截取缩略图 - function SetThumb(srcURL) { - var footer = "

使用原图确定

"; - var optButton = `

`; - mdlCropperID = ShowMsg('

宽度:px,高度:px

' + optButton + '
', { - footer: footer, - noClose: false, - title: '图片裁剪', - }); - setTimeout(function() { - $("#cropImg" + mdlCropperID).cropper(optCropper); - }, 500); - } -}); -$(document).ready(function() { if ($.fn.daterangepicker) { $('.datepicker').daterangepicker({ "singleDatePicker": true, diff --git a/src/admin/templets/catalog_main.htm b/src/admin/templets/catalog_main.htm index 2ea125e0..84d68e4a 100644 --- a/src/admin/templets/catalog_main.htm +++ b/src/admin/templets/catalog_main.htm @@ -47,26 +47,5 @@ - \ No newline at end of file diff --git a/src/admin/templets/index.htm b/src/admin/templets/index.htm index 499a733a..87e0aa8a 100644 --- a/src/admin/templets/index.htm +++ b/src/admin/templets/index.htm @@ -10,6 +10,7 @@ + @@ -62,16 +63,5 @@
- \ No newline at end of file diff --git a/src/static/web/css/admin.css b/src/static/web/css/admin.css index 947fb77a..f4b19e40 100644 --- a/src/static/web/css/admin.css +++ b/src/static/web/css/admin.css @@ -343,9 +343,6 @@ body.hidemenu .body-right { padding:10px; background:#f5f5f5 } -#fz-0 { - font-size:0 -} #_fileList,#_verList { height:360px; overflow-y:auto diff --git a/src/static/web/js/user.album.js b/src/static/web/js/user.album.js index cb2227b4..376ab94c 100644 --- a/src/static/web/js/user.album.js +++ b/src/static/web/js/user.album.js @@ -1,31 +1,38 @@ -(function() { - var startNum = 1; - function MakeUpload(mnum) { - var endNum = 0; - var upfield = document.getElementById("uploadfield"); - var pnumObj = document.getElementById("picnum"); - var fhtml = ""; - var dsel = " checked='checked' "; - var dplay = "display:none"; - if (mnum==0) endNum = startNum + Number(pnumObj.value); - else endNum = mnum; - if (endNum>120) endNum = 120; - for (startNum;startNum < endNum;startNum++) - { - if (startNum==1) { - dsel = " checked='checked' "; - dplay = "block"; - } else { - dsel = " "; - dplay = "display:none"; - } - fhtml = ""; - fhtml += "
"; - fhtml += "
选择
"; - upfield.innerHTML += fhtml; +var startNum = 1; +function MakeUpload(mnum) { + var endNum = 0; + var upfield = document.getElementById("uploadfield"); + var pnumObj = document.getElementById("picnum"); + var fhtml = ""; + var dsel = " checked='checked' "; + var dplay = "display:none"; + if (mnum==0) endNum = startNum + Number(pnumObj.value); + else endNum = mnum; + if (endNum>120) endNum = 120; + for (startNum;startNum < endNum;startNum++) + { + if (startNum==1) { + dsel = " checked='checked' "; + dplay = "block"; + } else { + dsel = " "; + dplay = "display:none"; } + fhtml = ""; + fhtml += "
"; + fhtml += "
选择
"; + upfield.innerHTML += fhtml; } -}); +} +function checkMuList(psid, cmid) { + if (document.getElementById('pagestyle3').checked) { + document.getElementById('spagelist').style.display = 'none'; + } else if (document.getElementById('pagestyle1').checked) { + document.getElementById('spagelist').style.display = 'block'; + } else { + document.getElementById('spagelist').style.display = 'none'; + } +} function CheckSelTable(nnum) { var cbox = document.getElementById('isokcheck'+nnum); var seltb = document.getElementById('seltb'+nnum); @@ -42,13 +49,4 @@ function checkSubmit() { alert("请您选择文档所属栏目"); return false; } -} -function checkMuList(psid, cmid) { - if (document.getElementById('pagestyle3').checked) { - document.getElementById('spagelist').style.display = 'none'; - } else if (document.getElementById('pagestyle1').checked) { - document.getElementById('spagelist').style.display = 'block'; - } else { - document.getElementById('spagelist').style.display = 'none'; - } } \ No newline at end of file