Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
php
/
maf
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
5fabf52b
authored
Jan 14, 2020
by
doszhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dos
parent
7b06cf31
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
1 deletions
+40
-1
Public/static/js/common.js
+40
-1
No files found.
Public/static/js/common.js
View file @
5fabf52b
...
...
@@ -61,13 +61,29 @@ let answerArr = [];
// 已经进入的题目
let
watchedQuestion
=
[
1
];
//结果
let
resultType
=
0
;
let
resultType
=
1
;
//记录初始状态下fontsize
const
fontSize
=
parseFloat
(
$
(
'html'
).
css
(
'fontSize'
));
//canvas 位置
let
canvasArr
=
[
[
23
,
120
,
607
,
907
],
[
29
,
120
,
582
,
874
],
[
29
,
120
,
582
,
874
],
[
29
,
120
,
603
,
904
],
[
29
,
120
,
582
,
870
],
[
29
,
120
,
582
,
904
],
[
29
,
120
,
582
,
904
],
[
29
,
120
,
595
,
906
]
];
//海报canvas
let
posterCanvas
;
let
posterCtx
;
$
(
document
).
ready
(
function
()
{
createPoster
();
$
(
"input"
).
on
(
"blur"
,
function
()
{
window
.
scroll
(
0
,
0
);
//失焦后强制让页面归位
});
...
...
@@ -119,6 +135,24 @@ $(document).ready(function () {
});
});
function
createPoster
()
{
$
(
'.poster-canvas-block'
).
css
({
'width'
:
pxToRem
(
canvasArr
[
resultType
][
2
])
+
'rem'
,
'height'
:
pxToRem
(
canvasArr
[
resultType
][
3
])
+
'rem'
,
'top'
:
pxToRem
(
canvasArr
[
resultType
][
1
])
+
'rem'
,
'left'
:
pxToRem
(
canvasArr
[
resultType
][
0
])
+
'rem'
,
})
//海报canvas定义
let
canvasinfo
=
initCanvas
(
'.poster-canvas-block'
,
'posterCanvas'
,
designPxToRealPx
(
canvasArr
[
resultType
][
2
]),
designPxToRealPx
(
canvasArr
[
resultType
][
3
]),
true
);
posterCanvas
=
canvasinfo
[
0
];
posterCtx
=
canvasinfo
[
1
];
let
posterImg
=
new
Image
();
posterImg
.
src
=
'http://maf.dev.izhida.cn/Public/static/image2/poster'
+
resultType
+
'.png'
;
posterImg
.
onload
=
function
()
{
posterCtx
.
drawImage
(
posterImg
,
0
,
0
,
posterCanvas
.
width
,
posterCanvas
.
height
);
}
}
function
submitAnswer
()
{
if
(
nowAnswer
!==
''
)
{
if
(
answerArr
[
0
]
==
0
)
{
...
...
@@ -278,4 +312,8 @@ function RandomNumBoth(Min, Max) {
function
pxToRem
(
px
)
{
return
(
px
/
20
)
*
fontSize
;
}
function
designPxToRealPx
(
px
)
{
return
px
/
20
*
fontSize
;
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment