Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
COMP90082-ePortfolio-team03
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tian Ye
COMP90082-ePortfolio-team03
Commits
454a84be
Commit
454a84be
authored
May 31, 2020
by
Ye Tian
Browse files
Options
Downloads
Patches
Plain Diff
update pagebar.js
parent
74a6e60f
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
web/js/ToolBar/pagebar.js
+61
-29
61 additions, 29 deletions
web/js/ToolBar/pagebar.js
with
61 additions
and
29 deletions
web/js/ToolBar/pagebar.js
+
61
−
29
View file @
454a84be
loadSubPage
=
function
(
data
){
/**
var
pageSize
=
5
;
* 自定义参数
* @param data 所有条Json数据
* @param type 1:加载request里的project列表
* 2: 加载当前用户发送的request列表
*/
loadSubPage
=
function
(
data
,
type
){
var
pageSize
=
1
;
var
pageNum
=
Math
.
ceil
(
data
.
length
/
pageSize
);
var
pageNum
=
Math
.
ceil
(
data
.
length
/
pageSize
);
var
dataStr
=
JSON
.
stringify
(
data
);
var
dataStr
=
JSON
.
stringify
(
data
);
...
@@ -8,39 +14,39 @@ loadSubPage = function(data){
...
@@ -8,39 +14,39 @@ loadSubPage = function(data){
}
else
{
}
else
{
$
(
"
#page-bar
"
).
append
(
'
<div id="currentPage" style="display: none"></div>
'
);
//用来存放当前页面编号
$
(
"
#page-bar
"
).
append
(
'
<div id="currentPage" style="display: none"></div>
'
);
//用来存放当前页面编号
$
(
"
#page-bar
"
).
append
(
"
<li id='previousBtn' class='page-item disabled'>
\n
"
+
$
(
"
#page-bar
"
).
append
(
"
<li id='previousBtn' class='page-item disabled'>
\n
"
+
"
<a class='page-link' href='#' tabindex='-1' onclick='changePage(
"
+
"
-1,
"
+
dataStr
+
"
,
"
+
i
+
"
,
"
+
pageSize
+
"
,
"
+
pageNum
+
"
)'>Previous</a>
\n
"
+
"
<a class='page-link' href='#' tabindex='-1' onclick='changePage(
"
+
"
-1,
"
+
dataStr
+
"
,
"
+
i
+
"
,
"
+
pageSize
+
"
,
"
+
pageNum
+
"
,
"
+
type
+
"
)'>Previous</a>
\n
"
+
"
</li>
"
);
"
</li>
"
);
for
(
var
i
=
1
;
i
<=
pageNum
;
i
++
){
for
(
var
i
=
1
;
i
<=
pageNum
;
i
++
){
// $("#page-bar").append("<li class='page-item'><a class='page-link' onclick='loadParticularPage("+dataStr+","+i+","+pageSize+","+pageNum+",\""+idStr+",\""+htmlStr+"\")' href='#'>"+i+"</a></li>");
// $("#page-bar").append("<li class='page-item'><a class='page-link' onclick='loadParticularPage("+dataStr+","+i+","+pageSize+","+pageNum+",\""+idStr+",\""+htmlStr+"\")' href='#'>"+i+"</a></li>");
$
(
"
#page-bar
"
).
append
(
"
<li class='page-item' id='subpage
"
+
i
+
"
'><a class='page-link' onclick='loadParticularPage(
"
+
dataStr
+
"
,
"
+
i
+
"
,
"
+
pageSize
+
"
,
"
+
pageNum
+
"
)' href='#'>
"
+
i
+
"
</a></li>
"
);
$
(
"
#page-bar
"
).
append
(
"
<li class='page-item' id='subpage
"
+
i
+
"
'><a class='page-link' onclick='loadParticularPage(
"
+
dataStr
+
"
,
"
+
i
+
"
,
"
+
pageSize
+
"
,
"
+
pageNum
+
"
,
"
+
type
+
"
)' href='#'>
"
+
i
+
"
</a></li>
"
);
// $("#page-bar").append('<li class="page-item">' +
// $("#page-bar").append('<li class="page-item">' +
// // '<a class="page-link" href="#" onclick="test(\''+data+'\')">'+i+'</a></li>');
// // '<a class="page-link" href="#" onclick="test(\''+data+'\')">'+i+'</a></li>');
}
}
$
(
"
#page-bar
"
).
append
(
"
<li id='nextBtn' class='page-item'>
\n
"
+
$
(
"
#page-bar
"
).
append
(
"
<li id='nextBtn' class='page-item'>
\n
"
+
"
<a class='page-link' href='#' tabindex='1' onclick='changePage(
"
+
"
1,
"
+
dataStr
+
"
,
"
+
i
+
"
,
"
+
pageSize
+
"
,
"
+
pageNum
+
"
)'>Next</a>
\n
"
+
"
<a class='page-link' href='#' tabindex='1' onclick='changePage(
"
+
"
1,
"
+
dataStr
+
"
,
"
+
i
+
"
,
"
+
pageSize
+
"
,
"
+
pageNum
+
"
,
"
+
type
+
"
)'>Next</a>
\n
"
+
"
</li>
"
);
"
</li>
"
);
loadParticularPage
(
data
,
1
,
pageSize
,
pageNum
);
loadParticularPage
(
data
,
1
,
pageSize
,
pageNum
,
type
);
}
}
}
}
function
changePage
(
move
,
dataStr
,
p
,
pageSize
,
pageNum
){
function
changePage
(
move
,
dataStr
,
p
,
pageSize
,
pageNum
,
type
){
var
curPage
=
$
(
"
#currentPage
"
).
html
();
var
curPage
=
$
(
"
#currentPage
"
).
html
();
var
newPage
=
parseInt
(
curPage
)
+
move
;
var
newPage
=
parseInt
(
curPage
)
+
move
;
if
(
newPage
>
0
&&
newPage
<=
pageNum
){
if
(
newPage
>
0
&&
newPage
<=
pageNum
){
loadParticularPage
(
dataStr
,
newPage
,
pageSize
,
pageNum
);
loadParticularPage
(
dataStr
,
newPage
,
pageSize
,
pageNum
,
type
);
}
}
}
}
function
loadParticularPage
(
dataStr
,
p
,
pageSize
,
pageNum
)
{
function
loadParticularPage
(
dataStr
,
p
,
pageSize
,
pageNum
,
type
)
{
var
data
=
eval
(
dataStr
);
var
data
=
eval
(
dataStr
);
//清空原先列表
//
//清空原先列表
$
(
"
#requestProjectList
"
).
html
(
""
);
//
$("#requestProjectList").html("");
//记录当前页
//记录当前页
的标号
$
(
"
#currentPage
"
).
html
(
p
);
$
(
"
#currentPage
"
).
html
(
p
);
//样式准备
//样式准备
...
@@ -57,6 +63,10 @@ function loadParticularPage(dataStr, p, pageSize, pageNum) {
...
@@ -57,6 +63,10 @@ function loadParticularPage(dataStr, p, pageSize, pageNum) {
//加载数据显示列表
//加载数据显示列表
var
start
=
(
parseInt
(
p
)
-
1
)
*
pageSize
;
var
start
=
(
parseInt
(
p
)
-
1
)
*
pageSize
;
if
(
type
==
1
){
//清空原先列表
$
(
"
#requestProjectList
"
).
html
(
""
);
for
(
var
x
=
start
;
x
<
start
+
pageSize
;
x
++
){
for
(
var
x
=
start
;
x
<
start
+
pageSize
;
x
++
){
var
projectId
=
data
[
x
].
projectid
;
//project id留作备用
var
projectId
=
data
[
x
].
projectid
;
//project id留作备用
$
(
"
#requestProjectList
"
).
append
(
'
<li>
\n
'
+
$
(
"
#requestProjectList
"
).
append
(
'
<li>
\n
'
+
...
@@ -75,5 +85,27 @@ function loadParticularPage(dataStr, p, pageSize, pageNum) {
...
@@ -75,5 +85,27 @@ function loadParticularPage(dataStr, p, pageSize, pageNum) {
'
</div>
\n
'
+
'
</div>
\n
'
+
'
</li>
'
);
'
</li>
'
);
}
}
}
else
if
(
type
==
2
){
$
(
"
#myRequestsList
"
).
html
(
""
);
for
(
var
x
=
start
;
x
<
start
+
pageSize
;
x
++
){
var
statusNum
=
data
[
x
].
requeststatus
;
var
status
=
"
Unhandled
"
;
if
(
statusNum
==
'
1
'
)
status
=
"
Refused
"
;
else
if
(
statusNum
==
'
2
'
)
status
=
"
Approved
"
;
$
(
"
#myRequestsList
"
).
append
(
'
<li>
\n
'
+
'
<div class="req-in">
\n
'
+
'
<div class="req-detail">
\n
'
+
'
<span style="font-size: x-large; ">
'
+
data
[
x
].
projectname
+
'
</span>
\n
'
+
'
<h4>Project Owner: <a href="other-person.html?id=
'
+
data
[
x
].
userid
+
'
">
'
+
data
[
x
].
name
+
'
</a> Apply date:
'
+
data
[
x
].
str_requesttime
+
'
</h4>
\n
'
+
'
</div>
\n
'
+
'
<div class="req-status">
\n
'
+
'
<span>Status:</span>
\n
'
+
'
<span class="status">
'
+
status
+
'
</span>
\n
'
+
'
</div>
\n
'
+
'
<div class="req-btn"><input type="button" onclick="deleteRequest(
'
+
data
[
x
].
requestid
+
'
)" value="DELETE"/></div>
'
+
'
</div>
\n
'
+
'
</li>
'
);
}
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment