From 7106eab177cb474817da33374fc23900b1ffc5a1 Mon Sep 17 00:00:00 2001
From: taoshihan1991 <630892807@qq.com>
Date: Mon, 28 Sep 2020 13:52:10 +0800
Subject: [PATCH] =?UTF-8?q?=E5=BC=95=E5=85=A5=E6=A8=A1=E5=BC=8F=E7=AE=80?=
=?UTF-8?q?=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
static/html/index.html | 9 +--
static/html/setting_deploy.html | 13 +---
static/js/gofly-front.js | 103 ++++++++++++++++++++++++--------
3 files changed, 82 insertions(+), 43 deletions(-)
diff --git a/static/html/index.html b/static/html/index.html
index f52a49c..87c23f4 100644
--- a/static/html/index.html
+++ b/static/html/index.html
@@ -165,17 +165,10 @@
-
-
-
-
diff --git a/static/html/setting_deploy.html b/static/html/setting_deploy.html
index 04f0650..f1c444f 100644
--- a/static/html/setting_deploy.html
+++ b/static/html/setting_deploy.html
@@ -6,19 +6,12 @@
-
+
diff --git a/static/js/gofly-front.js b/static/js/gofly-front.js
index 4839da5..03324b2 100644
--- a/static/js/gofly-front.js
+++ b/static/js/gofly-front.js
@@ -1,34 +1,86 @@
var launchButtonFlag=false;
-$("#launchButton").click(function() {
- if (launchButtonFlag) return;
- var width=$(window).width();
- if(width<768){
- window.open(GOFLY_URL+'/chatIndex?kefu_id='+GOFLY_KEFU_ID+'&refer='+window.document.title);
- return;
- }
- layer.open({
- type: 2,
- title: "Chat with me",
- closeBtn: 1, //不显示关闭按钮
- shade: [0],
- area: ['520px', '530px'],
- offset: 'rb', //右下角弹出
- anim: 2,
- content: [GOFLY_URL+'/chatIndex?kefu_id='+GOFLY_KEFU_ID+'&refer='+window.document.title, 'yes'], //iframe的url,no代表不显示滚动条
- end: function(){
- launchButtonFlag=false;
- $(".launchButton").show();
+var titleTimer,titleNum=0;
+var originTitle = document.title;
+if (typeof GOFLY_URL=="undefined"){
+ var GOFLY_URL="https://gofly.sopans.com";
+}
+if (typeof GOFLY_KEFU_ID=="undefined"){
+ var GOFLY_KEFU_ID="";
+}
+if (typeof GOFLY_BTN_TEXT=="undefined"){
+ var GOFLY_BTN_TEXT="Chat with me";
+}
+dynamicLoadCss(GOFLY_URL+"/static/css/gofly-front.css");
+if (typeof $!="function"){
+ dynamicLoadJs("https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js",function () {
+ dynamicLoadJs("https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js",function () {
+ clickBtn();
+ });
+ });
+}else{
+ dynamicLoadJs("https://cdn.bootcdn.net/ajax/libs/layer/3.1.1/layer.min.js",function () {
+ clickBtn();
+ });
+}
+
+function clickBtn(){
+ $('body').append('');
+ $("#launchButton").on("click",function() {
+ if (launchButtonFlag) return;
+ var width=$(window).width();
+ if(width<768){
+ window.open(GOFLY_URL+'/chatIndex?kefu_id='+GOFLY_KEFU_ID+'&refer='+window.document.title);
+ return;
}
+ layer.open({
+ type: 2,
+ title: GOFLY_BTN_TEXT,
+ closeBtn: 1, //不显示关闭按钮
+ shade: [0],
+ area: ['520px', '530px'],
+ offset: 'rb', //右下角弹出
+ anim: 2,
+ content: [GOFLY_URL+'/chatIndex?kefu_id='+GOFLY_KEFU_ID+'&refer='+window.document.title, 'yes'], //iframe的url,no代表不显示滚动条
+ end: function(){
+ launchButtonFlag=false;
+ $(".launchButton").show();
+ }
+ });
+ launchButtonFlag=true;
+ $(".launchButton").hide();
});
- launchButtonFlag=true;
- $(".launchButton").hide();
-});
+ $("body").click(function () {
+ clearTimeout(titleTimer);
+ document.title = originTitle;
+ });
+}
+function dynamicLoadCss(url) {
+ var head = document.getElementsByTagName('head')[0];
+ var link = document.createElement('link');
+ link.type='text/css';
+ link.rel = 'stylesheet';
+ link.href = url;
+ head.appendChild(link);
+}
+function dynamicLoadJs(url, callback) {
+ var head = document.getElementsByTagName('head')[0];
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.src = url;
+ if(typeof(callback)=='function'){
+ script.onload = script.onreadystatechange = function () {
+ if (!this.readyState || this.readyState === "loaded" || this.readyState === "complete"){
+ callback();
+ script.onload = script.onreadystatechange = null;
+ }
+ };
+ }
+ head.appendChild(script);
+}
-var titleTimer,titleNum=0;
-var originTitle = document.title;
function flashTitle() {
titleNum++;
- if (titleNum == 3) {
+ if (titleNum >=3) {
titleNum = 1;
}
if (titleNum == 1) {
@@ -49,3 +101,4 @@ window.onfocus = function () {
clearTimeout(titleTimer);
document.title = originTitle;
};
+