@ajaxjs/ui 1.2.9 → 1.3.1

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 (139) hide show
  1. package/.browserslistrc +3 -0
  2. package/.eslintrc.js +26 -0
  3. package/babel.config.js +5 -0
  4. package/deprecated/api-helper.zip +0 -0
  5. package/deprecated/api-helper2.zip +0 -0
  6. package/deprecated/api-selector.zip +0 -0
  7. package/deprecated/common-ui.zip +0 -0
  8. package/deprecated/data-source.zip +0 -0
  9. package/deprecated/table-selector.zip +0 -0
  10. package/deprecated/utils.js +220 -0
  11. package/dist/@ajaxjs/widgets.common.js +3627 -0
  12. package/dist/@ajaxjs/widgets.common.js.map +1 -0
  13. package/dist/@ajaxjs/widgets.css +1 -0
  14. package/dist/@ajaxjs/widgets.umd.js +3638 -0
  15. package/dist/@ajaxjs/widgets.umd.js.map +1 -0
  16. package/dist/@ajaxjs/widgets.umd.min.js +2 -0
  17. package/dist/@ajaxjs/widgets.umd.min.js.map +1 -0
  18. package/dist/demo.html +1 -0
  19. package/examples/App.vue +137 -0
  20. package/package.json +50 -41
  21. package/public/favicon.ico +0 -0
  22. package/public/index.html +17 -0
  23. package/{dist → src}/data-source/data-source.js +16 -16
  24. package/src/data-source/data-source.js.map +1 -0
  25. package/{dist → src}/data-source/data-source.ts +16 -14
  26. package/{dist → src}/iam/iam.js +10 -5
  27. package/src/iam/iam.js.map +1 -0
  28. package/{dist → src}/iam/iam.ts +9 -4
  29. package/src/iam/user.vue +53 -0
  30. package/src/index.js +48 -0
  31. package/{dist/iView-ext/fast-iview-table → src/iview-ext}/list.js +4 -7
  32. package/src/iview-ext/list.js.map +1 -0
  33. package/{dist/iView-ext/fast-iview-table → src/iview-ext}/list.ts +3 -4
  34. package/{dist/table-selector → src/iview-ext}/table-selector.vue +17 -12
  35. package/{dist/iView-ext → src/iview-ext}/tips.vue +5 -2
  36. package/src/libs/entity.js.map +1 -0
  37. package/src/libs/iview-widgets.js.map +1 -0
  38. package/src/main.js +6 -0
  39. package/src/main.js.map +1 -0
  40. package/src/main.ts +7 -0
  41. package/src/shims-tsx.d.ts +11 -0
  42. package/{dist → src}/shims-vue.d.ts +4 -4
  43. package/src/style/common-functions.less +286 -0
  44. package/src/style/reset.less +19 -0
  45. package/src/style/reset2.less +49 -0
  46. package/tsconfig.json +40 -0
  47. package/vue.config.js +14 -0
  48. package/LICENSE +0 -201
  49. package/dist/api-helper/common/arg.vue +0 -46
  50. package/dist/api-helper/common/http-method.vue +0 -53
  51. package/dist/api-helper/common/input-table.vue +0 -128
  52. package/dist/api-helper/document/document-render.d.ts +0 -10
  53. package/dist/api-helper/document/document-render.js +0 -38
  54. package/dist/api-helper/document/document-render.js.map +0 -1
  55. package/dist/api-helper/document/document-render.ts +0 -35
  56. package/dist/api-helper/document/document-render.vue +0 -155
  57. package/dist/api-helper/document/document.d.ts +0 -31
  58. package/dist/api-helper/document/document.js +0 -55
  59. package/dist/api-helper/document/document.js.map +0 -1
  60. package/dist/api-helper/document/document.ts +0 -55
  61. package/dist/api-helper/document/document.vue +0 -78
  62. package/dist/api-helper/document/perview.vue +0 -0
  63. package/dist/api-helper/index.js +0 -142
  64. package/dist/api-helper/index.vue +0 -108
  65. package/dist/api-helper/request-body.vue +0 -66
  66. package/dist/api-helper/table.d.ts +0 -7
  67. package/dist/api-helper/table.js +0 -13
  68. package/dist/api-helper/table.js.map +0 -1
  69. package/dist/api-helper/table.ts +0 -10
  70. package/dist/api-helper/table.vue +0 -103
  71. package/dist/api-helper/xhr.js +0 -100
  72. package/dist/api-helper2/api-helper.d.ts +0 -194
  73. package/dist/api-helper2/api-helper.vue +0 -144
  74. package/dist/api-helper2/bookmark.vue +0 -168
  75. package/dist/api-helper2/common/arg.vue +0 -46
  76. package/dist/api-helper2/common/http-method.vue +0 -53
  77. package/dist/api-helper2/document/document-render.vue +0 -189
  78. package/dist/api-helper2/document/document.vue +0 -130
  79. package/dist/api-helper2/document/perview.vue +0 -0
  80. package/dist/api-helper2/env.vue +0 -140
  81. package/dist/api-helper2/history.vue +0 -116
  82. package/dist/api-helper2/main.vue +0 -70
  83. package/dist/api-helper2/request-body.vue +0 -68
  84. package/dist/api-helper2/table.vue +0 -116
  85. package/dist/api-selector/api-list-dataservice.d.ts +0 -18
  86. package/dist/api-selector/api-list-dataservice.js +0 -209
  87. package/dist/api-selector/api-list-dataservice.js.map +0 -1
  88. package/dist/api-selector/api-list-dataservice.ts +0 -232
  89. package/dist/api-selector/api-list-swagger.d.ts +0 -28
  90. package/dist/api-selector/api-list-swagger.js +0 -179
  91. package/dist/api-selector/api-list-swagger.js.map +0 -1
  92. package/dist/api-selector/api-list-swagger.ts +0 -206
  93. package/dist/api-selector/api-list.d.ts +0 -80
  94. package/dist/api-selector/api-list.js +0 -129
  95. package/dist/api-selector/api-list.js.map +0 -1
  96. package/dist/api-selector/api-list.ts +0 -135
  97. package/dist/api-selector/index.vue +0 -125
  98. package/dist/api-selector/test-dataservice.d.ts +0 -23
  99. package/dist/api-selector/test-dataservice.js +0 -74
  100. package/dist/api-selector/test-dataservice.js.map +0 -1
  101. package/dist/api-selector/test-swagger.d.ts +0 -901
  102. package/dist/api-selector/test-swagger.js +0 -656
  103. package/dist/api-selector/test-swagger.js.map +0 -1
  104. package/dist/data-source/data-source.css +0 -44
  105. package/dist/data-source/data-source.d.ts +0 -14
  106. package/dist/data-source/data-source.html +0 -59
  107. package/dist/data-source/data-source.js.map +0 -1
  108. package/dist/iView-ext/fast-iview-table/fast-iview-table.d.ts +0 -37
  109. package/dist/iView-ext/fast-iview-table/fast-iview-table.js +0 -72
  110. package/dist/iView-ext/fast-iview-table/fast-iview-table.js.map +0 -1
  111. package/dist/iView-ext/fast-iview-table/fast-iview-table.ts +0 -75
  112. package/dist/iView-ext/fast-iview-table/fast-iview-table.vue +0 -52
  113. package/dist/iView-ext/fast-iview-table/list.d.ts +0 -44
  114. package/dist/iView-ext/fast-iview-table/list.js.map +0 -1
  115. package/dist/iam/iam.d.ts +0 -9
  116. package/dist/iam/iam.js.map +0 -1
  117. package/dist/index.d.ts +0 -57
  118. package/dist/index.js +0 -22
  119. package/dist/index.js.map +0 -1
  120. package/dist/index.ts +0 -18
  121. package/dist/libs/entity.d.ts +0 -26
  122. package/dist/libs/entity.js.map +0 -1
  123. package/dist/libs/iview-widgets.d.ts +0 -59
  124. package/dist/libs/iview-widgets.js.map +0 -1
  125. package/dist/main.d.ts +0 -1
  126. package/dist/main.js +0 -24
  127. package/dist/main.js.map +0 -1
  128. package/dist/main.ts +0 -22
  129. package/dist/table-selector/table-selector.htm +0 -28
  130. package/dist/table-selector/table-selector.js +0 -149
  131. /package/{dist → src}/data-source/data-source.less +0 -0
  132. /package/{dist → src}/data-source/data-source.vue +0 -0
  133. /package/{dist → src}/libs/api-helper.d.ts +0 -0
  134. /package/{dist → src}/libs/api-list.d.ts +0 -0
  135. /package/{dist → src}/libs/common.d.ts +0 -0
  136. /package/{dist → src}/libs/entity.js +0 -0
  137. /package/{dist → src}/libs/entity.ts +0 -0
  138. /package/{dist → src}/libs/iview-widgets.js +0 -0
  139. /package/{dist → src}/libs/iview-widgets.ts +0 -0
@@ -1,142 +0,0 @@
1
- import RequestBody from "./request-body.vue";
2
- import Document from "./document/document.vue";
3
- import InputTable from "./common/input-table.vue";
4
-
5
- import { codemirror } from "vue-codemirror";
6
- import "codemirror/addon/selection/active-line.js";
7
- import "codemirror/addon/edit/closebrackets.js";
8
- import "codemirror/mode/javascript/javascript";
9
- import "codemirror/addon/lint/json-lint";
10
- import "codemirror/lib/codemirror.css";
11
- import "codemirror/addon/hint/show-hint.css";
12
- import "codemirror/theme/base16-light.css";
13
-
14
- import xhr from "./xhr";
15
-
16
- export default {
17
- components: { RequestBody, Document, InputTable, codemirror },
18
- mixins: [xhr],
19
- data() {
20
- return {
21
- mainTab: 'form',
22
- url: {
23
- prefix: "https://dd.com",
24
- // main: "https://jsonplaceholder.typicode.com/posts",
25
- main: "https://httpbin.org/post",
26
- },
27
- httpMethod: "POST",
28
-
29
- cmOption: {
30
- tabSize: 4,
31
- styleActiveLine: true,
32
- lineNumbers: true,
33
- mode: "application/json",
34
- // theme: "monokai"
35
- },
36
-
37
- requestParams: {
38
- form: {
39
- contentType: 'application/x-www-form-urlencoded',
40
- data: [
41
- {
42
- enable: true,
43
- key: "param1",
44
- value: "bar",
45
- desc: "",
46
- },
47
- {
48
- enable: true,
49
- key: "param2",
50
- value: "foo",
51
- desc: "",
52
- },
53
- // {
54
- // enable: true,
55
- // key: "",
56
- // value: "",
57
- // desc: "",
58
- // },
59
- ]
60
- },
61
- head: [
62
- {
63
- enable: true,
64
- key: "",
65
- value: "",
66
- desc: "",
67
- },
68
- ],
69
- raw: {
70
- contentType: 'application/json',
71
- json: '{ "title": "My post title", "body": "This is the body of my post." }',
72
- },
73
- queryString: [
74
- {
75
- enable: true,
76
- key: "",
77
- value: "",
78
- desc: "",
79
- },
80
- ],
81
- },
82
-
83
- requestAll: "",
84
- responseHead: "",
85
- responseBody: "",
86
- };
87
- },
88
- mounted() {
89
-
90
- },
91
- methods: {
92
- load() {
93
- let params, contentType;
94
-
95
- if ('form' === this.mainTab) {
96
- contentType = this.requestParams.form.contentType;
97
- params = json2fromParams(this.requestParams.form.data);
98
- } else if ('raw' === this.mainTab) {
99
- contentType = this.requestParams.raw.contentType;
100
- params = this.requestParams.raw.json;
101
- }
102
-
103
- this.doRequest(this.httpMethod, this.url.main, params, {
104
- header: {
105
- 'content-type': contentType
106
- }
107
- });
108
- },
109
- authToken() {
110
- // 读取粘贴板
111
- try {
112
- navigator.clipboard.readText().then((v) => {
113
- console.log("获取剪贴板成功:", v);
114
- this.requestParams.head.unshift({
115
- enable: true,
116
- key: "Authorization",
117
- value: "Bearer " + v,
118
- desc: "认证用的 token",
119
- });
120
- }).catch((v) => {
121
- console.log("获取剪贴板失败: ", v);
122
- });
123
- } catch (e) {
124
- console.log(e);
125
- this.$Message.error('不支持读取粘贴板');
126
- }
127
- },
128
-
129
- formatJs() {
130
- let json = this.requestParams.raw.json;
131
- json = JSON.stringify(JSON.parse(json), null, 4);
132
- this.requestParams.raw.json = json;
133
- }
134
- },
135
- };
136
-
137
- function json2fromParams(arr) {
138
- let _arr = [];
139
- arr.forEach(({ key, value }) => _arr.push(key + '=' + encodeURIComponent(value)));
140
-
141
- return _arr.join('&');
142
- }
@@ -1,108 +0,0 @@
1
- <template>
2
- <div style="clear: both;margin: 30px; border:1px solid lightgray;padding:10px 5px">
3
- <section class="url-bar">
4
- <Input v-model="url.main" style="width: 70%">
5
- <span slot="prepend">
6
- <Select v-model="httpMethod" style="width: 80px">
7
- <Option value="GET">GET</Option>
8
- <Option value="POST">POST</Option>
9
- <Option value="PUT">PUT</Option>
10
- <Option value="DELETE">DELETE</Option>
11
- <Option value="PATCH">PATCH</Option>
12
- <Option value="HEAD">HEAD</Option>
13
- <Option value="OPTION">OPTION</Option>
14
- </Select>
15
- <!-- <Divider type="vertical" />
16
- {{ url.prefix }} -->
17
- </span>
18
- </Input>
19
- <Button style="width: 8%" type="primary" @click="load" :disabled="loading">发送</Button>
20
- <!-- <Button style="width: 8%">保存</Button> -->
21
- </section>
22
-
23
- <!-- <Document /> -->
24
-
25
- <Tabs name="request" class="request" v-model="mainTab" :animated="false">
26
- <TabPane label="请求体 Form" name="form" tab="request">
27
- <div style="margin:10px 0;">
28
- content-type
29
- <Select
30
- style="width:260px;"
31
- size="small"
32
- transfer
33
- v-model="requestParams.form.contentType"
34
- >
35
- <Option value="application/x-www-form-urlencoded">application/x-www-form-urlencoded</Option>
36
- <Option value="multipart/form-data">multipart/form-data</Option>
37
- </Select>
38
- </div>
39
- <InputTable :data="requestParams.form.data" />
40
- </TabPane>
41
- <TabPane label="请求体 Raw" name="raw" tab="request">
42
- <div style="margin:10px 0;">
43
- <a style="float:right;" @click="formatJs">格式化</a>
44
- content-type
45
- <Select
46
- style="width:260px;"
47
- size="small"
48
- transfer
49
- v-model="requestParams.raw.contentType"
50
- >
51
- <Option value="application/json">application/json</Option>
52
- <Option value="application/x-www-form-urlencoded">application/x-www-form-urlencoded</Option>
53
- <Option value="multipart/form-data">multipart/form-data</Option>
54
- <Option value="text/plain">text/plain</Option>
55
- <Option value="text/plain">text/xml</Option>
56
- </Select>
57
- </div>
58
-
59
- <!-- JSON 源码编辑器-->
60
- <codemirror
61
- class="code-editor"
62
- ref="cm"
63
- v-model="requestParams.raw.json"
64
- :options="cmOption"
65
- style="height:200px;"
66
- ></codemirror>
67
- </TabPane>
68
- <TabPane tab="request" label="查询参数 Query" name="name3">
69
- <InputTable :data="requestParams.queryString" />
70
- </TabPane>
71
- <TabPane label="头部参数" name="head" tab="request">
72
- <InputTable :data="requestParams.head" />
73
- <div style="float:right;margin-top:10px;">
74
- <a @click="authToken">一键生成 Bear Token</a>
75
- </div>
76
- </TabPane>
77
- </Tabs>
78
-
79
- <Tabs class="response" name="response" value="responseContent" :animated="false">
80
- <TabPane tab="response" label="返回内容" name="responseContent">
81
- <div style="clear:both;height:30px;font-size:8pt;">
82
- <div style="float:right;height:30px;">Elapsed: {{this.response.elapsed}}ms HTTP status code: <span v-html="formatStatusCode()"></span></div>
83
- </div>
84
- <!-- JSON 源码编辑器-->
85
- <codemirror class="code-editor" v-model="responseBody" :options="cmOption" style="height:300px;"></codemirror>
86
- </TabPane>
87
- <TabPane tab="response" label="返回头部" name="responseHead">
88
- <Input type="textarea" :rows="8" :readonly="true" v-model="responseHead" />
89
- </TabPane>
90
- <TabPane tab="response" label="请求信息" name="requestHead">
91
- <Input type="textarea" :rows="8" :readonly="true" v-model="requestAll" />
92
- </TabPane>
93
- </Tabs>
94
- </div>
95
- </template>
96
-
97
- <script src="./index.js"></script>
98
-
99
- <style lang="less" scoped>
100
- .request {
101
- clear: both;
102
- }
103
-
104
- .url-bar > * {
105
- float: left;
106
- margin-right: 10px;
107
- }
108
- </style>
@@ -1,66 +0,0 @@
1
- <template>
2
- <div>
3
- <RadioGroup v-model="requestType" type="button" size="small">
4
- <Radio label="Form"></Radio>
5
-
6
- <Radio label="Raw"></Radio>
7
- </RadioGroup>
8
- <!--
9
- <span v-if="requestType == 'JSON'" class="jsonRootType">JSON 根类型
10
- <RadioGroup v-model="json.rootType" size="small">
11
- <Radio label="Object" size="small"></Radio>
12
- <Radio label="Array"></Radio>
13
- </RadioGroup>
14
- </span>-->
15
-
16
- <div style="margin-top: 20px">
17
- <section v-if="requestType == 'Form'">
18
- <Table mode="SIMPLE" />
19
- </section>
20
-
21
- <section v-if="requestType == 'JSON'">
22
- <Table mode="SCHEME" />
23
- </section>
24
-
25
- <section v-if="requestType == 'Raw'">
26
- <div style="width:500px;margin:10px 0;">
27
- ContentType
28
- <Select v-model="raw.contentType" style="width:200px;" size="small" transfer>
29
- <Option value="application/json">application/json</Option>
30
- <Option value="application/x-www-form-urlencoded">application/x-www-form-urlencoded</Option>
31
- <Option value="multipart/form-data">multipart/form-data</Option>
32
- <Option value="text/plain">text/plain</Option>
33
- <Option value="text/plain">text/xml</Option>
34
- </Select>
35
- </div>
36
- <Input type="textarea" :rows="4" />
37
- </section>
38
- </div>
39
- </div>
40
- </template>
41
-
42
- <script lang="ts">
43
- import Table from "./table.vue";
44
-
45
- export default {
46
- components: { Table },
47
- data() {
48
- return {
49
- requestType: "Form",
50
- json: {
51
- rootType: "Object",
52
- },
53
- raw: {
54
- contentType: "application/json",
55
- },
56
- };
57
- },
58
- };
59
- </script>
60
-
61
- <style lang="less" scoped>
62
- .jsonRootType {
63
- font-size: 9pt;
64
- padding-left: 20px;
65
- }
66
- </style>
@@ -1,7 +0,0 @@
1
- declare const _default: {
2
- props: {
3
- mode: StringConstructor;
4
- };
5
- data(): API_HELPER_TABLE;
6
- };
7
- export default _default;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = {
4
- props: {
5
- mode: String,
6
- },
7
- data() {
8
- return {
9
- // mode: "SCHEME",
10
- };
11
- },
12
- };
13
- //# sourceMappingURL=table.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"table.js","sourceRoot":"","sources":["../../src/api-helper/table.ts"],"names":[],"mappings":";;AAAA,kBAAe;IACb,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;KACb;IACD,IAAI;QACF,OAAO;QACL,oBAAoB;SACD,CAAC;IACxB,CAAC;CACF,CAAC"}
@@ -1,10 +0,0 @@
1
- export default {
2
- props: {
3
- mode: String,
4
- },
5
- data() {
6
- return {
7
- // mode: "SCHEME",
8
- } as API_HELPER_TABLE;
9
- },
10
- };
@@ -1,103 +0,0 @@
1
- <template>
2
- <div class="table" :class="mode">
3
- <header>
4
- <ul>
5
- <li class="check"><input type="checkbox" /></li>
6
- <li class="name">参数变量名</li>
7
- <li class="type">类型</li>
8
- <li class="value">参数值</li>
9
- <li class="default">值示例</li>
10
- <li class="required">必填</li>
11
- <li class="comment">说明</li>
12
- <li class="action">操作</li>
13
- </ul>
14
- </header>
15
-
16
- <ul class="tableBody">
17
- <li>
18
- <div class="row check">
19
- <input type="checkbox" />
20
- </div>
21
- <div class="row name">
22
- <Input value="dfgg" size="small" />
23
- </div>
24
- <div class="row type">
25
- <Select size="small" transfer>
26
- <Option value="string">string</Option>
27
- <Option value="number">number</Option>
28
- <Option value="boolean">boolean</Option>
29
- <Option value="object">object</Option>
30
- <Option value="array">array</Option>
31
- <Option value="null">null</Option>
32
- </Select>
33
- </div>
34
- <div class="row value">
35
- <Input value="dfgg" size="small" />
36
- </div>
37
-
38
- <div class="row comment">
39
- <Input value="dfgg" size="small" />
40
- </div>
41
- <div class="row action"></div>
42
- </li>
43
- </ul>
44
- </div>
45
- </template>
46
-
47
- <script lang="ts" src="./table.ts"></script>
48
-
49
- <style lang="less" scoped>
50
- .table {
51
- width: 100%;
52
-
53
- .check {
54
- width: 50px;
55
- }
56
- .name {
57
- width: 200px;
58
- }
59
- .type {
60
- width: 100px;
61
- }
62
- .value {
63
- width: 200px;
64
- }
65
- .comment {
66
- width: 300px;
67
- }
68
- .action {
69
- width: 100px;
70
- }
71
-
72
- .row {
73
- display: inline-block;
74
- padding: 0 4px;
75
- box-sizing: border-box;
76
- }
77
- }
78
-
79
- .SCHEME {
80
- .default,
81
- .required {
82
- display: none;
83
- }
84
- }
85
-
86
- header {
87
- background-color: #f8f8f9;
88
- li {
89
- // text-align: center;
90
- padding: 6px 14px;
91
- display: inline-block;
92
- font-weight: bold;
93
- box-sizing: border-box;
94
- }
95
- }
96
-
97
- .tableBody {
98
- li {
99
- padding: 10px;
100
- box-sizing: border-box;
101
- }
102
- }
103
- </style>
@@ -1,100 +0,0 @@
1
- // XHR 发送组件
2
- export default {
3
- data() {
4
- return {
5
- loading: false,
6
- response: {
7
- readyState: 0,
8
- status: 0,
9
- elapsed: 0,
10
- },
11
- };
12
- },
13
-
14
- methods: {
15
- doRequest(method, url, params, cfg) {
16
- let el = new Date();
17
- let xhr = new XMLHttpRequest();
18
- xhr.open(method, url);
19
- xhr.timeout = 5000; // 设置超时时间为5秒
20
- xhr.ontimeout = () => this.loading = false;// 请求超时后的处理
21
- xhr.onreadystatechange = () => {
22
- this.loading = true;
23
- this.response.readyState = xhr.readyState;
24
- this.response.status = xhr.status;
25
-
26
- if (xhr.readyState === 4) {
27
- try {
28
- if (!xhr.responseText) {
29
- this.$Message.error('服务端返回空的字符串');
30
- this.loading = false;
31
-
32
- return;
33
- }
34
-
35
- // 跨域可能不能获取完整的响应头 https://qzy.im/blog/2020/09/can-not-get-response-header-using-javascript-in-cors-request/
36
- let heads = xhr.getAllResponseHeaders();
37
- heads = heads.split(';').join('\n');
38
- this.responseHead = heads;
39
-
40
- let parseContentType = cfg && cfg.parseContentType;
41
- switch (parseContentType) {
42
- case "text":
43
- data = responseText;
44
- break;
45
- case "xml":
46
- data = xhr.responseXML;
47
- break;
48
- case "json":
49
- default:
50
- this.responseBody = JSON.stringify(JSON.parse(xhr.responseText), null, 2);
51
- }
52
- } catch (e) {
53
- alert("HTTP 请求错误:\n" + e + "\nURL: " + url); // 提示用户 异常
54
- } finally {
55
- this.loading = false;
56
- this.response.elapsed = new Date() - el;
57
- }
58
- }
59
- };
60
-
61
- let requestAll = 'HEAD \n' + method.toUpperCase() + ' ' + url + '\n';
62
-
63
- if (cfg && cfg.header) {
64
- for (let i in cfg.header) {
65
- requestAll += i + " : " + cfg.header[i] + '\n';
66
- xhr.setRequestHeader(i, cfg.header[i]);
67
- }
68
- }
69
-
70
- if (params)
71
- requestAll += 'BODY:\n' + params;
72
-
73
- this.requestAll = requestAll;
74
- xhr.send(params || null);
75
- },
76
-
77
- formatStatusCode() {
78
- let code = this.response.status;
79
- let str = code + '';
80
-
81
- if (str[0] === '2')
82
- return `<span style="color:green">${code}</span>`;
83
- else if (str[0] === '4' || str[0] === '5')
84
- return `<span style="color:red">${code}</span>`;
85
- else
86
- return str;
87
- }
88
- },
89
- };
90
-
91
- function json2fromParams(param) {
92
- let result = "";
93
-
94
- for (let name in param) {
95
- if (typeof param[name] != "function")
96
- result += "&" + name + "=" + encodeURIComponent(param[name]);
97
- }
98
-
99
- return result.substring(1);
100
- }