修复因 CDN 失效导致无法使用的问题

修复因 CDN 失效导致无法使用的问题
重构部分代码,界面更美观
This commit is contained in:
mengkunsoft
2019-04-27 13:50:38 +08:00
parent 6fcd55bef0
commit 85a33bb3c3
9 changed files with 377 additions and 330 deletions

1
js/clipboard.min.js vendored Normal file

File diff suppressed because one or more lines are too long

5
js/jquery.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,82 +1,88 @@
/**
* Created by bangbang on 14/10/10.
* Revised by mengkun on 17/03/16
* 原始代码来自 bangbang(http://lmbtfy.cn/)mengkun(https://mkblog.cn) 在原作的基础上作了一些小修改,以适应移动端浏览
* Github 地址https://github.com/mengkunsoft/lmbtfy
*
* 转载或使用时,还请保留以上信息,谢谢!
*/
function urlEncode(String) {
return encodeURIComponent(String).replace(/'/g,"%27").replace(/"/g,"%22");
}
$(document).ready(function (){
ZeroClipboard.config({swfPath: '//cdnjscn.b0.upaiyun.com/libs/zeroclipboard/2.1.6/ZeroClipboard.swf'});
var clip = new ZeroClipboard($('#copy'));
$('#search').on('click', function (){
var link = window.location.origin + window.location.pathname + '?' + urlEncode($('#kw').val());
$.ajax({
url: 'get.php?longUrl='+link,
type: "GET",
dataType: "jsonp", //使用JSONP方法进行AJAX
cache: false,
success: function (data) {
if (data){
if(!(typeof data.urls === undefined || typeof data.urls == "undefined")) //防止短网址失败
{
link = data.urls[0].url_short;
}
}
$('#go').attr("href",link);
$('#link').show();
$('#instructions').text('复制下面的地址,然后发给伸手党吧!');
$('#lmbtfyLink').val(link).focus().select();
}
})
});
var $container = $('.container');
$container.on('click', '#go', function (){ //点击预览
var link = $('#lmbtfyLink').val();
if (!!link){
//window.open(link); //新窗口打开
//window.location = link;
$(document).ready(function () {
/* 复制结果 */
var clipboard = new ClipboardJS('.btn-copy');
clipboard.on('success', function(e) {
if (e.trigger.disabled === false || e.trigger.disabled === undefined) {
showTips('<span style="color: #4caf50">复制成功!赶紧把链接甩给伸手党们!</span>');
}
});
clipboard.on('error', function(e) {
showTips('<span style="color: red">复制失败,请手动复制</span>');
});
var $outputLink = $('#output-link');
$('#search').on('click', function () {
var link = window.location.origin + window.location.pathname + '?' + encodeURIComponent($('#kw').val());
$('#output-box').fadeIn();
showTips('复制下面的地址');
$outputLink.val(link).focus().select();
/* 尝试缩短网址 */
$.ajax({
url: 'api.php?url=' + encodeURIComponent(link),
dataType: 'json',
success: function (data) {
if(data.code == 200) $outputLink.val(data.result).focus().select();
}
});
});
/* 预览 */
var $container = $('.container');
$container.on('click', '#btn-preview', function () {
var link = $outputLink.val();
if (!!link) {
window.open(link);
}
});
/* 回车搜索 */
var $kw = $('#kw');
$kw.on('keydown', function (e) {
if (e.keyCode == 13){
if (e.keyCode == 13) {
$('#search').trigger('click');
}
});
if (!!window.location.search){
if (!!window.location.search) {
var kw = decodeURIComponent(window.location.search.substr(1));
var $instructions = $('#instructions');
var $arrow = $('#arrow');
setTimeout(function (){
$instructions.text('1、找到输入框并选中');
showTips('让我来帮你百度一下');
setTimeout(function() {
showTips('1、找到输入框并选中');
$arrow.show().animate({
left: $kw.offset().left + 10 + 'px',
top: ($kw.offset().top + $kw.height()/2) + 'px'
}, 2000, function (){
$instructions.text('2、输入你的问题');
}, 2000, function () {
showTips('2、输入你的问题');
$arrow.hide();
var $kw = $('#kw');
$kw.focus();
var i = 0;
var interval = setInterval(function (){
var interval = setInterval(function () {
$kw.val(kw.substr(0,i));
i++;
if (i > kw.length){
if (i > kw.length) {
clearInterval(interval);
$instructions.text('3、下“百度一下”按钮');
showTips('3、点击下“百度一下”按钮');
$arrow.show();
var $search = $('#search');
$arrow.animate({
left: $search.offset().left + $search.width()/2 + 'px',
top: $search.offset().top + $search.height()/2 + 'px'
}, 1000, function () {
$instructions.html('<strong>这对你而言就是这么困难么?</strong>');
setTimeout(function (){
window.location = 'http://www.baidu.com/s?ch=3&ie=utf-8&wd=' + encodeURIComponent(kw);
showTips('<strong>这对你而言就是这么困难么?</strong>');
setTimeout(function () {
window.location = 'https://www.baidu.com/s?ch=3&ie=utf-8&wd=' + encodeURIComponent(kw);
}, 2000);
})
});
}
}, 200);
});
@@ -84,21 +90,21 @@ $(document).ready(function (){
}
});
function showAbout() //弹出消息
{
var windowWidth = $(window).width();
var windowHeight = $(window).height();
var popupHeight = $("#msgbox").height();
var popupWidth = $("#msgbox").width();
//添加并显示遮罩层
$("#mask").width(windowWidth).height(windowHeight).click(function() {hideAbout(); }).fadeIn(200);
$("#msgbox").css({"position": "absolute","left":windowWidth/2-popupWidth/2,"top":windowHeight/2-popupHeight/2}).fadeIn(200);
/* 显示提示信息 */
function showTips(tips) {
$('#instructions').html(tips);
}
function hideAbout() //隐藏弹出的提示框
{
$("#mask").fadeOut(200);
$("#msgbox").fadeOut(200);
/* 弹出关于信息 */
function showAbout() {
var windowWidth = $(window).width(),
windowHeight = $(window).height(),
popupHeight = $("#about-box").height(),
popupWidth = $("#about-box").width();
$("#about-box").css({
"position": "absolute",
"left": windowWidth / 2 - popupWidth / 2,
"top": windowHeight / 2 - popupHeight / 2
}).fadeIn(200);
}