123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- var serverInteractively = function(options) {
- var WAIT_EXAM_HANDLER_ID = "#msgSpan";
- var WAIT_EXAM_END_ID = "input[id$=hide_end]";
- var WAIT_EXAM_CONVAN = "#aninateConvan";
- var aninateArray = [".", "..", "...", "....", ".....", "......"];
- var EXAM_MSG_ID = "#txt_message";
- var personExchangeLabel = "personExchange";
- var publicExchangeLabel = "publicExchange";
- var examinerExchangeLabel = "examinerExchange";
- // 获取交互时间间隔默认5秒
- var exchangeInterval = 5000;
- var publicExchangeList = new Hashtable();
- options = options || {};
- options.test_id = options.test_id || "";
- options.user_id = options.user_id || "";
- var sender = this;
- // 现场考试等待方法
- this.registWaitExam = function(url) {
- var interval = 1000;
- var convan = $(WAIT_EXAM_CONVAN);
- $(WAIT_EXAM_HANDLER_ID).everyTime(interval, 'waitExam', function() {
- beginInvoke(CMS_SystemConfig.VirtualDirectoryPath + "/OnlineTest/GetTestStatus", { test_id: options.test_id, userid: options.user_id }, function (rs) {
- if (rs.state) {
- $(WAIT_EXAM_END_ID).val(rs.limit);
- sender.registStartCountDown(url);
- }
- else {
- if (rs.msg.length > 0)
- $(WAIT_EXAM_HANDLER_ID).text(rs.msg);
- else {
- convan.text(waitAninate(convan.text().length));
- }
- }
- });
- });
- }
- this.registStartCountDown = function(url) {
- $("#countDown").show();
- $("#msgSpan").hide();
- $(".timer").calcTimer({
- limit: $(WAIT_EXAM_END_ID).val(),
- inputType: "s",
- format: "<span style='color:blue'><span style='font-size:14px'>#H</span>时<span style='font-size:14px'>#M</span>分<span style='font-size:14px'>#S</span>秒</span>",
- ontimeout: function() {
- if (typeof (url) == 'string') {
- if (url.length > 0) {
- window.location.href = url;
- }
- }
- else {
- url();
- }
- },
- onCountdownError: function(container) {
- var examLength = Invoke(CMS_SystemConfig.VirtualDirectoryPath + "/OnlineTest/GetStartLengthOfExam", { test_id: examInfo.test_id, userid: examinee.userid });
- $(WAIT_EXAM_END_ID).val(examLength);
- sender.registStartCountDown(url);
- }
- });
- }
- this.registPersonExchange = function() {
- $(EXAM_MSG_ID).everyTime(exchangeInterval, personExchangeLabel, function() {
- beginInvoke(CMS_SystemConfig.VirtualDirectoryPath + "/OnlineTest/ListPersonalExchange", { test_id: options.test_id, userid: options.user_id }, function (rs) {
- var param = eval(rs);
- for (var i = 0; i < param.length; i++) {
- var p = param[i];
- behaviour.handleCommand(p.type, { type: 'person', intData: p.extendInt, sender: sender });
- }
- });
- });
- }
- this.registPublicExchange = function() {
- $(EXAM_MSG_ID).everyTime(exchangeInterval, publicExchangeLabel, function() {
- beginInvoke(CMS_SystemConfig.VirtualDirectoryPath + "/OnlineTest/ListPublicExchange", { test_id: options.test_id }, function (rs) {
- var param = eval(rs);
- for (var i = 0; i < param.length; i++) {
- var p = param[i];
- if (!publicExchangeList.contains(p.id)) {
- publicExchangeList.add(p.id, p.type);
- behaviour.handleCommand(p.type, { type: 'all', intData: p.extendInt, sender: sender });
- }
- }
- });
- });
- }
- this.removeExamineeExchangeEvent = function() {
- $(EXAM_MSG_ID).stopTime(personExchangeLabel);
- //$(EXAM_MSG_ID).stopTime(publicExchangeLabel);
- }
- var waitAninate = function(index) {
- if (index >= aninateArray.length)
- index = 0;
- return aninateArray[index];
- }
- }
|