|
|
@ -43,7 +43,14 @@ function add(type) { |
|
|
|
if (content == null) { |
|
|
|
return; |
|
|
|
} |
|
|
|
submit(content, 'text'); |
|
|
|
if (CHECK_URL(content)) { |
|
|
|
console.log(content); |
|
|
|
submit(content, 'url'); |
|
|
|
} |
|
|
|
else { |
|
|
|
submit(content, 'text'); |
|
|
|
} |
|
|
|
|
|
|
|
page.content = null; |
|
|
|
return; |
|
|
|
} |
|
|
@ -67,7 +74,6 @@ function submit(content, type,order) { |
|
|
|
var data = new FormData(); |
|
|
|
data.append("content", content); |
|
|
|
data.append('type', type); |
|
|
|
data.append('order', order); |
|
|
|
sendRequest(url,data,function () { |
|
|
|
getContent('block'); |
|
|
|
}) |
|
|
@ -81,6 +87,9 @@ function getContent(type) { |
|
|
|
if ("undefined" != typeof phonenum) { |
|
|
|
data.append('phonenum',phonenum); |
|
|
|
} |
|
|
|
if (page.id != null) { |
|
|
|
data.append('id', page.id); |
|
|
|
} |
|
|
|
|
|
|
|
var name = $("#search").val(); |
|
|
|
if(name != ""){ |
|
|
@ -89,9 +98,11 @@ function getContent(type) { |
|
|
|
sendRequest(url, data, function (data) { |
|
|
|
if (type == 'collection') { |
|
|
|
page.textList = data.collections; |
|
|
|
checkLike(); |
|
|
|
} |
|
|
|
else { |
|
|
|
page.textList = data.blocks; |
|
|
|
getWebName(); |
|
|
|
} |
|
|
|
for (i in page.textList) { |
|
|
|
page.textList[i]['order'] = i; |
|
|
@ -100,10 +111,29 @@ function getContent(type) { |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
checkLike(); |
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
async function getWebName() { |
|
|
|
for (i in page.textList) { |
|
|
|
(function (i) { |
|
|
|
var dt = new FormData(); |
|
|
|
var obj = page.textList[i]; |
|
|
|
if (obj['type'] != 'url') { |
|
|
|
continue; |
|
|
|
} |
|
|
|
dt.append('url', obj['content']); |
|
|
|
sendRequest('block/get_web_name', dt, function (data) { |
|
|
|
obj['content'] = data.name; |
|
|
|
Vue.set(page.textList, obj['order'], obj); |
|
|
|
}); |
|
|
|
})(i); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
async function checkLike() { |
|
|
|
for (i in page.textList) { |
|
|
|
(function (i) { |
|
|
@ -158,29 +188,28 @@ var page = new Vue({ |
|
|
|
var data = new FormData(); |
|
|
|
data.append("new_order", pos); |
|
|
|
data.append("id", obj.id); |
|
|
|
if (type == "block";) { |
|
|
|
sendRequest(url, data, getBlock); |
|
|
|
if (type == 'block';) { |
|
|
|
data.append('collection_id', page.id); |
|
|
|
} |
|
|
|
else{ |
|
|
|
sendRequest(url, data, getCollection); |
|
|
|
} |
|
|
|
|
|
|
|
sendRequest(url, data, getContent(type)); |
|
|
|
}, |
|
|
|
delete_item: function(order,type) { |
|
|
|
var url; |
|
|
|
var url = type+'/delete'; |
|
|
|
var data = new FormData(); |
|
|
|
data.append("collection_id", this.id); |
|
|
|
console.log(order); |
|
|
|
if (type == "block") { |
|
|
|
data.append("block_id", this.textList[order]['id']); |
|
|
|
url = "block/delete"; |
|
|
|
} |
|
|
|
else { |
|
|
|
url = "collection/delete"; |
|
|
|
} |
|
|
|
this.textList.splice(this.textList[order], 1); |
|
|
|
sendRequest(url, data, function () { ;}); |
|
|
|
|
|
|
|
for (i in page.textList) { |
|
|
|
page.textList[i]['order'] = i; |
|
|
|
if (type == 'block' && page.textList[i]['type'] == 'picture') { |
|
|
|
page.textList[i]['content'] = get_url(page.textList[i]['content']); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}, |
|
|
|
jump_to: function (url,block_name,collection_id) { |
|
|
|
window.location.href = url+"?name="+block_name+"&id="+collection_id; |
|
|
@ -191,6 +220,8 @@ var page = new Vue({ |
|
|
|
var url = type + '/update'; |
|
|
|
var data = new FormData(); |
|
|
|
if (type == 'collection') { |
|
|
|
data.append('collection_id', obj['id']); |
|
|
|
|
|
|
|
if (this.name != null) { |
|
|
|
obj['name'] = this.name; |
|
|
|
data.append('name', this.name); |
|
|
@ -201,6 +232,8 @@ var page = new Vue({ |
|
|
|
} |
|
|
|
} |
|
|
|
else { |
|
|
|
data.append('collection_id', this.id); |
|
|
|
data.append('block_id', obj['id']); |
|
|
|
if (this.content != null) { |
|
|
|
obj['content'] = this.content; |
|
|
|
data.append('content', this.content); |
|
|
@ -238,3 +271,28 @@ var page = new Vue({ |
|
|
|
} |
|
|
|
} |
|
|
|
) |
|
|
|
|
|
|
|
function CHECK_URL(url){ |
|
|
|
//url= 协议://(ftp的登录信息)[IP|域名](:端口号)(/或?请求参数)
|
|
|
|
var strRegex = '^((https|http|ftp)://)?'//(https或http或ftp):// 可有可无
|
|
|
|
+ '(([\\w_!~*\'()\\.&=+$%-]+: )?[\\w_!~*\'()\\.&=+$%-]+@)?' //ftp的user@ 可有可无
|
|
|
|
+ '(([0-9]{1,3}\\.){3}[0-9]{1,3}' // IP形式的URL- 3位数字.3位数字.3位数字.3位数字
|
|
|
|
+ '|' // 允许IP和DOMAIN(域名)
|
|
|
|
+ '(localhost)|' //匹配localhost
|
|
|
|
+ '([\\w_!~*\'()-]+\\.)*' // 域名- 至少一个[英文或数字_!~*\'()-]加上.
|
|
|
|
+ '\\w+\\.' // 一级域名 -英文或数字 加上.
|
|
|
|
+ '[a-zA-Z]{1,6})' // 顶级域名- 1-6位英文
|
|
|
|
+ '(:[0-9]{1,5})?' // 端口- :80 ,1-5位数字
|
|
|
|
+ '((/?)|' // url无参数结尾 - 斜杆或这没有
|
|
|
|
+ '(/[\\w_!~*\'()\\.;?:@&=+$,%#-]+)+/?)$';//请求参数结尾- 英文或数字和[]内的各种字符
|
|
|
|
|
|
|
|
var strRegex1 = '^(?=^.{3,255}$)((http|https|ftp)?:\/\/)?(www\.)?[a-zA-Z0-9][-a-zA-Z0-9]{0,62}(\.[a-zA-Z0-9][-a-zA-Z0-9]{0,62})+(:\d+)*(\/)?(?:\/(.+)\/?$)?(\/\w+\.\w+)*([\?&]\w+=\w*|[\u4e00-\u9fa5]+)*$'; |
|
|
|
var re=new RegExp(strRegex,'i');//i不区分大小写
|
|
|
|
console.log(re); |
|
|
|
//将url做uri转码后再匹配,解除请求参数中的中文和空字符影响
|
|
|
|
if (re.test(encodeURI(url))) { |
|
|
|
return (true); |
|
|
|
} else { |
|
|
|
return (false); |
|
|
|
} |
|
|
|
} |