2021-11-17 14:01:01 +00:00
|
|
|
/**
|
|
|
|
* 来自于copy_btn.js paste.js合并
|
2023-01-29 22:43:40 +00:00
|
|
|
* 简单图床-复制链接
|
2023-01-29 22:15:24 +00:00
|
|
|
* 2023-01-30
|
2021-11-17 14:01:01 +00:00
|
|
|
*/
|
2023-01-29 22:43:40 +00:00
|
|
|
|
|
|
|
document.getElementsByClassName('copyBtn1')[0].onclick = function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
var copyVal = document.getElementById("links");
|
|
|
|
copyVal.select();
|
|
|
|
try {
|
2023-01-29 22:15:24 +00:00
|
|
|
navigator.clipboard.writeText(copyVal.value).then(function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
//success info
|
2022-01-12 18:48:08 +00:00
|
|
|
new $.zui.Messager("复制成功", {
|
2022-01-19 10:56:59 +00:00
|
|
|
type: "primary", // 定义颜色主题
|
2022-05-09 06:37:58 +00:00
|
|
|
icon: "ok-sign" // 定义消息图标
|
2022-01-12 18:48:08 +00:00
|
|
|
}).show();
|
2021-11-17 14:01:01 +00:00
|
|
|
console.log("复制成功");
|
2023-01-29 22:15:24 +00:00
|
|
|
}, function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
//fail info
|
|
|
|
alert("复制失败");
|
2023-01-29 22:15:24 +00:00
|
|
|
});
|
2021-11-17 14:01:01 +00:00
|
|
|
} catch (err) {
|
|
|
|
alert(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-29 22:43:40 +00:00
|
|
|
document.getElementsByClassName('copyBtn2')[0].onclick = function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
var copyVal = document.getElementById("bbscode");
|
|
|
|
copyVal.select();
|
|
|
|
try {
|
2023-01-29 22:15:24 +00:00
|
|
|
navigator.clipboard.writeText(copyVal.value).then(function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
//success info
|
2022-01-12 18:48:08 +00:00
|
|
|
new $.zui.Messager("复制成功", {
|
2022-01-19 10:56:59 +00:00
|
|
|
type: "primary", // 定义颜色主题
|
|
|
|
icon: "ok-sign" // 定义消息图标
|
2022-01-12 18:48:08 +00:00
|
|
|
}).show();
|
2021-11-17 14:01:01 +00:00
|
|
|
console.log("复制成功");
|
2023-01-29 22:15:24 +00:00
|
|
|
}, function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
//fail info
|
|
|
|
alert("复制失败");
|
2023-01-29 22:15:24 +00:00
|
|
|
});
|
2021-11-17 14:01:01 +00:00
|
|
|
} catch (err) {
|
|
|
|
alert(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-29 22:43:40 +00:00
|
|
|
document.getElementsByClassName('copyBtn3')[0].onclick = function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
var copyVal = document.getElementById("markdown");
|
|
|
|
copyVal.select();
|
|
|
|
try {
|
2023-01-29 22:15:24 +00:00
|
|
|
navigator.clipboard.writeText(copyVal.value).then(function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
//success info
|
2022-01-12 18:48:08 +00:00
|
|
|
new $.zui.Messager("复制成功", {
|
2022-01-19 10:56:59 +00:00
|
|
|
type: "primary", // 定义颜色主题
|
|
|
|
icon: "ok-sign" // 定义消息图标
|
2022-01-12 18:48:08 +00:00
|
|
|
}).show();
|
2021-11-17 14:01:01 +00:00
|
|
|
console.log("复制成功");
|
2023-01-29 22:15:24 +00:00
|
|
|
}, function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
//fail info
|
|
|
|
alert("复制失败");
|
2023-01-29 22:15:24 +00:00
|
|
|
});
|
2021-11-17 14:01:01 +00:00
|
|
|
} catch (err) {
|
|
|
|
alert(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-29 22:43:40 +00:00
|
|
|
document.getElementsByClassName('copyBtn4')[0].onclick = function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
var copyVal = document.getElementById("html");
|
|
|
|
copyVal.select();
|
|
|
|
try {
|
2023-01-29 22:15:24 +00:00
|
|
|
navigator.clipboard.writeText(copyVal.value).then(function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
//success info
|
2022-01-12 18:48:08 +00:00
|
|
|
new $.zui.Messager("复制成功", {
|
2022-01-19 10:56:59 +00:00
|
|
|
type: "primary", // 定义颜色主题
|
|
|
|
icon: "ok-sign" // 定义消息图标
|
2022-01-12 18:48:08 +00:00
|
|
|
}).show();
|
2021-11-17 14:01:01 +00:00
|
|
|
console.log("复制成功");
|
2023-01-29 22:15:24 +00:00
|
|
|
}, function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
//fail info
|
|
|
|
alert("复制失败");
|
2023-01-29 22:15:24 +00:00
|
|
|
});
|
2021-11-17 14:01:01 +00:00
|
|
|
} catch (err) {
|
|
|
|
alert(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-29 22:43:40 +00:00
|
|
|
document.getElementsByClassName('copyBtn5')[0].onclick = function () {
|
2023-01-29 22:15:24 +00:00
|
|
|
var copyVal = document.getElementById("thumb");
|
2021-11-17 14:01:01 +00:00
|
|
|
copyVal.select();
|
|
|
|
try {
|
2023-01-29 22:15:24 +00:00
|
|
|
navigator.clipboard.writeText(copyVal.value).then(function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
//success info
|
2022-01-12 18:48:08 +00:00
|
|
|
new $.zui.Messager("复制成功", {
|
2022-01-19 10:56:59 +00:00
|
|
|
type: "primary", // 定义颜色主题
|
|
|
|
icon: "ok-sign" // 定义消息图标
|
2022-01-12 18:48:08 +00:00
|
|
|
}).show();
|
2021-11-17 14:01:01 +00:00
|
|
|
console.log("复制成功");
|
2023-01-29 22:15:24 +00:00
|
|
|
}, function () {
|
2021-11-17 14:01:01 +00:00
|
|
|
//fail info
|
|
|
|
alert("复制失败");
|
2023-01-29 22:15:24 +00:00
|
|
|
});
|
2021-11-17 14:01:01 +00:00
|
|
|
} catch (err) {
|
|
|
|
alert(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-29 22:43:40 +00:00
|
|
|
document.getElementsByClassName('copyBtn6')[0].onclick = function () {
|
2023-01-29 22:15:24 +00:00
|
|
|
var copyVal = document.getElementById("del");
|
|
|
|
copyVal.select();
|
|
|
|
try {
|
|
|
|
navigator.clipboard.writeText(copyVal.value).then(function () {
|
|
|
|
//success info
|
|
|
|
new $.zui.Messager("复制成功", {
|
|
|
|
type: "primary", // 定义颜色主题
|
|
|
|
icon: "ok-sign" // 定义消息图标
|
|
|
|
}).show();
|
|
|
|
console.log("复制成功");
|
|
|
|
}, function () {
|
|
|
|
//fail info
|
|
|
|
alert("复制失败");
|
|
|
|
});
|
|
|
|
} catch (err) {
|
|
|
|
alert(err);
|
|
|
|
}
|
|
|
|
}
|
2021-11-17 14:01:01 +00:00
|
|
|
|
2023-01-29 22:15:24 +00:00
|
|
|
// 按钮状态
|
|
|
|
$('#btnLinks, #btnBbscode, #btnMarkDown, #btnHtml, #btnThumb, #btnDel').on('click', function () {
|
|
|
|
$(this).button('loading').delay(2000).queue(function () {
|
|
|
|
$(this).button('reset');
|
|
|
|
})
|
2021-11-17 14:01:01 +00:00
|
|
|
});
|
|
|
|
|
2023-01-29 22:43:40 +00:00
|
|
|
/** 粘贴上传 2023-01-30 */
|
2023-01-29 22:15:24 +00:00
|
|
|
(function () {
|
|
|
|
document.addEventListener('paste', function (e) {
|
2021-11-17 14:01:01 +00:00
|
|
|
var items = ((e.clipboardData || window.clipboardData).items) || [];
|
|
|
|
var file = null;
|
|
|
|
|
|
|
|
if (items && items.length) {
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
if (items[i].type.indexOf('image') !== -1) {
|
|
|
|
file = items[i].getAsFile();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!file) {
|
2023-01-29 22:15:24 +00:00
|
|
|
$.zui.messager.show('粘贴内容非图片!', {
|
|
|
|
icon: 'bell',
|
|
|
|
time: 3000,
|
|
|
|
type: 'danger',
|
|
|
|
placement: 'top'
|
|
|
|
});
|
2021-11-17 14:01:01 +00:00
|
|
|
return;
|
|
|
|
}
|
2023-01-29 22:15:24 +00:00
|
|
|
|
2021-11-17 14:01:01 +00:00
|
|
|
var formData = new FormData();
|
|
|
|
formData.append('file', file);
|
|
|
|
var xhr = new XMLHttpRequest();
|
|
|
|
|
2023-01-29 22:15:24 +00:00
|
|
|
xhr.onreadystatechange = function () {
|
|
|
|
if (xhr.readyState == 1) {
|
|
|
|
$.zui.messager.show('粘贴上传中...', {
|
|
|
|
icon: 'bell',
|
|
|
|
time: 3000,
|
|
|
|
type: 'primary',
|
|
|
|
placement: 'top'
|
|
|
|
});
|
|
|
|
$(".uploader").addClass("load-indicator loading"); // 增加正在上传状态
|
|
|
|
}
|
2021-11-17 14:01:01 +00:00
|
|
|
|
2023-01-29 22:15:24 +00:00
|
|
|
if (xhr.readyState >= 4) {
|
|
|
|
$.zui.messager.show('粘贴上传中...', {
|
|
|
|
icon: 'bell',
|
|
|
|
time: 3000,
|
|
|
|
type: 'primary',
|
|
|
|
placement: 'top'
|
|
|
|
});
|
|
|
|
$(".uploader").removeClass("load-indicator loading"); // 移除正在上传状态
|
|
|
|
}
|
|
|
|
}
|
2021-11-17 14:01:01 +00:00
|
|
|
|
2023-01-29 22:15:24 +00:00
|
|
|
xhr.onload = function () {
|
|
|
|
var result = JSON.parse(this.responseText);
|
|
|
|
if (result.result === 'success') {
|
|
|
|
var links = document.getElementById("links");
|
|
|
|
links.innerHTML += result.url + "\n";
|
|
|
|
|
|
|
|
var bbscode = document.getElementById("bbscode");
|
|
|
|
bbscode.innerHTML += "[img]" + result.url + "[/img]\n";
|
|
|
|
|
|
|
|
var markdown = document.getElementById("markdown");
|
|
|
|
markdown.innerHTML += "\n";
|
|
|
|
|
|
|
|
var html = document.getElementById("html");
|
|
|
|
html.innerHTML += "<img src=\"" + result.url + "\" />\n";
|
|
|
|
|
|
|
|
var del = document.getElementById("thumb");
|
|
|
|
del.innerHTML += result.thumb + "\n";
|
|
|
|
|
|
|
|
var del = document.getElementById("del");
|
|
|
|
del.innerHTML += result.del + "\n";
|
|
|
|
|
|
|
|
$.zui.messager.show('粘贴上传成功...', {
|
|
|
|
icon: 'bell',
|
|
|
|
time: 4000,
|
|
|
|
type: 'success',
|
|
|
|
placement: 'top'
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$.zui.messager.show('上传失败...' + result.message, {
|
|
|
|
icon: 'bell',
|
|
|
|
time: 4000,
|
|
|
|
type: 'primary',
|
|
|
|
placement: 'top'
|
|
|
|
});
|
2021-11-17 14:01:01 +00:00
|
|
|
}
|
|
|
|
};
|
2023-01-29 22:15:24 +00:00
|
|
|
xhr.onerror = function () {
|
|
|
|
$.zui.messager.show('因网络问题导致的上传失败...', {
|
|
|
|
icon: 'bell',
|
|
|
|
time: 4000,
|
|
|
|
type: 'primary',
|
|
|
|
placement: 'top'
|
|
|
|
});
|
2021-11-17 14:01:01 +00:00
|
|
|
};
|
2022-02-04 17:18:15 +00:00
|
|
|
xhr.open('POST', './application/upload.php', true);
|
2021-11-17 14:01:01 +00:00
|
|
|
xhr.send(formData);
|
|
|
|
});
|
|
|
|
})();
|
2022-05-25 10:23:17 +00:00
|
|
|
|
2023-01-29 22:43:40 +00:00
|
|
|
/** 导航状态 */
|
2023-01-29 22:15:24 +00:00
|
|
|
$('.nav-pills').find('a').each(function () {
|
2022-05-25 10:23:17 +00:00
|
|
|
if (this.href == document.location.href) {
|
|
|
|
$(this).parent().addClass('active'); // this.className = 'active';
|
|
|
|
}
|
|
|
|
});
|