Ignore:
Timestamp:
2021-12-13T13:36:30+13:00 (2 years ago)
Author:
cstephen
Message:

Use arrow function shorthand to capture scope, removing need for const that = this

Location:
main/trunk/model-interfaces-dev/atea/ocr/src/components
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/model-interfaces-dev/atea/ocr/src/components/EditPage.vue

    r35770 r35805  
    213213            }
    214214
    215             const that = this;
    216 
    217215            ModalController.open(
    218216                this.translations.get("DiscardEditsModal_Title"),
     
    222220                    this.translations.get("DiscardEditsModal_ButtonCancel")
    223221                ],
    224                 async function(buttonName) {
    225                     if (buttonName === that.translations.get("DiscardEditsModal_ButtonContinue")) {
    226                         that.closeAndDiscard(true);
     222                (buttonName) => {
     223                    if (buttonName === this.translations.get("DiscardEditsModal_ButtonContinue")) {
     224                        this.closeAndDiscard(true);
    227225                    }
    228226                }
     
    233231
    234232            const buffer = Buffer.from(this.imageBuffer);
    235             const that = this;
    236233
    237234            const modifiedBuffer = await Jimp.read(buffer)
    238235                .then(async image => {
    239                     if (that.invert) {
     236                    if (this.invert) {
    240237                        image.invert();
    241238                    }
    242239
    243                     if (that.rotation !== 0) {
    244                         image.rotate(-that.rotation);
     240                    if (this.rotation !== 0) {
     241                        image.rotate(-this.rotation);
    245242                    }
    246243
  • main/trunk/model-interfaces-dev/atea/ocr/src/components/MainPage.vue

    r35800 r35805  
    7979                }
    8080
    81                 const that = this;
    8281                this.ocrInProgress = true;
    83                 const longTimeout = setTimeout(function() {
    84                     SnackController.addSnack(that.translations.get("MainPage_DelayedOcrMessage"), 8000);
    85                 }, 10000);
     82
     83                const longTimeout = setTimeout(() => {
     84                    SnackController.addSnack(this.translations.get("MainPage_DelayedOcrMessage"), 8000);
     85                }, 10000)
    8686
    8787                const arrayView = new Uint8Array(this.imageBuffer);
     
    118118        },
    119119        confirmOcr() {
    120             const that = this;
    121 
    122120            ModalController.open(
    123121                this.translations.get("OCREditedModal_Title"),
     
    127125                    this.translations.get("OCREditedModal_ButtonCancel")
    128126                ],
    129                 async function(buttonName) {
    130                     if (buttonName === that.translations.get("OCREditedModal_ButtonContinue")) {
    131                         that.ocrTextEdited = false;
    132                         await that.doOcr();
     127                async (buttonName) => {
     128                    if (buttonName === this.translations.get("OCREditedModal_ButtonContinue")) {
     129                        this.ocrTextEdited = false;
     130                        await this.doOcr();
    133131                    }
    134132                }
     
    153151        reset(hard) {
    154152            if (!hard) {
    155                 const that = this;
    156 
    157153                ModalController.open(
    158154                    this.translations.get("NewImageModal_Title"),
     
    162158                        this.translations.get("NewImageModal_ButtonCancel")
    163159                    ],
    164                     function(buttonName) {
    165                         if (buttonName === that.translations.get("NewImageModal_ButtonContinue")) {
    166                             that.reset(true);
     160                    (buttonName) => {
     161                        if (buttonName === this.translations.get("NewImageModal_ButtonContinue")) {
     162                            this.reset(true);
    167163                        }
    168164                    }
  • main/trunk/model-interfaces-dev/atea/ocr/src/components/ModalDialog.vue

    r35762 r35805  
    109109        this.waitingOnClose = true;
    110110        const item = this.queue.shift();
    111         const that = this;
    112111
    113112        this.modal.show(
     
    115114            item.description,
    116115            item.buttons,
    117             function(buttonName, id) {
    118                 that.waitingOnClose = false;
    119                 that.showModals();
     116            (buttonName, id) => {
     117                this.waitingOnClose = false;
     118                this.showModals();
    120119                item.callback(buttonName, id);
    121120            },
  • main/trunk/model-interfaces-dev/atea/ocr/src/components/OcrImageDisplay.vue

    r35793 r35805  
    5353            e.preventDefault();
    5454
    55             const that = this;
    5655            /** @type {DOMRect} */
    57             const magContainerBounds = that.$refs.magContainer.getBoundingClientRect();
     56            const magContainerBounds = this.$refs.magContainer.getBoundingClientRect();
    5857            /** @type {HTMLDivElement} */
    5958            const magnifier = this.$refs.magnifier;
     
    124123    watch: {
    125124        imageUrl() {
    126             const that = this;
    127             setTimeout(function() {
    128                 that.updateMagnifier(that.$refs.ocrImage);
     125            setTimeout(() => {
     126                this.updateMagnifier(this.$refs.ocrImage);
    129127            }, 100);
    130128        },
     
    134132            }
    135133
    136             const that = this;
    137             setTimeout(function() {
    138                 that.updateMagnifier(that.$refs.thresholdedImage);
     134            setTimeout(() => {
     135                this.updateMagnifier(this.$refs.thresholdedImage);
    139136            }, 100);
    140137        },
    141138        showThresholdedImage(newValue) {
    142             const that = this;
    143             setTimeout(function() {
     139            setTimeout(() => {
    144140                if (newValue) {
    145                     that.updateMagnifier(that.$refs.thresholdedImage);
     141                    this.updateMagnifier(this.$refs.thresholdedImage);
    146142                }
    147143                else {
    148                     that.updateMagnifier(that.$refs.ocrImage);
     144                    this.updateMagnifier(this.$refs.ocrImage);
    149145                }
    150146            }, 100);
     
    160156    },
    161157    mounted() {
    162         const that = this;
    163         setTimeout(function() {
    164             that.updateMagnifier(that.$refs.ocrImage);
     158        setTimeout(() => {
     159            this.updateMagnifier(this.$refs.ocrImage);
    165160        }, 100);
    166161    }
  • main/trunk/model-interfaces-dev/atea/ocr/src/components/Snackbar.vue

    r35785 r35805  
    4040        setContent(content, timeout = 3000) {
    4141            this.content = content;
    42             const that = this;
    4342
    44             setTimeout(function() {
    45                 that.content = null;
     43            setTimeout(() => {
     44                this.content = null;
    4645            }, timeout);
    4746        }
Note: See TracChangeset for help on using the changeset viewer.