uooc/优课/智慧树 查题小组手

进入做题界面自动查询答案并且填充内容

  1. // ==UserScript==
  2. // @name uooc/优课/智慧树 查题小组手
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.0.9
  5. // @description 进入做题界面自动查询答案并且填充内容
  6. // @author shulan
  7. // @match *://www.uooc.net.cn/exam/*
  8. // @match *://www.uooconline.com/exam/*
  9. // @match *://*.zhihuishu.com/*
  10. // @match *://*.chaoxing.com/*
  11. // @grant unsafeWindow
  12. // @grant GM_xmlhttpRequest
  13. // @grant window.onload
  14. // @grant window.console
  15. // @license MIT
  16. // ==/UserScript==
  17.  
  18.  
  19. /******/ (() => { // webpackBootstrap
  20. /******/ "use strict";
  21. /******/ var __webpack_modules__ = ({
  22.  
  23. /***/ 312:
  24. /***/ ((module) => {
  25.  
  26.  
  27.  
  28. var has = Object.prototype.hasOwnProperty
  29. , prefix = '~';
  30.  
  31. /**
  32. * Constructor to create a storage for our `EE` objects.
  33. * An `Events` instance is a plain object whose properties are event names.
  34. *
  35. * @constructor
  36. * @private
  37. */
  38. function Events() {}
  39.  
  40. //
  41. // We try to not inherit from `Object.prototype`. In some engines creating an
  42. // instance in this way is faster than calling `Object.create(null)` directly.
  43. // If `Object.create(null)` is not supported we prefix the event names with a
  44. // character to make sure that the built-in object properties are not
  45. // overridden or used as an attack vector.
  46. //
  47. if (Object.create) {
  48. Events.prototype = Object.create(null);
  49.  
  50. //
  51. // This hack is needed because the `__proto__` property is still inherited in
  52. // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.
  53. //
  54. if (!new Events().__proto__) prefix = false;
  55. }
  56.  
  57. /**
  58. * Representation of a single event listener.
  59. *
  60. * @param {Function} fn The listener function.
  61. * @param {*} context The context to invoke the listener with.
  62. * @param {Boolean} [once=false] Specify if the listener is a one-time listener.
  63. * @constructor
  64. * @private
  65. */
  66. function EE(fn, context, once) {
  67. this.fn = fn;
  68. this.context = context;
  69. this.once = once || false;
  70. }
  71.  
  72. /**
  73. * Add a listener for a given event.
  74. *
  75. * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
  76. * @param {(String|Symbol)} event The event name.
  77. * @param {Function} fn The listener function.
  78. * @param {*} context The context to invoke the listener with.
  79. * @param {Boolean} once Specify if the listener is a one-time listener.
  80. * @returns {EventEmitter}
  81. * @private
  82. */
  83. function addListener(emitter, event, fn, context, once) {
  84. if (typeof fn !== 'function') {
  85. throw new TypeError('The listener must be a function');
  86. }
  87.  
  88. var listener = new EE(fn, context || emitter, once)
  89. , evt = prefix ? prefix + event : event;
  90.  
  91. if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;
  92. else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);
  93. else emitter._events[evt] = [emitter._events[evt], listener];
  94.  
  95. return emitter;
  96. }
  97.  
  98. /**
  99. * Clear event by name.
  100. *
  101. * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.
  102. * @param {(String|Symbol)} evt The Event name.
  103. * @private
  104. */
  105. function clearEvent(emitter, evt) {
  106. if (--emitter._eventsCount === 0) emitter._events = new Events();
  107. else delete emitter._events[evt];
  108. }
  109.  
  110. /**
  111. * Minimal `EventEmitter` interface that is molded against the Node.js
  112. * `EventEmitter` interface.
  113. *
  114. * @constructor
  115. * @public
  116. */
  117. function EventEmitter() {
  118. this._events = new Events();
  119. this._eventsCount = 0;
  120. }
  121.  
  122. /**
  123. * Return an array listing the events for which the emitter has registered
  124. * listeners.
  125. *
  126. * @returns {Array}
  127. * @public
  128. */
  129. EventEmitter.prototype.eventNames = function eventNames() {
  130. var names = []
  131. , events
  132. , name;
  133.  
  134. if (this._eventsCount === 0) return names;
  135.  
  136. for (name in (events = this._events)) {
  137. if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);
  138. }
  139.  
  140. if (Object.getOwnPropertySymbols) {
  141. return names.concat(Object.getOwnPropertySymbols(events));
  142. }
  143.  
  144. return names;
  145. };
  146.  
  147. /**
  148. * Return the listeners registered for a given event.
  149. *
  150. * @param {(String|Symbol)} event The event name.
  151. * @returns {Array} The registered listeners.
  152. * @public
  153. */
  154. EventEmitter.prototype.listeners = function listeners(event) {
  155. var evt = prefix ? prefix + event : event
  156. , handlers = this._events[evt];
  157.  
  158. if (!handlers) return [];
  159. if (handlers.fn) return [handlers.fn];
  160.  
  161. for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {
  162. ee[i] = handlers[i].fn;
  163. }
  164.  
  165. return ee;
  166. };
  167.  
  168. /**
  169. * Return the number of listeners listening to a given event.
  170. *
  171. * @param {(String|Symbol)} event The event name.
  172. * @returns {Number} The number of listeners.
  173. * @public
  174. */
  175. EventEmitter.prototype.listenerCount = function listenerCount(event) {
  176. var evt = prefix ? prefix + event : event
  177. , listeners = this._events[evt];
  178.  
  179. if (!listeners) return 0;
  180. if (listeners.fn) return 1;
  181. return listeners.length;
  182. };
  183.  
  184. /**
  185. * Calls each of the listeners registered for a given event.
  186. *
  187. * @param {(String|Symbol)} event The event name.
  188. * @returns {Boolean} `true` if the event had listeners, else `false`.
  189. * @public
  190. */
  191. EventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {
  192. var evt = prefix ? prefix + event : event;
  193.  
  194. if (!this._events[evt]) return false;
  195.  
  196. var listeners = this._events[evt]
  197. , len = arguments.length
  198. , args
  199. , i;
  200.  
  201. if (listeners.fn) {
  202. if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);
  203.  
  204. switch (len) {
  205. case 1: return listeners.fn.call(listeners.context), true;
  206. case 2: return listeners.fn.call(listeners.context, a1), true;
  207. case 3: return listeners.fn.call(listeners.context, a1, a2), true;
  208. case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;
  209. case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;
  210. case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;
  211. }
  212.  
  213. for (i = 1, args = new Array(len -1); i < len; i++) {
  214. args[i - 1] = arguments[i];
  215. }
  216.  
  217. listeners.fn.apply(listeners.context, args);
  218. } else {
  219. var length = listeners.length
  220. , j;
  221.  
  222. for (i = 0; i < length; i++) {
  223. if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);
  224.  
  225. switch (len) {
  226. case 1: listeners[i].fn.call(listeners[i].context); break;
  227. case 2: listeners[i].fn.call(listeners[i].context, a1); break;
  228. case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;
  229. case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;
  230. default:
  231. if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {
  232. args[j - 1] = arguments[j];
  233. }
  234.  
  235. listeners[i].fn.apply(listeners[i].context, args);
  236. }
  237. }
  238. }
  239.  
  240. return true;
  241. };
  242.  
  243. /**
  244. * Add a listener for a given event.
  245. *
  246. * @param {(String|Symbol)} event The event name.
  247. * @param {Function} fn The listener function.
  248. * @param {*} [context=this] The context to invoke the listener with.
  249. * @returns {EventEmitter} `this`.
  250. * @public
  251. */
  252. EventEmitter.prototype.on = function on(event, fn, context) {
  253. return addListener(this, event, fn, context, false);
  254. };
  255.  
  256. /**
  257. * Add a one-time listener for a given event.
  258. *
  259. * @param {(String|Symbol)} event The event name.
  260. * @param {Function} fn The listener function.
  261. * @param {*} [context=this] The context to invoke the listener with.
  262. * @returns {EventEmitter} `this`.
  263. * @public
  264. */
  265. EventEmitter.prototype.once = function once(event, fn, context) {
  266. return addListener(this, event, fn, context, true);
  267. };
  268.  
  269. /**
  270. * Remove the listeners of a given event.
  271. *
  272. * @param {(String|Symbol)} event The event name.
  273. * @param {Function} fn Only remove the listeners that match this function.
  274. * @param {*} context Only remove the listeners that have this context.
  275. * @param {Boolean} once Only remove one-time listeners.
  276. * @returns {EventEmitter} `this`.
  277. * @public
  278. */
  279. EventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {
  280. var evt = prefix ? prefix + event : event;
  281.  
  282. if (!this._events[evt]) return this;
  283. if (!fn) {
  284. clearEvent(this, evt);
  285. return this;
  286. }
  287.  
  288. var listeners = this._events[evt];
  289.  
  290. if (listeners.fn) {
  291. if (
  292. listeners.fn === fn &&
  293. (!once || listeners.once) &&
  294. (!context || listeners.context === context)
  295. ) {
  296. clearEvent(this, evt);
  297. }
  298. } else {
  299. for (var i = 0, events = [], length = listeners.length; i < length; i++) {
  300. if (
  301. listeners[i].fn !== fn ||
  302. (once && !listeners[i].once) ||
  303. (context && listeners[i].context !== context)
  304. ) {
  305. events.push(listeners[i]);
  306. }
  307. }
  308.  
  309. //
  310. // Reset the array, or remove it completely if we have no more listeners.
  311. //
  312. if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;
  313. else clearEvent(this, evt);
  314. }
  315.  
  316. return this;
  317. };
  318.  
  319. /**
  320. * Remove all listeners, or those of the specified event.
  321. *
  322. * @param {(String|Symbol)} [event] The event name.
  323. * @returns {EventEmitter} `this`.
  324. * @public
  325. */
  326. EventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {
  327. var evt;
  328.  
  329. if (event) {
  330. evt = prefix ? prefix + event : event;
  331. if (this._events[evt]) clearEvent(this, evt);
  332. } else {
  333. this._events = new Events();
  334. this._eventsCount = 0;
  335. }
  336.  
  337. return this;
  338. };
  339.  
  340. //
  341. // Alias methods names because people roll like that.
  342. //
  343. EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
  344. EventEmitter.prototype.addListener = EventEmitter.prototype.on;
  345.  
  346. //
  347. // Expose the prefix.
  348. //
  349. EventEmitter.prefixed = prefix;
  350.  
  351. //
  352. // Allow `EventEmitter` to be imported as module namespace.
  353. //
  354. EventEmitter.EventEmitter = EventEmitter;
  355.  
  356. //
  357. // Expose the module.
  358. //
  359. if (true) {
  360. module.exports = EventEmitter;
  361. }
  362.  
  363.  
  364. /***/ }),
  365.  
  366. /***/ 293:
  367. /***/ ((__unused_webpack_module, exports) => {
  368.  
  369.  
  370. Object.defineProperty(exports, "__esModule", ({ value: true }));
  371. function cancelAttachShadow() {
  372. var callback = function () { };
  373. callback.toString = function () {
  374. return 'function () { [native code] }';
  375. };
  376. // @ts-ignore
  377. (unsafeWindow || window).Element.prototype.attachShadow = callback;
  378. }
  379. exports["default"] = cancelAttachShadow;
  380.  
  381.  
  382. /***/ }),
  383.  
  384. /***/ 233:
  385. /***/ ((__unused_webpack_module, exports) => {
  386.  
  387.  
  388. Object.defineProperty(exports, "__esModule", ({ value: true }));
  389. function cancelAttachShadowByVueInstance() {
  390. for (var _i = 0, _a = Array.from(document.querySelectorAll('.subject_describe > div')); _i < _a.length; _i++) {
  391. var div = _a[_i];
  392. // @ts-ignore
  393. div.__vue__.$el.innerHTML = div.__vue__._data.shadowDom.textContent;
  394. }
  395. }
  396. exports["default"] = cancelAttachShadowByVueInstance;
  397.  
  398.  
  399. /***/ }),
  400.  
  401. /***/ 73:
  402. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  403.  
  404.  
  405. var __extends = (this && this.__extends) || (function () {
  406. var extendStatics = function (d, b) {
  407. extendStatics = Object.setPrototypeOf ||
  408. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  409. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  410. return extendStatics(d, b);
  411. };
  412. return function (d, b) {
  413. if (typeof b !== "function" && b !== null)
  414. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  415. extendStatics(d, b);
  416. function __() { this.constructor = d; }
  417. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  418. };
  419. })();
  420. var __importDefault = (this && this.__importDefault) || function (mod) {
  421. return (mod && mod.__esModule) ? mod : { "default": mod };
  422. };
  423. Object.defineProperty(exports, "__esModule", ({ value: true }));
  424. exports.AdapaterManager = exports.AdapterManagerEventEmitType = void 0;
  425. var eventEmitter_1 = __importDefault(__webpack_require__(873));
  426. var lifecycle_1 = __webpack_require__(199);
  427. var AdapterManagerEventEmitType;
  428. (function (AdapterManagerEventEmitType) {
  429. AdapterManagerEventEmitType["ADAPTER_CHANGE"] = "ADAPTER_CHANGE";
  430. })(AdapterManagerEventEmitType = exports.AdapterManagerEventEmitType || (exports.AdapterManagerEventEmitType = {}));
  431. var AdapaterManager = /** @class */ (function (_super) {
  432. __extends(AdapaterManager, _super);
  433. function AdapaterManager() {
  434. var _this = _super !== null && _super.apply(this, arguments) || this;
  435. _this.adapters = [];
  436. return _this;
  437. }
  438. AdapaterManager.prototype.register = function (adapter) {
  439. if (!this.test(adapter))
  440. return;
  441. if (!this.adapter)
  442. this.adapter = adapter;
  443. this.adapters.push(adapter);
  444. if (adapter instanceof lifecycle_1.LifeCycleEvents) {
  445. adapter.emit('after_register');
  446. }
  447. };
  448. AdapaterManager.prototype.use = function () {
  449. var arg = [];
  450. for (var _i = 0; _i < arguments.length; _i++) {
  451. arg[_i] = arguments[_i];
  452. }
  453. this.emit(AdapaterManager.EVENT_EMIT_TYPE.ADAPTER_CHANGE);
  454. };
  455. AdapaterManager.prototype.getAdapters = function () {
  456. return this.adapters;
  457. };
  458. AdapaterManager.prototype.getAdapter = function () {
  459. return this.adapter;
  460. };
  461. AdapaterManager.prototype.test = function (adapter) {
  462. return true;
  463. };
  464. AdapaterManager.ERROR = {
  465. ADAPTER_NOT_FOUND: /** @class */ (function (_super) {
  466. __extends(ADAPTER_NOT_FOUND, _super);
  467. function ADAPTER_NOT_FOUND() {
  468. return _super.call(this, '[adapter manager]: ADAPTER_NOT_FOUND') || this;
  469. }
  470. return ADAPTER_NOT_FOUND;
  471. }(Error)),
  472. };
  473. AdapaterManager.EVENT_EMIT_TYPE = AdapterManagerEventEmitType;
  474. return AdapaterManager;
  475. }(eventEmitter_1.default));
  476. exports.AdapaterManager = AdapaterManager;
  477.  
  478.  
  479. /***/ }),
  480.  
  481. /***/ 873:
  482. /***/ ((__unused_webpack_module, exports) => {
  483.  
  484.  
  485. Object.defineProperty(exports, "__esModule", ({ value: true }));
  486. var EventEmitter = /** @class */ (function () {
  487. function EventEmitter() {
  488. this.events = new Map();
  489. }
  490. EventEmitter.prototype.on = function (key, callback) {
  491. if (!this.events.has(key)) {
  492. this.events.set(key, []);
  493. }
  494. var eventList = this.events.get(key);
  495. eventList.push(callback);
  496. };
  497. EventEmitter.prototype.emit = function (key) {
  498. var _this = this;
  499. var args = [];
  500. for (var _i = 1; _i < arguments.length; _i++) {
  501. args[_i - 1] = arguments[_i];
  502. }
  503. if (!this.events.has(key))
  504. return;
  505. var eventList = this.events.get(key);
  506. eventList.forEach(function (fn) { return fn.apply(_this, args); });
  507. };
  508. EventEmitter.prototype.once = function (key, callback) {
  509. var _this = this;
  510. var handle = function () {
  511. var args = [];
  512. for (var _i = 0; _i < arguments.length; _i++) {
  513. args[_i] = arguments[_i];
  514. }
  515. callback.apply(_this, args);
  516. };
  517. this.on(key, handle);
  518. return function () {
  519. _this.events.set(key, _this.events.get(key).filter(function (fn) { return fn !== handle; }));
  520. };
  521. };
  522. return EventEmitter;
  523. }());
  524. exports["default"] = EventEmitter;
  525.  
  526.  
  527. /***/ }),
  528.  
  529. /***/ 683:
  530. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  531.  
  532.  
  533. var __extends = (this && this.__extends) || (function () {
  534. var extendStatics = function (d, b) {
  535. extendStatics = Object.setPrototypeOf ||
  536. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  537. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  538. return extendStatics(d, b);
  539. };
  540. return function (d, b) {
  541. if (typeof b !== "function" && b !== null)
  542. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  543. extendStatics(d, b);
  544. function __() { this.constructor = d; }
  545. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  546. };
  547. })();
  548. Object.defineProperty(exports, "__esModule", ({ value: true }));
  549. exports.QuestionMatchStatus = exports.QuestionType = exports.QuestionAdapter = exports.Question = void 0;
  550. var lifecycle_1 = __webpack_require__(199);
  551. var Question = /** @class */ (function () {
  552. function Question(question, options, type) {
  553. if (question === void 0) { question = ''; }
  554. if (options === void 0) { options = []; }
  555. if (type === void 0) { type = QuestionType.Radio; }
  556. this.question = question;
  557. this.options = options;
  558. this.type = type;
  559. }
  560. Question.prototype.set_answer = function (answer) {
  561. this.answer = answer;
  562. };
  563. Question.prototype.match_answer = function (answers, format) {
  564. var _this = this;
  565. return this.options
  566. .map(function (item, index) { return [format(_this.type, item.body), index]; })
  567. .filter(function (_a) {
  568. var option = _a[0];
  569. return answers.some(function (answer) { return option.includes(answer) || option === answer; });
  570. })
  571. .map(function (_a) {
  572. var _ = _a[0], index = _a[1];
  573. return index;
  574. });
  575. };
  576. return Question;
  577. }());
  578. exports.Question = Question;
  579. var QuestionAdapter = /** @class */ (function (_super) {
  580. __extends(QuestionAdapter, _super);
  581. function QuestionAdapter() {
  582. return _super !== null && _super.apply(this, arguments) || this;
  583. }
  584. return QuestionAdapter;
  585. }(lifecycle_1.LifeCycleEvents));
  586. exports.QuestionAdapter = QuestionAdapter;
  587. var QuestionType;
  588. (function (QuestionType) {
  589. /** 单选 */
  590. QuestionType[QuestionType["Radio"] = 0] = "Radio";
  591. /** 多选 */
  592. QuestionType[QuestionType["Checkbox"] = 1] = "Checkbox";
  593. /** 判断 */
  594. QuestionType[QuestionType["Judge"] = 3] = "Judge";
  595. /** 填空 */
  596. QuestionType[QuestionType["InBlank"] = 2] = "InBlank";
  597. })(QuestionType = exports.QuestionType || (exports.QuestionType = {}));
  598. var QuestionMatchStatus;
  599. (function (QuestionMatchStatus) {
  600. QuestionMatchStatus[QuestionMatchStatus["NOTFOUND"] = 0] = "NOTFOUND";
  601. QuestionMatchStatus[QuestionMatchStatus["NOTMATCH"] = 1] = "NOTMATCH";
  602. QuestionMatchStatus[QuestionMatchStatus["MATCHED"] = 2] = "MATCHED";
  603. })(QuestionMatchStatus = exports.QuestionMatchStatus || (exports.QuestionMatchStatus = {}));
  604.  
  605.  
  606. /***/ }),
  607.  
  608. /***/ 928:
  609. /***/ (function(__unused_webpack_module, exports) {
  610.  
  611.  
  612. var __assign = (this && this.__assign) || function () {
  613. __assign = Object.assign || function(t) {
  614. for (var s, i = 1, n = arguments.length; i < n; i++) {
  615. s = arguments[i];
  616. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  617. t[p] = s[p];
  618. }
  619. return t;
  620. };
  621. return __assign.apply(this, arguments);
  622. };
  623. Object.defineProperty(exports, "__esModule", ({ value: true }));
  624. exports.Service = void 0;
  625. var Service = /** @class */ (function () {
  626. function Service() {
  627. }
  628. Service.fetch = function (params) {
  629. return new Promise(function (resolve, reject) {
  630. GM_xmlhttpRequest(__assign(__assign({}, params), { onload: function (data) {
  631. resolve(data);
  632. }, onerror: function (error) {
  633. reject(error);
  634. } }));
  635. });
  636. };
  637. return Service;
  638. }());
  639. exports.Service = Service;
  640.  
  641.  
  642. /***/ }),
  643.  
  644. /***/ 181:
  645. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  646.  
  647.  
  648. var __assign = (this && this.__assign) || function () {
  649. __assign = Object.assign || function(t) {
  650. for (var s, i = 1, n = arguments.length; i < n; i++) {
  651. s = arguments[i];
  652. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  653. t[p] = s[p];
  654. }
  655. return t;
  656. };
  657. return __assign.apply(this, arguments);
  658. };
  659. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  660. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  661. return new (P || (P = Promise))(function (resolve, reject) {
  662. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  663. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  664. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  665. step((generator = generator.apply(thisArg, _arguments || [])).next());
  666. });
  667. };
  668. var __generator = (this && this.__generator) || function (thisArg, body) {
  669. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  670. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  671. function verb(n) { return function (v) { return step([n, v]); }; }
  672. function step(op) {
  673. if (f) throw new TypeError("Generator is already executing.");
  674. while (_) try {
  675. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  676. if (y = 0, t) op = [op[0] & 2, t.value];
  677. switch (op[0]) {
  678. case 0: case 1: t = op; break;
  679. case 4: _.label++; return { value: op[1], done: false };
  680. case 5: _.label++; y = op[1]; op = [0]; continue;
  681. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  682. default:
  683. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  684. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  685. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  686. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  687. if (t[2]) _.ops.pop();
  688. _.trys.pop(); continue;
  689. }
  690. op = body.call(thisArg, _);
  691. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  692. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  693. }
  694. };
  695. Object.defineProperty(exports, "__esModule", ({ value: true }));
  696. exports.EventEmitType = exports.QuestionIterable = void 0;
  697. var index_1 = __webpack_require__(377);
  698. var index_2 = __webpack_require__(352);
  699. var index_3 = __webpack_require__(49);
  700. var view_1 = __webpack_require__(855);
  701. var adapterManager_1 = __webpack_require__(73);
  702. var WindowController_1 = __webpack_require__(915);
  703. var SearchController_1 = __webpack_require__(412);
  704. var AnswerView_1 = __webpack_require__(695);
  705. var ServiceAdapterChange_1 = __webpack_require__(723);
  706. var index_4 = __webpack_require__(682);
  707. var icodef_1 = __webpack_require__(819);
  708. var Message_1 = __webpack_require__(489);
  709. var Questions = /** @class */ (function () {
  710. function Questions(quetions) {
  711. this.quetions = quetions;
  712. }
  713. Questions.from = function (adapter) {
  714. return new Questions(adapter.parse());
  715. };
  716. Questions.registerAdapter = function (adapter) {
  717. var instance = new adapter();
  718. if (!instance.match())
  719. return;
  720. this.questionAdapter.push(instance);
  721. };
  722. Questions.questionAdapter = [];
  723. return Questions;
  724. }());
  725. Questions.registerAdapter(index_1.QuestionItemFromMooc);
  726. Questions.registerAdapter(index_2.QuestionItemFromZHIHUISHU);
  727. Questions.registerAdapter(index_3.QuestionItemFromChaoxing);
  728. var QuestionIterable = /** @class */ (function () {
  729. function QuestionIterable(adapter) {
  730. var _this = this;
  731. this.adapter = adapter;
  732. this.adapter.on(adapterManager_1.AdapaterManager.EVENT_EMIT_TYPE.ADAPTER_CHANGE, function () {
  733. _this.resetContext();
  734. });
  735. this.resetContext();
  736. }
  737. QuestionIterable.prototype.syncContextWithAdapter = function () {
  738. var adapter = this.adapter.getAdapter();
  739. adapter.emit('before_match_questions');
  740. Object.assign(this.runningContext, {
  741. data: adapter.parse(),
  742. });
  743. adapter.emit('after_match_questions');
  744. };
  745. QuestionIterable.prototype.next = function (callback) {
  746. return __awaiter(this, void 0, void 0, function () {
  747. var _a, data, index, status, running;
  748. return __generator(this, function (_b) {
  749. switch (_b.label) {
  750. case 0:
  751. console.log(__assign({}, this.runningContext));
  752. _a = this.runningContext, data = _a.data, index = _a.index, status = _a.status, running = _a.running;
  753. if (status === 'done' || status === 'pause' || running)
  754. return [2 /*return*/];
  755. else if (status !== 'running') {
  756. this.setStatus('running');
  757. }
  758. this.runningContext.running = true;
  759. if (index >= data.length)
  760. return [2 /*return*/];
  761. return [4 /*yield*/, callback(data[index], index)];
  762. case 1:
  763. _b.sent();
  764. index += 1;
  765. if (index >= data.length) {
  766. this.setStatus('done');
  767. }
  768. Object.assign(this.runningContext, { running: false, index: index });
  769. this.next(callback);
  770. return [2 /*return*/];
  771. }
  772. });
  773. });
  774. };
  775. QuestionIterable.prototype.pause = function () {
  776. this.setStatus('pause');
  777. };
  778. QuestionIterable.prototype.resetContext = function () {
  779. this.runningContext = {
  780. index: 0,
  781. status: 'canplay',
  782. data: [],
  783. running: false,
  784. };
  785. this.syncContextWithAdapter();
  786. };
  787. QuestionIterable.prototype.setStatus = function (status) {
  788. this.runningContext.status = status;
  789. };
  790. return QuestionIterable;
  791. }());
  792. exports.QuestionIterable = QuestionIterable;
  793. var EventEmitType;
  794. (function (EventEmitType) {
  795. EventEmitType["USER_SEARCH"] = "USERSEARCH";
  796. EventEmitType["USER_SEARCH_RESULT"] = "USER_SEARCH_RESULT";
  797. EventEmitType["AUTO_FIND_PAUSE"] = "AUTO_FIND_PAUSE";
  798. EventEmitType["AUTO_FIND_PLAY"] = "AUTO_FIND_PLAY";
  799. EventEmitType["REFIND_QUESTION"] = "REFIND_QUETION";
  800. })(EventEmitType = exports.EventEmitType || (exports.EventEmitType = {}));
  801. window.addEventListener('load', function () {
  802. var application = new view_1.View();
  803. var serviceAdapterManager = index_4.ServiceAdapterManager.getInstance();
  804. serviceAdapterManager.register(new icodef_1.ICodef());
  805. application.register(new WindowController_1.WindowController());
  806. application.register(new ServiceAdapterChange_1.ServiceAdapterChange());
  807. application.register(new SearchController_1.SearchController());
  808. application.register(new Message_1.Message());
  809. application.register(new AnswerView_1.AnswerView());
  810. application.start();
  811. $(document.body).append(application.container);
  812. });
  813.  
  814.  
  815. /***/ }),
  816.  
  817. /***/ 199:
  818. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  819.  
  820.  
  821. var __extends = (this && this.__extends) || (function () {
  822. var extendStatics = function (d, b) {
  823. extendStatics = Object.setPrototypeOf ||
  824. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  825. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  826. return extendStatics(d, b);
  827. };
  828. return function (d, b) {
  829. if (typeof b !== "function" && b !== null)
  830. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  831. extendStatics(d, b);
  832. function __() { this.constructor = d; }
  833. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  834. };
  835. })();
  836. var __importDefault = (this && this.__importDefault) || function (mod) {
  837. return (mod && mod.__esModule) ? mod : { "default": mod };
  838. };
  839. Object.defineProperty(exports, "__esModule", ({ value: true }));
  840. exports.LifeCycleEvents = void 0;
  841. var eventEmitter_1 = __importDefault(__webpack_require__(873));
  842. var LifeCycleEvents = /** @class */ (function (_super) {
  843. __extends(LifeCycleEvents, _super);
  844. function LifeCycleEvents() {
  845. return _super !== null && _super.apply(this, arguments) || this;
  846. }
  847. return LifeCycleEvents;
  848. }(eventEmitter_1.default));
  849. exports.LifeCycleEvents = LifeCycleEvents;
  850.  
  851.  
  852. /***/ }),
  853.  
  854. /***/ 49:
  855. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  856.  
  857.  
  858. var __extends = (this && this.__extends) || (function () {
  859. var extendStatics = function (d, b) {
  860. extendStatics = Object.setPrototypeOf ||
  861. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  862. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  863. return extendStatics(d, b);
  864. };
  865. return function (d, b) {
  866. if (typeof b !== "function" && b !== null)
  867. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  868. extendStatics(d, b);
  869. function __() { this.constructor = d; }
  870. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  871. };
  872. })();
  873. var __importDefault = (this && this.__importDefault) || function (mod) {
  874. return (mod && mod.__esModule) ? mod : { "default": mod };
  875. };
  876. Object.defineProperty(exports, "__esModule", ({ value: true }));
  877. exports.QuestionOfChaoxing = exports.QuestionItemFromChaoxing = void 0;
  878. var question_1 = __webpack_require__(683);
  879. var cancelAttachShadow_1 = __importDefault(__webpack_require__(293));
  880. function questions2json(questions) {
  881. return questions
  882. .map(function (index, question) { return ({
  883. type: question_1.QuestionType.Radio,
  884. question: (function () {
  885. var _a, _b;
  886. var nodes = (_a = $(question).find('.mark_name').get(0)) === null || _a === void 0 ? void 0 : _a.childNodes;
  887. if (!nodes || !nodes.length)
  888. return '';
  889. return ((_b = nodes[nodes.length - 1]) === null || _b === void 0 ? void 0 : _b.textContent) || '';
  890. })(),
  891. options: $(question)
  892. .find('.mark_letter')
  893. .map(function (index, option) {
  894. var optionel = $(option).text();
  895. var firstSpot = optionel.indexOf('.');
  896. var prefix = optionel.slice(0, firstSpot);
  897. var body = optionel.slice(firstSpot);
  898. return {
  899. prefix: prefix.slice(0),
  900. body: body,
  901. };
  902. })
  903. .toArray(),
  904. }); })
  905. .toArray();
  906. }
  907. var QuestionItemFromChaoxing = /** @class */ (function (_super) {
  908. __extends(QuestionItemFromChaoxing, _super);
  909. function QuestionItemFromChaoxing() {
  910. var _this = _super.call(this) || this;
  911. _this.on('after_register', function () {
  912. (0, cancelAttachShadow_1.default)();
  913. });
  914. return _this;
  915. }
  916. QuestionItemFromChaoxing.prototype.parse = function () {
  917. var questionItem = questions2json($('.questionLi'));
  918. console.log(questionItem);
  919. return questionItem.map(function (item, index) { return new QuestionOfChaoxing(index, { question: item.question, options: item.options, type: item.type }); });
  920. };
  921. QuestionItemFromChaoxing.prototype.match = function () {
  922. return /^(.)*:\/\/(.)*\.chaoxing\.com\/mooc2\/work/.test(location.href);
  923. };
  924. return QuestionItemFromChaoxing;
  925. }(question_1.QuestionAdapter));
  926. exports.QuestionItemFromChaoxing = QuestionItemFromChaoxing;
  927. var QuestionOfChaoxing = /** @class */ (function (_super) {
  928. __extends(QuestionOfChaoxing, _super);
  929. function QuestionOfChaoxing(position, question) {
  930. var _this = _super.call(this, question.question, question.options, question.type) || this;
  931. _this.position = position;
  932. return _this;
  933. }
  934. QuestionOfChaoxing.prototype.select = function () {
  935. var _this = this;
  936. var _a;
  937. if (typeof this.position !== 'number')
  938. return;
  939. (_a = this.answer) === null || _a === void 0 ? void 0 : _a.map(function (index) {
  940. $(".queBox .ti-alist:eq(".concat(_this.position, ") .ti-a .ti-a-i [type=radio]:eq(").concat(index, ")")).click();
  941. });
  942. };
  943. return QuestionOfChaoxing;
  944. }(question_1.Question));
  945. exports.QuestionOfChaoxing = QuestionOfChaoxing;
  946.  
  947.  
  948. /***/ }),
  949.  
  950. /***/ 769:
  951. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  952.  
  953.  
  954. var __extends = (this && this.__extends) || (function () {
  955. var extendStatics = function (d, b) {
  956. extendStatics = Object.setPrototypeOf ||
  957. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  958. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  959. return extendStatics(d, b);
  960. };
  961. return function (d, b) {
  962. if (typeof b !== "function" && b !== null)
  963. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  964. extendStatics(d, b);
  965. function __() { this.constructor = d; }
  966. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  967. };
  968. })();
  969. Object.defineProperty(exports, "__esModule", ({ value: true }));
  970. exports.QuestionAdapterManager = void 0;
  971. var adapterManager_1 = __webpack_require__(73);
  972. var QuestionAdapterManager = /** @class */ (function (_super) {
  973. __extends(QuestionAdapterManager, _super);
  974. function QuestionAdapterManager() {
  975. var _this = _super !== null && _super.apply(this, arguments) || this;
  976. _this.index = 0;
  977. return _this;
  978. }
  979. QuestionAdapterManager.prototype.use = function () {
  980. this.adapter = this.adapters[this.index];
  981. _super.prototype.use.call(this);
  982. };
  983. QuestionAdapterManager.prototype.test = function (adapter) {
  984. return adapter.match();
  985. };
  986. return QuestionAdapterManager;
  987. }(adapterManager_1.AdapaterManager));
  988. exports.QuestionAdapterManager = QuestionAdapterManager;
  989.  
  990.  
  991. /***/ }),
  992.  
  993. /***/ 377:
  994. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  995.  
  996.  
  997. var __extends = (this && this.__extends) || (function () {
  998. var extendStatics = function (d, b) {
  999. extendStatics = Object.setPrototypeOf ||
  1000. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1001. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1002. return extendStatics(d, b);
  1003. };
  1004. return function (d, b) {
  1005. if (typeof b !== "function" && b !== null)
  1006. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1007. extendStatics(d, b);
  1008. function __() { this.constructor = d; }
  1009. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1010. };
  1011. })();
  1012. var __importDefault = (this && this.__importDefault) || function (mod) {
  1013. return (mod && mod.__esModule) ? mod : { "default": mod };
  1014. };
  1015. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1016. exports.QuestionOfMooc = exports.QuestionItemFromMooc = void 0;
  1017. var question_1 = __webpack_require__(683);
  1018. var cancelAttachShadow_1 = __importDefault(__webpack_require__(293));
  1019. function questions2json(questions) {
  1020. return questions
  1021. .map(function (index, question) { return ({
  1022. type: question_1.QuestionType.Radio,
  1023. question: $(question).find('.ti-q-c').text(),
  1024. options: $(question)
  1025. .find('.ti-alist .ti-a')
  1026. .map(function (index, option) {
  1027. var optionel = $(option);
  1028. var prefix = optionel.find('.ti-a-i').text().trim();
  1029. var body = optionel.find('.ti-a-c').text().trim();
  1030. return {
  1031. prefix: prefix.slice(0, prefix.indexOf('.')),
  1032. body: body,
  1033. };
  1034. })
  1035. .toArray(),
  1036. }); })
  1037. .toArray();
  1038. }
  1039. var QuestionItemFromMooc = /** @class */ (function (_super) {
  1040. __extends(QuestionItemFromMooc, _super);
  1041. function QuestionItemFromMooc() {
  1042. var _this = _super.call(this) || this;
  1043. _this.on('after_register', function () {
  1044. (0, cancelAttachShadow_1.default)();
  1045. });
  1046. return _this;
  1047. }
  1048. QuestionItemFromMooc.prototype.parse = function () {
  1049. var questionItem = questions2json($('.queBox'));
  1050. return questionItem.map(function (item, index) { return new QuestionOfMooc(index, { question: item.question, options: item.options, type: item.type }); });
  1051. };
  1052. QuestionItemFromMooc.prototype.match = function () {
  1053. return /^(.)*:\/\/(.)*\.(uooc\.net\.cn|uooconline\.com)\/exam/.test(location.href);
  1054. };
  1055. return QuestionItemFromMooc;
  1056. }(question_1.QuestionAdapter));
  1057. exports.QuestionItemFromMooc = QuestionItemFromMooc;
  1058. var QuestionOfMooc = /** @class */ (function (_super) {
  1059. __extends(QuestionOfMooc, _super);
  1060. function QuestionOfMooc(position, question) {
  1061. var _this = _super.call(this, question.question, question.options, question.type) || this;
  1062. _this.position = position;
  1063. return _this;
  1064. }
  1065. QuestionOfMooc.prototype.select = function () {
  1066. var _this = this;
  1067. var _a;
  1068. if (typeof this.position !== 'number')
  1069. return;
  1070. (_a = this.answer) === null || _a === void 0 ? void 0 : _a.map(function (index) {
  1071. $(".queBox .ti-alist:eq(".concat(_this.position, ") .ti-a .ti-a-i [type=radio]:eq(").concat(index, ")")).click();
  1072. });
  1073. };
  1074. return QuestionOfMooc;
  1075. }(question_1.Question));
  1076. exports.QuestionOfMooc = QuestionOfMooc;
  1077.  
  1078.  
  1079. /***/ }),
  1080.  
  1081. /***/ 352:
  1082. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1083.  
  1084.  
  1085. var __extends = (this && this.__extends) || (function () {
  1086. var extendStatics = function (d, b) {
  1087. extendStatics = Object.setPrototypeOf ||
  1088. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1089. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1090. return extendStatics(d, b);
  1091. };
  1092. return function (d, b) {
  1093. if (typeof b !== "function" && b !== null)
  1094. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1095. extendStatics(d, b);
  1096. function __() { this.constructor = d; }
  1097. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1098. };
  1099. })();
  1100. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1101. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1102. return new (P || (P = Promise))(function (resolve, reject) {
  1103. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1104. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1105. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1106. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1107. });
  1108. };
  1109. var __generator = (this && this.__generator) || function (thisArg, body) {
  1110. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1111. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1112. function verb(n) { return function (v) { return step([n, v]); }; }
  1113. function step(op) {
  1114. if (f) throw new TypeError("Generator is already executing.");
  1115. while (_) try {
  1116. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1117. if (y = 0, t) op = [op[0] & 2, t.value];
  1118. switch (op[0]) {
  1119. case 0: case 1: t = op; break;
  1120. case 4: _.label++; return { value: op[1], done: false };
  1121. case 5: _.label++; y = op[1]; op = [0]; continue;
  1122. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1123. default:
  1124. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1125. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1126. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1127. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1128. if (t[2]) _.ops.pop();
  1129. _.trys.pop(); continue;
  1130. }
  1131. op = body.call(thisArg, _);
  1132. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1133. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1134. }
  1135. };
  1136. var __importDefault = (this && this.__importDefault) || function (mod) {
  1137. return (mod && mod.__esModule) ? mod : { "default": mod };
  1138. };
  1139. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1140. exports.QuestionItemFromZHIHUISHU = exports.QuestionOfZHIHUISHU = void 0;
  1141. var question_1 = __webpack_require__(683);
  1142. var delay_1 = __importDefault(__webpack_require__(225));
  1143. var cancelAttachShadowByVueInstance_1 = __importDefault(__webpack_require__(233));
  1144. var typeRegList = [
  1145. [question_1.QuestionType.Radio, /单选题/],
  1146. [question_1.QuestionType.Checkbox, /多选题/],
  1147. ];
  1148. function questions2json(questions) {
  1149. return questions
  1150. .map(function (index, question) {
  1151. var typeText = $(question).find('.subject_type').text();
  1152. var type = typeRegList.reduce(function (result, rule) {
  1153. if (rule[1].test(typeText))
  1154. return rule[0];
  1155. return result;
  1156. }, question_1.QuestionType.Radio);
  1157. return {
  1158. type: type,
  1159. question: $(question).find('.subject_stem .subject_describe').text(),
  1160. options: $(question)
  1161. .find('.subject_node .nodeLab')
  1162. .map(function (index, option) {
  1163. var optionel = $(option);
  1164. var prefix = optionel.find('.ABCase').text().trim();
  1165. var body = optionel.find('.node_detail').text().trim();
  1166. return {
  1167. prefix: prefix.slice(0, prefix.indexOf('.')),
  1168. body: body,
  1169. };
  1170. })
  1171. .toArray(),
  1172. };
  1173. })
  1174. .toArray();
  1175. }
  1176. var QuestionOfZHIHUISHU = /** @class */ (function (_super) {
  1177. __extends(QuestionOfZHIHUISHU, _super);
  1178. function QuestionOfZHIHUISHU(position, question) {
  1179. var _this = _super.call(this, question.question, question.options, question.type) || this;
  1180. _this.position = position;
  1181. return _this;
  1182. }
  1183. QuestionOfZHIHUISHU.prototype.select = function () {
  1184. var _a;
  1185. return __awaiter(this, void 0, void 0, function () {
  1186. var answer, _b, _c, _d, _i, index, el, _e, answer_1, index;
  1187. return __generator(this, function (_f) {
  1188. switch (_f.label) {
  1189. case 0:
  1190. if (typeof this.position !== 'number')
  1191. return [2 /*return*/];
  1192. answer = this.answer || [];
  1193. _b = this.type;
  1194. switch (_b) {
  1195. case question_1.QuestionType.Checkbox: return [3 /*break*/, 1];
  1196. case question_1.QuestionType.Radio: return [3 /*break*/, 6];
  1197. }
  1198. return [3 /*break*/, 6];
  1199. case 1:
  1200. _c = [];
  1201. for (_d in this.options)
  1202. _c.push(_d);
  1203. _i = 0;
  1204. _f.label = 2;
  1205. case 2:
  1206. if (!(_i < _c.length)) return [3 /*break*/, 5];
  1207. index = _c[_i];
  1208. el = $(".examPaper_subject:eq(".concat(this.position, ") .subject_node .nodeLab input[type]:eq(").concat(index, ")"));
  1209. if (!((_a = el.get(0)) === null || _a === void 0 ? void 0 : _a.checked)) return [3 /*break*/, 4];
  1210. el.click();
  1211. return [4 /*yield*/, (0, delay_1.default)(1000)];
  1212. case 3:
  1213. _f.sent();
  1214. _f.label = 4;
  1215. case 4:
  1216. _i++;
  1217. return [3 /*break*/, 2];
  1218. case 5: return [3 /*break*/, 6];
  1219. case 6:
  1220. _e = 0, answer_1 = answer;
  1221. _f.label = 7;
  1222. case 7:
  1223. if (!(_e < answer_1.length)) return [3 /*break*/, 10];
  1224. index = answer_1[_e];
  1225. $(".examPaper_subject:eq(".concat(this.position, ") .subject_node .nodeLab input[type]:eq(").concat(index, ")")).click();
  1226. return [4 /*yield*/, (0, delay_1.default)(1000)];
  1227. case 8:
  1228. _f.sent();
  1229. _f.label = 9;
  1230. case 9:
  1231. _e++;
  1232. return [3 /*break*/, 7];
  1233. case 10: return [2 /*return*/];
  1234. }
  1235. });
  1236. });
  1237. };
  1238. return QuestionOfZHIHUISHU;
  1239. }(question_1.Question));
  1240. exports.QuestionOfZHIHUISHU = QuestionOfZHIHUISHU;
  1241. var QuestionItemFromZHIHUISHU = /** @class */ (function (_super) {
  1242. __extends(QuestionItemFromZHIHUISHU, _super);
  1243. function QuestionItemFromZHIHUISHU() {
  1244. var _this = _super.call(this) || this;
  1245. _this.on('before_match_questions', function () {
  1246. (0, cancelAttachShadowByVueInstance_1.default)();
  1247. });
  1248. return _this;
  1249. }
  1250. QuestionItemFromZHIHUISHU.prototype.parse = function () {
  1251. var questionItem = questions2json($('.examPaper_subject'));
  1252. return questionItem.map(function (item, index) { return new QuestionOfZHIHUISHU(index, { question: item.question, options: item.options, type: item.type }); });
  1253. };
  1254. QuestionItemFromZHIHUISHU.prototype.match = function () {
  1255. return /^(.)*:\/\/onlineexamh5new\.zhihuishu\.com\/stuExamWeb\.html.*/.test(location.href);
  1256. };
  1257. return QuestionItemFromZHIHUISHU;
  1258. }(question_1.QuestionAdapter));
  1259. exports.QuestionItemFromZHIHUISHU = QuestionItemFromZHIHUISHU;
  1260.  
  1261.  
  1262. /***/ }),
  1263.  
  1264. /***/ 819:
  1265. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1266.  
  1267.  
  1268. var __extends = (this && this.__extends) || (function () {
  1269. var extendStatics = function (d, b) {
  1270. extendStatics = Object.setPrototypeOf ||
  1271. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1272. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1273. return extendStatics(d, b);
  1274. };
  1275. return function (d, b) {
  1276. if (typeof b !== "function" && b !== null)
  1277. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1278. extendStatics(d, b);
  1279. function __() { this.constructor = d; }
  1280. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1281. };
  1282. })();
  1283. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1284. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1285. return new (P || (P = Promise))(function (resolve, reject) {
  1286. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1287. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1288. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1289. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1290. });
  1291. };
  1292. var __generator = (this && this.__generator) || function (thisArg, body) {
  1293. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1294. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1295. function verb(n) { return function (v) { return step([n, v]); }; }
  1296. function step(op) {
  1297. if (f) throw new TypeError("Generator is already executing.");
  1298. while (_) try {
  1299. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1300. if (y = 0, t) op = [op[0] & 2, t.value];
  1301. switch (op[0]) {
  1302. case 0: case 1: t = op; break;
  1303. case 4: _.label++; return { value: op[1], done: false };
  1304. case 5: _.label++; y = op[1]; op = [0]; continue;
  1305. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1306. default:
  1307. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1308. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1309. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1310. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1311. if (t[2]) _.ops.pop();
  1312. _.trys.pop(); continue;
  1313. }
  1314. op = body.call(thisArg, _);
  1315. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1316. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1317. }
  1318. };
  1319. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1320. exports.ICodef = void 0;
  1321. var question_1 = __webpack_require__(683);
  1322. var service_1 = __webpack_require__(928);
  1323. var ICodef = /** @class */ (function (_super) {
  1324. __extends(ICodef, _super);
  1325. function ICodef() {
  1326. var _this = _super !== null && _super.apply(this, arguments) || this;
  1327. _this.name = 'icodef';
  1328. return _this;
  1329. }
  1330. ICodef.prototype.fetch = function (question) {
  1331. var _this = this;
  1332. return new Promise(function (resolve) { return __awaiter(_this, void 0, void 0, function () {
  1333. var response, data;
  1334. return __generator(this, function (_a) {
  1335. switch (_a.label) {
  1336. case 0: return [4 /*yield*/, service_1.Service.fetch({
  1337. method: 'POST',
  1338. url: 'http://cx.icodef.com/wyn-nb',
  1339. headers: {
  1340. 'Content-Type': 'application/x-www-form-urlencoded',
  1341. Authorization: '',
  1342. },
  1343. data: "question=".concat(encodeURIComponent(question.question), "&type=").concat(question.type),
  1344. })];
  1345. case 1:
  1346. response = _a.sent();
  1347. data = JSON.parse(response.responseText);
  1348. resolve(data);
  1349. return [2 /*return*/];
  1350. }
  1351. });
  1352. }); });
  1353. };
  1354. ICodef.prototype.format_answer = function (type, data) {
  1355. var answers = [];
  1356. switch (type) {
  1357. case question_1.QuestionType.Checkbox:
  1358. var datas = data.split('#');
  1359. answers.push.apply(answers, datas.map(function (item) { return item.trim(); }));
  1360. break;
  1361. case question_1.QuestionType.Radio:
  1362. answers.push(data.trim());
  1363. break;
  1364. }
  1365. return {
  1366. answers: answers,
  1367. };
  1368. };
  1369. ICodef.prototype.format_option = function (type, option) {
  1370. return option.trim().replace(/,/g, ',').replace(/。/g, '.').replace(/(/g, '(').replace(/)/g, ')').replace(/(“|”)/g, '"');
  1371. };
  1372. return ICodef;
  1373. }(service_1.Service));
  1374. exports.ICodef = ICodef;
  1375.  
  1376.  
  1377. /***/ }),
  1378.  
  1379. /***/ 682:
  1380. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1381.  
  1382.  
  1383. var __extends = (this && this.__extends) || (function () {
  1384. var extendStatics = function (d, b) {
  1385. extendStatics = Object.setPrototypeOf ||
  1386. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1387. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1388. return extendStatics(d, b);
  1389. };
  1390. return function (d, b) {
  1391. if (typeof b !== "function" && b !== null)
  1392. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1393. extendStatics(d, b);
  1394. function __() { this.constructor = d; }
  1395. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1396. };
  1397. })();
  1398. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1399. exports.ServiceAdapterManager = void 0;
  1400. var adapterManager_1 = __webpack_require__(73);
  1401. var ServiceAdapterManager = /** @class */ (function (_super) {
  1402. __extends(ServiceAdapterManager, _super);
  1403. function ServiceAdapterManager() {
  1404. return _super !== null && _super.apply(this, arguments) || this;
  1405. }
  1406. ServiceAdapterManager.prototype.use = function (index) {
  1407. if (!this.adapters.length) {
  1408. throw new adapterManager_1.AdapaterManager.ERROR.ADAPTER_NOT_FOUND();
  1409. }
  1410. this.adapter = this.adapters[index];
  1411. };
  1412. ServiceAdapterManager.getInstance = function () {
  1413. if (this.__SIMPLE__)
  1414. return this.__SIMPLE__;
  1415. return (this.__SIMPLE__ = new ServiceAdapterManager());
  1416. };
  1417. return ServiceAdapterManager;
  1418. }(adapterManager_1.AdapaterManager));
  1419. exports.ServiceAdapterManager = ServiceAdapterManager;
  1420.  
  1421.  
  1422. /***/ }),
  1423.  
  1424. /***/ 225:
  1425. /***/ ((__unused_webpack_module, exports) => {
  1426.  
  1427.  
  1428. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1429. var delay = function (time) { return new Promise(function (resolve) { return setTimeout(function () { return resolve(undefined); }, time); }); };
  1430. exports["default"] = delay;
  1431.  
  1432.  
  1433. /***/ }),
  1434.  
  1435. /***/ 695:
  1436. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1437.  
  1438.  
  1439. var __extends = (this && this.__extends) || (function () {
  1440. var extendStatics = function (d, b) {
  1441. extendStatics = Object.setPrototypeOf ||
  1442. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1443. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1444. return extendStatics(d, b);
  1445. };
  1446. return function (d, b) {
  1447. if (typeof b !== "function" && b !== null)
  1448. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1449. extendStatics(d, b);
  1450. function __() { this.constructor = d; }
  1451. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1452. };
  1453. })();
  1454. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1455. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1456. return new (P || (P = Promise))(function (resolve, reject) {
  1457. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1458. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1459. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1460. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1461. });
  1462. };
  1463. var __generator = (this && this.__generator) || function (thisArg, body) {
  1464. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1465. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1466. function verb(n) { return function (v) { return step([n, v]); }; }
  1467. function step(op) {
  1468. if (f) throw new TypeError("Generator is already executing.");
  1469. while (_) try {
  1470. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1471. if (y = 0, t) op = [op[0] & 2, t.value];
  1472. switch (op[0]) {
  1473. case 0: case 1: t = op; break;
  1474. case 4: _.label++; return { value: op[1], done: false };
  1475. case 5: _.label++; y = op[1]; op = [0]; continue;
  1476. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1477. default:
  1478. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1479. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1480. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1481. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1482. if (t[2]) _.ops.pop();
  1483. _.trys.pop(); continue;
  1484. }
  1485. op = body.call(thisArg, _);
  1486. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1487. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1488. }
  1489. };
  1490. var __importDefault = (this && this.__importDefault) || function (mod) {
  1491. return (mod && mod.__esModule) ? mod : { "default": mod };
  1492. };
  1493. var _a;
  1494. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1495. exports.AnswerView = exports.ANSWER_EVENT_TYPE = void 0;
  1496. var __1 = __webpack_require__(181);
  1497. var question_1 = __webpack_require__(683);
  1498. var platform_1 = __webpack_require__(769);
  1499. var chaoxing_1 = __webpack_require__(49);
  1500. var mooc_1 = __webpack_require__(377);
  1501. var zhihuishu_1 = __webpack_require__(352);
  1502. var delay_1 = __importDefault(__webpack_require__(225));
  1503. var _1 = __webpack_require__(855);
  1504. var index_1 = __webpack_require__(682);
  1505. var background = (_a = {},
  1506. _a[question_1.QuestionMatchStatus.NOTFOUND] = 'rgba(255, 0, 0, 0.3)',
  1507. _a[question_1.QuestionMatchStatus.NOTMATCH] = 'rgba(0, 255, 0, 0.3)',
  1508. _a[question_1.QuestionMatchStatus.MATCHED] = 'rgba(0, 0, 255, 0.3)',
  1509. _a);
  1510. var ANSWER_EVENT_TYPE;
  1511. (function (ANSWER_EVENT_TYPE) {
  1512. ANSWER_EVENT_TYPE["FOLD"] = "FOLD";
  1513. })(ANSWER_EVENT_TYPE = exports.ANSWER_EVENT_TYPE || (exports.ANSWER_EVENT_TYPE = {}));
  1514. var AnswerView = /** @class */ (function (_super) {
  1515. __extends(AnswerView, _super);
  1516. function AnswerView() {
  1517. var _this = _super !== null && _super.apply(this, arguments) || this;
  1518. _this.name = 'answer-view';
  1519. return _this;
  1520. }
  1521. AnswerView.prototype.apply = function (view) {
  1522. var element = (this.container = this.createElement());
  1523. this.view = view;
  1524. this.register(element, view);
  1525. view.common.append(element);
  1526. this.autoFind();
  1527. };
  1528. AnswerView.prototype.createElement = function () {
  1529. return $("\n <div class=\"\">\n <div style=\"display: flex; align-items: center;\">\n \u672A\u5B8C\u5168\u5339\u914D\u7B54\u6848<div style=\"margin-right: 10px; width: 10px; height: 10px; background: ".concat(background[question_1.QuestionMatchStatus.NOTMATCH], "\"></div>\n \u672A\u627E\u5230\u7B54\u6848<div style=\"margin-right: 10px; width: 10px; height: 10px; background: ").concat(background[question_1.QuestionMatchStatus.NOTFOUND], "\"></div>\n \u5339\u914D\u5230\u7B54\u6848<div style=\"margin-right: 10px; width: 10px; height: 10px; background: ").concat(background[question_1.QuestionMatchStatus.MATCHED], "\"></div>\n </div>\n <div class=\"autoFindController\">\n <button class=\"pause\">\u6682\u505C</button>\n <button class=\"play\">\u5F00\u59CB</button>\n <button class=\"reset\">\u91CD\u65B0\u6536\u96C6\u9898\u76EE</button>\n </div>\n <table class=\"header-fixed\" style=\"height: 20px; width: 100%;background: #fff;\">\n <tr>\n <td width=\"50px\">\u5E8F\u53F7</td>\n <td width=\"300px\" style=\"padding: 5px 10px\" >\u95EE\u9898</td>\n <td width=\"150px\">\u7B54\u6848</td>\n </tr>\n </table>\n <div class=\"list-body\" style=\"overflow: hidden auto; max-height: 300px;\">\n <table class=\"listarea\"></table>\n </div>\n </div>\n "));
  1530. };
  1531. AnswerView.prototype.register = function (element, view) {
  1532. var _this = this;
  1533. this.container.find('.pause').on('click', function () {
  1534. view.emit(__1.EventEmitType.AUTO_FIND_PAUSE);
  1535. });
  1536. this.container.find('.play').on('click', function () {
  1537. view.emit(__1.EventEmitType.AUTO_FIND_PLAY);
  1538. });
  1539. this.container.find('.reset').on('click', function () {
  1540. _this.resetQuestions();
  1541. view.emit(__1.EventEmitType.REFIND_QUESTION);
  1542. });
  1543. view.on(AnswerView.event.FOLD, function () {
  1544. _this.container.toggle();
  1545. });
  1546. };
  1547. AnswerView.prototype.autoFind = function () {
  1548. var self = this;
  1549. var view = this.view;
  1550. var questionAdapterManager = new platform_1.QuestionAdapterManager();
  1551. questionAdapterManager.register(new mooc_1.QuestionItemFromMooc());
  1552. questionAdapterManager.register(new chaoxing_1.QuestionItemFromChaoxing());
  1553. questionAdapterManager.register(new zhihuishu_1.QuestionItemFromZHIHUISHU());
  1554. var questionInterable = new __1.QuestionIterable(questionAdapterManager);
  1555. function questionProcessHandler(question, index) {
  1556. return __awaiter(this, void 0, void 0, function () {
  1557. var status, service, questionAnswer, answers, answer;
  1558. return __generator(this, function (_a) {
  1559. switch (_a.label) {
  1560. case 0:
  1561. service = index_1.ServiceAdapterManager.getInstance().getAdapter();
  1562. _a.label = 1;
  1563. case 1:
  1564. _a.trys.push([1, , 4, 6]);
  1565. console.group("".concat(Number(index) + 1, ": ").concat(question.question));
  1566. return [4 /*yield*/, service.fetch({
  1567. question: question.question,
  1568. type: question.type,
  1569. options: question.options,
  1570. })];
  1571. case 2:
  1572. questionAnswer = _a.sent();
  1573. console.log(questionAnswer.data);
  1574. status = question_1.QuestionMatchStatus.NOTFOUND;
  1575. if (questionAnswer.code !== 1) {
  1576. if (questionAnswer.code === 0) {
  1577. console.log('发生错误');
  1578. }
  1579. else if (questionAnswer.code === -1) {
  1580. console.log('未找到答案');
  1581. }
  1582. return [2 /*return*/];
  1583. }
  1584. answers = service.format_answer(question.type, questionAnswer.data);
  1585. console.log(answers.answers);
  1586. question.rawAnswer = answers.answers;
  1587. answer = question.match_answer(answers.answers, service.format_option);
  1588. console.log(answer);
  1589. status = question_1.QuestionMatchStatus.NOTMATCH;
  1590. if (!answer.length) {
  1591. console.log('没匹配到答案');
  1592. return [2 /*return*/];
  1593. }
  1594. status = question_1.QuestionMatchStatus.MATCHED;
  1595. question.set_answer(answer);
  1596. return [4 /*yield*/, question.select()];
  1597. case 3:
  1598. _a.sent();
  1599. return [3 /*break*/, 6];
  1600. case 4:
  1601. console.groupEnd();
  1602. self.appendQuestion(question, status);
  1603. return [4 /*yield*/, (0, delay_1.default)(3000)];
  1604. case 5:
  1605. _a.sent();
  1606. return [7 /*endfinally*/];
  1607. case 6: return [2 /*return*/];
  1608. }
  1609. });
  1610. });
  1611. }
  1612. questionInterable.next(questionProcessHandler);
  1613. view.on(__1.EventEmitType.AUTO_FIND_PAUSE, function () {
  1614. questionInterable.pause();
  1615. });
  1616. view.on(__1.EventEmitType.AUTO_FIND_PLAY, function () {
  1617. questionInterable.setStatus('canplay');
  1618. questionInterable.next(questionProcessHandler);
  1619. });
  1620. view.on(__1.EventEmitType.REFIND_QUESTION, function () {
  1621. self.resetQuestions();
  1622. questionInterable.resetContext();
  1623. questionInterable.next(questionProcessHandler);
  1624. });
  1625. };
  1626. AnswerView.prototype.appendQuestion = function (question, status) {
  1627. var position = question.position, title = question.question, rawAnswer = question.rawAnswer;
  1628. this.container.find('.listarea').append($("\n <tr style=\"background: ".concat(background[status], "; color: rgba(0,0,0, 0.71);\">\n <td width=\"50px\">").concat(position + 1, "</td>\n <td width=\"300px\" style=\"padding: 5px 10px\">").concat(title, "</td>\n <td width=\"150px\">").concat((rawAnswer === null || rawAnswer === void 0 ? void 0 : rawAnswer.length) ? rawAnswer.join('<br/><br/>') : '未找到答案', "</td>\n </tr>\n ")));
  1629. this.container.find('.list-body').scrollTop(Number.MAX_SAFE_INTEGER);
  1630. };
  1631. AnswerView.prototype.resetQuestions = function () {
  1632. this.container.find('.listarea').html('');
  1633. };
  1634. AnswerView.event = ANSWER_EVENT_TYPE;
  1635. return AnswerView;
  1636. }(_1.ViewPlugin));
  1637. exports.AnswerView = AnswerView;
  1638.  
  1639.  
  1640. /***/ }),
  1641.  
  1642. /***/ 489:
  1643. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1644.  
  1645.  
  1646. var __extends = (this && this.__extends) || (function () {
  1647. var extendStatics = function (d, b) {
  1648. extendStatics = Object.setPrototypeOf ||
  1649. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1650. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1651. return extendStatics(d, b);
  1652. };
  1653. return function (d, b) {
  1654. if (typeof b !== "function" && b !== null)
  1655. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1656. extendStatics(d, b);
  1657. function __() { this.constructor = d; }
  1658. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1659. };
  1660. })();
  1661. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1662. exports.Message = void 0;
  1663. var index_1 = __webpack_require__(855);
  1664. var MessageEvent;
  1665. (function (MessageEvent) {
  1666. MessageEvent["MESSAGE"] = "MESSAGE";
  1667. })(MessageEvent || (MessageEvent = {}));
  1668. var Message = /** @class */ (function (_super) {
  1669. __extends(Message, _super);
  1670. function Message() {
  1671. var _this = _super !== null && _super.apply(this, arguments) || this;
  1672. _this.name = 'message-view';
  1673. return _this;
  1674. }
  1675. Message.prototype.apply = function (view) {
  1676. var element = (this.container = this.createElement());
  1677. this.register(element, view);
  1678. view.common.append(element);
  1679. };
  1680. Message.prototype.createElement = function () {
  1681. return $("\n <div class=\"message\">\u7ED3\u679C\uFF1A<pre class=\"message-view\"></pre></div>\n ");
  1682. };
  1683. Message.prototype.register = function (element, view) {
  1684. view.on(MessageEvent.MESSAGE, function (message) {
  1685. element.find('.message-view').text(message);
  1686. });
  1687. };
  1688. Message.show = function (view, message) {
  1689. view.emit(MessageEvent.MESSAGE, message);
  1690. };
  1691. return Message;
  1692. }(index_1.ViewPlugin));
  1693. exports.Message = Message;
  1694.  
  1695.  
  1696. /***/ }),
  1697.  
  1698. /***/ 412:
  1699. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1700.  
  1701.  
  1702. var __extends = (this && this.__extends) || (function () {
  1703. var extendStatics = function (d, b) {
  1704. extendStatics = Object.setPrototypeOf ||
  1705. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1706. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1707. return extendStatics(d, b);
  1708. };
  1709. return function (d, b) {
  1710. if (typeof b !== "function" && b !== null)
  1711. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1712. extendStatics(d, b);
  1713. function __() { this.constructor = d; }
  1714. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1715. };
  1716. })();
  1717. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  1718. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  1719. return new (P || (P = Promise))(function (resolve, reject) {
  1720. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  1721. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  1722. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  1723. step((generator = generator.apply(thisArg, _arguments || [])).next());
  1724. });
  1725. };
  1726. var __generator = (this && this.__generator) || function (thisArg, body) {
  1727. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  1728. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  1729. function verb(n) { return function (v) { return step([n, v]); }; }
  1730. function step(op) {
  1731. if (f) throw new TypeError("Generator is already executing.");
  1732. while (_) try {
  1733. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  1734. if (y = 0, t) op = [op[0] & 2, t.value];
  1735. switch (op[0]) {
  1736. case 0: case 1: t = op; break;
  1737. case 4: _.label++; return { value: op[1], done: false };
  1738. case 5: _.label++; y = op[1]; op = [0]; continue;
  1739. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  1740. default:
  1741. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  1742. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  1743. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  1744. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  1745. if (t[2]) _.ops.pop();
  1746. _.trys.pop(); continue;
  1747. }
  1748. op = body.call(thisArg, _);
  1749. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  1750. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  1751. }
  1752. };
  1753. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1754. exports.SearchController = void 0;
  1755. var _1 = __webpack_require__(855);
  1756. var index_1 = __webpack_require__(682);
  1757. var question_1 = __webpack_require__(683);
  1758. var Message_1 = __webpack_require__(489);
  1759. var SearchController = /** @class */ (function (_super) {
  1760. __extends(SearchController, _super);
  1761. function SearchController() {
  1762. var _this = _super !== null && _super.apply(this, arguments) || this;
  1763. _this.name = 'search-controller';
  1764. return _this;
  1765. }
  1766. SearchController.prototype.apply = function (view) {
  1767. var element = this.createElement();
  1768. this.register(element, view);
  1769. view.common.append(element);
  1770. };
  1771. SearchController.prototype.createElement = function () {
  1772. return $("\n <div class=\"search-controller\">\n <input class=\"search-input\" />\n <button class=\"search-btn\">\u641C\u7D22</button>\n </div>\n ");
  1773. };
  1774. SearchController.prototype.register = function (element, view) {
  1775. var _this = this;
  1776. var input = element.find('.search-input');
  1777. element.find('.search-btn').on('click', function () { return __awaiter(_this, void 0, void 0, function () {
  1778. var value, service, response, data;
  1779. return __generator(this, function (_a) {
  1780. switch (_a.label) {
  1781. case 0:
  1782. value = input.val();
  1783. if (!value) {
  1784. Message_1.Message.show(view, '请输入内容');
  1785. return [2 /*return*/];
  1786. }
  1787. service = index_1.ServiceAdapterManager.getInstance().getAdapter();
  1788. return [4 /*yield*/, service.fetch({
  1789. question: value,
  1790. type: question_1.QuestionType.Radio,
  1791. options: [],
  1792. })];
  1793. case 1:
  1794. response = _a.sent();
  1795. if (response.code !== 1) {
  1796. if (response.code === 0) {
  1797. Message_1.Message.show(view, '发生错误');
  1798. }
  1799. else if (response.code === -1) {
  1800. Message_1.Message.show(view, '未找到答案');
  1801. }
  1802. return [2 /*return*/];
  1803. }
  1804. data = service.format_answer(question_1.QuestionType.Checkbox, response.data).answers;
  1805. Message_1.Message.show(view, data.join('\n'));
  1806. return [2 /*return*/];
  1807. }
  1808. });
  1809. }); });
  1810. };
  1811. return SearchController;
  1812. }(_1.ViewPlugin));
  1813. exports.SearchController = SearchController;
  1814.  
  1815.  
  1816. /***/ }),
  1817.  
  1818. /***/ 723:
  1819. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1820.  
  1821.  
  1822. var __extends = (this && this.__extends) || (function () {
  1823. var extendStatics = function (d, b) {
  1824. extendStatics = Object.setPrototypeOf ||
  1825. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1826. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1827. return extendStatics(d, b);
  1828. };
  1829. return function (d, b) {
  1830. if (typeof b !== "function" && b !== null)
  1831. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1832. extendStatics(d, b);
  1833. function __() { this.constructor = d; }
  1834. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1835. };
  1836. })();
  1837. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1838. exports.ServiceAdapterChange = void 0;
  1839. var _1 = __webpack_require__(855);
  1840. var service_1 = __webpack_require__(682);
  1841. var ServiceAdapterChange = /** @class */ (function (_super) {
  1842. __extends(ServiceAdapterChange, _super);
  1843. function ServiceAdapterChange() {
  1844. var _this = _super !== null && _super.apply(this, arguments) || this;
  1845. _this.name = 'service-adapter-change';
  1846. return _this;
  1847. }
  1848. ServiceAdapterChange.prototype.apply = function (view) {
  1849. var element = this.createElement();
  1850. this.register(element, view);
  1851. view.common.append(element);
  1852. };
  1853. ServiceAdapterChange.prototype.createElement = function () {
  1854. var adapters = service_1.ServiceAdapterManager.getInstance().getAdapters();
  1855. var names = adapters.map(function (adapter) { return adapter.name; });
  1856. return $("\n <div class=\"service-adapter-controller\">\n <select class=\"service-adapter-select\">\n ".concat(names.map(function (name, index) { return "<option value=\"".concat(index, "\">").concat(name, "</option>"); }), "\n </select>\n </div>\n "));
  1857. };
  1858. ServiceAdapterChange.prototype.register = function (element, view) {
  1859. element.find('.service-adapter-select').on('input', function () {
  1860. var index = Number(element.find('.service-adapter-select').val());
  1861. service_1.ServiceAdapterManager.getInstance().use(index);
  1862. });
  1863. };
  1864. return ServiceAdapterChange;
  1865. }(_1.ViewPlugin));
  1866. exports.ServiceAdapterChange = ServiceAdapterChange;
  1867.  
  1868.  
  1869. /***/ }),
  1870.  
  1871. /***/ 915:
  1872. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1873.  
  1874.  
  1875. var __extends = (this && this.__extends) || (function () {
  1876. var extendStatics = function (d, b) {
  1877. extendStatics = Object.setPrototypeOf ||
  1878. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1879. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1880. return extendStatics(d, b);
  1881. };
  1882. return function (d, b) {
  1883. if (typeof b !== "function" && b !== null)
  1884. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1885. extendStatics(d, b);
  1886. function __() { this.constructor = d; }
  1887. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1888. };
  1889. })();
  1890. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1891. exports.WindowController = void 0;
  1892. var _1 = __webpack_require__(855);
  1893. var AnswerView_1 = __webpack_require__(695);
  1894. var WindowController = /** @class */ (function (_super) {
  1895. __extends(WindowController, _super);
  1896. function WindowController() {
  1897. var _this = _super !== null && _super.apply(this, arguments) || this;
  1898. _this.name = 'window-controller';
  1899. return _this;
  1900. }
  1901. WindowController.prototype.apply = function (view) {
  1902. var element = this.createElement();
  1903. this.register(element, view);
  1904. view.controller.append(element);
  1905. console.log(view, element, 'window - controller register');
  1906. };
  1907. WindowController.prototype.createElement = function () {
  1908. return $("\n <div style=\"display: flex; justify-content: flex-end; width: 100%; align-items: center; align-content: center; font-size: 24px;\">\n <div style=\"cursor: pointer; height: 20px; padding-left: 5px; line-height: 20px; font-size: .7em;\" class=\"fold\">\u6298\u53E0\u7B54\u6848\u533A\u57DF</div>\n <div style=\"cursor: pointer; width: 20px; height: 20px; padding-left: 5px; line-height: 20px;\" class=\"windowToMin\">-</div>\n <div style=\"cursor: pointer; width: 20px; height: 20px; padding-left: 5px; line-height: 20px;\" class=\"windowClose\">x</div>\n </div>\n ");
  1909. };
  1910. WindowController.prototype.register = function (element, view) {
  1911. var openIcon = $("<div class=\"openIcon\" style=\"z-index: 1000; width: 20px; height: 20px; position: fixed; right: 50px; top: 50px; background: red;\"></div>");
  1912. var container = view.container;
  1913. $(document.body).append(openIcon);
  1914. openIcon.hide();
  1915. openIcon.on('click', function () {
  1916. container.show();
  1917. });
  1918. element.find('.windowClose').on('click', function () {
  1919. container.hide();
  1920. });
  1921. element.find('.windowToMin').on('click', function () {
  1922. container.hide();
  1923. openIcon.show();
  1924. });
  1925. element.find('.fold').on('click', function () {
  1926. view.emit(AnswerView_1.AnswerView.event.FOLD);
  1927. });
  1928. };
  1929. return WindowController;
  1930. }(_1.ViewPlugin));
  1931. exports.WindowController = WindowController;
  1932.  
  1933.  
  1934. /***/ }),
  1935.  
  1936. /***/ 855:
  1937. /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
  1938.  
  1939.  
  1940. var __extends = (this && this.__extends) || (function () {
  1941. var extendStatics = function (d, b) {
  1942. extendStatics = Object.setPrototypeOf ||
  1943. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  1944. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  1945. return extendStatics(d, b);
  1946. };
  1947. return function (d, b) {
  1948. if (typeof b !== "function" && b !== null)
  1949. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  1950. extendStatics(d, b);
  1951. function __() { this.constructor = d; }
  1952. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1953. };
  1954. })();
  1955. var __importDefault = (this && this.__importDefault) || function (mod) {
  1956. return (mod && mod.__esModule) ? mod : { "default": mod };
  1957. };
  1958. Object.defineProperty(exports, "__esModule", ({ value: true }));
  1959. exports.View = exports.ViewPlugin = void 0;
  1960. var eventemitter3_1 = __importDefault(__webpack_require__(312));
  1961. var ViewPlugin = /** @class */ (function () {
  1962. function ViewPlugin() {
  1963. }
  1964. return ViewPlugin;
  1965. }());
  1966. exports.ViewPlugin = ViewPlugin;
  1967. var View = /** @class */ (function (_super) {
  1968. __extends(View, _super);
  1969. function View() {
  1970. var _this = _super.call(this) || this;
  1971. _this.plugins = [];
  1972. _this.container = _this.creatElement();
  1973. _this.controller = _this.container.find('.top-container');
  1974. _this.common = _this.container.find('.common');
  1975. return _this;
  1976. }
  1977. View.prototype.register = function (view) {
  1978. this.plugins.push(view);
  1979. };
  1980. View.prototype.creatElement = function () {
  1981. return $("\n <div style=\"z-index: 1000; position: fixed;right: 0;top: 0;width: 500px;max-height: 400px;background: #fff;overflow: hidden auto;\" class=\"container\">\n <div class=\"top-container\"></div>\n <div class=\"common\"></div>\n </div>\n ");
  1982. };
  1983. View.prototype.start = function () {
  1984. var _this = this;
  1985. this.plugins.forEach(function (plugin) {
  1986. console.log(plugin.name, 'will register');
  1987. plugin.apply(_this);
  1988. console.log(plugin.name, 'did register');
  1989. });
  1990. };
  1991. return View;
  1992. }(eventemitter3_1.default));
  1993. exports.View = View;
  1994.  
  1995.  
  1996. /***/ })
  1997.  
  1998. /******/ });
  1999. /************************************************************************/
  2000. /******/ // The module cache
  2001. /******/ var __webpack_module_cache__ = {};
  2002. /******/
  2003. /******/ // The require function
  2004. /******/ function __webpack_require__(moduleId) {
  2005. /******/ // Check if module is in cache
  2006. /******/ var cachedModule = __webpack_module_cache__[moduleId];
  2007. /******/ if (cachedModule !== undefined) {
  2008. /******/ return cachedModule.exports;
  2009. /******/ }
  2010. /******/ // Create a new module (and put it into the cache)
  2011. /******/ var module = __webpack_module_cache__[moduleId] = {
  2012. /******/ // no module.id needed
  2013. /******/ // no module.loaded needed
  2014. /******/ exports: {}
  2015. /******/ };
  2016. /******/
  2017. /******/ // Execute the module function
  2018. /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  2019. /******/
  2020. /******/ // Return the exports of the module
  2021. /******/ return module.exports;
  2022. /******/ }
  2023. /******/
  2024. /************************************************************************/
  2025. /******/
  2026. /******/ // startup
  2027. /******/ // Load entry module and return exports
  2028. /******/ // This entry module is referenced by other modules so it can't be inlined
  2029. /******/ var __webpack_exports__ = __webpack_require__(181);
  2030. /******/
  2031. /******/ })()
  2032. ;