package com.github.hronom.scrape.dat.rooms.view.controllers;

import com.github.hronom.scrape.dat.rooms.view.views.ScrapeView;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.BadLocationException;

public class WebsiteUrlTypingController {
    private static final Logger logger = LogManager.getLogger();

    private final ScrapeView scrapeView;

    public WebsiteUrlTypingController(ScrapeView scrapeViewArg) {
        scrapeView = scrapeViewArg;
        scrapeView.addWebsiteUrlDocumentListener(new DocumentListener() {
            @Override
            public void insertUpdate(DocumentEvent e) {
                try {
                    String str = e.getDocument().getText(0, e.getDocument().getLength());
                    if (str.contains("svc.prd.motel6.com")) {
                        scrapeView.selectParser(ScrapeView.Parser.Motel6_json);
                    } else if (str.contains("motel6.com")) {
                        scrapeView.selectParser(ScrapeView.Parser.Motel6_html);
                    } else if (str.contains("redroof.com")) {
                        scrapeView.selectParser(ScrapeView.Parser.RedRoof);
                    } else if (str.contains("redlion.com")) {
                        scrapeView.selectParser(ScrapeView.Parser.RedLion);
                    } else if (str.contains("ebookers.com")) {
                        scrapeView.selectParser(ScrapeView.Parser.ebookers);
                    } else if (str.contains("windsurfercrs.com")) {
                        scrapeView.selectParser(ScrapeView.Parser.windsurfercrs);
                    }
                } catch (BadLocationException exception) {
                    logger.error(exception);
                }
            }

            @Override
            public void removeUpdate(DocumentEvent e) {
            }

            @Override
            public void changedUpdate(DocumentEvent e) {
            }
        });
    }
}

@@ -1697,24 +1697,162 @@
 surfercrs);%0A
+                    %7D else if (str.contains(%22booking.com%22)) %7B%0A                        scrapeView.selectParser(ScrapeView.Parser.booking);%0A
             

Update typing controller to support booking.com