Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yoho-blk
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
1
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
xuqi
9 years ago
Commit
cc1c4acd289747bc3da32e462969de42076785d0
1 parent
d3e8377f
add comments to common js
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
public/js/common/index.js
public/js/common/return-top.js
public/js/common/index.js
View file @
cc1c4ac
...
...
@@ -4,6 +4,11 @@
* @date: 2017/7/5
*/
/**
* 获取cookie值
* @param name [string] cookie键名
* @return [string] cookie值
*/
function
cookie
(
name
)
{
var
re
=
new
RegExp
(
name
+
'=([^;$]*)'
,
'i'
),
matchPattern
=
'$1'
;
...
...
@@ -11,6 +16,12 @@ function cookie(name) {
return
re
.
test
(
decodeURIComponent
(
document
.
cookie
))
?
RegExp
[
matchPattern
]
:
''
;
}
/**
* 设置cookie
* @param name [string] cookie键名
* @param value [string] cookie值
* @pamra options [object] cookie参数项
*/
function
setCookie
(
name
,
value
,
options
)
{
var
expires
=
''
,
path
,
...
...
@@ -42,6 +53,10 @@ function setCookie(name, value, options) {
}
}
/**
* query参数解析
* @return [object] query key-value map
*/
function
queryString
()
{
var
vars
=
{},
hash
,
...
...
@@ -56,6 +71,11 @@ function queryString() {
return
vars
;
}
/**
* 获取字符串长度(一个中文=2个字符)
* @param str [string]
* @return [num] 字符串长度
*/
function
getStrLength
(
str
)
{
var
cArr
=
str
.
match
(
/
[\u
4e00-
\u
9fa5a
]
/ig
);
...
...
@@ -63,8 +83,8 @@ function getStrLength(str) {
}
module
.
exports
=
{
cookie
:
cookie
,
// 获取cookie
setCookie
:
setCookie
,
// 设置cookie
queryString
:
queryString
,
// query参数解析
getStrLength
:
getStrLength
// 获取字符串长度(一个中文=2个字符)
cookie
:
cookie
,
setCookie
:
setCookie
,
queryString
:
queryString
,
getStrLength
:
getStrLength
};
...
...
public/js/common/return-top.js
View file @
cc1c4ac
...
...
@@ -8,6 +8,9 @@ var $ = require('yoho-jquery');
var
$returnTop
=
$
(
'.return-top'
);
/**
* 是否显示返回顶部按钮
*/
function
showOrNot
()
{
if
(
$
(
window
).
height
()
>=
$
(
document
).
height
())
{
$returnTop
.
addClass
(
'hide'
);
...
...
Please
register
or
login
to post a comment