Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
phpdts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nemo Ma
phpdts
Commits
ddedf381
Commit
ddedf381
authored
Jul 14, 2023
by
unknown
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
拆分录像js
- 只会在游戏界面启用录像功能
parent
ac5f916d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
86 deletions
+91
-86
include/game20130526.js
include/game20130526.js
+1
-86
include/record.js
include/record.js
+85
-0
templates/default/header.htm
templates/default/header.htm
+5
-0
No files found.
include/game20130526.js
View file @
ddedf381
...
...
@@ -571,61 +571,6 @@ function skill_unacquired_mouseout(e)
}
}
//录制处理
var
recordedData
=
[];
var
isRecording
=
true
;
function
startRecording
()
{
isRecording
=
true
;
console
.
log
(
'
startRecording
'
);
window
.
alert
(
'
开始录像,录制中的游戏数据会保留在浏览器内,请不要刷新或关闭该页面。
'
);
// 监听所有按钮的点击事件
document
.
addEventListener
(
'
click
'
,
recordButtonClick
);
var
linkElement
=
document
.
querySelector
(
'
a[onclick="startRecording()"]
'
);
if
(
linkElement
)
{
linkElement
.
textContent
=
"
>>停止录像
"
;
linkElement
.
setAttribute
(
'
onclick
'
,
'
stopRecording()
'
);
}
}
document
.
addEventListener
(
'
click
'
,
recordButtonClick
);
function
stopRecording
()
{
isRecording
=
false
;
var
linkElement
=
document
.
querySelector
(
'
a[onclick="stopRecording()"]
'
);
if
(
linkElement
)
{
linkElement
.
textContent
=
"
>>开始录像
"
;
linkElement
.
setAttribute
(
'
onclick
'
,
'
startRecording()
'
);
}
// 停止监听
document
.
removeEventListener
(
'
click
'
,
recordButtonClick
);
//downloadRecordedData();
}
function
downloadRecordedData
()
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
()
{
var
arrayBuffer
=
reader
.
result
;
var
uint8Array
=
new
Uint8Array
(
arrayBuffer
);
var
gzippedData
=
pako
.
gzip
(
uint8Array
);
var
downloadLink
=
document
.
createElement
(
"
a
"
);
downloadLink
.
href
=
URL
.
createObjectURL
(
new
Blob
([
gzippedData
]));
downloadLink
.
download
=
"
recorded_data.html.gz
"
;
downloadLink
.
click
();
};
reader
.
readAsArrayBuffer
(
new
Blob
(
recordedData
,
{
type
:
"
text/html
"
}));
}
function
recordButtonClick
(
event
)
{
// 如果录制状态为 true,则将当前前端的全部静态网页数据保存到数组中
if
(
isRecording
)
{
recordedData
.
push
(
document
.
documentElement
.
outerHTML
.
concat
(
"
\n
"
));
sendLastRecordedData
(
recordedData
);
}
}
function
selectRecordedFile
()
{
var
input
=
document
.
createElement
(
"
input
"
);
input
.
type
=
"
file
"
;
...
...
@@ -730,34 +675,4 @@ function displayRecordedData(file) {
}
};*/
function
sendLastRecordedData
(
recordedData
)
{
const
nickinfoElement
=
document
.
getElementById
(
'
nickinfo
'
);
if
(
!
nickinfoElement
)
{
return
;
}
const
nickinfo
=
nickinfoElement
.
innerText
;
const
lastRecord
=
recordedData
[
recordedData
.
length
-
1
];
fetch
(
'
record_backend.php
'
,
{
method
:
'
POST
'
,
body
:
JSON
.
stringify
({
lastRecord
,
nickinfo
}),
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
})
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
// 处理从后端返回的响应
//console.log(data);
})
.
catch
(
error
=>
{
// 处理错误
console
.
error
(
error
);
});
}
\ No newline at end of file
include/record.js
0 → 100644
View file @
ddedf381
//录制处理
var
recordedData
=
[];
var
isRecording
=
true
;
function
startRecording
()
{
isRecording
=
true
;
console
.
log
(
'
startRecording
'
);
window
.
alert
(
'
开始录像,录制中的游戏数据会保留在浏览器内,请不要刷新或关闭该页面。
'
);
// 监听所有按钮的点击事件
document
.
addEventListener
(
'
click
'
,
recordButtonClick
);
var
linkElement
=
document
.
querySelector
(
'
a[onclick="startRecording()"]
'
);
if
(
linkElement
)
{
linkElement
.
textContent
=
"
>>停止录像
"
;
linkElement
.
setAttribute
(
'
onclick
'
,
'
stopRecording()
'
);
}
}
document
.
addEventListener
(
'
click
'
,
recordButtonClick
);
function
stopRecording
()
{
isRecording
=
false
;
var
linkElement
=
document
.
querySelector
(
'
a[onclick="stopRecording()"]
'
);
if
(
linkElement
)
{
linkElement
.
textContent
=
"
>>开始录像
"
;
linkElement
.
setAttribute
(
'
onclick
'
,
'
startRecording()
'
);
}
// 停止监听
document
.
removeEventListener
(
'
click
'
,
recordButtonClick
);
//downloadRecordedData();
}
function
downloadRecordedData
()
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
()
{
var
arrayBuffer
=
reader
.
result
;
var
uint8Array
=
new
Uint8Array
(
arrayBuffer
);
var
gzippedData
=
pako
.
gzip
(
uint8Array
);
var
downloadLink
=
document
.
createElement
(
"
a
"
);
downloadLink
.
href
=
URL
.
createObjectURL
(
new
Blob
([
gzippedData
]));
downloadLink
.
download
=
"
recorded_data.html.gz
"
;
downloadLink
.
click
();
};
reader
.
readAsArrayBuffer
(
new
Blob
(
recordedData
,
{
type
:
"
text/html
"
}));
}
function
recordButtonClick
(
event
)
{
// 如果录制状态为 true,则将当前前端的全部静态网页数据保存到数组中
if
(
isRecording
)
{
recordedData
.
push
(
document
.
documentElement
.
outerHTML
.
concat
(
"
\n
"
));
sendLastRecordedData
(
recordedData
);
}
}
function
sendLastRecordedData
(
recordedData
)
{
const
nickinfoElement
=
document
.
getElementById
(
'
nickinfo
'
);
if
(
!
nickinfoElement
)
{
return
;
}
const
nickinfo
=
nickinfoElement
.
innerText
;
const
lastRecord
=
recordedData
[
recordedData
.
length
-
1
];
fetch
(
'
record_backend.php
'
,
{
method
:
'
POST
'
,
body
:
JSON
.
stringify
({
lastRecord
,
nickinfo
}),
headers
:
{
'
Content-Type
'
:
'
application/json
'
}
})
.
then
(
response
=>
response
.
json
())
.
then
(
data
=>
{
// 处理从后端返回的响应
//console.log(data);
})
.
catch
(
error
=>
{
// 处理错误
console
.
error
(
error
);
});
}
templates/default/header.htm
View file @
ddedf381
...
...
@@ -12,6 +12,9 @@
<script
type=
"text/javascript"
src=
"include/game20130526.js"
></script>
<script
type=
"text/javascript"
src=
"include/json.js"
></script>
<script
type=
"text/javascript"
src=
"include/pako.js"
></script>
<!--{if (CURSCRIPT == 'game')}-->
<script
type=
"text/javascript"
src=
"include/record.js"
></script>
<!--{/if}-->
<!--{if (CURSCRIPT == 'game' && $pls=='1')}-->
<style>
body
{
background-image
:
url("../../img/location/1.jpg")
;
background-position
:
center
;}
...
...
@@ -206,7 +209,9 @@
</div>
</a>
</span>
<!--{if (CURSCRIPT == 'game')}-->
<a
href=
"javascript:void(0)"
onclick=
"stopRecording()"
>
>>停止录像
</a>
<!--{/if}-->
<a
href=
"record.php"
>
>>回放录像
</a>
<a
href=
"admin.php"
>
>>{lang admin}
</a>
<a
href=
"https://bbs.brdts.online/"
target=
"_blank"
>
>>{lang report}
</a>
...
...
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