|
129 | 129 | ],
|
130 | 130 | };
|
131 | 131 |
|
132 |
| - let json = [JSON.stringify(data, null, 2)]; |
| 132 | + const json = [JSON.stringify(data, null, 2)]; |
133 | 133 |
|
134 | 134 | data.summary = data.summary
|
135 | 135 | .replace('Brazil', 'Brasil')
|
|
189 | 189 | el.className = el.className.replace(
|
190 | 190 | new RegExp(
|
191 | 191 | '(^|\\b)' + className.split(' ').join('|') + '(\\b|$)',
|
192 |
| - 'gi' |
| 192 | + 'gi', |
193 | 193 | ),
|
194 |
| - ' ' |
| 194 | + ' ', |
195 | 195 | );
|
196 | 196 | }
|
197 | 197 | },
|
|
236 | 236 | try {
|
237 | 237 | data = JSON.parse(this.responseText, jsondiffpatch.dateReviver);
|
238 | 238 | } catch (parseError) {
|
239 |
| - // eslint-disable-next-line standard/no-callback-literal |
| 239 | + // eslint-disable-next-line n/no-callback-literal |
240 | 240 | return callback('parse error: ' + parseError);
|
241 | 241 | }
|
242 | 242 | if (this.status >= 200 && this.status < 400) {
|
|
250 | 250 | request = null;
|
251 | 251 | },
|
252 | 252 | runScriptTags: function(el) {
|
253 |
| - let scripts = el.querySelectorAll('script'); |
| 253 | + const scripts = el.querySelectorAll('script'); |
254 | 254 | for (let i = 0; i < scripts.length; i++) {
|
255 |
| - let s = scripts[i]; |
| 255 | + const s = scripts[i]; |
256 | 256 | // eslint-disable-next-line no-eval
|
257 | 257 | eval(s.innerHTML);
|
258 | 258 | }
|
|
335 | 335 | this.editor = CodeMirror.fromTextArea(this.element, {
|
336 | 336 | mode: 'javascript',
|
337 | 337 | json: true,
|
338 |
| - readOnly: readOnly, |
| 338 | + readOnly, |
339 | 339 | });
|
340 | 340 | if (!readOnly) {
|
341 | 341 | this.editor.on('change', compare);
|
|
391 | 391 | case 'visual':
|
392 | 392 | visualdiff.innerHTML = jsondiffpatch.formatters.html.format(
|
393 | 393 | delta,
|
394 |
| - left |
| 394 | + left, |
395 | 395 | );
|
396 | 396 | if (!document.getElementById('showunchanged').checked) {
|
397 | 397 | jsondiffpatch.formatters.html.hideUnchanged();
|
|
400 | 400 | break;
|
401 | 401 | case 'annotated':
|
402 | 402 | annotateddiff.innerHTML = jsondiffpatch.formatters.annotated.format(
|
403 |
| - delta |
| 403 | + delta, |
404 | 404 | );
|
405 | 405 | break;
|
406 | 406 | case 'json':
|
|
458 | 458 | dom.on(
|
459 | 459 | document.getElementById('show-delta-type-visual'),
|
460 | 460 | 'click',
|
461 |
| - showSelectedDeltaType |
| 461 | + showSelectedDeltaType, |
462 | 462 | );
|
463 | 463 | dom.on(
|
464 | 464 | document.getElementById('show-delta-type-annotated'),
|
465 | 465 | 'click',
|
466 |
| - showSelectedDeltaType |
| 466 | + showSelectedDeltaType, |
467 | 467 | );
|
468 | 468 | dom.on(
|
469 | 469 | document.getElementById('show-delta-type-json'),
|
470 | 470 | 'click',
|
471 |
| - showSelectedDeltaType |
| 471 | + showSelectedDeltaType, |
472 | 472 | );
|
473 | 473 |
|
474 | 474 | dom.on(document.getElementById('swap'), 'click', function() {
|
475 |
| - let leftValue = areas.left.getValue(); |
| 475 | + const leftValue = areas.left.getValue(); |
476 | 476 | areas.left.setValue(areas.right.getValue());
|
477 | 477 | areas.right.setValue(leftValue);
|
478 | 478 | compare();
|
|
488 | 488 | jsondiffpatch.formatters.html.showUnchanged(
|
489 | 489 | document.getElementById('showunchanged').checked,
|
490 | 490 | null,
|
491 |
| - 800 |
| 491 | + 800, |
492 | 492 | );
|
493 | 493 | });
|
494 | 494 |
|
|
514 | 514 |
|
515 | 515 | dom.text(
|
516 | 516 | document.getElementById('json-panel-left').querySelector('h2'),
|
517 |
| - (data.left && data.left.name) || 'left.json' |
| 517 | + (data.left && data.left.name) || 'left.json', |
518 | 518 | );
|
519 | 519 | dom.text(
|
520 | 520 | document.getElementById('json-panel-right').querySelector('h2'),
|
521 |
| - (data.right && data.right.name) || 'right.json' |
| 521 | + (data.right && data.right.name) || 'right.json', |
522 | 522 | );
|
523 | 523 |
|
524 | 524 | document
|
|
539 | 539 | load.gist = function(id) {
|
540 | 540 | dom.getJson('https://api.github.com/gists/' + id, function(error, data) {
|
541 | 541 | if (error) {
|
542 |
| - let message = error + (data && data.message ? data.message : ''); |
| 542 | + const message = error + (data && data.message ? data.message : ''); |
543 | 543 | load.data({
|
544 | 544 | error: message,
|
545 | 545 | });
|
546 | 546 | return;
|
547 | 547 | }
|
548 |
| - let filenames = []; |
549 |
| - for (let filename in data.files) { |
550 |
| - let file = data.files[filename]; |
| 548 | + const filenames = []; |
| 549 | + for (const filename in data.files) { |
| 550 | + const file = data.files[filename]; |
551 | 551 | if (file.language === 'JSON') {
|
552 | 552 | filenames.push(filename);
|
553 | 553 | }
|
554 | 554 | }
|
555 | 555 | filenames.sort();
|
556 |
| - let files = [data.files[filenames[0]], data.files[filenames[1]]]; |
| 556 | + const files = [data.files[filenames[0]], data.files[filenames[1]]]; |
557 | 557 | /* jshint camelcase: false */
|
558 | 558 | load.data({
|
559 | 559 | url: data.html_url,
|
|
577 | 577 | const rightValue = decodeURIComponent(rightValueArg);
|
578 | 578 | const urlmatch = /https?:\/\/.*\/([^/]+\.json)(?:[?#].*)?/;
|
579 | 579 | const dataLoaded = {
|
580 |
| - description: description, |
| 580 | + description, |
581 | 581 | left: {},
|
582 | 582 | right: {},
|
583 | 583 | };
|
|
633 | 633 | gist: /^(?:https?:\/\/)?(?:gist\.github\.com\/)?(?:[\w0-9\-a-f]+\/)?([0-9a-f]+)$/i,
|
634 | 634 | leftright: /^(?:desc=(.*)?&)?left=(.*)&right=(.*)&?$/i,
|
635 | 635 | };
|
636 |
| - for (let loader in matchers) { |
| 636 | + for (const loader in matchers) { |
637 | 637 | const match = matchers[loader].exec(key);
|
638 | 638 | if (match) {
|
639 | 639 | return load[loader].apply(load, match.slice(1));
|
|
658 | 658 | dom.on(document.getElementById('examples'), 'change', function() {
|
659 | 659 | const example = trim(this.value);
|
660 | 660 | switch (example) {
|
661 |
| - case 'text': |
| 661 | + case 'text': { |
662 | 662 | const exampleJson = getExampleJson();
|
663 | 663 | load.data({
|
664 | 664 | left: {
|
|
671 | 671 | },
|
672 | 672 | });
|
673 | 673 | break;
|
| 674 | + } |
674 | 675 | case 'gist':
|
675 | 676 | document.location = '?benjamine/9188826';
|
676 | 677 | break;
|
677 | 678 | case 'moving':
|
678 | 679 | document.location =
|
679 | 680 | '?desc=moving%20around&left=' +
|
680 | 681 | encodeURIComponent(
|
681 |
| - JSON.stringify([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]) |
| 682 | + JSON.stringify([0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]), |
682 | 683 | ) +
|
683 | 684 | '&right=' +
|
684 | 685 | encodeURIComponent(
|
685 |
| - JSON.stringify([10, 0, 1, 7, 2, 4, 5, 6, 88, 9, 3]) |
| 686 | + JSON.stringify([10, 0, 1, 7, 2, 4, 5, 6, 88, 9, 3]), |
686 | 687 | );
|
687 | 688 | break;
|
688 | 689 | case 'query':
|
|
693 | 694 | JSON.stringify({
|
694 | 695 | "don't": 'abuse',
|
695 | 696 | with: ['large', 'urls'],
|
696 |
| - }) |
| 697 | + }), |
697 | 698 | ) +
|
698 | 699 | '&right=' +
|
699 | 700 | encodeURIComponent(
|
700 | 701 | JSON.stringify({
|
701 | 702 | "don't": 'use',
|
702 | 703 | with: ['>', 2, 'KB urls'],
|
703 |
| - }) |
| 704 | + }), |
704 | 705 | );
|
705 | 706 | break;
|
706 | 707 | case 'urls':
|
707 | 708 | document.location =
|
708 | 709 | '?desc=http%20raw%20file%20urls&left=' +
|
709 | 710 | encodeURIComponent(
|
710 | 711 | 'https://rawi.8713187.xyz/benjamine/JsonDiffPatch/' +
|
711 |
| - 'c83e942971c627f61ef874df3cfdd50a95f1c5a2/package.json' |
| 712 | + 'c83e942971c627f61ef874df3cfdd50a95f1c5a2/package.json', |
712 | 713 | ) +
|
713 | 714 | '&right=' +
|
714 | 715 | encodeURIComponent(
|
715 |
| - 'https://rawi.8713187.xyz/benjamine/JsonDiffPatch/master/package.json' |
| 716 | + 'https://rawi.8713187.xyz/benjamine/JsonDiffPatch/master/package.json', |
716 | 717 | );
|
717 | 718 | break;
|
718 | 719 | default:
|
|
0 commit comments