|
8 | 8 | <link href="./lib/demo.css" rel="stylesheet"/> |
9 | 9 |
|
10 | 10 | <script src="https://unpkg.com/axios/dist/axios.min.js"></script> |
| 11 | + <script src="https://unpkg.com/zepto/dist/zepto.min.js"></script> |
| 12 | + <script src="https://unpkg.com/wavesurfer.js"></script> |
11 | 13 | <script src="../dist/vconsole.min.js"></script> |
12 | 14 | </head> |
13 | 15 | <body ontouchstart> |
|
45 | 47 | <a onclick="sendBeacon()" href="javascript:;" class="weui_btn weui_btn_default">sendBeacon</a> |
46 | 48 | <a onclick="axiosRequest('GET')" href="javascript:;" class="weui_btn weui_btn_default">Axios: GET</a> |
47 | 49 | <a onclick="axiosRequest('POST')" href="javascript:;" class="weui_btn weui_btn_default">Axios: POST</a> |
| 50 | + <a onclick="zeptoRequest('POST')" href="javascript:;" class="weui_btn weui_btn_default">Zepto: POST</a> |
48 | 51 | <a onclick="scrolling()" href="javascript:;" class="weui_btn weui_btn_default">Scrolling</a> |
49 | 52 | <a onclick="crossDomain()" href="javascript:;" class="weui_btn weui_btn_default">Cross Domain</a> |
| 53 | + <a onclick="testWavesurfer()" href="javascript:;" class="weui_btn weui_btn_default">Wavesurfer.js</a> |
50 | 54 | </div> |
51 | 55 |
|
52 | 56 | <div class="section"> |
|
113 | 117 | if (postType === 'json') { |
114 | 118 | postData = JSON.stringify(postData); |
115 | 119 | } |
116 | | - console.log('post data:', postData); |
| 120 | + console.log(xhr.setRequestHeader); |
117 | 121 | xhr.open('POST', `./data/${file}?method=fetchPost&c=中文`); |
| 122 | + xhr.setRequestHeader.apply(xhr, ['custom-auth', 'foobar']); |
118 | 123 | xhr.send(postData); |
119 | 124 | // xhr.send(JSON.stringify({foo: 'bar', id: Math.random(), '<xss0>': '<xss1> XSS Attack!'})); |
120 | 125 | } |
|
173 | 178 | } |
174 | 179 |
|
175 | 180 | function getFetchSimple() { |
176 | | - window.fetch('./data/large.json?type=fetchGet&id=' + Math.random()).then((data) => { |
| 181 | + window.fetch('./data/massive.json?type=fetchGet&id=' + Math.random()).then((data) => { |
177 | 182 | return data.json(); |
178 | 183 | }).then((data) => { |
179 | 184 | console.log('getFetchSimple Response:', data); |
|
375 | 380 | }); |
376 | 381 | } |
377 | 382 |
|
| 383 | +function zeptoRequest(method = 'GET') { |
| 384 | + vConsole.show(); |
| 385 | + $.ajax({ |
| 386 | + type: method, |
| 387 | + async: true, |
| 388 | + url: './data/success.json?method=zepto&r=' + Math.random(), |
| 389 | + headers: { |
| 390 | + 'content-type': 'application/x-www-form-urlencoded', |
| 391 | + 'custom-auth': 'foobar' |
| 392 | + }, |
| 393 | + data: { |
| 394 | + foo: 'bar', |
| 395 | + }, |
| 396 | + xhrFields:{ |
| 397 | + withCredentials: true |
| 398 | + }, |
| 399 | + dataType: 'json', |
| 400 | + success(data) { |
| 401 | + console.log('zeptoRequest response:', data); |
| 402 | + }, |
| 403 | + }); |
| 404 | +} |
| 405 | + |
378 | 406 | function optionsXHR() { |
379 | 407 | console.info('optionsXHR() Start'); |
380 | 408 | const url = window.location.origin + '/dev/success.json?method=optionsXHR&s=200&id=' + Math.random() + '&<xss0>'; |
|
413 | 441 | console.info('optionsFetch() End'); |
414 | 442 | } |
415 | 443 |
|
| 444 | +function testWavesurfer() { |
| 445 | + showPanel(); |
| 446 | + const div = document.createElement('DIV'); |
| 447 | + div.id = 'waveform'; |
| 448 | + document.body.append(div); |
| 449 | + var wavesurfer = WaveSurfer.create({ |
| 450 | + container: '#waveform', |
| 451 | + waveColor: 'violet', |
| 452 | + progressColor: 'purple' |
| 453 | + }); |
| 454 | + wavesurfer.load('./data/a.wav?method=fetch'); |
| 455 | +} |
| 456 | + |
416 | 457 | function scrolling() { |
417 | 458 | vConsole.setOption('maxNetworkNumber', 60); |
418 | 459 | let n = 0 |
|
0 commit comments