image-server-selector.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. //评卷状态模块
  2. var image_server_selector = function(option, success) {
  3. var object = new ImageServerSelector(option);
  4. success();
  5. return object;
  6. }
  7. function ImageServerSelector(option) {
  8. this.markControl = option.markControl;
  9. this.servers = option.servers;
  10. this.flag = option.flag != undefined && option.flag.length > 0 ? option.flag : '/ok.jpg';
  11. this.connect(0);
  12. }
  13. ImageServerSelector.prototype.connect = function(index) {
  14. if (isArray(this.servers) && this.servers.length > index) {
  15. var self = this;
  16. var url = this.servers[index].trim();
  17. if (url.length > 0) {
  18. $.ajax({
  19. url: url + this.flag,
  20. type: 'GET',
  21. cache: false,
  22. //timeout: 1000,
  23. error: function() {
  24. self.connect(index + 1);
  25. },
  26. success: function() {
  27. self.markControl.context.imageServer = url;
  28. }
  29. });
  30. } else {
  31. self.connect(index + 1);
  32. }
  33. }
  34. }