<html>
	<head>
		<title>3DPrinterOS Client</title>
		<link rel="stylesheet" type="text/css" href="/static/styles/style.css">
	</head>
	<body bgcolor=#003333>
        <script>
        document.addEventListener('DOMContentLoaded', function() {
            var printerTypeSelect = document.querySelector('select[name="printer_type"]');
            var passwordInput = document.querySelector('input[name="password"]');
            var forcedSNRInput = document.querySelector('input[name="serial_number"]');
            var detectSerialNumberDiv = document.getElementById('detect_serial');

            printerTypeSelect.addEventListener('change', function() {
              var selectedOption = this.options[this.selectedIndex];
              var requiredFields = selectedOption.getAttribute('required_fields');

              if (requiredFields && requiredFields.includes('password')) {
                passwordInput.style.display = 'block';
              } else {
                passwordInput.style.display = 'none';
              }

              if (requiredFields && requiredFields.includes('forced_SNR') || requiredFields.includes('serial_number')) {
                forcedSNRInput.style.display = 'block';
                detectSerialNumberDiv.style.display = 'none';
              } else {
                forcedSNRInput.style.display = 'none';
                detectSerialNumberDiv.style.display = 'block';
              }
            });
        });
        </script>
		<div id='host_version' align='right' style='align: right; color: #006666'>!!!URL!!! !!!VERSION!!!</div>
		<div class="block1">
			<div class="block2">
				3DPrinterOS Client
			</div>
			<center>
				<div class="block3">
					<p>
						Please enter IP and select type of your printer
					</p>
					<form action="/process_network_printer" method="post" style='display: inline' id="printer_type">
                        <div>
                            <input type="text" name="printer_ip" maxlength="128" placeholder="Printer IP address" class="text_field">
                        </div>
                        <div>
                            <input type="text" name="printer_port" maxlength="16" placeholder="Printer port(empty for auto)" class="text_field">
                        </div>
                        <div>
                            <input type="text" name="password" maxlength="32" placeholder="Printer password" class="text_field" style="display:none">
                        </div>
                        <div>
                            <input type="text" name="serial_number" maxlength="64" placeholder="Printer serial number" class="text_field" style="display:none">
                        </div>
                        <div>
                            <font>
                                !!!TYPE_SELECT!!!
                            </font>
                        </div>
                        <div id="detect_serial">
                            <label>Detect serial number</label>
                            <input type="checkbox" name="run_detector" id="run_detector" class="checkbox">
                        </div>
                        <div>
                            <input type="button" onClick="location.href='/'" value="Back" style="" class="big_button">
                            <input type="submit" value="Connect" style="background: #ff9900" class="big_button">
                        </div>
					</form>
				</div>
			</center>
		</div>
	</body>
</html>
