diff --git a/js/coin.js b/js/coin.js
deleted file mode 100644
index f262924..0000000
--- a/js/coin.js
+++ /dev/null
@@ -1,333 +0,0 @@
-// 封装的加载东币系统函数
-function loadCoinSystem() {
- // 获取当前时间并转换为北京时间
- function getCurrentTime() {
- const now = new Date();
- const beijingTime = new Date(now.getTime() + 8 * 60 * 60 * 1000); // 直接加8小时
- return beijingTime.toISOString().replace('T', ' ').substring(0, 19); // 格式化时间
- }
-
- // 初始化东币系统
- async function initializeCoinSystem() {
- try {
- // 检查 verify.json 文件是否存在且为 true
- const verifyUrl = `https://download.xn--xhq44jb2fzpc.com/user/${curemail}/coin/verify.json`;
- const response = await fetchNoCache(verifyUrl);
- const verifyResponse = await response.json(); // 正确地处理响应体中的 JSON 数据
-
- console.log("Verify Response: ", verifyResponse);
-
- if (verifyResponse === true) {
- // 读取 list.json 文件
- const listUrl = `https://download.xn--xhq44jb2fzpc.com/user/${curemail}/coin/list.json`;
- const coinDataResponse = await fetchNoCache(listUrl);
- const coinData = await coinDataResponse.json(); // 处理 coinData JSON 数据
- renderCoinContent(coinData);
- } else {
- throw new Error('Verification required');
- }
- } catch (error) {
- console.error("Error in initializeCoinSystem: ", error);
- renderVerificationPrompt();
- }
- }
-
-
-
-// 渲染东币内容并分页显示
-function renderCoinContent(coinData) {
- const coinContent = document.getElementById('coin-content');
- const itemsPerPage = 10; // 每页显示的记录数
- let currentPage = 1; // 当前页码
-
- // 初始化内容
- coinContent.innerHTML = `
-
当前东币数:${coinData.coins}
- 下载某些资源时会花费东币,而投稿审核通过后可以获得东币。
- 请注意:由于下载同一份文件两次,从服务器流出的下行流量也会计算两次,因此当您多次下载同一个需要东币的资源时,东币也会多次扣除。我们建议您减少不必要的重复下载。
- 每页显示10条东币记录,最近的记录将显示在最后。
- `;
-
- // 渲染表格数据
- function renderTable(page) {
- const start = (page - 1) * itemsPerPage;
- const end = start + itemsPerPage;
- const transactions = coinData.transactions.slice(start, end);
-
- let table = coinContent.querySelector('table');
-
- // 如果表格不存在,创建一个新的表格
- if (!table) {
- table = document.createElement('table');
- const headerRow = table.insertRow();
- headerRow.innerHTML = `时间 | 明细 | 操作 | `;
- coinContent.appendChild(table);
- } else {
- // 如果表格存在,清空之前的内容(除标题外)
- table.innerHTML = table.rows[0].innerHTML; // 保留标题行
- }
-
- transactions.forEach(transaction => {
- const row = table.insertRow();
- row.innerHTML = `
- ${transaction.date} |
- ${transaction.type === 'credit' ? '+' : '-'}${transaction.amount} |
- ${transaction.description} |
- `;
- });
- }
-
- // 渲染页码
- function renderPagination() {
- const totalPages = Math.ceil(coinData.transactions.length / itemsPerPage);
- const pagination = document.createElement('div');
- pagination.className = 'pagination';
-
- // 页码前添加“页码:”
- const pageLabel = document.createElement('span');
- // pageLabel.textContent = '每页显示10条记录。';
- // pageLabel.style.marginRight = '10px';
- pagination.appendChild(pageLabel);
-
- for (let i = 1; i <= totalPages; i++) {
- const pageLink = document.createElement('button');
- pageLink.textContent = i;
- pageLink.className = 'page-link';
- pageLink.style.margin = '0 5px';
- pageLink.style.fontWeight = (i === currentPage) ? 'bold' : 'normal'; // 当前页码加粗
- pageLink.disabled = (i === currentPage);
- pageLink.addEventListener('click', () => {
- currentPage = i;
- renderTable(currentPage);
- renderPagination();
- });
- pagination.appendChild(pageLink);
- }
-
- // 清空并添加新的分页控件
- const existingPagination = coinContent.querySelector('.pagination');
- if (existingPagination) {
- coinContent.removeChild(existingPagination);
- }
- coinContent.appendChild(pagination);
- }
-
- // 初始渲染
- renderTable(currentPage);
- renderPagination();
-}
-
-
-
-
-// 渲染验证提示
-function renderVerificationPrompt() {
- const coinContent = document.getElementById('coin-content');
- coinContent.innerHTML = `
- 您需要进行手机验证以解锁东币系统。下载某些资源时会花费东币,而投稿审核通过后可以获得东币。
- 请注意:由于下载同一份文件两次,从服务器流出的下行流量也会计算两次,因此当您多次下载同一个需要东币的资源时,东币也会多次扣除。我们建议您减少不必要的重复下载。
-
- `;
-
- // 按钮样式定义
- const firstVerifyBtn = document.getElementById('first-verify-btn');
- firstVerifyBtn.style.display = 'block';
- firstVerifyBtn.style.margin = '0 auto';
- firstVerifyBtn.style.padding = '10px 20px';
- firstVerifyBtn.style.backgroundColor = '#007BFF';
- firstVerifyBtn.style.color = '#fff';
- firstVerifyBtn.style.border = 'none';
- firstVerifyBtn.style.borderRadius = '4px';
- firstVerifyBtn.style.cursor = 'pointer';
- firstVerifyBtn.style.textAlign = 'center';
-
- // 判断是否为夜间模式
- const isDarkMode = document.body.classList.contains('dark');
- if (isDarkMode) {
- firstVerifyBtn.style.backgroundColor = '#444';
- firstVerifyBtn.style.color = '#fff';
- }
-
- firstVerifyBtn.onmouseover = function () {
- if (isDarkMode) {
- firstVerifyBtn.style.backgroundColor = '#555';
- } else {
- firstVerifyBtn.style.backgroundColor = '#0056b3';
- }
- };
-
- firstVerifyBtn.onmouseout = function () {
- if (isDarkMode) {
- firstVerifyBtn.style.backgroundColor = '#444';
- } else {
- firstVerifyBtn.style.backgroundColor = '#007BFF';
- }
- };
-
- firstVerifyBtn.onmousedown = function () {
- if (isDarkMode) {
- firstVerifyBtn.style.backgroundColor = '#333';
- } else {
- firstVerifyBtn.style.backgroundColor = '#003f7f';
- }
- };
-
- // 点击验证按钮,弹出模态框
- firstVerifyBtn.addEventListener('click', showVerificationModal);
-}
-
-
- // 显示验证模态框
- function showVerificationModal() {
- const modal = document.getElementById('verification-modal');
- modal.style.display = 'block';
-
- const sendCodeBtn = document.getElementById('send-code-btn');
- const verifyBtn = document.getElementById('verify-btn');
- const phoneNumberInput = document.getElementById('phone-number');
- const verificationCodeInput = document.getElementById('verification-code');
- const modalMessage = document.getElementById('modal-message');
-
- // 发送验证码事件
- sendCodeBtn.addEventListener('click', async () => {
- const phoneNumber = phoneNumberInput.value.trim();
- if (!/^\d{11}$/.test(phoneNumber) || phoneNumber.charAt(0) !== '1') {
- modalMessage.innerText = '请输入有效的11位手机号码!';
- return;
- }
-
- try {
- // 检查手机号是否已验证
- const phoneHash = CryptoJS.SHA256(phoneNumber).toString();
- const phonesResponse = await fetchNoCache('https://download.xn--xhq44jb2fzpc.com/user/pn.json');
- const phonesData = await phonesResponse.json();
-
- if (phonesData.includes(phoneHash)) {
- modalMessage.innerText = '此手机号已被验证过!';
- sendCodeBtn.disabled = false;
- sendCodeBtn.textContent = '发送验证码';
- return;
- }
-
- // 禁用发送按钮并修改按钮文本
- sendCodeBtn.disabled = true;
- sendCodeBtn.textContent = '禁用中...';
- setTimeout(() => {
- sendCodeBtn.disabled = false;
- sendCodeBtn.textContent = '发送验证码';
- }, 120000); // 2分钟后重新启用发送按钮并恢复原始文本
-
- const response = await fetch('https://sms.xn--xhq44jb2fzpc.com/send-code', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ phoneNumber })
- });
- const result = await response.json();
- if (response.ok) {
- modalMessage.innerText = '验证码已发送。若未收到,2分钟后可重新发送。';
- sessionStorage.setItem('phoneNumber', phoneNumber); // 保存手机号
- } else {
- modalMessage.innerText = `发送失败!请稍后再试。`;
- sendCodeBtn.disabled = false; // 如果发送失败,立即恢复按钮可用状态
- sendCodeBtn.textContent = '发送验证码'; // 恢复原始按钮文本
- }
- } catch (error) {
- modalMessage.innerText = '发送验证码时出错,请稍后重试。';
- sendCodeBtn.disabled = false; // 如果发送失败,立即恢复按钮可用状态
- sendCodeBtn.textContent = '发送验证码'; // 恢复原始按钮文本
- }
- });
-
-
- // 验证验证码事件
- verifyBtn.addEventListener('click', async () => {
- const phoneNumber = sessionStorage.getItem('phoneNumber'); // 从 sessionStorage 中获取手机号
- const verificationCode = verificationCodeInput.value.trim();
-
- // 每次开始验证前清空消息文本
- modalMessage.innerText = '';
-
- if (!verificationCode || !phoneNumber) {
- modalMessage.innerText = '请输入手机号和验证码。';
- return;
- }
-
- try {
- const response = await fetch('https://sms.xn--xhq44jb2fzpc.com/verify-code', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ phoneNumber, verificationCode })
- });
- const result = await response.json();
-
- // 检查响应状态和验证结果
- if (response.ok && result.verified) {
- modalMessage.innerText = '验证通过,请稍后……';
-
- // 确保在正确验证后,不再处理错误消息
- verifyBtn.disabled = true; // 禁用按钮,防止多次点击
- verificationCodeInput.disabled = true; // 禁用输入框,防止再次输入
-
- const phoneHash = CryptoJS.SHA256(phoneNumber).toString();
- const phonesResponse = await fetchNoCache('https://download.xn--xhq44jb2fzpc.com/user/pn.json');
- const phonesData = await phonesResponse.json();
- phonesData.push(phoneHash);
-
- // 写入加密后的手机号到 pn.json
- await client.put('user/pn.json', new Blob([JSON.stringify(phonesData)], { type: 'application/json' }));
-
- // 写入未加密的手机号到用户特定的 pn.json
- await client.put(`user/${curemail}/pn.json`, new Blob([JSON.stringify({ phoneNumber })], { type: 'application/json' }));
-
- setTimeout(async () => {
- modal.style.display = 'none';
-
- // 初始化金币系统
- const initialData = {
- userEmail: curemail,
- coins: 50,
- transactions: [
- {
- type: 'credit',
- amount: 50,
- description: '初始东币奖励',
- date: getCurrentTime()
- }
- ]
- };
- const userInfoBlob = new Blob([JSON.stringify(true)], { type: 'application/json' });
- await client.put(`user/${curemail}/coin/verify.json`, userInfoBlob);
-
- const coinBlob = new Blob([JSON.stringify(initialData)], { type: 'application/json' });
- await client.put(`user/${curemail}/coin/list.json`, coinBlob);
-
- // 重新读取并渲染金币信息
- renderCoinContent(initialData);
- }, 2000);
- } else {
- modalMessage.innerText = '验证码错误,请重新输入。';
- }
- } catch (error) {
- modalMessage.innerText = '验证时出错,请稍后重试。';
- }
- });
-
-
-
-
- }
-
-
-
- document.getElementById('cancel-btn').addEventListener('click', function() {
- // 获取模态框元素
- const modal = document.getElementById('verification-modal');
-
- // 隐藏模态框
- modal.style.display = 'none';
- });
-
- // 初始化系统
- initializeCoinSystem();
-}
-
diff --git a/js/coin.min.js b/js/coin.min.js
deleted file mode 100644
index e2da28e..0000000
--- a/js/coin.min.js
+++ /dev/null
@@ -1,14 +0,0 @@
-function loadCoinSystem(){function d(r){let a=document.getElementById("coin-content"),s=1;function c(e){e=10*(e-1),e=r.transactions.slice(e,10+e);let t=a.querySelector("table");t?t.innerHTML=t.rows[0].innerHTML:((t=document.createElement("table")).insertRow().innerHTML="时间 | 明细 | 操作 | ",a.appendChild(t)),e.forEach(e=>{t.insertRow().innerHTML=`
- ${e.date} |
- ${"credit"===e.type?"+":"-"}${e.amount} |
- ${e.description} |
- `})}a.innerHTML=`
- 当前东币数:${r.coins}
- 下载某些资源时会花费东币,而投稿审核通过后可以获得东币。
- 请注意:由于下载同一份文件两次,从服务器流出的下行流量也会计算两次,因此当您多次下载同一个需要东币的资源时,东币也会多次扣除。我们建议您减少不必要的重复下载。
- 每页显示10条东币记录,最近的记录将显示在最后。
- `,c(s),function t(){var n=Math.ceil(r.transactions.length/10),o=document.createElement("div"),e=(o.className="pagination",document.createElement("span"));o.appendChild(e);for(let e=1;e<=n;e++){var i=document.createElement("button");i.textContent=e,i.className="page-link",i.style.margin="0 5px",i.style.fontWeight=e===s?"bold":"normal",i.disabled=e===s,i.addEventListener("click",()=>{c(s=e),t()}),o.appendChild(i)}e=a.querySelector(".pagination");e&&a.removeChild(e),a.appendChild(o)}()}function o(){let a=document.getElementById("verification-modal"),o=(a.style.display="block",document.getElementById("send-code-btn")),s=document.getElementById("verify-btn"),i=document.getElementById("phone-number"),c=document.getElementById("verification-code"),l=document.getElementById("modal-message");o.addEventListener("click",async()=>{var e=i.value.trim();if(/^\d{11}$/.test(e)&&"1"===e.charAt(0))try{var t,n=CryptoJS.SHA256(e).toString();(await(await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/user/pn.json")).json()).includes(n)?(l.innerText="此手机号已被验证过!",o.disabled=!1,o.textContent="发送验证码"):(o.disabled=!0,o.textContent="禁用中...",setTimeout(()=>{o.disabled=!1,o.textContent="发送验证码"},12e4),await(t=await fetch("https://sms.xn--xhq44jb2fzpc.com/send-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phoneNumber:e})})).json(),t.ok?(l.innerText="验证码已发送。若未收到,2分钟后可重新发送。",sessionStorage.setItem("phoneNumber",e)):(l.innerText="发送失败!请稍后再试。",o.disabled=!1,o.textContent="发送验证码"))}catch(e){l.innerText="发送验证码时出错,请稍后重试。",o.disabled=!1,o.textContent="发送验证码"}else l.innerText="请输入有效的11位手机号码!"}),s.addEventListener("click",async()=>{var e=sessionStorage.getItem("phoneNumber"),t=c.value.trim();if(l.innerText="",t&&e)try{var n,o,i=await fetch("https://sms.xn--xhq44jb2fzpc.com/verify-code",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({phoneNumber:e,verificationCode:t})}),r=await i.json();i.ok&&r.verified?(l.innerText="验证通过,请稍后……",s.disabled=!0,c.disabled=!0,n=CryptoJS.SHA256(e).toString(),(o=await(await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/user/pn.json")).json()).push(n),await client.put("user/pn.json",new Blob([JSON.stringify(o)],{type:"application/json"})),await client.put(`user/${curemail}/pn.json`,new Blob([JSON.stringify({phoneNumber:e})],{type:"application/json"})),setTimeout(async()=>{a.style.display="none";var e={userEmail:curemail,coins:50,transactions:[{type:"credit",amount:50,description:"初始东币奖励",date:(e=new Date,new Date(e.getTime()+288e5).toISOString().replace("T"," ").substring(0,19))}]},t=new Blob([JSON.stringify(!0)],{type:"application/json"}),t=(await client.put(`user/${curemail}/coin/verify.json`,t),new Blob([JSON.stringify(e)],{type:"application/json"}));await client.put(`user/${curemail}/coin/list.json`,t),d(e)},2e3)):l.innerText="验证码错误,请重新输入。"}catch(e){l.innerText="验证时出错,请稍后重试。"}else l.innerText="请输入手机号和验证码。"})}document.getElementById("cancel-btn").addEventListener("click",function(){document.getElementById("verification-modal").style.display="none"}),async function(){try{var e=`https://download.xn--xhq44jb2fzpc.com/user/${curemail}/coin/verify.json`,t=await(await fetchNoCache(e)).json();if(console.log("Verify Response: ",t),!0!==t)throw new Error("Verification required");var n=`https://download.xn--xhq44jb2fzpc.com/user/${curemail}/coin/list.json`;d(await(await fetchNoCache(n)).json())}catch(e){console.error("Error in initializeCoinSystem: ",e);{let e=document.getElementById("coin-content"),t=(e.innerHTML=`
- 您需要进行手机验证以解锁东币系统。下载某些资源时会花费东币,而投稿审核通过后可以获得东币。
- 请注意:由于下载同一份文件两次,从服务器流出的下行流量也会计算两次,因此当您多次下载同一个需要东币的资源时,东币也会多次扣除。我们建议您减少不必要的重复下载。
-
- `,document.getElementById("first-verify-btn")),n=(t.style.display="block",t.style.margin="0 auto",t.style.padding="10px 20px",t.style.backgroundColor="#007BFF",t.style.color="#fff",t.style.border="none",t.style.borderRadius="4px",t.style.cursor="pointer",t.style.textAlign="center",document.body.classList.contains("dark"));n&&(t.style.backgroundColor="#444",t.style.color="#fff");t.onmouseover=function(){n?t.style.backgroundColor="#555":t.style.backgroundColor="#0056b3"},t.onmouseout=function(){n?t.style.backgroundColor="#444":t.style.backgroundColor="#007BFF"},t.onmousedown=function(){n?t.style.backgroundColor="#333":t.style.backgroundColor="#003f7f"},t.addEventListener("click",o);return}}}()}
\ No newline at end of file
diff --git a/js/dl - 副本.js b/js/dl - 副本.js
deleted file mode 100644
index 7cf9b05..0000000
--- a/js/dl - 副本.js
+++ /dev/null
@@ -1,93 +0,0 @@
-let client;
-
-async function fetchNoCache(url) {
- const timestamp = new Date().getTime();
- const noCacheUrl = `${url}?timestamp=${timestamp}`;
- return fetch(noCacheUrl);
-}
-
-async function f1() {
- try {
- const r1 = await fetchNoCache('https://download.xn--xhq44jb2fzpc.com/download/json/s.json');
- const d1 = await r1.json();
-
- const m1 = d1.masterKey;
- const k1 = CryptoJS.SHA256(m1);
-
- const c1 = {
- region: d2(d1.encryptedRegion, k1),
- accessKeyId: d2(d1.encryptedKeyId, k1),
- accessKeySecret: d2(d1.encryptedKeySecret, k1),
- bucket: d2(d1.encryptedBucket, k1)
- };
-
- client = new OSS(c1);
- // console.log("OSS Client Initialized Successfully with decrypted config", client);
- } catch (e1) {
- console.error('Failed to fetch or decrypt OSS config:', e1);
- }
-}
-
-function d2(e2, k2) {
- e2 = e2.replace(/\s/g, '');
- const e3 = CryptoJS.enc.Base64.parse(e2);
- const iv = CryptoJS.lib.WordArray.create(e3.words.slice(0, 4));
- const e4 = CryptoJS.lib.WordArray.create(e3.words.slice(4));
-
- const d3 = CryptoJS.AES.decrypt({ ciphertext: e4 }, k2, {
- iv: iv,
- mode: CryptoJS.mode.CBC,
- padding: CryptoJS.pad.Pkcs7
- });
- return d3.toString(CryptoJS.enc.Utf8);
-}
-
-document.addEventListener('DOMContentLoaded', function() {
- const initializeDownloadLink = (linkId, popupId, key) => {
- const downloadLink = document.getElementById(linkId);
- const popup = document.getElementById(popupId);
- const popupContent = popup.querySelector('.popup-content');
-
- downloadLink.addEventListener('click', function() {
- let countdown = 3;
-
- f1().then(() => {
- if (client) {
- // 在这里生成签名URL
- let actualLink = client.signatureUrl(key, {
- expires: 20, // 过期时间为 20 秒
- response: {
- 'content-disposition': 'attachment' // 强制下载
- }
- });
-
- // 替换域名部分
- const sanitizedUrl = actualLink.replace('emberimg.oss-cn-beijing.aliyuncs.com', 'download.xn--xhq44jb2fzpc.com');
-
- const updatePopup = () => {
- if (countdown > 0) {
- popupContent.textContent = `${countdown}秒后将开始下载...`;
- countdown--;
- setTimeout(updatePopup, 1000);
- } else {
- popup.style.display = 'none';
- window.location.href = sanitizedUrl;
- }
- };
-
- popup.style.display = 'block';
- updatePopup();
-
- } else {
- console.error('Failed to initialize OSS client due to decryption error.');
- }
- }).catch(e2 => {
- console.log('Error initializing OSS Client:', e2);
- });
- });
- };
-
- window.initializeDownloadLink = initializeDownloadLink;
-});
-
-
diff --git a/js/dl.js b/js/dl.js
deleted file mode 100644
index 7cf9b05..0000000
--- a/js/dl.js
+++ /dev/null
@@ -1,93 +0,0 @@
-let client;
-
-async function fetchNoCache(url) {
- const timestamp = new Date().getTime();
- const noCacheUrl = `${url}?timestamp=${timestamp}`;
- return fetch(noCacheUrl);
-}
-
-async function f1() {
- try {
- const r1 = await fetchNoCache('https://download.xn--xhq44jb2fzpc.com/download/json/s.json');
- const d1 = await r1.json();
-
- const m1 = d1.masterKey;
- const k1 = CryptoJS.SHA256(m1);
-
- const c1 = {
- region: d2(d1.encryptedRegion, k1),
- accessKeyId: d2(d1.encryptedKeyId, k1),
- accessKeySecret: d2(d1.encryptedKeySecret, k1),
- bucket: d2(d1.encryptedBucket, k1)
- };
-
- client = new OSS(c1);
- // console.log("OSS Client Initialized Successfully with decrypted config", client);
- } catch (e1) {
- console.error('Failed to fetch or decrypt OSS config:', e1);
- }
-}
-
-function d2(e2, k2) {
- e2 = e2.replace(/\s/g, '');
- const e3 = CryptoJS.enc.Base64.parse(e2);
- const iv = CryptoJS.lib.WordArray.create(e3.words.slice(0, 4));
- const e4 = CryptoJS.lib.WordArray.create(e3.words.slice(4));
-
- const d3 = CryptoJS.AES.decrypt({ ciphertext: e4 }, k2, {
- iv: iv,
- mode: CryptoJS.mode.CBC,
- padding: CryptoJS.pad.Pkcs7
- });
- return d3.toString(CryptoJS.enc.Utf8);
-}
-
-document.addEventListener('DOMContentLoaded', function() {
- const initializeDownloadLink = (linkId, popupId, key) => {
- const downloadLink = document.getElementById(linkId);
- const popup = document.getElementById(popupId);
- const popupContent = popup.querySelector('.popup-content');
-
- downloadLink.addEventListener('click', function() {
- let countdown = 3;
-
- f1().then(() => {
- if (client) {
- // 在这里生成签名URL
- let actualLink = client.signatureUrl(key, {
- expires: 20, // 过期时间为 20 秒
- response: {
- 'content-disposition': 'attachment' // 强制下载
- }
- });
-
- // 替换域名部分
- const sanitizedUrl = actualLink.replace('emberimg.oss-cn-beijing.aliyuncs.com', 'download.xn--xhq44jb2fzpc.com');
-
- const updatePopup = () => {
- if (countdown > 0) {
- popupContent.textContent = `${countdown}秒后将开始下载...`;
- countdown--;
- setTimeout(updatePopup, 1000);
- } else {
- popup.style.display = 'none';
- window.location.href = sanitizedUrl;
- }
- };
-
- popup.style.display = 'block';
- updatePopup();
-
- } else {
- console.error('Failed to initialize OSS client due to decryption error.');
- }
- }).catch(e2 => {
- console.log('Error initializing OSS Client:', e2);
- });
- });
- };
-
- window.initializeDownloadLink = initializeDownloadLink;
-});
-
-
diff --git a/js/dl.min.js b/js/dl.min.js
deleted file mode 100644
index ff91d08..0000000
--- a/js/dl.min.js
+++ /dev/null
@@ -1 +0,0 @@
-let client;async function fetchNoCache(e){var t=(new Date).getTime();return fetch(e+"?timestamp="+t)}async function f1(){try{var e=await(await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/download/json/s.json")).json(),t=e.masterKey,n=CryptoJS.SHA256(t),o={region:d2(e.encryptedRegion,n),accessKeyId:d2(e.encryptedKeyId,n),accessKeySecret:d2(e.encryptedKeySecret,n),bucket:d2(e.encryptedBucket,n)};client=new OSS(o)}catch(e){console.error("Failed to fetch or decrypt OSS config:",e)}}function d2(e,t){e=e.replace(/\s/g,"");var e=CryptoJS.enc.Base64.parse(e),n=CryptoJS.lib.WordArray.create(e.words.slice(0,4)),e=CryptoJS.lib.WordArray.create(e.words.slice(4));return CryptoJS.AES.decrypt({ciphertext:e},t,{iv:n,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)}document.addEventListener("DOMContentLoaded",function(){window.initializeDownloadLink=(e,t,o)=>{e=document.getElementById(e);let c=document.getElementById(t),r=c.querySelector(".popup-content");e.addEventListener("click",function(){let n=3;f1().then(()=>{if(client){let e=client.signatureUrl(o,{expires:20,response:{"content-disposition":"attachment"}}).replace("emberimg.oss-cn-beijing.aliyuncs.com","download.xn--xhq44jb2fzpc.com"),t=()=>{0{console.log("Error initializing OSS Client:",e)})})}});
\ No newline at end of file
diff --git a/js/dlwithcoin.js b/js/dlwithcoin.js
deleted file mode 100644
index 3a449c1..0000000
--- a/js/dlwithcoin.js
+++ /dev/null
@@ -1,166 +0,0 @@
-
-let client;
-
-function getCookie(name) {
- const nameEQ = name + "=";
- const ca = document.cookie.split(';');
- for(let i = 0; i < ca.length; i++) {
- let c = ca[i];
- while (c.charAt(0) == ' ') c = c.substring(1,c.length);
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
- }
- return null;
-}
-
-async function fetchNoCache(url) {
- const timestamp = new Date().getTime();
- const noCacheUrl = `${url}?timestamp=${timestamp}`;
- return fetch(noCacheUrl);
-}
-
-async function f1() {
- try {
- const r1 = await fetchNoCache('https://download.xn--xhq44jb2fzpc.com/upload/json/s.json');
- const d1 = await r1.json();
-
- const m1 = d1.masterKey;
- const k1 = CryptoJS.SHA256(m1);
-
- const c1 = {
- region: d2(d1.encryptedRegion, k1),
- accessKeyId: d2(d1.encryptedKeyId, k1),
- accessKeySecret: d2(d1.encryptedKeySecret, k1),
- bucket: d2(d1.encryptedBucket, k1)
- };
-
- client = new OSS(c1);
- // console.log("OSS Client Initialized Successfully with decrypted config", client);
- } catch (e1) {
- console.error('Failed to fetch or decrypt OSS config:', e1);
- }
-}
-
-function d2(e2, k2) {
- e2 = e2.replace(/\s/g, '');
- const e3 = CryptoJS.enc.Base64.parse(e2);
- const iv = CryptoJS.lib.WordArray.create(e3.words.slice(0, 4));
- const e4 = CryptoJS.lib.WordArray.create(e3.words.slice(4));
-
- const d3 = CryptoJS.AES.decrypt({ ciphertext: e4 }, k2, {
- iv: iv,
- mode: CryptoJS.mode.CBC,
- padding: CryptoJS.pad.Pkcs7
- });
- return d3.toString(CryptoJS.enc.Utf8);
-}
-
-// 初始化client
-f1();
-
-document.addEventListener("DOMContentLoaded", function() {
- // const linkId = "{{ .Get "id" }}";
- // const objectKey = "{{ .Get "url" }}"; // 使用URL参数作为OSS对象的key
- // const popupId = "popup-" + linkId;
- // const requiredCoins = {{ .Get "coin" | default 0 }}; // 获取需要扣除的东币数,默认为0
- // const resourceTitle = "{{ .Get "title" }}"; // 获取资源标题
-
- const linkId = "aaa";
- const objectKey = "bbb"; // 使用URL参数作为OSS对象的key
- const popupId = "popup-" + linkId;
- const requiredCoins = 666; // 获取需要扣除的东币数,默认为0
- const resourceTitle = "ccc"
-
- const checkAndDownload = async () => {
- const loggedIn = getCookie('loggedIn');
- const email = getCookie('userEmail');
-
- if (!loggedIn) {
- alert("请登录后下载!");
- window.location.href = "/submission";
- return;
- }
-
- if (requiredCoins > 0) {
- const coinListUrl = `https://download.xn--xhq44jb2fzpc.com/user/${email}/coin/list.json`;
- try {
- const response = await fetchNoCache(coinListUrl);
- if (!response.ok) {
- alert("您还未激活东币系统,请前往激活!");
- window.location.href = "/submission";
- return;
- }
- const data = await response.json();
- if (data.coins < requiredCoins) {
- alert(`您的东币数量不够!当前资源要求东币数:${requiredCoins};您的东币数:${data.coins}。`);
- return;
- } else {
- if (confirm(`当前下载操作花费:${requiredCoins}东币;您的东币:${data.coins}。是否继续?`)) {
- data.coins -= requiredCoins;
- data.transactions.push({
- type: "debit",
- amount: requiredCoins,
- description: `下载资源:${resourceTitle}`, // 使用资源标题
- date: getCurrentTime()
- });
- const coinBlob = new Blob([JSON.stringify(data)], { type: 'application/json' });
- await client.put(`user/${email}/coin/list.json`, coinBlob);
-
- // 调用下载功能并进行倒计时
- startDownload(linkId, popupId, objectKey);
- }
- }
- } catch (error) {
- console.error("Error handling coins for download:", error);
- alert("无法处理您的请求,请稍后重试。");
- }
- } else {
- // 如果不需要东币,直接开始下载
- startDownload(linkId, popupId, objectKey);
- }
- };
-
- const startDownload = (linkId, popupId, key) => {
- let countdown = 3;
- const popup = document.getElementById(popupId);
- const popupContent = popup.querySelector('.popup-content');
-
- if (client) {
- let actualLink = client.signatureUrl(key, {
- expires: 20, // 过期时间为 20 秒
- response: {
- 'content-disposition': 'attachment' // 强制下载
- }
- });
-
- // 替换域名部分
- const sanitizedUrl = actualLink.replace('emberimg.oss-cn-beijing.aliyuncs.com', 'download.xn--xhq44jb2fzpc.com');
-
- const updatePopup = () => {
- if (countdown > 0) {
- popupContent.textContent = `${countdown}秒后将开始下载...`;
- countdown--;
- setTimeout(updatePopup, 1000);
- } else {
- popup.style.display = 'none';
- window.location.href = sanitizedUrl;
- }
- };
-
- popup.style.display = 'block';
- updatePopup();
-
- } else {
- console.error('OSS client is not initialized.');
- }
- };
-
- document.getElementById(linkId).addEventListener('click', checkAndDownload);
-});
-
-
-
-function getCurrentTime() {
- const now = new Date();
- const beijingTime = new Date(now.getTime() + 8 * 60 * 60 * 1000); // 直接加8小时
- return beijingTime.toISOString().replace('T', ' ').substring(0, 19); // 格式化时间
-}
\ No newline at end of file
diff --git a/js/dlwithcoin.min.js b/js/dlwithcoin.min.js
deleted file mode 100644
index 10557b4..0000000
--- a/js/dlwithcoin.min.js
+++ /dev/null
@@ -1 +0,0 @@
-let client;function getCookie(t){const n=t+"=";const o=document.cookie.split(";");for(let e=0;e{const t=getCookie("loggedIn");const e=getCookie("userEmail");if(!t){alert("请登录后下载!");window.location.href="/submission";return}if(l>0){const n=`https://download.xn--xhq44jb2fzpc.com/user/${e}/coin/list.json`;try{const o=await fetchNoCache(n);if(!o.ok){alert("您还未激活金币系统,请前往激活!");window.location.href="/submission";return}const c=await o.json();if(c.coins{let o=3;const c=document.getElementById(e);const s=c.querySelector(".popup-content");if(client){let t=client.signatureUrl(n,{expires:20,response:{"content-disposition":"attachment"}});const i=t.replace("emberimg.oss-cn-beijing.aliyuncs.com","download.xn--xhq44jb2fzpc.com");const r=()=>{if(o>0){s.textContent=`${o}秒后将开始下载...`;o--;setTimeout(r,1e3)}else{c.style.display="none";window.location.href=i}};c.style.display="block";r()}else{console.error("OSS client is not initialized.")}};document.getElementById(i).addEventListener("click",t)});function getCurrentTime(){const t=new Date;const e=new Date(t.getTime()+8*60*60*1e3);return e.toISOString().replace("T"," ").substring(0,19)}
\ No newline at end of file
diff --git a/js/downloadjm.js b/js/downloadjm.js
deleted file mode 100644
index 3e79c9e..0000000
--- a/js/downloadjm.js
+++ /dev/null
@@ -1 +0,0 @@
-let client;async function fetchNoCache(e){const t=(new Date).getTime();const n=`${e}?timestamp=${t}`;return fetch(n)}async function f1(){try{const e=await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/download/json/s.json");const t=await e.json();const n=t.masterKey;const o=CryptoJS.SHA256(n);const c={region:d2(t.encryptedRegion,o),accessKeyId:d2(t.encryptedKeyId,o),accessKeySecret:d2(t.encryptedKeySecret,o),bucket:d2(t.encryptedBucket,o)};client=new OSS(c)}catch(e){console.error("Failed to fetch or decrypt OSS config:",e)}}function d2(e,t){e=e.replace(/\s/g,"");const n=CryptoJS.enc.Base64.parse(e);const o=CryptoJS.lib.WordArray.create(n.words.slice(0,4));const c=CryptoJS.lib.WordArray.create(n.words.slice(4));const r=CryptoJS.AES.decrypt({ciphertext:c},t,{iv:o,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7});return r.toString(CryptoJS.enc.Utf8)}
\ No newline at end of file
diff --git a/js/qv.js b/js/qv.js
deleted file mode 100644
index aedca23..0000000
--- a/js/qv.js
+++ /dev/null
@@ -1,126 +0,0 @@
-let client;
-
-async function f1() {
- try {
- const r1 = await fetch('https://download.xn--xhq44jb2fzpc.com/upload/json/s.json');
- const d1 = await r1.json();
-
- const m1 = d1.masterKey;
-
- const k1 = CryptoJS.SHA256(m1);
-
- const c1 = {
- region: d2(d1.encryptedRegion, k1),
- accessKeyId: d2(d1.encryptedKeyId, k1),
- accessKeySecret: d2(d1.encryptedKeySecret, k1),
- bucket: d2(d1.encryptedBucket, k1)
- };
-
- client = new OSS(c1);
- // console.log("OSS Client Initialized Successfully with decrypted config", client);
- } catch (e1) {
- console.error('Failed to fetch or decrypt OSS config:', e1);
- }
-}
-
-function d2(e2, k2) {
- e2 = e2.replace(/\s/g, '');
- const e3 = CryptoJS.enc.Base64.parse(e2);
- const iv = CryptoJS.lib.WordArray.create(e3.words.slice(0, 4));
- const e4 = CryptoJS.lib.WordArray.create(e3.words.slice(4));
-
- const d3 = CryptoJS.AES.decrypt({ ciphertext: e4 }, k2, {
- iv: iv,
- mode: CryptoJS.mode.CBC,
- padding: CryptoJS.pad.Pkcs7
- });
- return d3.toString(CryptoJS.enc.Utf8);
-}
-
-document.addEventListener('DOMContentLoaded', function() {
- f1().then(() => {
- if (client) {
- } else {
- console.error('Failed to initialize OSS client due to decryption error.');
- }
- }).catch(e2 => {
- console.log('Error initializing OSS Client:', e2);
- });
-});
-
-// 获取Cookie的函数
-function getCookie(name) {
- const nameEQ = name + "=";
- const ca = document.cookie.split(';');
- for (let i = 0; i < ca.length; i++) {
- let c = ca[i];
- while (c.charAt(0) == ' ') c = c.substring(1, c.length);
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
- }
- return null;
-}
-
-// 获取登录状态和用户邮箱
-const loggedIn = getCookie('loggedIn');
-const email = getCookie('userEmail');
-
-// 检查用户是否已登录
-if (!loggedIn || !email) {
- alert("您未登录,请先登录后操作!");
- window.location.href = "/submission";
-} else {
- // 检查用户是否已经完成验证
- const checkVerificationStatus = async () => {
- try {
- const response = await fetch(`https://download.xn--xhq44jb2fzpc.com/user/${email}/qv.json`);
- if (response.ok) {
- const data = await response.json();
- if (data === true) {
- alert("您已经完成验证,无需再次验证!");
- window.location.href = "/submission";
- }
- }
- } catch (error) {
- console.log("没有找到验证文件,继续验证流程。");
- }
- };
-
- checkVerificationStatus();
-
- // 验证按钮点击事件
- document.getElementById('verifybtn').addEventListener('click', async () => {
- try {
- // 调用IP验证API
- const ipResponse = await fetch('https://ipquery.xn--xhq44jb2fzpc.com/api/check-ip');
- const ipResult = await ipResponse.json();
-
- if (ipResult.data.isInNeU) {
- // NEU校园网内,进行验证通过操作
- const verificationData = true;
- const userInfoBlob = new Blob([JSON.stringify(verificationData)], { type: 'application/json' });
- try {
- await client.put(`user/${email}/qv.json`, userInfoBlob);
- // setVerifiedCookie(email);
- alert("您已完成验证!");
- window.location.href = "/submission";
- } catch (err) {
- console.error('OSS写入失败:', err);
- alert("验证失败,请稍后重试。");
- }
- } else {
- alert("您未连接NEU校园网,请连接后重试!");
- }
- } catch (error) {
- console.error('IP验证失败:', error);
- alert("验证失败,请稍后重试。");
- }
- });
-}
-
-// function setVerifiedCookie(email) {
-// const domain = window.location.hostname.includes('localhost') ? 'localhost' : `.${window.location.hostname.split('.').slice(-2).join('.')}`;
-// const expires = new Date(Date.now() + 20 * 60 * 1000).toUTCString(); // 20分钟
-// document.cookie = `loggedIn=true; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
-// document.cookie = `userEmail=${email}; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
-// document.cookie = `verified=true; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
-// }
\ No newline at end of file
diff --git a/js/qv.min.js b/js/qv.min.js
deleted file mode 100644
index 5afccf3..0000000
--- a/js/qv.min.js
+++ /dev/null
@@ -1 +0,0 @@
-let client;async function f1(){try{var e=await(await fetch("https://download.xn--xhq44jb2fzpc.com/upload/json/s.json")).json(),t=e.masterKey,o=CryptoJS.SHA256(t),n={region:d2(e.encryptedRegion,o),accessKeyId:d2(e.encryptedKeyId,o),accessKeySecret:d2(e.encryptedKeySecret,o),bucket:d2(e.encryptedBucket,o)};client=new OSS(n)}catch(e){console.error("Failed to fetch or decrypt OSS config:",e)}}function d2(e,t){e=e.replace(/\s/g,"");var e=CryptoJS.enc.Base64.parse(e),o=CryptoJS.lib.WordArray.create(e.words.slice(0,4)),e=CryptoJS.lib.WordArray.create(e.words.slice(4));return CryptoJS.AES.decrypt({ciphertext:e},t,{iv:o,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)}function getCookie(e){var o=e+"=",n=document.cookie.split(";");for(let t=0;t{client||console.error("Failed to initialize OSS client due to decryption error.")}).catch(e=>{console.log("Error initializing OSS Client:",e)})});let loggedIn=getCookie("loggedIn"),email=getCookie("userEmail");if(loggedIn&&email){let e=async()=>{try{var e=await fetch(`https://download.xn--xhq44jb2fzpc.com/user/${email}/qv.json`);e.ok&&!0===await e.json()&&(alert("您已经完成验证,无需再次验证!"),window.location.href="/submission")}catch(e){console.log("没有找到验证文件,继续验证流程。")}};e(),document.getElementById("verifybtn").addEventListener("click",async()=>{try{if((await(await fetch("https://ipquery.xn--xhq44jb2fzpc.com/api/check-ip")).json()).data.isInNeU){var e=new Blob([JSON.stringify(!0)],{type:"application/json"});try{await client.put(`user/${email}/qv.json`,e),alert("您已完成验证!"),window.location.href="/submission"}catch(e){console.error("OSS写入失败:",e),alert("验证失败,请稍后重试。")}}else alert("您未连接NEU校园网,请连接后重试!")}catch(e){console.error("IP验证失败:",e),alert("验证失败,请稍后重试。")}})}else alert("您未登录,请先登录后操作!"),window.location.href="/submission";
\ No newline at end of file
diff --git a/js/single.js b/js/single.js
deleted file mode 100644
index dd033c5..0000000
--- a/js/single.js
+++ /dev/null
@@ -1,196 +0,0 @@
-async function fetchNoCache(url) {
- const timestamp = new Date().getTime();
- const noCacheUrl = `${url}?timestamp=${timestamp}`;
- return fetch(noCacheUrl);
-}
-
-async function updateAuthorInfo(email) {
- if (!email) {
- console.log("Email not provided, skipping author info update.");
- return;
- }
-
- const jsonPath = `https://download.xn--xhq44jb2fzpc.com/user/${email}/p.json`;
-
- try {
- const response = await fetchNoCache(jsonPath);
- if (response.ok) {
- const data = await response.json();
- if (data && data.nickname) {
- document.getElementById('post-author').innerText = data.nickname;
- console.log("Author name has been successfully updated.");
- } else {
- document.getElementById('post-author').innerText = "默认昵称";
- console.log("Default author name set due to missing 'nickname' field in response.");
- }
- } else if (response.status === 404) {
- document.getElementById('post-author').innerText = "默认昵称";
- } else {
- throw new Error('Failed to fetch p.json');
- }
- } catch (error) {
- console.error("Error loading author info:", error);
- document.getElementById('post-author').innerText = "默认昵称";
- }
-}
-
-// 设置提示框文本并显示
-function showTooltip(targetIcon, title, content) {
- const tooltip = document.getElementById('tooltip');
- const tooltipTitle = document.getElementById('tooltip-title');
- const tooltipContent = document.getElementById('tooltip-content');
-
- tooltipTitle.textContent = title;
- tooltipContent.textContent = content;
-
- tooltip.classList.add('show');
-}
-
-// 隐藏提示框
-function hideTooltip() {
- const tooltip = document.getElementById('tooltip');
- tooltip.classList.remove('show');
-}
-
-// 处理点击外部隐藏提示框
-document.body.addEventListener('click', (event) => {
- const tooltip = document.getElementById('tooltip');
- const verifiedIcon = document.getElementById('verified-icon');
- const invitedIcon = document.getElementById('invited-icon');
-
- if (!verifiedIcon.contains(event.target) && !invitedIcon.contains(event.target) && !tooltip.contains(event.target)) {
- hideTooltip();
- }
-});
-
-async function checkVerifiedStatus(email) {
- if (!email) {
- console.log("Email not provided, skipping verified status check.");
- return;
- }
-
- const url = 'https://download.xn--xhq44jb2fzpc.com/upload/verified-email/verified-email.json';
- const verifiedIcon = document.getElementById('verified-icon');
- const tooltipTitle = "认证作者"; // Title for the tooltip
-
- try {
- const response = await fetchNoCache(url);
- if (response.ok) {
- const verifiedEmails = await response.json();
- if (verifiedEmails.includes(email)) {
- verifiedIcon.style.display = 'inline-flex';
- console.log('Email is verified.');
-
- // Set up event listeners
- verifiedIcon.addEventListener('mouseenter', () => fetchVerificationDetails(email, verifiedIcon));
- verifiedIcon.addEventListener('mouseleave', hideTooltip);
- verifiedIcon.addEventListener('click', () => fetchVerificationDetails(email, verifiedIcon));
- } else {
- console.log('Email is not verified.');
- }
- } else {
- throw new Error('Failed to fetch verified-email.json');
- }
- } catch (error) {
- console.error('Error loading or parsing verified-email.json:', error);
- }
-}
-
-async function fetchVerificationDetails(email, icon) {
- const detailsUrl = `https://download.xn--xhq44jb2fzpc.com/user/${email}/verified.json`;
-
- try {
- const response = await fetchNoCache(detailsUrl);
- if (response.ok) {
- const data = await response.json();
- showTooltip(icon, "认证作者", data.description); // Use description from verified.json
- } else if (response.status === 404) {
- // If the verified.json file is not found, show a default message
- showTooltip(icon, "认证作者", "本作者为经过网站认证的优质内容分享者。");
- }
- } catch (error) {
- console.error('Error fetching verification details:', error);
- showTooltip(icon, "认证作者", "本作者为经过网站认证的优质内容分享者。"); // Default message on error
- }
-}
-
-async function checkInvitedStatus(email) {
- if (!email) {
- console.log("Email not provided, skipping invited author status check.");
- return;
- }
-
- const invitedEmailUrl = 'https://download.xn--xhq44jb2fzpc.com/upload/invited-email/invited-email.json';
- const invitedIcon = document.getElementById('invited-icon');
-
- try {
- const response = await fetchNoCache(invitedEmailUrl);
- if (response.ok) {
- const invitedEmails = await response.json();
- if (invitedEmails.includes(email)) {
- invitedIcon.style.display = 'inline-flex';
- console.log('Email is an invited author.');
-
- invitedIcon.addEventListener('mouseenter', () => fetchInvitedInfo(email, invitedIcon));
- invitedIcon.addEventListener('mouseleave', hideTooltip);
- invitedIcon.addEventListener('click', () => fetchInvitedInfo(email, invitedIcon));
- } else {
- console.log('Email is not an invited author.');
- }
- } else {
- throw new Error('Failed to fetch invited-email.json');
- }
- } catch (error) {
- console.error('Error loading or parsing invited-email.json:', error);
- }
-}
-
-async function fetchInvitedInfo(email, icon) {
- const infoUrl = `https://download.xn--xhq44jb2fzpc.com/user/${email}/invited.json`;
- try {
- const response = await fetchNoCache(infoUrl);
- if (response.ok) {
- const data = await response.json();
- showTooltip(icon, "特邀作者", data.description || '无详细信息');
- } else {
- showTooltip(icon, "特邀作者", '无法获取信息');
- }
- } catch (error) {
- console.error('Error fetching invited info:', error);
- showTooltip(icon, "特邀作者", '无法加载信息');
- }
-}
-
-
-
-async function updateAvatar(email) {
-if (!email) {
- console.log("Email not provided, skipping avatar update.");
- return;
-}
-
-const avatarUrl = `https://download.xn--xhq44jb2fzpc.com/user/${email}/avatar`;
-const defaultAvatarUrl = "https://download.xn--xhq44jb2fzpc.com/avatar/default.png?x-oss-process=style/avatar_comp";
-
-try {
- const response = await fetchNoCache(avatarUrl);
- const timestamp = new Date().getTime();
- if (response.ok) {
- // 保证头像实时更新
- document.getElementById('avatar').src = `${avatarUrl}?timestamp=${timestamp}?x-oss-process=style/avatar_comp`;
- document.getElementById('avatar').style.display = "block";
- console.log("Avatar updated.");
- } else if (response.status === 404) {
- document.getElementById('avatar').src = defaultAvatarUrl;
- document.getElementById('avatar').style.display = "block";
- console.log("Avatar file not found, using default avatar.");
- } else {
- throw new Error('Failed to fetch avatar');
- }
-} catch (error) {
- document.getElementById('avatar').src = defaultAvatarUrl;
- document.getElementById('avatar').style.display = "block";
- console.error("Error loading avatar:", error);
-}
-
-}
\ No newline at end of file
diff --git a/js/submission.js b/js/submission.js
deleted file mode 100644
index 7ad8aaa..0000000
--- a/js/submission.js
+++ /dev/null
@@ -1,920 +0,0 @@
-let client;
-let s = false;
-var curemail = "";
-var submitted = 0;
-
-// 检查 Cookie 的函数
-function getCookie(name) {
- const nameEQ = name + "=";
- const ca = document.cookie.split(';');
- for(let i = 0; i < ca.length; i++) {
- let c = ca[i];
- while (c.charAt(0) == ' ') c = c.substring(1,c.length);
- if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
- }
- return null;
-}
-
-document.addEventListener('DOMContentLoaded', function() {
- const loggedIn = getCookie('loggedIn');
- const email = getCookie('userEmail'); // 从 Cookie 中获取用户邮箱
- if (loggedIn === 'true' && email) {
- s = true;
- curemail = email; // 将用户邮箱赋值给 curemail 变量
- initializeUserSession();
- }
-});
-
-// 设置登录状态的 Cookie
-function setLoginCookie(email) {
- const domain = window.location.hostname.includes('localhost') ? 'localhost' : `.${window.location.hostname.split('.').slice(-2).join('.')}`;
- const expires = new Date(Date.now() + 20 * 60 * 1000).toUTCString(); // 20分钟
- document.cookie = `loggedIn=true; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
- document.cookie = `userEmail=${email}; domain=${domain}; path=/; expires=${expires}; SameSite=Lax`;
-}
-
-
-function logout() {
- const domain = window.location.hostname.includes('localhost') ? 'localhost' : `.${window.location.hostname.split('.').slice(-2).join('.')}`;
-
- // 清除登录状态的 Cookie
- document.cookie = `loggedIn=; domain=${domain}; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
- document.cookie = `userEmail=; domain=${domain}; path=/; expires=Thu, 01 Jan 1970 00:00:00 GMT;`;
-
- // 清除其他相关的状态变量
- s = false;
- curemail = "";
-
- // 重定向到登录页面或首页
- window.location.href = "/submission"; // 请根据实际情况修改重定向地址
-}
-
-
-
-document.getElementById('loginForm').addEventListener('submit', async function(event) {
- event.preventDefault();
- const email = document.getElementById('email').value;
- const password = document.getElementById('password').value;
- const hashedPassword = CryptoJS.SHA256(password).toString();
- const hashedEmail = CryptoJS.SHA256(email).toString();
- const emailFilePath = 'user/email.json';
- const hashedEmailFilePath = 'user/he.json';
- const userPasswordFilePath = `user/${email}/p.json`;
-
- try {
- // 读取加密邮箱列表
- let hashedEmailResponse = await client.get(hashedEmailFilePath);
- let registeredHashedEmails = JSON.parse(hashedEmailResponse.content);
-
- if (registeredHashedEmails.registeredEmails.includes(hashedEmail)) {
- let passwordResponse = await client.get(userPasswordFilePath);
- let storedUser = JSON.parse(passwordResponse.content);
-
- if (storedUser.h[0] === hashedPassword) {
- s = true;
- curemail = email;
- document.getElementById('message').innerText = '登录成功!正在加载中...';
-
- // 设置登录状态的 Cookie,作用于当前域名及其子域名
- setLoginCookie(curemail);
-
- setTimeout(initializeUserSession, 3000);
-
- } else {
- document.getElementById('message').innerText = '密码错误。';
- }
- } else {
- if (confirm('此邮箱没有注册。是否注册?')) {
- // 注册流程
- let emailResponse = await client.get(emailFilePath);
- let registeredEmails = JSON.parse(emailResponse.content).registeredEmails;
- registeredEmails.push(email);
-
- const updatedEmailJson = JSON.stringify({ registeredEmails: registeredEmails }, null, 2);
- await client.put(emailFilePath, new Blob([updatedEmailJson], { type: 'application/json' }));
-
- // 更新加密邮箱列表
- registeredHashedEmails.registeredEmails.push(hashedEmail);
- const updatedHashedEmailJson = JSON.stringify(registeredHashedEmails, null, 2);
- await client.put(hashedEmailFilePath, new Blob([updatedHashedEmailJson], { type: 'application/json' }));
-
- const newUserDetails = {
- h: [hashedPassword],
- nickname: "默认昵称",
- hasAvatar: false
- };
- const newUserJson = JSON.stringify(newUserDetails, null, 2);
- await client.put(userPasswordFilePath, new Blob([newUserJson], { type: 'application/json' }));
-
- s = true;
- curemail = email;
- document.getElementById('message').innerText = '注册并登录成功!正在加载中...';
-
- // 设置登录状态的 Cookie,作用于当前域名及其子域名
- setLoginCookie(curemail);
-
- setTimeout(initializeUserSession, 3000);
- }
- }
- } catch (error) {
- console.error('Error:', error);
- document.getElementById('message').innerText = '发生错误,请稍后重试。';
- }
-});
-
-
-
-
-var simplemde = new SimpleMDE({
- element: document.getElementById("input"),
- placeholder: "请在此处编辑并预览您的内容详情。",
- spellChecker: false,
- toolbar: [
- "side-by-side",
- "|",
- "bold",
- "italic",
- "heading-1",
- "heading-2",
- "heading-3",
- "|",
- "quote",
- "unordered-list",
- "ordered-list",
- "|",
- "link",
- "image",
- "table",
- "horizontal-rule",
- "|",
- "preview",
- "fullscreen"
- ]
-});
-
-function initializeUserSession() {
- document.getElementById('logout').style.display = 'block';
- document.getElementById('login').style.display = 'none';
- document.getElementById('navContainer').style.display = 'block';
- checkAndLoadAvatar();
- updateUserInfo();
- checkVerifiedStatus(curemail);
- checkInvitedStatus(curemail);
- fetchSubmittedCount(curemail);
- document.getElementById('userEmail').innerText = curemail;
- checkqv(curemail);
-}
-
-async function checkqv(curemail) {
- try {
- const response = await fetch(`https://download.xn--xhq44jb2fzpc.com/user/${curemail}/qv.json`);
-
- if (response.ok) {
- const data = await response.json();
- if (data === true) {
- // 用户已经完成NEU校园网认证
- // console.log("NEU校园网认证已完成");
- } else {
- // 文件存在但内容不是true
- showCustomModal();
- }
- } else {
- // 文件不存在
- showCustomModal();
- }
- } catch (error) {
- console.error('检查NEU校园网认证状态时出错:', error);
- showCustomModal();
- }
-}
-
-function showCustomModal() {
- const modal = document.getElementById('customModal');
- const overlay = document.getElementById('modalOverlay');
- modal.style.display = 'block';
- overlay.style.display = 'block';
-
- // 绑定确认按钮的点击事件
- document.getElementById('confirmButton').addEventListener('click', () => {
- window.location.href = "/qualification_verify";
- });
-
- // 绑定退出登录按钮的点击事件
- document.getElementById('logoutButton').addEventListener('click', () => {
- logout(); // 调用已定义的logout函数
- });
-}
-
-
-
-async function f1() {
- try {
- const r1 = await fetchNoCache('https://download.xn--xhq44jb2fzpc.com/upload/json/s.json');
- const d1 = await r1.json();
-
- const m1 = d1.masterKey;
-
- const k1 = CryptoJS.SHA256(m1);
-
- const c1 = {
- region: d2(d1.encryptedRegion, k1),
- accessKeyId: d2(d1.encryptedKeyId, k1),
- accessKeySecret: d2(d1.encryptedKeySecret, k1),
- bucket: d2(d1.encryptedBucket, k1)
- };
-
- client = new OSS(c1);
- // console.log("OSS Client Initialized Successfully with decrypted config", client);
- } catch (e1) {
- console.error('Failed to fetch or decrypt OSS config:', e1);
- }
-}
-
-function d2(e2, k2) {
- e2 = e2.replace(/\s/g, '');
- const e3 = CryptoJS.enc.Base64.parse(e2);
- const iv = CryptoJS.lib.WordArray.create(e3.words.slice(0, 4));
- const e4 = CryptoJS.lib.WordArray.create(e3.words.slice(4));
-
- const d3 = CryptoJS.AES.decrypt({ ciphertext: e4 }, k2, {
- iv: iv,
- mode: CryptoJS.mode.CBC,
- padding: CryptoJS.pad.Pkcs7
- });
- return d3.toString(CryptoJS.enc.Utf8);
-}
-
-document.addEventListener('DOMContentLoaded', function() {
- f1().then(() => {
- if (client) {
- } else {
- console.error('Failed to initialize OSS client due to decryption error.');
- }
- }).catch(e2 => {
- console.log('Error initializing OSS Client:', e2);
- });
-});
-
-const buttons = document.querySelectorAll('.navButton'); // Get all navButtons
-buttons.forEach(button => {
- button.addEventListener('click', function() {
- buttons.forEach(b => b.classList.remove('selected')); // Remove 'selected' from all buttons
- this.classList.add('selected'); // Add 'selected' to the clicked button
- });
-});
-
-function showSubmission() {
- document.getElementById('submission-area').style.display = 'block';
- document.getElementById('myinfo').style.display = 'none';
- document.getElementById('mysubmission').style.display = 'none';
- document.getElementById('mycoin').style.display = 'none';
-
-}
-
-function showMyInfo() {
- document.getElementById('submission-area').style.display = 'none';
- document.getElementById('myinfo').style.display = 'block';
- document.getElementById('mysubmission').style.display = 'none';
- document.getElementById('mycoin').style.display = 'none';
-
-}
-
-function showMyContent() {
- document.getElementById('submission-area').style.display = 'none';
- document.getElementById('myinfo').style.display = 'none';
- fetchSubmissionData(curemail, submitted);
- document.getElementById('mysubmission').style.display = 'block';
- document.getElementById('mycoin').style.display = 'block';
- loadCoinSystem();
-
-}
-
-async function updateUserInfo() {
- if (!s) {
- console.log("User is not logged in.");
- return;
- }
-
- const jsonPath = `https://download.xn--xhq44jb2fzpc.com/user/${curemail}/p.json`;
-
- try {
- const response = await fetchNoCache(jsonPath);
- if (response.ok) {
- const data = await response.json();
- if (data && data.nickname) {
- document.getElementById('nickname').innerText = data.nickname;
- console.log("Nickname has been successfully updated.");
- } else {
- document.getElementById('nickname').innerText = "Default Nickname";
- console.log("Default nickname set due to missing 'nickname' field in response.");
- }
- } else {
- throw new Error('p.json not found');
- }
- } catch (error) {
- console.error("Error loading p.json:", error);
- document.getElementById('nickname').innerText = "Default Nickname";
- }
-}
-
-async function checkAndLoadAvatar() {
- if (!s) {
- console.log("User is not logged in.");
- return;
- }
-
- const jsonPath = `https://download.xn--xhq44jb2fzpc.com/user/${curemail}/p.json`;
- const avatarPath = `https://download.xn--xhq44jb2fzpc.com/user/${curemail}/avatar`;
- const defaultAvatarPath = "https://download.xn--xhq44jb2fzpc.com/avatar/default.png";
-
- try {
- const response = await fetchNoCache(jsonPath);
- if (response.ok) {
- const data = await response.json();
- if (data.hasAvatar) {
- var newAvatarPath = avatarPath + '?t=' + Date.now(); // 添加时间戳
- document.getElementById('myinfoavatar').src = newAvatarPath;
- console.log("Custom avatar loaded.");
- } else {
- document.getElementById('myinfoavatar').src = defaultAvatarPath;
- console.log("Default avatar loaded due to `hasAvatar` being false.");
- }
- } else {
- throw new Error('p.json not found');
- }
- } catch (error) {
- document.getElementById('myinfoavatar').src = defaultAvatarPath;
- console.error("Error loading p.json. Using default avatar:", error);
- }
-}
-
-// 设置提示框文本并显示
-function showTooltip(targetIcon, title, content) {
- const tooltip = document.getElementById('tooltip');
- const tooltipTitle = document.getElementById('tooltip-title');
- const tooltipContent = document.getElementById('tooltip-content');
-
- tooltipTitle.textContent = title;
- tooltipContent.textContent = content;
-
- tooltip.classList.add('show');
-}
-
-// 隐藏提示框
-function hideTooltip() {
- const tooltip = document.getElementById('tooltip');
- tooltip.classList.remove('show');
-}
-
-// 处理点击外部隐藏提示框
-document.body.addEventListener('click', (event) => {
- const tooltip = document.getElementById('tooltip');
- const verifiedIcon = document.getElementById('verified-icon');
- const invitedIcon = document.getElementById('invited-icon');
-
- if (!verifiedIcon.contains(event.target) && !invitedIcon.contains(event.target) && !tooltip.contains(event.target)) {
- hideTooltip();
- }
-});
-
-async function checkVerifiedStatus(email) {
- if (!email) {
- console.log("Email not provided, skipping verified status check.");
- return;
- }
-
- const url = 'https://download.xn--xhq44jb2fzpc.com/upload/verified-email/verified-email.json';
- const verifiedIcon = document.getElementById('verified-icon');
- const tooltipTitle = "认证作者"; // Title for the tooltip
-
- try {
- const response = await fetchNoCache(url);
- if (response.ok) {
- const verifiedEmails = await response.json();
- if (verifiedEmails.includes(email)) {
- verifiedIcon.style.display = 'inline-flex';
- console.log('Email is verified.');
-
- // Set up event listeners
- verifiedIcon.addEventListener('mouseenter', () => fetchVerificationDetails(email, verifiedIcon));
- verifiedIcon.addEventListener('mouseleave', hideTooltip);
- verifiedIcon.addEventListener('click', () => fetchVerificationDetails(email, verifiedIcon));
- } else {
- console.log('Email is not verified.');
- }
- } else {
- throw new Error('Failed to fetch verified-email.json');
- }
- } catch (error) {
- console.error('Error loading or parsing verified-email.json:', error);
- }
-}
-
-async function fetchVerificationDetails(email, icon) {
- const detailsUrl = `https://download.xn--xhq44jb2fzpc.com/user/${email}/verified.json`;
-
- try {
- const response = await fetchNoCache(detailsUrl);
- if (response.ok) {
- const data = await response.json();
- showTooltip(icon, "认证作者", data.description); // Use description from verified.json
- } else if (response.status === 404) {
- // If the verified.json file is not found, show a default message
- showTooltip(icon, "认证作者", "本作者为经过网站认证的优质内容分享者。");
- }
- } catch (error) {
- console.error('Error fetching verification details:', error);
- showTooltip(icon, "认证作者", "本作者为经过网站认证的优质内容分享者。"); // Default message on error
- }
-}
-
-async function checkInvitedStatus(email) {
- if (!email) {
- console.log("Email not provided, skipping invited author status check.");
- return;
- }
-
- const invitedEmailUrl = 'https://download.xn--xhq44jb2fzpc.com/upload/invited-email/invited-email.json';
- const invitedIcon = document.getElementById('invited-icon');
-
- try {
- const response = await fetchNoCache(invitedEmailUrl);
- if (response.ok) {
- const invitedEmails = await response.json();
- if (invitedEmails.includes(email)) {
- invitedIcon.style.display = 'inline-flex';
- console.log('Email is an invited author.');
-
- invitedIcon.addEventListener('mouseenter', () => fetchInvitedInfo(email, invitedIcon));
- invitedIcon.addEventListener('mouseleave', hideTooltip);
- invitedIcon.addEventListener('click', () => fetchInvitedInfo(email, invitedIcon));
- } else {
- console.log('Email is not an invited author.');
- }
- } else {
- throw new Error('Failed to fetch invited-email.json');
- }
- } catch (error) {
- console.error('Error loading or parsing invited-email.json:', error);
- }
-}
-
-async function fetchInvitedInfo(email, icon) {
- const infoUrl = `https://download.xn--xhq44jb2fzpc.com/user/${email}/invited.json`;
- try {
- const response = await fetchNoCache(infoUrl);
- if (response.ok) {
- const data = await response.json();
- showTooltip(icon, "特邀作者", data.description || '无详细信息');
- } else {
- showTooltip(icon, "特邀作者", '无法获取信息');
- }
- } catch (error) {
- console.error('Error fetching invited info:', error);
- showTooltip(icon, "特邀作者", '无法加载信息');
- }
-}
-
-async function editNickname() {
- if (!s) {
- alert("您尚未登录,请登录后再尝试修改昵称。");
- return;
- }
-
- const newNickname = prompt("请输入新的昵称:");
- if (newNickname === null) {
- // 用户取消输入框,不做任何处理
- return;
- }
- if (newNickname.trim() === "") {
- alert("昵称不能为空!");
- return;
- }
-
- const jsonPath = `https://download.xn--xhq44jb2fzpc.com/user/${curemail}/p.json`;
-
- try {
- const response = await fetchNoCache(jsonPath);
-
- if (response.ok) {
- const data = await response.json();
- data.nickname = newNickname;
-
- const userInfoBlob = new Blob([JSON.stringify(data)], { type: 'application/json' });
- await client.put(`user/${curemail}/p.json`, userInfoBlob);
- console.log("p.json has been successfully updated with new nickname.");
-
- setTimeout(() => {
- document.getElementById('nickname').innerText = newNickname;
- console.log("Nickname has been updated on the page.");
- }, 1000);
- } else {
- throw new Error('Failed to fetch p.json');
- }
- } catch (error) {
- console.error("Error updating nickname:", error);
- }
-}
-
-document.getElementById('editNicknameBtn').addEventListener('click', editNickname);
-
-
-async function uploadAvatar(event) {
- var file = event.target.files[0];
- if (file && file.size <= 1048576) { // Size must be less than 1MB
- if (s === true) {
- var jsonPath = `user/${curemail}/p.json`; // Correct path for p.json
- var filePath = `user/${curemail}/avatar`; // Correct path for avatar file
-
- try {
- // Try to fetch existing p.json to see if it needs updating
- const response = await fetchNoCache(`https://download.xn--xhq44jb2fzpc.com/${jsonPath}`);
- let data;
- if (response.ok) {
- data = await response.json();
- } else {
- // If p.json does not exist or can't be loaded, initialize with default values
- data = {
- h: [hashedPassword], // Assuming hashedPassword is available here, if not, need to hash it
- nickname: "默认昵称",
- hasAvatar: false
- };
- }
-
- // Always upload the avatar image
- await client.put(filePath, file);
- console.log("Avatar has been successfully uploaded.");
-
- // Update hasAvatar flag and upload updated p.json only if necessary
- if (!data.hasAvatar) {
- data.hasAvatar = true; // Update the flag because we are uploading an avatar now
- const userInfoBlob = new Blob([JSON.stringify(data)], { type: 'application/json' });
- await client.put(jsonPath, userInfoBlob);
- console.log("p.json has been successfully uploaded.");
-
- setTimeout(() => {
- document.getElementById('myinfoavatar').src = `https://download.xn--xhq44jb2fzpc.com/${filePath}`;
- console.log("myinfoavatar's src has been updated to the new avatar.");
- }, 2000);
- } else {
- // If the avatar already exists and no new src is needed, force reload the image after 2 seconds
- setTimeout(() => {
- document.getElementById('myinfoavatar').src += '?' + new Date().getTime(); // Add timestamp to force reload
- console.log("Forced reload of the existing avatar.");
- }, 2000);
- }
- } catch (error) {
- console.error('Failed to upload new avatar or update p.json:', error);
- }
- } else {
- alert("You are not logged in, please log in before attempting to upload an avatar.");
- }
- } else {
- alert("头像必须小于 1MB!");
- }
-}
-
-document.querySelector('.overlay').addEventListener('click', function() {
- document.getElementById('fileInput').click(); // Trigger file input
-});
-
-const input = document.getElementById('input');
-// const preview = document.getElementById('preview');
-
-// input.addEventListener('input', () => {
-// const markdownText = input.value;
-// preview.innerHTML = marked.parse(markdownText);
-// });
-
-// Initialize with empty content
-// preview.innerHTML = marked.parse('');
-
-async function fetchSubmittedCount(email) {
- const url = `https://download.xn--xhq44jb2fzpc.com/upload/${email}/submitted.json`;
-
- try {
- const response = await fetchNoCache(url);
- if (response.ok) {
- const count = await response.json();
- submitted = count;
- console.log("Submitted count updated:", submitted);
- } else {
- throw new Error('File not found or access error');
- }
- } catch (error) {
- submitted = 0;
- console.log("Error fetching submitted count:", error);
- }
-}
-
-
-async function fetchSubmissionData(email, submitted) {
- let markdownTable = `
-## 投稿记录
-
-| 标题 | 板块 | 审核状态 | 审核备注 |
-|------|------|------|------|`;
-
- for (let i = 1; i <= submitted; i++) {
- const statusUrl = `https://download.xn--xhq44jb2fzpc.com/upload/${email}/${i}/status.json`;
-
- try {
- const response = await fetchNoCache(statusUrl);
- if (response.ok) {
- const data = await response.json();
- const { title, section, status, note, link } = data;
-
- // 设置标题列的内容,如果状态为“已通过”,则设置为超链接
- let titleContent = title || '无标题';
- if (status === '已通过' && link) {
- titleContent = `${titleContent}`;
- }
-
- markdownTable += `
-| ${titleContent} | ${section || '无板块'} | ${status || '无状态'} | ${note || ''} |`;
- } else {
- console.error(`无法获取 ${statusUrl}: ${response.status} ${response.statusText}`);
- }
- } catch (error) {
- console.error(`请求 ${statusUrl} 时发生错误:`, error);
- }
- }
-
- if (submitted === 0) {
- markdownTable += `
-| 没有投稿记录 | | | |`;
- }
-
- document.getElementById('mysubmission').innerHTML = marked.parse(markdownTable);
-}
-
-
-
-
-
-function validateFiles(event) {
- const maxFiles = 10;
- const maxFileSize = 2 * 1024 * 1024; // 2MB in bytes
- const maxCompressedFileSize = 20 * 1024 * 1024; // 20MB in bytes
- const files = event.target.files;
-
- if (files.length > maxFiles) {
- alert(`您只能选择最多 ${maxFiles} 个文件。`);
- event.target.value = ''; // 清除已选文件
- return;
- }
-
- let hasCompressedFile = false;
-
- for (let i = 0; i < files.length; i++) {
- const file = files[i];
- const fileName = file.name;
- const fileSize = file.size;
- const fileExtension = fileName.split('.').pop().toLowerCase();
-
- if (fileExtension === 'zip' || fileExtension === 'rar') {
- if (hasCompressedFile) {
- alert(`您只能上传一个压缩文件。`);
- event.target.value = ''; // 清除已选文件
- return;
- }
- hasCompressedFile = true;
- if (fileSize > maxCompressedFileSize) {
- alert(`压缩文件 "${fileName}" 超过了大小限制(20MB)。`);
- event.target.value = ''; // 清除已选文件
- return;
- }
- } else {
- if (fileSize > maxFileSize) {
- alert(`文件 "${fileName}" 超过了大小限制(2MB)。`);
- event.target.value = ''; // 清除已选文件
- return;
- }
- }
- }
-
- if (hasCompressedFile && files.length > 1) {
- alert('上传压缩文件时,只能上传一个文件。');
- event.target.value = ''; // 清除已选文件
- return;
- }
-}
-
-// 显示时间
-function getBeijingTime() {
- const now = new Date();
- const utcOffset = now.getTimezoneOffset() * 60000;
- const beijingOffset = 8 * 60 * 60 * 1000;
- const beijingTime = new Date(now.getTime() + utcOffset + beijingOffset);
- return beijingTime.toLocaleString('zh-CN', { timeZone: 'Asia/Shanghai' });
-}
-
-function displayBeijingTime() {
- const beijingTimeElement = document.getElementById('beijing-time');
- beijingTimeElement.textContent = getBeijingTime();
-}
-
-window.onload = function() {
- displayBeijingTime();
-}
-
-// // 获取当前北京时间并转化为纯数字格式
-// function getNumericBeijingTime() {
-// const beijingTimeElement = document.getElementById('beijing-time').textContent.trim();
-// const [date, time] = beijingTimeElement.split(' ');
-// const [year, month, day] = date.split('/');
-// const [hours, minutes] = time.split(':');
-// return `${year}${month.padStart(2, '0')}${day.padStart(2, '0')}${hours.padStart(2, '0')}${minutes.padStart(2, '0')}`;
-// }
-
-async function uploadImage(event) {
- const file = event.target.files[0];
- const email = document.querySelector("input[name='email']").value.trim();
-
- if (!s) {
- alert("您还没有登录,请登录后再上传图片!");
- return;
- }
-
- if (!file) {
- alert("请先选择图片文件!");
- return;
- }
-
- if (file.size > 2 * 1024 * 1024) {
- alert("图片文件大小不能超过2MB!");
- event.target.value = '';
- return;
- }
-
- const postId = submitted + 1;
- const filePath = `upload/${email}/${postId}/postimg/${file.name}`;
-
- try {
- const result = await client.put(filePath, file);
- const imageUrl = `https://download.xn--xhq44jb2fzpc.com/${filePath}`;
- const imageTag = `
`;
-
- // 展示图片URL和HTML标签
- document.getElementById("imageUrl").innerText = imageTag;
- // document.getElementById("imageUrl").href = imageUrl;
- document.getElementById("imagePreview").src = imageUrl;
- document.getElementById("imagePreview").style.display = "block";
- document.getElementById("copyButton").style.display = "inline-block";
-
- } catch (error) {
- console.error("图片上传失败:", error);
- alert("图片上传失败!");
- event.target.value = '';
- }
-}
-
-
-// 复制HTML标签到剪贴板
-function copyImageUrl() {
- const imageTag = document.getElementById("imageUrl").innerText;
- // 创建一个临时文本区域元素
- const textArea = document.createElement("textarea");
- textArea.value = imageTag;
- document.body.appendChild(textArea);
- textArea.select();
-
- try {
- const successful = document.execCommand('copy');
- const msg = successful ? '标签已复制到剪贴板!请直接粘贴到 markdown 编辑区中,并根据预览效果调整大小。' : '复制失败!';
- alert(msg);
- } catch (err) {
- alert("复制失败!", err);
- }
-
- document.body.removeChild(textArea);
-}
-
-
-
-document.getElementById('SubmitButton').onclick = function() {
-
-const section = document.getElementById('section').value;
-const wp = document.querySelector("input[name='wp']").value.trim();
-const wppassword = document.querySelector("input[name='wppassword']").value.trim();
-const note = document.querySelector("input[name='note']").value.trim();
-const markdownContent = simplemde.value().trim();
-
-if (!confirm('请仔细检查后提交,多次提交无关内容将被禁止访问网站!')) {
- return; // 用户点击取消,终止提交
-}
-
-uploadData();
-
-async function uploadData() {
- if (!s) {
- alert("您还未登录,请登录后再进行投稿。");
- return;
- }
-
- const email = curemail;
- const title = document.querySelector("input[name='title']").value.trim();
-
- if (!title) {
- alert("请填写内容的标题。");
- return;
- }
-
- const postId = submitted + 1;
-
- try {
- // 获取用户昵称
- const response = await fetch(`https://download.xn--xhq44jb2fzpc.com/user/${email}/p.json`);
- if (!response.ok) {
- throw new Error('无法加载用户数据');
- }
- const userData = await response.json();
- const nickname = userData.nickname || "未知昵称";
-
- const note = "";
- const link = "";
-
- const userInfoText = `时间:${getBeijingTime()}\n内容标题:${title}\n邮箱:${email}\n板块:${section}\n昵称:${nickname}\n备注:${note}\n网盘外链:${wp}\n网盘提取密码:${wppassword}\n资源展示页:\n${markdownContent}`;
- const userTextFilePath = `upload/${email}/${postId}/userinfo.txt`;
- const statusFilePath = `upload/${email}/${postId}/status.json`;
- const statusData = { title: title, status: "审核中", section: section, note: note, link: link };
-
- await client.put(userTextFilePath, new Blob([userInfoText], { type: 'text/plain' }));
-
- await client.put(statusFilePath, new Blob([JSON.stringify(statusData)], { type: 'application/json' }));
-
- const files = document.getElementById('filePicker').files;
- for (let i = 0; i < files.length; i++) {
- await client.put(`upload/${email}/${postId}/files/${files[i].name}`, files[i]);
- }
-
- submitted += 1;
- await client.put(`upload/${email}/submitted.json`, new Blob([JSON.stringify(submitted)], { type: 'application/json' }));
-
- window.location.href = '/submissionsuccess/';
- } catch (error) {
- console.error("上传失败:", error);
- alert("投稿失败,请重试!");
- }
-}
-
-
-
-};
-
-document.getElementById('SaveDraft').addEventListener('click', async () => {
- if (!s) {
- alert("非法操作!请先登录。");
- return;
- }
-
- if (confirm("确认保存草稿吗?如您之前有草稿内容,此操作会覆盖前一次的草稿内容。")) {
- // 获取SimpleMDE编辑器中的内容
- const draftContent = simplemde.value();
- const currentPostId = submitted + 1;
- const filePath = `upload/${curemail}/${currentPostId}/draft.json`;
-
- const draftData = new Blob([JSON.stringify({ content: draftContent }, null, 2)], { type: 'application/json' });
-
- try {
- await client.put(filePath, draftData);
- alert("草稿已保存!");
- } catch (error) {
- console.error("保存草稿时出错:", error);
- alert("保存草稿失败,请稍后再试。");
- }
- }
-});
-
-
-document.getElementById('LoadDraft').addEventListener('click', async () => {
- if (!s) {
- alert("非法操作!请先登录。");
- return;
- }
-
- const currentPostId = submitted + 1;
- const draftURL = `https://download.xn--xhq44jb2fzpc.com/upload/${curemail}/${currentPostId}/draft.json`;
-
- try {
- const response = await fetchNoCache(draftURL);
- if (!response.ok) {
- if (response.status === 404) {
- alert("没有草稿记录!");
- } else {
- throw new Error("无法加载草稿内容");
- }
- } else {
- const draftData = await response.json();
- if (confirm("此操作会覆盖您当前的输入内容,确认加载草稿吗?")) {
- // 设置SimpleMDE编辑器中的内容
- simplemde.value(draftData.content);
- alert("草稿已加载!");
- }
- }
- } catch (error) {
- console.error("加载草稿时出错:", error);
- alert("加载草稿失败,请稍后再试。");
- }
-});
-
diff --git a/js/submission.min.js b/js/submission.min.js
deleted file mode 100644
index e6b9629..0000000
--- a/js/submission.min.js
+++ /dev/null
@@ -1,16 +0,0 @@
-let client,s=!1;var curemail="",submitted=0;function getCookie(e){var n=e+"=",o=document.cookie.split(";");for(let t=0;t{window.location.href="/qualification_verify"}),document.getElementById("logoutButton").addEventListener("click",()=>{logout()})}async function f1(){try{var e=await(await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/upload/json/s.json")).json(),t=e.masterKey,n=CryptoJS.SHA256(t),o={region:d2(e.encryptedRegion,n),accessKeyId:d2(e.encryptedKeyId,n),accessKeySecret:d2(e.encryptedKeySecret,n),bucket:d2(e.encryptedBucket,n)};client=new OSS(o)}catch(e){console.error("Failed to fetch or decrypt OSS config:",e)}}function d2(e,t){e=e.replace(/\s/g,"");var e=CryptoJS.enc.Base64.parse(e),n=CryptoJS.lib.WordArray.create(e.words.slice(0,4)),e=CryptoJS.lib.WordArray.create(e.words.slice(4));return CryptoJS.AES.decrypt({ciphertext:e},t,{iv:n,mode:CryptoJS.mode.CBC,padding:CryptoJS.pad.Pkcs7}).toString(CryptoJS.enc.Utf8)}document.addEventListener("DOMContentLoaded",function(){f1().then(()=>{client||console.error("Failed to initialize OSS client due to decryption error.")}).catch(e=>{console.log("Error initializing OSS Client:",e)})});let buttons=document.querySelectorAll(".navButton");function showSubmission(){document.getElementById("submission-area").style.display="block",document.getElementById("myinfo").style.display="none",document.getElementById("mysubmission").style.display="none",document.getElementById("mycoin").style.display="none"}function showMyInfo(){document.getElementById("submission-area").style.display="none",document.getElementById("myinfo").style.display="block",document.getElementById("mysubmission").style.display="none",document.getElementById("mycoin").style.display="none"}function showMyContent(){document.getElementById("submission-area").style.display="none",document.getElementById("myinfo").style.display="none",fetchSubmissionData(curemail,submitted),document.getElementById("mysubmission").style.display="block",document.getElementById("mycoin").style.display="block",loadCoinSystem()}async function updateUserInfo(){if(s){var e=`https://download.xn--xhq44jb2fzpc.com/user/${curemail}/p.json`;try{var t=await fetchNoCache(e);if(!t.ok)throw new Error("p.json not found");var n=await t.json();n&&n.nickname?(document.getElementById("nickname").innerText=n.nickname,console.log("Nickname has been successfully updated.")):(document.getElementById("nickname").innerText="Default Nickname",console.log("Default nickname set due to missing 'nickname' field in response."))}catch(e){console.error("Error loading p.json:",e),document.getElementById("nickname").innerText="Default Nickname"}}else console.log("User is not logged in.")}async function checkAndLoadAvatar(){if(s){var e=`https://download.xn--xhq44jb2fzpc.com/user/${curemail}/p.json`,t=`https://download.xn--xhq44jb2fzpc.com/user/${curemail}/avatar`,n="https://download.xn--xhq44jb2fzpc.com/avatar/default.png";try{var o,i=await fetchNoCache(e);if(!i.ok)throw new Error("p.json not found");(await i.json()).hasAvatar?(o=t+"?t="+Date.now(),document.getElementById("myinfoavatar").src=o,console.log("Custom avatar loaded.")):(document.getElementById("myinfoavatar").src=n,console.log("Default avatar loaded due to `hasAvatar` being false."))}catch(e){document.getElementById("myinfoavatar").src=n,console.error("Error loading p.json. Using default avatar:",e)}}else console.log("User is not logged in.")}function showTooltip(e,t,n){var o=document.getElementById("tooltip"),i=document.getElementById("tooltip-title"),a=document.getElementById("tooltip-content");i.textContent=t,a.textContent=n,o.classList.add("show")}function hideTooltip(){document.getElementById("tooltip").classList.remove("show")}async function checkVerifiedStatus(t){if(t){let e=document.getElementById("verified-icon");try{var n=await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/upload/verified-email/verified-email.json");if(!n.ok)throw new Error("Failed to fetch verified-email.json");(await n.json()).includes(t)?(e.style.display="inline-flex",console.log("Email is verified."),e.addEventListener("mouseenter",()=>fetchVerificationDetails(t,e)),e.addEventListener("mouseleave",hideTooltip),e.addEventListener("click",()=>fetchVerificationDetails(t,e))):console.log("Email is not verified.")}catch(e){console.error("Error loading or parsing verified-email.json:",e)}}else console.log("Email not provided, skipping verified status check.")}async function fetchVerificationDetails(e,t){e=`https://download.xn--xhq44jb2fzpc.com/user/${e}/verified.json`;try{var n=await fetchNoCache(e);n.ok?showTooltip(t,"认证作者",(await n.json()).description):404===n.status&&showTooltip(t,"认证作者","本作者为经过网站认证的优质内容分享者。")}catch(e){console.error("Error fetching verification details:",e),showTooltip(t,"认证作者","本作者为经过网站认证的优质内容分享者。")}}async function checkInvitedStatus(t){if(t){let e=document.getElementById("invited-icon");try{var n=await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/upload/invited-email/invited-email.json");if(!n.ok)throw new Error("Failed to fetch invited-email.json");(await n.json()).includes(t)?(e.style.display="inline-flex",console.log("Email is an invited author."),e.addEventListener("mouseenter",()=>fetchInvitedInfo(t,e)),e.addEventListener("mouseleave",hideTooltip),e.addEventListener("click",()=>fetchInvitedInfo(t,e))):console.log("Email is not an invited author.")}catch(e){console.error("Error loading or parsing invited-email.json:",e)}}else console.log("Email not provided, skipping invited author status check.")}async function fetchInvitedInfo(e,t){e=`https://download.xn--xhq44jb2fzpc.com/user/${e}/invited.json`;try{var n=await fetchNoCache(e);n.ok?showTooltip(t,"特邀作者",(await n.json()).description||"无详细信息"):showTooltip(t,"特邀作者","无法获取信息")}catch(e){console.error("Error fetching invited info:",e),showTooltip(t,"特邀作者","无法加载信息")}}async function editNickname(){if(s){let e=prompt("请输入新的昵称:");if(null!==e)if(""===e.trim())alert("昵称不能为空!");else{var t=`https://download.xn--xhq44jb2fzpc.com/user/${curemail}/p.json`;try{var n=await fetchNoCache(t);if(!n.ok)throw new Error("Failed to fetch p.json");var o=await n.json(),i=(o.nickname=e,new Blob([JSON.stringify(o)],{type:"application/json"}));await client.put(`user/${curemail}/p.json`,i),console.log("p.json has been successfully updated with new nickname."),setTimeout(()=>{document.getElementById("nickname").innerText=e,console.log("Nickname has been updated on the page.")},1e3)}catch(e){console.error("Error updating nickname:",e)}}}else alert("您尚未登录,请登录后再尝试修改昵称。")}async function uploadAvatar(t){t=t.target.files[0];if(t&&t.size<=1048576)if(!0===s){var n=`user/${curemail}/p.json`,o=`user/${curemail}/avatar`;try{var i,a=await fetchNoCache("https://download.xn--xhq44jb2fzpc.com/"+n);let e;e=a.ok?await a.json():{h:[hashedPassword],nickname:"默认昵称",hasAvatar:!1},await client.put(o,t),console.log("Avatar has been successfully uploaded."),e.hasAvatar?setTimeout(()=>{document.getElementById("myinfoavatar").src+="?"+(new Date).getTime(),console.log("Forced reload of the existing avatar.")},2e3):(e.hasAvatar=!0,i=new Blob([JSON.stringify(e)],{type:"application/json"}),await client.put(n,i),console.log("p.json has been successfully uploaded."),setTimeout(()=>{document.getElementById("myinfoavatar").src="https://download.xn--xhq44jb2fzpc.com/"+o,console.log("myinfoavatar's src has been updated to the new avatar.")},2e3))}catch(e){console.error("Failed to upload new avatar or update p.json:",e)}}else alert("You are not logged in, please log in before attempting to upload an avatar.");else alert("头像必须小于 1MB!")}buttons.forEach(e=>{e.addEventListener("click",function(){buttons.forEach(e=>e.classList.remove("selected")),this.classList.add("selected")})}),document.body.addEventListener("click",e=>{var t=document.getElementById("tooltip"),n=document.getElementById("verified-icon"),o=document.getElementById("invited-icon");n.contains(e.target)||o.contains(e.target)||t.contains(e.target)||hideTooltip()}),document.getElementById("editNicknameBtn").addEventListener("click",editNickname),document.querySelector(".overlay").addEventListener("click",function(){document.getElementById("fileInput").click()});let input=document.getElementById("input");async function fetchSubmittedCount(e){e=`https://download.xn--xhq44jb2fzpc.com/upload/${e}/submitted.json`;try{var t=await fetchNoCache(e);if(!t.ok)throw new Error("File not found or access error");var n=await t.json();submitted=n,console.log("Submitted count updated:",submitted)}catch(e){submitted=0,console.log("Error fetching submitted count:",e)}}async function fetchSubmissionData(t,n){let o=`
-## 投稿记录
-
-| 标题 | 板块 | 审核状态 | 审核备注 |
-|------|------|------|------|`;for(let e=1;e<=n;e++){var i=`https://download.xn--xhq44jb2fzpc.com/upload/${t}/${e}/status.json`;try{var a=await fetchNoCache(i);if(a.ok){var{title:l,section:s,status:c,note:r,link:d}=await a.json();let e=l||"无标题";"已通过"===c&&d&&(e=`${e}`),o+=`
-| ${e} | ${s||"无板块"} | ${c||"无状态"} | ${r||""} |`}else console.error(`无法获取 ${i}: ${a.status} `+a.statusText)}catch(e){console.error(`请求 ${i} 时发生错误:`,e)}}0===n&&(o+=`
-| 没有投稿记录 | | | |`),document.getElementById("mysubmission").innerHTML=marked.parse(o)}function validateFiles(n){var o=n.target.files;if(10`;document.getElementById("imageUrl").innerText=i,document.getElementById("imagePreview").src=o,document.getElementById("imagePreview").style.display="block",document.getElementById("copyButton").style.display="inline-block"}catch(e){console.error("图片上传失败:",e),alert("图片上传失败!"),t.target.value=""}}else alert("请先选择图片文件!");else alert("您还没有登录,请登录后再上传图片!")}function copyImageUrl(){var e=document.getElementById("imageUrl").innerText,t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select();try{var n=document.execCommand("copy");alert(n?"标签已复制到剪贴板!请直接粘贴到 markdown 编辑区中,并根据预览效果调整大小。":"复制失败!")}catch(e){alert("复制失败!",e)}document.body.removeChild(t)}window.onload=function(){displayBeijingTime()},document.getElementById("SubmitButton").onclick=function(){let m=document.getElementById("section").value,u=document.querySelector("input[name='wp']").value.trim(),p=document.querySelector("input[name='wppassword']").value.trim();document.querySelector("input[name='note']").value.trim();let y=simplemde.value().trim();confirm("请仔细检查后提交,多次提交无关内容将被禁止访问网站!")&&!async function(){if(s){var t=curemail,e=document.querySelector("input[name='title']").value.trim();if(e){var n=submitted+1;try{var o=await fetch(`https://download.xn--xhq44jb2fzpc.com/user/${t}/p.json`);if(!o.ok)throw new Error("无法加载用户数据");var i=(await o.json()).nickname||"未知昵称",a=`时间:${getBeijingTime()}
-内容标题:${e}
-邮箱:${t}
-板块:${m}
-昵称:${i}
-备注:${""}
-网盘外链:${u}
-网盘提取密码:${p}
-资源展示页:
-`+y,l=`upload/${t}/${n}/userinfo.txt`,c=`upload/${t}/${n}/status.json`,r={title:e,status:"审核中",section:m,note:"",link:""},d=(await client.put(l,new Blob([a],{type:"text/plain"})),await client.put(c,new Blob([JSON.stringify(r)],{type:"application/json"})),document.getElementById("filePicker").files);for(let e=0;e{if(s){if(confirm("确认保存草稿吗?如您之前有草稿内容,此操作会覆盖前一次的草稿内容。")){var e=simplemde.value(),t=`upload/${curemail}/${submitted+1}/draft.json`,e=new Blob([JSON.stringify({content:e},null,2)],{type:"application/json"});try{await client.put(t,e),alert("草稿已保存!")}catch(e){console.error("保存草稿时出错:",e),alert("保存草稿失败,请稍后再试。")}}}else alert("非法操作!请先登录。")}),document.getElementById("LoadDraft").addEventListener("click",async()=>{if(s){var e=`https://download.xn--xhq44jb2fzpc.com/upload/${curemail}/${submitted+1}/draft.json`;try{var t=await fetchNoCache(e);if(t.ok){var n=await t.json();confirm("此操作会覆盖您当前的输入内容,确认加载草稿吗?")&&(simplemde.value(n.content),alert("草稿已加载!"))}else{if(404!==t.status)throw new Error("无法加载草稿内容");alert("没有草稿记录!")}}catch(e){console.error("加载草稿时出错:",e),alert("加载草稿失败,请稍后再试。")}}else alert("非法操作!请先登录。")});
\ No newline at end of file
diff --git a/js/uglifyjs b/js/uglifyjs
deleted file mode 100644
index e69de29..0000000
diff --git a/js/uglifyjs.txt b/js/uglifyjs.txt
deleted file mode 100644
index e57e48b..0000000
--- a/js/uglifyjs.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-假设你的 JavaScript 文件名为 submission.js,你可以使用以下命令来压缩和混淆它:
-
-uglifyjs submission.js -o submission.min.js -m -c
-
--o script.min.js:指定输出文件名为 script.min.js。
--m:启用变量名压缩(mangle),会将变量名压缩成更短的形式。
--c:启用代码压缩(compress),会对代码进行优化以减少文件体积。
-
-uglifyjs coin.js -o coin.min.js -m -c
-uglifyjs dlwithcoin.js -o dlwithcoin.min.js -m
diff --git a/js/新建 文本文档.txt b/js/新建 文本文档.txt
deleted file mode 100644
index e69de29..0000000