axj-ab_ 1.0.10 → 1.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +21 -10
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -223,7 +223,7 @@ var ab_ = {
223
223
  },
224
224
  nextT: function () {
225
225
  var t = ab_.time();
226
- if (t < _nextT) {
226
+ if (t <= _nextT) {
227
227
  t = ++_nextT;
228
228
  }
229
229
  else {
@@ -562,19 +562,27 @@ var ab_ = {
562
562
  xhrReq: function (loading, headers, url, posts, callback, init) {
563
563
  var xhr = new XMLHttpRequest();
564
564
  var done = XMLHttpRequest.DONE || 4;
565
+ var onDone = function() {
566
+ if(done == -1) return
567
+ done = -1
568
+ onDone = undefined
569
+ loading && loading();
570
+ if (callback) {
571
+ if (xhr.status === 200) {
572
+ callback(null, xhr.responseText);
573
+ }
574
+ else {
575
+ callback(xhr.text || 'fail', null);
576
+ }
577
+ }
578
+ }
565
579
  xhr.onreadystatechange = function () {
566
580
  if (xhr.readyState === done) {
567
- loading && loading();
568
- if (callback) {
569
- if (xhr.status === 200) {
570
- callback(null, xhr.responseText);
571
- }
572
- else {
573
- callback(xhr.text || 'fail', null);
574
- }
575
- }
581
+ onDone()
576
582
  }
577
583
  };
584
+ xhr.onloadend = onDone
585
+ xhr.ontimeout = onDone
578
586
  // 设置30s超时时间
579
587
  // xhr.timeout = 30000
580
588
  // xhr.ontimeout = ab_.xhrOntimeout()
@@ -947,6 +955,9 @@ var ab_ = {
947
955
  return i >= len ? '' : name.substr(0, i);
948
956
  },
949
957
  aNameC: function (a, name, underline) {
958
+ if (name && name[0] === "@") {
959
+ return name.substr(1);
960
+ }
950
961
  if (!a || !name) {
951
962
  return name;
952
963
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "axj-ab_",
3
3
  "type": "commonjs",
4
- "version": "1.0.10",
4
+ "version": "1.0.12",
5
5
  "description": "",
6
6
  "main": "index.js",
7
7
  "scripts": {