if (window.__RTE && typeof window.__RTE === 'object') {
// 遍历window.__RTE对象的所有属性
for (let key in window.__RTE) {
// 检查属性是否是函数
if (typeof window.__RTE[key] === 'function') {
// 输出函数名称
console.log(key);
// 如果你还想查看函数的定义或者其它信息,你可以这样做:
// 输出函数的定义(函数体)
console.log(window.__RTE[key].toString());
// 或者输出函数的长度(参数个数)
console.log(window.__RTE[key].length);
}
}
} else {
console.log('window.__RTE is not defined or not an object.');
}
2.4以此获取到全局变量函数:SaveItem()
[JavaScript] 纯文本查看复制代码
function(qId, psqId, answer, attach) {
function SaveItem(qId, psqId, answer, attach) {
var self = this,
callback = (arguments.length > 4 ? arguments[4] : null);
// 客户端判卷用到的方法
function saveAnswerAndStatus(qId, psqId, qa, rightAnswers, attach) {
var rightAnswer, len = rightAnswers.length;
for (var i = 0; i < len; i++) {
rightAnswer = rightAnswers[i];
if (rightAnswer.questionId == qId) {
break;
}
}
var score = 0,
right = false;
if (rightAnswer) {
if (rightAnswer.type == 1) {
/*单选题*/
if (rightAnswer.answer == qa) {
score = rightAnswer.score;
right = true;
}
} else if (rightAnswer.type == 2) {
/*多选替*/
var tmpAnswer = rightAnswer.answer;
var breaked = false;
for (var i = 0; i < qa.length; i++) {
var a = qa.charAt(i);
if (tmpAnswer.indexOf(a) < 0) {
breaked = true;
break;
}
tmpAnswer = tmpAnswer.replace(a, '');
}
if (!breaked && tmpAnswer.length == 0) {
score = rightAnswer.score;
right = true;
}
}
}
saveAnswerFunc({
qId: qId,
userExamId: self.userExamId,
body: {
psqId: psqId,
answer: qa,
attach: attach,
score: score,
right: right
}
});
}
//保存答案
function saveAnswerFunc(params) {
const saveAnswerRemote = self.basePath + '/myanswer/clientSave/' + self.userExamId + '/' + params.qId;
const saveAnswerService = self.basePath + '/myanswer/newSave/' + self.userExamId + '/' + params.qId;
const bodyParams = params.body;
bodyParams["m"] = encryption(params.userExamId, params.qId, bodyParams);
try {
$.post(saveAnswerService, bodyParams, function(data) {
if (data && data.success) {
if (callback && $.isFunction(callback)) {
callback.apply(self);
}
if (data.leftTime) {
self.leftTime = data.leftTime;
}
saveUserAnswerCallback(qId);
} else {
const message = "保存答案失败," + data.errMsg;
self.Message(message, 'err', [{
label: '刷新',
func: function() {
window.location.reload()
}
}], true);
}
}, 'json')
} finally {
try {
bodyParams["httpUrl"] = saveAnswerRemote;
cefobj.localSaveAnswer(JSON.stringify(bodyParams))
} catch (e) {
console.log("保存本地出错: " + e)
}
}
}
// 使用loadScript函数加载MD5.js
loadScript('https://XXX.XXX..com/exam/statics/scripts/MD5.js')
.then(() => {
console.log('https://XXX.XXX.com/exam/statics/scripts/MD5.js has been loaded and executed');
})
.catch(error => {
console.error('There was an error loading https://XXX.XXX.com/exam/statics/scripts/MD5.js:', error);
});