|
@@ -15,10 +15,10 @@
|
|
|
<body>
|
|
|
|
|
|
<div class="keyWord">
|
|
|
- <p class="title">示例:开发(附加词)</p>
|
|
|
+ <p class="title">示例:运维(排除词)</p>
|
|
|
<!-- 添加附加词 -->
|
|
|
<div class="enter addkeyWord">
|
|
|
- <input type="text" class="enterOne" placeholder="请输入附加词" />
|
|
|
+ <input type="text" class="enterOne" placeholder="请输入排除词" />
|
|
|
<div class="btn">
|
|
|
<button disabled>确认</button>
|
|
|
</div>
|
|
@@ -67,28 +67,42 @@
|
|
|
<script src="{{Msg "seo" "cdn"}}/wx_dataExport/js/zepto.js?v={{Msg "seo" "version"}}"></script>
|
|
|
<script src="{{Msg "seo" "cdn"}}/wx_dataExport/js/weui.min.js?v={{Msg "seo" "version"}}"></script>
|
|
|
<script>
|
|
|
+ var keyWordArr = [];
|
|
|
var excludeArr = [];
|
|
|
- if(localStorage.exclude !== "" && localStorage.exclude !== undefined){
|
|
|
- var exclude = localStorage.exclude.split(",");
|
|
|
- excludeArr = exclude;
|
|
|
+ var url = location.href;
|
|
|
+ var token = decodeURI(url.match(/=.*/)).replace("=", "");
|
|
|
+ //
|
|
|
+ if(localStorage.keyWord !== "" && localStorage.keyWord !== undefined){
|
|
|
+ var keyWord = localStorage.keyWord;
|
|
|
+ keyWordArr = JSON.parse(keyWord);
|
|
|
var html = "";
|
|
|
- for(var i in exclude){
|
|
|
- html +=
|
|
|
- `<li>
|
|
|
+ for(var i in keyWordArr){
|
|
|
+ var keyWords = keyWordArr[i].keyWord;
|
|
|
+ var excludes = keyWordArr[i].exclude;
|
|
|
+ if(keyWords === token){
|
|
|
+ excludeArr = excludes;
|
|
|
+ console.log(excludeArr)
|
|
|
+ if(excludes !== undefined){
|
|
|
+ for(var m in excludes){
|
|
|
+ html +=
|
|
|
+ `<li>
|
|
|
<div class="one">
|
|
|
<div>
|
|
|
<span>
|
|
|
- <p class="key">${ exclude[i] }</p>
|
|
|
+ <p class="key">${ excludes[m] }</p>
|
|
|
</span>
|
|
|
</div>
|
|
|
<button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
</div>
|
|
|
<div class="modify">
|
|
|
- <span contentEditable="true">${ exclude[i] }</span>
|
|
|
+ <span contentEditable="true">${ excludes[m] }</span>
|
|
|
<button class="deleteKey">删除</button>
|
|
|
<button class="ascertainKey">确定</button>
|
|
|
</div>
|
|
|
</li>`
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
$('.showKeyWord > ul').prepend(html);
|
|
|
}
|
|
@@ -96,10 +110,10 @@
|
|
|
|
|
|
$('.knowBtn').on('click',function(){
|
|
|
$(".problemPop").hide()
|
|
|
- })
|
|
|
+ });
|
|
|
$(".problem").on('click',function(){
|
|
|
$(".problemPop").css("display",'flex');
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
function hasWords () {
|
|
|
var showKeyWordLength = $(".showKeyWord ul").find('li').length;
|
|
@@ -111,19 +125,19 @@
|
|
|
$(".showKeyWord").show();
|
|
|
}
|
|
|
}
|
|
|
- hasWords()
|
|
|
+ hasWords();
|
|
|
|
|
|
// 添加按钮
|
|
|
$(".addKeyWord i").on('click',function(){
|
|
|
$(".addkeyWord").show();
|
|
|
$(".showKeyWord").hide();
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
// 添加keyWords检查输入框内是否有文字,如果有才能点击添加按钮
|
|
|
$('.addkeyWord input.enterOne').on('input', function() {
|
|
|
if ($(this).val().length >= 100) {
|
|
|
- var s = $(this).val().slice(0,100)
|
|
|
- $(this).val(s)
|
|
|
+ var s = $(this).val().slice(0,100);
|
|
|
+ $(this).val(s);
|
|
|
|
|
|
weui.toast('附加词不能超过100字', {
|
|
|
duration: 2000,
|
|
@@ -133,78 +147,99 @@
|
|
|
return
|
|
|
}
|
|
|
|
|
|
- var buttonDOM = $(this).siblings().find('button')[0]
|
|
|
+ var buttonDOM = $(this).siblings().find('button')[0];
|
|
|
if ($(this).val().length >= 1) {
|
|
|
- buttonDOM.style.opacity = 1
|
|
|
+ buttonDOM.style.opacity = 1;
|
|
|
buttonDOM.removeAttribute("disabled")
|
|
|
} else {
|
|
|
- buttonDOM.style.opacity = .5
|
|
|
+ buttonDOM.style.opacity = .5;
|
|
|
buttonDOM.setAttribute("disabled", true)
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
// 添加 按钮的点击事件
|
|
|
$('.addkeyWord .btn button').on('click', function(){
|
|
|
- var keyWord = $('.addkeyWord input.enterOne').val()
|
|
|
- excludeArr.push(keyWord);
|
|
|
- localStorage.setItem("exclude", excludeArr);
|
|
|
+ var exclude = $('.addkeyWord input.enterOne').val();
|
|
|
+ if(excludeArr===undefined){
|
|
|
+ excludeArr = [];
|
|
|
+ }
|
|
|
+ excludeArr.push(exclude);
|
|
|
+ for(var i in keyWordArr){
|
|
|
+ if(keyWordArr[i].keyWord === token){
|
|
|
+ keyWordArr[i].exclude = excludeArr
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sessionStorage.exclude = JSON.stringify(excludeArr);
|
|
|
+ localStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
var html = `<li>
|
|
|
<div class="one">
|
|
|
<div>
|
|
|
<span>
|
|
|
- <p class="key">${ keyWord }</p>
|
|
|
+ <p class="key">${ exclude }</p>
|
|
|
</span>
|
|
|
</div>
|
|
|
<button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
</div>
|
|
|
<div class="modify">
|
|
|
- <span contentEditable="true">${ keyWord }</span>
|
|
|
+ <span contentEditable="true">${ exclude }</span>
|
|
|
<button class="deleteKey">删除</button>
|
|
|
<button class="ascertainKey">确定</button>
|
|
|
</div>
|
|
|
- </li>`
|
|
|
- $('.showKeyWord > ul').prepend(html)
|
|
|
+ </li>`;
|
|
|
+ $('.showKeyWord > ul').prepend(html);
|
|
|
|
|
|
// 隐藏
|
|
|
$(".addkeyWord").hide();
|
|
|
$('.showKeyWord').show();
|
|
|
- $('.enter.addkeyWord > input').val('')
|
|
|
- var buttonDOM = $('.enter.addkeyWord .btn button')[0]
|
|
|
- buttonDOM.style.opacity = .5
|
|
|
+ $('.enter.addkeyWord > input').val('');
|
|
|
+ var buttonDOM = $('.enter.addkeyWord .btn button')[0];
|
|
|
+ buttonDOM.style.opacity = .5;
|
|
|
buttonDOM.setAttribute("disabled", true)
|
|
|
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
// 编辑
|
|
|
$(".showKeyWord").on('click', '.editKeyWord',function(e){
|
|
|
$('.modify span').each(function(item){
|
|
|
$('.modify span')[0].contentEditable = true
|
|
|
- })
|
|
|
+ });
|
|
|
// console.log($(this).parent().siblings().find('span').text())
|
|
|
- $(this).parent().hide()
|
|
|
+ $(this).parent().hide();
|
|
|
$(this).parent().siblings().css('display','block')
|
|
|
- })
|
|
|
+ });
|
|
|
|
|
|
// 编辑 删除
|
|
|
$('.showKeyWord').on('click', '.deleteKey', function(e) {
|
|
|
var exclude = $(this).parent().prev().find('.key').text();
|
|
|
excludeArr.splice($.inArray(exclude, excludeArr),1);
|
|
|
- localStorage.exclude = excludeArr.toString();
|
|
|
+ for(var i in keyWordArr){
|
|
|
+ if(keyWordArr[i].keyWord === token){
|
|
|
+ keyWordArr[i].exclude = excludeArr
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sessionStorage.exclude = JSON.stringify(excludeArr);
|
|
|
+ localStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
$(this).parents('li').remove();
|
|
|
hasWords()
|
|
|
// console.log('删除附加词:',$(this).parent().find('span').text())
|
|
|
})
|
|
|
// 编辑 确定
|
|
|
$('.showKeyWord').on('click', '.ascertainKey', function(e) {
|
|
|
- var keyWord = $(this).siblings('span').text();
|
|
|
- var exclude = $(this).parent().prev().find('.key').text();
|
|
|
+ var exclude = $(this).siblings('span').text();
|
|
|
+ var excludes = $(this).parent().prev().find('.key').text();
|
|
|
for(var i in excludeArr){
|
|
|
- if(excludeArr[i] === exclude){
|
|
|
- excludeArr[i] = keyWord;
|
|
|
+ if(excludeArr[i] === excludes){
|
|
|
+ excludeArr[i] = exclude;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for(var m in keyWordArr){
|
|
|
+ if(keyWordArr[m].keyWord === token){
|
|
|
+ keyWordArr[m].exclude = excludeArr
|
|
|
}
|
|
|
}
|
|
|
- localStorage.exclude = excludeArr.toString();
|
|
|
- $(this).parent().siblings().find('.key').text(keyWord)
|
|
|
+ sessionStorage.exclude = JSON.stringify(excludeArr);
|
|
|
+ localStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
+ $(this).parent().siblings().find('.key').text(exclude);
|
|
|
$(this).parent().hide().siblings().show()
|
|
|
})
|
|
|
|