EasyImages2.0/public/static/EasyImage.js

238 lines
7.0 KiB
JavaScript
Raw Normal View History

2021-11-17 14:01:01 +00:00
/**
* 来自于copy_btn.js paste.js合并
* 简单图床-复制
*/
var copyBtn = document.getElementsByClassName('copyBtn1')[0];
2022-05-09 06:37:58 +00:00
copyBtn.onclick = function() {
2021-11-17 14:01:01 +00:00
var copyVal = document.getElementById("links");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//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("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn2')[0];
2022-05-09 06:37:58 +00:00
copyBtn.onclick = function() {
2021-11-17 14:01:01 +00:00
var copyVal = document.getElementById("bbscode");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//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("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn3')[0];
2022-05-09 06:37:58 +00:00
copyBtn.onclick = function() {
2021-11-17 14:01:01 +00:00
var copyVal = document.getElementById("markdown");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//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("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn4')[0];
2022-05-09 06:37:58 +00:00
copyBtn.onclick = function() {
2021-11-17 14:01:01 +00:00
var copyVal = document.getElementById("html");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//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("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
var copyBtn = document.getElementsByClassName('copyBtn5')[0];
2022-05-09 06:37:58 +00:00
copyBtn.onclick = function() {
2021-11-17 14:01:01 +00:00
var copyVal = document.getElementById("del");
copyVal.select();
try {
if (document.execCommand('copy', false, null)) {
//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("复制成功");
} else {
//fail info
alert("复制失败");
}
} catch (err) {
//fail info
alert(err);
}
}
// btn状态
2022-05-09 06:37:58 +00:00
$('#btnLinks').on('click', function() {
2021-11-17 14:01:01 +00:00
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
2022-05-09 06:37:58 +00:00
setTimeout(function() {
2021-11-17 14:01:01 +00:00
$btn.button('reset');
}, 2000);
});
2022-05-09 06:37:58 +00:00
$('#btnBbscode').on('click', function() {
2021-11-17 14:01:01 +00:00
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
2022-05-09 06:37:58 +00:00
setTimeout(function() {
2021-11-17 14:01:01 +00:00
$btn.button('reset');
}, 2000);
});
2022-05-09 06:37:58 +00:00
$('#btnMarkDown').on('click', function() {
2021-11-17 14:01:01 +00:00
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
2022-05-09 06:37:58 +00:00
setTimeout(function() {
2021-11-17 14:01:01 +00:00
$btn.button('reset');
}, 2000);
});
2022-05-09 06:37:58 +00:00
$('#btnHtml').on('click', function() {
2021-11-17 14:01:01 +00:00
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
2022-05-09 06:37:58 +00:00
setTimeout(function() {
2021-11-17 14:01:01 +00:00
$btn.button('reset');
}, 2000);
});
2022-05-09 06:37:58 +00:00
$('#btndel').on('click', function() {
2021-11-17 14:01:01 +00:00
var $btn = $(this);
$btn.button('loading');
// 此处使用 setTimeout 来模拟你的复杂功能逻辑
2022-05-09 06:37:58 +00:00
setTimeout(function() {
2021-11-17 14:01:01 +00:00
$btn.button('reset');
}, 2000);
});
/****************************************************************
2022-05-09 06:37:58 +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) {
2022-02-03 03:47:42 +00:00
alert('粘贴内容非图片!');
2021-11-17 14:01:01 +00:00
return;
}
var formData = new FormData();
formData.append('file', file);
var xhr = new XMLHttpRequest();
2022-05-09 06:37:58 +00:00
xhr.onload = function() {
2021-11-17 14:01:01 +00:00
try {
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 += "![](" + result.url + ")\n";
var html = document.getElementById("html");
html.innerHTML += "&lt;img src=\"" + result.url + "\" /&#62;\n";
var del = document.getElementById("del");
del.innerHTML += result.del + "\n";
} else {
alert('上传失败1');
}
} catch (e) {
alert('上传失败2');
}
};
2022-05-09 06:37:58 +00:00
xhr.onerror = function() {
2021-11-17 14:01:01 +00:00
alert('上传失败3');
};
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-02-03 03:47:42 +00:00
/******************************************************************/
2021-11-17 14:01:01 +00:00
var _hmt = _hmt || [];
2022-05-09 06:37:58 +00:00
(function() {
2021-11-17 14:01:01 +00:00
var hm = document.createElement("script");
2022-02-03 03:47:42 +00:00
hm.src = "https://hm.baidu.com/hm.js?c790ac2bdc2f385757ecd0183206108d";
2021-11-17 14:01:01 +00:00
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
2022-05-25 10:23:17 +00:00
})();
// 导航状态
$('.nav-pills').find('a').each(function() {
if (this.href == document.location.href) {
$(this).parent().addClass('active'); // this.className = 'active';
}
});