Showing
2 changed files
with
13 additions
and
12 deletions
@@ -44,6 +44,7 @@ var $clearHistory = $('#clear-history'); | @@ -44,6 +44,7 @@ var $clearHistory = $('#clear-history'); | ||
44 | var writeSearch = require('./write-search'); | 44 | var writeSearch = require('./write-search'); |
45 | 45 | ||
46 | var ranToken = writeSearch.getRanToken(); | 46 | var ranToken = writeSearch.getRanToken(); |
47 | +var ranToken2 = writeSearch.getRanToken2(); | ||
47 | 48 | ||
48 | var chHammer; | 49 | var chHammer; |
49 | 50 | ||
@@ -339,7 +340,8 @@ if ($('.brand-search-page').length > 0) { | @@ -339,7 +340,8 @@ if ($('.brand-search-page').length > 0) { | ||
339 | var html = '', | 340 | var html = '', |
340 | history, | 341 | history, |
341 | historys, i, | 342 | historys, i, |
342 | - brand, url, locate; | 343 | + localHistory, |
344 | + brand,url; | ||
343 | 345 | ||
344 | if (localStorage) { | 346 | if (localStorage) { |
345 | historys = localStorage.getItem('historys-brand'); | 347 | historys = localStorage.getItem('historys-brand'); |
@@ -352,17 +354,10 @@ if ($('.brand-search-page').length > 0) { | @@ -352,17 +354,10 @@ if ($('.brand-search-page').length > 0) { | ||
352 | if (history === '') { | 354 | if (history === '') { |
353 | continue; | 355 | continue; |
354 | } | 356 | } |
355 | - locate = history.indexOf('http://'); | ||
356 | - | ||
357 | - if (locate === -1) { | ||
358 | - brand = history; | ||
359 | - url = ''; | ||
360 | - } else { | ||
361 | - brand = history.substr(0, locate); | ||
362 | - url = history.substr(locate, history.length - locate); | ||
363 | - } | ||
364 | - | 357 | + localHistory = history.split(ranToken2); |
365 | 358 | ||
359 | + brand = localHistory[0]; | ||
360 | + url = localHistory[1]; | ||
366 | 361 | ||
367 | html += '<li><a href="' + url + '">' + brand + '</li>'; | 362 | html += '<li><a href="' + url + '">' + brand + '</li>'; |
368 | $historySearch.removeClass('hide'); | 363 | $historySearch.removeClass('hide'); |
@@ -5,6 +5,7 @@ | @@ -5,6 +5,7 @@ | ||
5 | */ | 5 | */ |
6 | 6 | ||
7 | var ranToken = ' ??++ '; | 7 | var ranToken = ' ??++ '; |
8 | +var ranToken2 = ' ???+++ '; | ||
8 | var $ = require('jquery'); | 9 | var $ = require('jquery'); |
9 | 10 | ||
10 | //获取分隔符 | 11 | //获取分隔符 |
@@ -12,6 +13,10 @@ function getRanToken() { | @@ -12,6 +13,10 @@ function getRanToken() { | ||
12 | return ranToken; | 13 | return ranToken; |
13 | } | 14 | } |
14 | 15 | ||
16 | +function getRanToken2() { | ||
17 | + return ranToken2; | ||
18 | +} | ||
19 | + | ||
15 | /** | 20 | /** |
16 | * 增加单条记录 | 21 | * 增加单条记录 |
17 | */ | 22 | */ |
@@ -32,7 +37,7 @@ function bindWirteLocal($brandList) { | @@ -32,7 +37,7 @@ function bindWirteLocal($brandList) { | ||
32 | $brandList.on('click', 'p , li', function(e) { | 37 | $brandList.on('click', 'p , li', function(e) { |
33 | var brandName, brandId, brandDomain, url; | 38 | var brandName, brandId, brandDomain, url; |
34 | var a = $(this).find('a'); | 39 | var a = $(this).find('a'); |
35 | - var query = a.attr('brandName') + a.attr('href'), | 40 | + var query = a.attr('brandName') + ranToken2 + a.attr('href'), |
36 | historys; | 41 | historys; |
37 | 42 | ||
38 | brandName = a.attr('brandName'); | 43 | brandName = a.attr('brandName'); |
@@ -78,5 +83,6 @@ function bindWirteLocal($brandList) { | @@ -78,5 +83,6 @@ function bindWirteLocal($brandList) { | ||
78 | 83 | ||
79 | 84 | ||
80 | exports.getRanToken = getRanToken; | 85 | exports.getRanToken = getRanToken; |
86 | +exports.getRanToken2 = getRanToken2; | ||
81 | 87 | ||
82 | exports.bindWirteLocal = bindWirteLocal; | 88 | exports.bindWirteLocal = bindWirteLocal; |
-
Please register or login to post a comment