Skip to content
This repository has been archived by the owner on Apr 25, 2022. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
CodFrm committed Nov 22, 2020
2 parents 49a4f3f + ebbeb9e commit 73355c8
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 56 deletions.
25 changes: 12 additions & 13 deletions src/mooc/chaoxing/question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,11 @@ abstract class cxQuestion implements Question {

protected isCorrect(): Element {
let el = this.el.querySelector(".Py_answer.clearfix,.Py_tk");
if (el && el.innerHTML.indexOf('正确答案') >= 0) {
if (el) {
if (el.querySelectorAll('.fr.dui').length > 0 || el.querySelectorAll('.fr.bandui').length > 0) {
return el;
} else if (el.innerHTML.indexOf('正确答案') >= 0) {
return el;
}
}
let topic = this.el.querySelector(".Cy_TItle.clearfix")
Expand All @@ -240,8 +242,15 @@ abstract class cxQuestion implements Question {
class cxSelectQuestion extends cxQuestion implements Question {

protected getContent(el: HTMLElement): string {
el = el.querySelector("a");
return el.innerHTML;
let ret = el.querySelector("a");
if (ret == null) {
let tmpel = <HTMLInputElement>el.querySelector("label > input,input");
if (tmpel.value == "true") {
return "对√";
}
return "错×";
}
return ret.innerHTML;
}

protected getOption(el: HTMLElement): string {
Expand Down Expand Up @@ -347,16 +356,6 @@ class cxJudgeQuestion extends cxSelectQuestion implements Question {
public Correct(): Answer {
let el = this.el.querySelector(".Py_answer.clearfix");
let ret = this.defaultAnswer();
let score = this.el.querySelector(".Cy_TItle.clearfix .font18.fb");
if (el.innerHTML.indexOf('正确答案') >= 0 || (score && score.querySelector(".Cy_TItle.clearfix .font18.fb").innerHTML != "0.0")) {
let correctText = el.querySelector("span").innerText;
if (correctText.indexOf('×') >= 0) {
ret.correct.push({option: false, content: false});
} else {
ret.correct.push({option: true, content: true});
}
return ret;
}
if (el.querySelectorAll('.fr.dui').length <= 0 && el.querySelectorAll('.fr.cuo').length <= 0) {
return null;
}
Expand Down
32 changes: 32 additions & 0 deletions src/mooc/zhihuishu/utils/css-tool.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* 美化按钮
* @param btn 按钮
*/
export function CssBtn(btn: HTMLButtonElement): HTMLButtonElement {
btn.style.position = 'relative';
btn.style.color = '#fff';
btn.style.padding = '0 16px';
btn.style.display = 'inline-block';
btn.style.height = '36px';
btn.style.fontSize = '14px';
btn.style.fontWeight = '500';
btn.style.outline = 'none';
btn.style.border = 'none';
btn.style.borderRadius = '4px';
btn.style.overflow = 'hidden';
btn.style.margin = '0 8px';

btn.addEventListener('mousedown', (e: MouseEvent) => {
let x = e.offsetX;
let y = e.offsetY;
let ripples = document.createElement('span');
ripples.style.left = x + 'px';
ripples.style.top = y + 'px';
ripples.className = "btn-ripple";
btn.appendChild(ripples);
setTimeout(() => {
ripples.remove();
}, 1000);
}, false)
return btn;
}
89 changes: 52 additions & 37 deletions src/mooc/zhihuishu/video.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {Mooc} from "@App/internal/app/mooc";
import {Hook, Context} from "@App/internal/utils/hook";
import {Application} from "@App/internal/application";
import { Mooc } from "@App/internal/app/mooc";
import { Hook, Context } from "@App/internal/utils/hook";
import { Application } from "@App/internal/application";
import "../../views/common";
import {randNumber, post, substrex, protocolPrompt} from "@App/internal/utils/utils";
import { randNumber, post, substrex, protocolPrompt, createBtn } from "@App/internal/utils/utils";
import { CssBtn } from "./utils/css-tool";
import * as queryString from "querystring";


export class ZhsVideo implements Mooc {

Expand All @@ -11,8 +14,10 @@ export class ZhsVideo implements Mooc {
protected nowVideoId: number;
protected videoList: any;
protected studiedLessonDtoId: number;
protected studyTotalTime: number;
protected watchPointPost: string;

public Init(): void {
public Init() {
this.hookAjax();
let timer = setInterval(() => {
try {
Expand All @@ -27,10 +32,7 @@ export class ZhsVideo implements Mooc {
let tools = document.createElement('div');
tools.className = "entrance_div";
tools.id = "cxtools";
let boomBtn = document.createElement("a");
boomBtn.href = "#";
boomBtn.className = "zhs-tools-btn";
boomBtn.innerText = "秒过视频";
let boomBtn = CssBtn(createBtn("秒过视频", "", "zhs-tools-btn"));
boomBtn.onclick = () => {
if (!protocolPrompt("秒过视频会产生不良记录,是否继续?", "boom_no_prompt")) {
return;
Expand All @@ -45,25 +47,36 @@ export class ZhsVideo implements Mooc {
let tn = time;
//通过id搜索视频信息
let lessonId = 0, smallLessonId = 0, chapterId = 0;
for (let i = 0; i < this.videoList.videoChapterDtos.length; i++) {
for (let n = 0; n < this.videoList.videoChapterDtos[i].videoLessons.length; n++) {
if (this.videoList.videoChapterDtos[i].videoLessons[n].videoId == this.nowVideoId) {
lessonId = this.videoList.videoChapterDtos[i].videoLessons[n].id;
smallLessonId = this.videoList.videoChapterDtos[i].videoLessons[n].ishaveChildrenLesson;
chapterId = this.videoList.videoChapterDtos[i].videoLessons[n].chapterId;
}
let subTit = (<HTMLSpanElement>document.querySelector(".current_play .hour")).innerText;
//获取x.x.x DOM
let videoTag = subTit.split('.');
if (videoTag.length >= 2) {
lessonId = this.videoList.videoChapterDtos[Number.parseInt(videoTag[0]) - 1].videoLessons[Number.parseInt(videoTag[1]) - 1].id;
chapterId = this.videoList.videoChapterDtos[Number.parseInt(videoTag[0]) - 1].videoLessons[Number.parseInt(videoTag[1]) - 1].chapterId;
switch (videoTag.length) {
case 3:
smallLessonId = this.videoList.videoChapterDtos[Number.parseInt(videoTag[0]) - 1]
.videoLessons[Number.parseInt(videoTag[1]) - 1]
.videoSmallLessons[Number.parseInt(videoTag[2]) - 1].id;
default:
break;
}
}
let s = [this.videoList.recruitId, lessonId, smallLessonId, this.nowVideoId, chapterId, "0", tn, time, timeStr]
, l = {
ev: n.Z(s),
learningTokenId: Base64.encode(this.studiedLessonDtoId.toString()),
uuid: substrex(document.cookie, "uuid%22%3A%22", "%22"),
dateFormate: Date.parse(<any>new Date()),
};
let postData = "ev=" + l.ev + "&learningTokenId=" + l.learningTokenId +
"&uuid=" + l.uuid + "&dateFormate=" + l.dateFormate;
const tims = parseInt((time / 1.999).toString());
for (let index = 0; index < tims; index++) {
this.learningTimeRecord();
}

let s = [this.videoList.recruitId, lessonId, smallLessonId, this.nowVideoId, chapterId, "0", tn, this.studyTotalTime, timeStr]
, l = {
watchPoint: this.watchPointPost,
ev: n.Z(s),
courseId: this.videoList.courseId,
learningTokenId: Base64.encode(this.studiedLessonDtoId.toString()),
uuid: substrex(document.cookie, "uuid%22%3A%22", "%22"),
dateFormate: Date.parse(<any>new Date()),
};
let postData = queryString.stringify(l);
post("https://studyservice.zhihuishu.com/learning/saveDatabaseIntervalTime", postData, false, function (data: any) {
let json = JSON.parse(data);
try {
Expand All @@ -77,28 +90,32 @@ export class ZhsVideo implements Mooc {
}
});
};
//TODO:优化,先这样把按钮弄出来
let li2 = document.createElement("li");
let startBtn = document.createElement("a");
startBtn.href = "#";
startBtn.className = "zhs-tools-btn zhs-start-btn";
startBtn.innerText = Application.App.config.auto ? "暂停挂机" : "开始挂机";
startBtn.onclick = () => {
const startBtnText = Application.App.config.auto ? "暂停挂机" : "开始挂机";
let startBtn = CssBtn(createBtn(startBtnText, "", "zhs-tools-btn zhs-start-btn"));
startBtn.addEventListener('click', () => {
if (startBtn.innerText == "暂停挂机") {
startBtn.innerText = "开始挂机";
Application.App.config.auto = false;
localStorage["auto"] = false;
} else {
startBtn.innerText = "暂停挂机";
localStorage["auto"] = true;
Application.App.config.auto = true;
this.play();
}
};
})
tools.appendChild(startBtn);
tools.appendChild(boomBtn);

document.querySelector(".videotop_box.fl").append(tools);
}

learningTimeRecord() {
var t = parseInt(((this.studyTotalTime / 5) + 2).toString())
, e = null == this.watchPointPost || "" == this.watchPointPost ? "0,1," : this.watchPointPost + ",";
this.watchPointPost = e + t;
this.studyTotalTime += 2;
}

protected compile() {
let interval = Application.App.config.interval;
Application.App.log.Info(interval + "分钟后自动切换下一节");
Expand All @@ -124,7 +141,6 @@ export class ZhsVideo implements Mooc {
if (this.video) {
this.video.muted = Application.App.config.video_mute;
this.video.playbackRate = Application.App.config.video_multiple;

Application.App.config.auto && this.video.play();
}
}
Expand Down Expand Up @@ -192,6 +208,7 @@ export class ZhsVideo implements Mooc {
get: function () {
let json = JSON.parse(this.response);
self.studiedLessonDtoId = json.data.studiedLessonDto.id;
self.studyTotalTime = json.data.studiedLessonDto.studyTotalTime;
return this.response;
}
});
Expand All @@ -200,8 +217,6 @@ export class ZhsVideo implements Mooc {
return ret;
});
}


}

var n = {
Expand Down
32 changes: 26 additions & 6 deletions src/views/common.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
window.addEventListener("load", () => {
let css = `#cxtools {
let css = `
@keyframes aniripple
{
0%{
width:0px;
height:0px;
opacity:0.4;
}
100%{
width:500px;
height:500px;
opacity:0;
}
}
#cxtools {
position: absolute;
left: 250px;
top: 2px;
width: 200px;
width: 210px;
font-size: 0;
}
Expand Down Expand Up @@ -32,10 +47,15 @@ window.addEventListener("load", () => {
font-size: 14px;
line-height: 24px;
margin:0;
}
.zhs-tools-btn:hover {
background: #ff3838;
cursor:pointer;
}
.btn-ripple{
position:absolute;
background:#000;
pointer-events:none;
transform:translate(-50%,-50%);
border-radius:50%;
animation:aniripple 1s linear infinite;
}
.zhs-start-btn{
Expand Down

0 comments on commit 73355c8

Please # to comment.