|
@@ -128,33 +128,6 @@
|
|
|
tokens = token;
|
|
|
}else{
|
|
|
tokens = token.split("_")[0];
|
|
|
- window.onload = function(){
|
|
|
- backListen();
|
|
|
- };
|
|
|
- // 监听浏览器回退事件
|
|
|
- function backListen () {
|
|
|
- if (window.history && window.history.pushState) {
|
|
|
- $(window).on('popstate', function () { // 点击后退会触发popstate事件
|
|
|
- var hashLocation = location.hash; // 获取点击后的页面的hash值
|
|
|
- var hashSplit = hashLocation.split("#!/"); // 将哈希值装进数组(这里可以在控制台打印看效果)
|
|
|
- var hashName = hashSplit[1]; // 取数组的第一个
|
|
|
-
|
|
|
- // 点击后的页面哈希值与上一个页面不同,借助这个区别可以判断是否离开了页面,从而做一些操作
|
|
|
- if (hashName !== '') {
|
|
|
- var hash = window.location.hash;
|
|
|
- if (hash === '') { // 如果当前页面没有哈希值
|
|
|
-
|
|
|
- sessionStorage.removeItem("flag"); // 这里我做了清除sessionStorage的操作
|
|
|
-
|
|
|
- // 强行回退一步,就不用多点一次了😎
|
|
|
- history.go(-1); // 直接跳过没有哈希值的页面,就不会出现要点两次才能回到真正的上一页了
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- // 将含有哈希值的页面,强行插入浏览器历史记录中,此时相当于该页面有两个url在历史记录中,一个是有hash的,一个是没有hash的。
|
|
|
- window.history.pushState('forward', null, '#');
|
|
|
- }
|
|
|
- }
|
|
|
}
|
|
|
//
|
|
|
if(sessionStorage.keyWord!==undefined && sessionStorage.keyWord!==""){
|
|
@@ -170,25 +143,27 @@
|
|
|
for(var y in appendedArr){
|
|
|
shtml +=
|
|
|
`<li>
|
|
|
- <div class="one">
|
|
|
- <div>
|
|
|
- <span>
|
|
|
- <p class="key">${ appendedArr[y] }</p>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
- </div>
|
|
|
- <div class="modify">
|
|
|
- <span class="ios-user-select" contentEditable="true">${ appendedArr[y] }</span>
|
|
|
- <button class="deleteKey">删除</button>
|
|
|
- <button class="ascertainKey">确定</button>
|
|
|
+ <div class="one">
|
|
|
+ <div>
|
|
|
+ <span>
|
|
|
+ <p class="key">${ appendedArr[y] }</p>
|
|
|
+ </span>
|
|
|
</div>
|
|
|
- </li>`
|
|
|
+ <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
+ </div>
|
|
|
+ <div class="modify">
|
|
|
+ <span class="ios-user-select" contentEditable="true">${ appendedArr[y] }</span>
|
|
|
+ <button class="deleteKey">删除</button>
|
|
|
+ <button class="ascertainKey">确定</button>
|
|
|
+ </div>
|
|
|
+ </li>`
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
$('.showKeyWord > ul').prepend(shtml);
|
|
|
+ $(".enter.addKeyWord").hide();
|
|
|
+ $(".showKeyWord").show();
|
|
|
}else{
|
|
|
if(localStorage.keyWord !== "" && localStorage.keyWord !== undefined){
|
|
|
var keyWord = localStorage.keyWord;
|
|
@@ -203,20 +178,20 @@
|
|
|
for(var m in appendeds){
|
|
|
html +=
|
|
|
`<li>
|
|
|
- <div class="one">
|
|
|
- <div>
|
|
|
- <span>
|
|
|
- <p class="key">${ appendeds[m] }</p>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
- </div>
|
|
|
- <div class="modify">
|
|
|
- <span contentEditable="true">${ appendeds[m] }</span>
|
|
|
- <button class="deleteKey">删除</button>
|
|
|
- <button class="ascertainKey">确定</button>
|
|
|
+ <div class="one">
|
|
|
+ <div>
|
|
|
+ <span>
|
|
|
+ <p class="key">${ appendeds[m] }</p>
|
|
|
+ </span>
|
|
|
</div>
|
|
|
- </li>`
|
|
|
+ <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
+ </div>
|
|
|
+ <div class="modify">
|
|
|
+ <span contentEditable="true">${ appendeds[m] }</span>
|
|
|
+ <button class="deleteKey">删除</button>
|
|
|
+ <button class="ascertainKey">确定</button>
|
|
|
+ </div>
|
|
|
+ </li>`
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -251,8 +226,12 @@
|
|
|
// 添加按钮
|
|
|
$(".addKeyWord i").on('click',function(){
|
|
|
var keyWord = tokens;
|
|
|
- sessionStorage.removeItem("keyWord");
|
|
|
- window.location.href="/jyapp/front/dataExport/appendedInput?keyWord="+keyWord;
|
|
|
+ // sessionStorage.removeItem("keyWord");
|
|
|
+ if(token.indexOf("_in")===-1){
|
|
|
+ window.location.href="/front/wx_dataExport/appendedInput?keyWord="+keyWord;
|
|
|
+ }else{
|
|
|
+ window.location.href="/front/wx_dataExport/appendedInput?keyWord="+keyWord+"_in";
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
// 添加keyWords检查输入框内是否有文字,如果有才能点击添加按钮
|
|
@@ -280,7 +259,7 @@
|
|
|
});
|
|
|
|
|
|
// 添加 按钮的点击事件
|
|
|
- $('.addkeyWord .btn .save').on('click', function(){
|
|
|
+ $('.addkeyWord .btn button').on('click', function(){
|
|
|
var appended = $('.addkeyWord input.enterOne').val();
|
|
|
if(appendedArr===undefined){
|
|
|
appendedArr = [];
|
|
@@ -308,22 +287,22 @@
|
|
|
}
|
|
|
}
|
|
|
sessionStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
- localStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
+ // localStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
var html = `<li>
|
|
|
- <div class="one">
|
|
|
- <div>
|
|
|
- <span>
|
|
|
- <p class="key">${ appended }</p>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
- </div>
|
|
|
- <div class="modify">
|
|
|
- <span contentEditable="true">${ appended }</span>
|
|
|
- <button class="deleteKey">删除</button>
|
|
|
- <button class="ascertainKey">确定</button>
|
|
|
+ <div class="one">
|
|
|
+ <div>
|
|
|
+ <span>
|
|
|
+ <p class="key">${ appended }</p>
|
|
|
+ </span>
|
|
|
</div>
|
|
|
- </li>`;
|
|
|
+ <button class="editKeyWord"><i class="iconfont icon-xiugai"></i> 修改</button>
|
|
|
+ </div>
|
|
|
+ <div class="modify">
|
|
|
+ <span contentEditable="true">${ appended }</span>
|
|
|
+ <button class="deleteKey">删除</button>
|
|
|
+ <button class="ascertainKey">确定</button>
|
|
|
+ </div>
|
|
|
+ </li>`;
|
|
|
$('.showKeyWord > ul').prepend(html);
|
|
|
|
|
|
// 隐藏
|
|
@@ -335,6 +314,7 @@
|
|
|
buttonDOM.style.opacity = .5;
|
|
|
buttonDOM.setAttribute("disabled", true)
|
|
|
});
|
|
|
+
|
|
|
// 编辑
|
|
|
$(".showKeyWord").on('click', '.editKeyWord',function(e){
|
|
|
$('.modify span').each(function(item){
|
|
@@ -344,6 +324,8 @@
|
|
|
// console.log($(this).parent().siblings().find('span').text())
|
|
|
$(this).parent().hide();
|
|
|
$(this).parent().siblings().css('display','block')
|
|
|
+ //
|
|
|
+ $(".addKeyWord").hide();
|
|
|
});
|
|
|
|
|
|
// 编辑 删除
|
|
@@ -356,9 +338,10 @@
|
|
|
}
|
|
|
}
|
|
|
sessionStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
- localStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
+ // localStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
$(this).parents('li').remove();
|
|
|
- hasWords()
|
|
|
+ $(".addKeyWord").show();
|
|
|
+ hasWords();
|
|
|
// console.log('删除附加词:',$(this).parent().find('span').text())
|
|
|
});
|
|
|
// 编辑 确定
|
|
@@ -375,14 +358,13 @@
|
|
|
}
|
|
|
});
|
|
|
return
|
|
|
- }else if(appended.length >= 20){
|
|
|
- var s = $(this).siblings('span').text().slice(0,19);
|
|
|
- $(this).siblings('span').text(s);
|
|
|
-
|
|
|
+ }else if($(this).parent().find("span").text().length >= 20){
|
|
|
+ var s = $(this).parent().find("span").text().slice(0,19);
|
|
|
+ $(this).parent().find("span").text(s);
|
|
|
weui.toast('附加词不能超过20字', {
|
|
|
duration: 2000,
|
|
|
className: 'text-overflow100',
|
|
|
- callback: function(){ console.log('close') }
|
|
|
+ callback: function(){}
|
|
|
});
|
|
|
return
|
|
|
}else{
|
|
@@ -397,10 +379,12 @@
|
|
|
}
|
|
|
}
|
|
|
sessionStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
- localStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
+ // localStorage.keyWord = JSON.stringify(keyWordArr);
|
|
|
$(this).parent().siblings().find('.key').text(appended);
|
|
|
$(this).parent().hide().siblings().show()
|
|
|
}
|
|
|
+ //
|
|
|
+ $(".addKeyWord").show();
|
|
|
});
|
|
|
|
|
|
//去空格方法
|
|
@@ -412,11 +396,11 @@
|
|
|
$('.modify span').keydown(function(){
|
|
|
var olength = $(this).text().replace(/\s+/g,'').length;
|
|
|
// console.log(olength)
|
|
|
- if(olength >= 100){
|
|
|
+ if(olength >= 20){
|
|
|
$('.fontLength').show();
|
|
|
- var s = $(this).text().slice(0,100);
|
|
|
+ var s = $(this).text().slice(0,19);
|
|
|
$(this).text(s);
|
|
|
- weui.toast('附加词不能超过100字', {
|
|
|
+ weui.toast('附加词不能超过20字', {
|
|
|
duration: 2000,
|
|
|
className: 'text-overflow100',
|
|
|
callback: function(){ console.log('close') }
|
|
@@ -427,9 +411,6 @@
|
|
|
$('.addkeyWord .btn .close').on('click', function () {
|
|
|
window.history.back();
|
|
|
});
|
|
|
- $(".app-back").on("click", function () {
|
|
|
- history.back();
|
|
|
- });
|
|
|
function keepLastIndex(obj) {
|
|
|
if (window.getSelection) {//ie11 10 9 ff safari
|
|
|
obj.focus(); //解决ff不获取焦点无法定位问题
|
|
@@ -444,7 +425,10 @@
|
|
|
range.select();
|
|
|
}
|
|
|
}
|
|
|
- })
|
|
|
+ });
|
|
|
+ $(".app-back").on("click", function () {
|
|
|
+ history.back();
|
|
|
+ });
|
|
|
|
|
|
</script>
|
|
|
</body>
|