|
@@ -23,7 +23,7 @@ $(function(){
|
|
|
}
|
|
|
}
|
|
|
hasWords();
|
|
|
-
|
|
|
+
|
|
|
//添加按钮
|
|
|
$(".addKeyWord i").on('click',function(){
|
|
|
sessionStorage.removeItem("keyWord");
|
|
@@ -32,6 +32,7 @@ $(function(){
|
|
|
|
|
|
// 添加keyWords检查输入框内是否有文字,如果有才能点击添加按钮
|
|
|
$('.addkeyWord input.enterOne').on('input', function() {
|
|
|
+ var buttonDOM = $(this).siblings()[1].children[0];
|
|
|
if ($(this).val().length >= 20) {
|
|
|
var s = $(this).val().slice(0,19);
|
|
|
$(this).val(s)
|
|
@@ -41,10 +42,8 @@ $(function(){
|
|
|
className: 'text-overflow100',
|
|
|
callback: function(){ console.log('close') }
|
|
|
});
|
|
|
- return
|
|
|
}
|
|
|
|
|
|
- var buttonDOM = $(this).siblings()[1].children[0];
|
|
|
if ($(this).val().length >= 1) {
|
|
|
buttonDOM.style.opacity = 1;
|
|
|
buttonDOM.removeAttribute("disabled");
|
|
@@ -59,7 +58,7 @@ $(function(){
|
|
|
$(this).next().find(".exclude").prop("disabled", true);
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+
|
|
|
// $('.exclusion input.enterOne').on('input', function() {
|
|
|
// var buttonDOM = $(this).siblings().find('button')[0]
|
|
|
// if ($(this).val().length >= 1) {
|
|
@@ -70,42 +69,165 @@ $(function(){
|
|
|
// buttonDOM.setAttribute("disabled", true)
|
|
|
// }
|
|
|
// })
|
|
|
-
|
|
|
+
|
|
|
// 添加 按钮的点击事件
|
|
|
$('.addkeyWord .btn .save').on('click', function(){
|
|
|
var keyWord = $('.addkeyWord input.enterOne').val();
|
|
|
+ var keyWordHtml = "";
|
|
|
+ var html = `
|
|
|
+ <li>
|
|
|
+ <div class="one">
|
|
|
+ <div>
|
|
|
+ <span>
|
|
|
+ <strong> 关键词:</strong>
|
|
|
+ <p class="key">${ keyWord }</p>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
+ </div>
|
|
|
+ <div class="modify">
|
|
|
+ <span class="ios-user-select" contentEditable="true">${ keyWord }</span>
|
|
|
+ <button class="addAdjunctWord">编辑 附加词</button>
|
|
|
+ <button class="addExclusion">添加 排除词</button>
|
|
|
+ <button class="deleteKey">删除</button>
|
|
|
+ <button class="ascertainKey">确定</button>
|
|
|
+ </div>
|
|
|
+ </li>`;
|
|
|
+ if(sessionStorage.keyWord!==""&&sessionStorage.keyWord!==undefined){
|
|
|
+ var keys = JSON.parse(sessionStorage.keyWord);
|
|
|
+ for(var i in keys){
|
|
|
+ var append = keys[i].appended;
|
|
|
+ var exclude = keys[i].exclude;
|
|
|
+ if(keys[i].keyWord === keyWord){
|
|
|
+ keyWordArr.push(keys[i]);
|
|
|
+ localStorage.setItem("keyWord", JSON.stringify(keyWordArr));
|
|
|
+ //
|
|
|
+ if(append !== undefined && exclude === undefined){
|
|
|
+ keyWordHtml += `
|
|
|
+ <li>
|
|
|
+ <div class="one">
|
|
|
+ <div>
|
|
|
+ <span>
|
|
|
+ <strong> 关键词:</strong>
|
|
|
+ <p class="key">${ keys[i].keyWord }</p>
|
|
|
+ </span>
|
|
|
+ <span>
|
|
|
+ <strong> 附加词:</strong>
|
|
|
+ <p class="addition">${ append }</p>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
+ </div>
|
|
|
+ <div class="modify">
|
|
|
+ <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
|
|
|
+ <button class="addAdjunctWord">编辑 附加词</button>
|
|
|
+ <button class="addExclusion">添加 排除词</button>
|
|
|
+ <button class="deleteKey">删除</button>
|
|
|
+ <button class="ascertainKey">确定</button>
|
|
|
+ </div>
|
|
|
+ </li>`;
|
|
|
+ }else if(append === undefined && exclude !== undefined){
|
|
|
+ keyWordHtml += `
|
|
|
+ <li>
|
|
|
+ <div class="one">
|
|
|
+ <div>
|
|
|
+ <span>
|
|
|
+ <strong> 关键词:</strong>
|
|
|
+ <p class="key">${ keys[i].keyWord }</p>
|
|
|
+ </span>
|
|
|
+ <span>
|
|
|
+ <strong> 排除词:</strong>
|
|
|
+ <p class="exclusion">${ exclude }</p>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
+ </div>
|
|
|
+ <div class="modify">
|
|
|
+ <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
|
|
|
+ <button class="addAdjunctWord">编辑 附加词</button>
|
|
|
+ <button class="addExclusion">添加 排除词</button>
|
|
|
+ <button class="deleteKey">删除</button>
|
|
|
+ <button class="ascertainKey">确定</button>
|
|
|
+ </div>
|
|
|
+ </li>`;
|
|
|
+ }else if(append !== undefined && exclude !== undefined){
|
|
|
+ keyWordHtml += `
|
|
|
+ <li>
|
|
|
+ <div class="one">
|
|
|
+ <div>
|
|
|
+ <span>
|
|
|
+ <strong> 关键词:</strong>
|
|
|
+ <p class="key">${ keys[i].keyWord }</p>
|
|
|
+ </span>
|
|
|
+ <span>
|
|
|
+ <strong> 附加词:</strong>
|
|
|
+ <p class="addition">${ append }</p>
|
|
|
+ </span>
|
|
|
+ <span>
|
|
|
+ <strong> 排除词:</strong>
|
|
|
+ <p class="exclusion">${ exclude }</p>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
+ </div>
|
|
|
+ <div class="modify">
|
|
|
+ <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
|
|
|
+ <button class="addAdjunctWord">编辑 附加词</button>
|
|
|
+ <button class="addExclusion">添加 排除词</button>
|
|
|
+ <button class="deleteKey">删除</button>
|
|
|
+ <button class="ascertainKey">确定</button>
|
|
|
+ </div>
|
|
|
+ </li>`;
|
|
|
+ }else if(append === undefined && exclude === undefined){
|
|
|
+ keyWordHtml += `
|
|
|
+ <li>
|
|
|
+ <div class="one">
|
|
|
+ <div>
|
|
|
+ <span>
|
|
|
+ <strong> 关键词:</strong>
|
|
|
+ <p class="key">${ keys[i].keyWord }</p>
|
|
|
+ </span>
|
|
|
+ </div>
|
|
|
+ <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
+ </div>
|
|
|
+ <div class="modify">
|
|
|
+ <span class="ios-user-select" contentEditable="true">${ keys[i].keyWord }</span>
|
|
|
+ <button class="addAdjunctWord">编辑 附加词</button>
|
|
|
+ <button class="addExclusion">添加 排除词</button>
|
|
|
+ <button class="deleteKey">删除</button>
|
|
|
+ <button class="ascertainKey">确定</button>
|
|
|
+ </div>
|
|
|
+ </li>`;
|
|
|
+ }
|
|
|
+ keyWordHtml = keyWordHtml.replace(/,/g, " ");
|
|
|
+ //
|
|
|
+ $('.showKeyWord > ul').prepend(keyWordHtml);
|
|
|
+ // 隐藏
|
|
|
+ $(".enter.addkeyWord").hide();
|
|
|
+ $(".showKeyWord").show();
|
|
|
+ $(".addKeyWord").show();
|
|
|
+ $('.enter.addkeyWord > input').val('');
|
|
|
+ var buttonDOM = $('.enter.addkeyWord .btn button')[0];
|
|
|
+ buttonDOM.style.opacity = .5;
|
|
|
+ buttonDOM.setAttribute("disabled", true);
|
|
|
+ return
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
var Obj = {"keyWord": keyWord};
|
|
|
keyWordArr.push(Obj);
|
|
|
localStorage.setItem("keyWord", JSON.stringify(keyWordArr));
|
|
|
- var html = `<li>
|
|
|
- <div class="one">
|
|
|
- <div>
|
|
|
- <span>
|
|
|
- <strong> 关键词:</strong>
|
|
|
- <p class="key">${ keyWord }</p>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
- </div>
|
|
|
- <div class="modify">
|
|
|
- <span contentEditable="true">${ keyWord }</span>
|
|
|
- <button class="addAdjunctWord">编辑 附加词</button>
|
|
|
- <button class="addExclusion">添加 排除词</button>
|
|
|
- <button class="deleteKey">删除</button>
|
|
|
- <button class="ascertainKey">确定</button>
|
|
|
- </div>
|
|
|
- </li>`
|
|
|
$('.showKeyWord > ul').prepend(html);
|
|
|
-
|
|
|
// 隐藏
|
|
|
$(".enter.addkeyWord").hide();
|
|
|
$(".showKeyWord").show();
|
|
|
$(".addKeyWord").show();
|
|
|
- $('.enter.addkeyWord > input').val('')
|
|
|
- var buttonDOM = $('.enter.addkeyWord .btn button')[0]
|
|
|
- buttonDOM.style.opacity = .5
|
|
|
- buttonDOM.setAttribute("disabled", true)
|
|
|
- })
|
|
|
+ $('.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){
|
|
@@ -143,7 +265,8 @@ $(function(){
|
|
|
}
|
|
|
}
|
|
|
$(this).parent().hide();
|
|
|
- $(this).parent().siblings().css('display','block')
|
|
|
+ $(this).parent().siblings().css('display','block');
|
|
|
+ $(".addKeyWord").hide();
|
|
|
});
|
|
|
|
|
|
// 编辑删除
|
|
@@ -163,6 +286,8 @@ $(function(){
|
|
|
keyWordArr = keyWordArr.filter((e=>{return e.keyWord!==keyWord}));
|
|
|
localStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
jQueryDOM.remove();
|
|
|
+ sessionStorage.removeItem("keyWord");
|
|
|
+ $(".addKeyWord").show();
|
|
|
hasWords()
|
|
|
}
|
|
|
}]
|
|
@@ -204,12 +329,13 @@ $(function(){
|
|
|
$this.parent().siblings().find('.key').text(keyWord)
|
|
|
$this.parent().hide().siblings().show()
|
|
|
}
|
|
|
+ $(".addKeyWord").show();
|
|
|
})
|
|
|
|
|
|
//去空格方法
|
|
|
String.prototype.trim = function(){
|
|
|
return this.replace(/(^\s*)|(\s*$)/g, ' ');
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
//关键词个数
|
|
|
$('.modify span').keydown(function(){
|
|
@@ -244,5 +370,4 @@ $(function(){
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
})
|