HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<body>
<div class="grid-container">
<!-- Top bar -->
<div class="top-bar">
<div class="top-bar-left">
<div class="menu-text">WPA Supplicant Generator</div>
</div>
<div class="top-bar-right">
<a href="#"><i class="fi-social-github"></i></a>
</div>
</div>
<!-- Body of page -->
<div class="grid-x grid-padding-x">
<div class="cell small-4">
<div class="card">
<div class="card-divider">
Config
</div>
<div class="card-section">
<label >
Country code:<br />
<select data-bind="options: countryOptions, optionsText: 'text', optionsValue: 'value', value: chosenCountry"></select>
</label>
<label>
Security Type:<br />
<label>
<select data-bind="options: securityOptions, optionsText: 'text', optionsValue: 'value', value: chosenSecurity"></select>
</label>
</label>
<!-- WPA/WPA2 -->
<div data-bind="visible: chosenSecurityType() === 'wpa'">
<label>
SSID (Network Name):<br />
<input type="text" data-bind="textInput: ssid" />
</label>
<label>
Password:<br />
<input type="text" data-bind="textInput: netPass">
</label>
</div>
<!-- No Password (You live dangerously) -->
<div data-bind="visible: chosenSecurityType() === 'open'">
<label>
SSID (Network Name):<br />
<input type="text" data-bind="textInput: ssid" />
</label>
</div>
<!-- Hidden SSID WPA/WPA2 -->
<div data-bind="visible: chosenSecurityType() === 'hidden'">
<label>
SSID (Network Name):<br />
<input type="text" data-bind="textInput: ssid" />
</label>
</div>
<!-- Hidden SSID No Password -->
<div data-bind="visible: chosenSecurityType() === 'hiddenPass'">
<label>
SSID (Network Name):<br />
<input type="text" data-bind="textInput: ssid" />
</label>
<label>
Password:<br />
<input type="text" data-bind="textInput: netPass">
</label>
</div>
</div>
</div>
</div>
<div class="cell small-8">
<label>
File contents:
<div contenteditable="true" id="supplicantText" class="bordered">
country=<span data-bind="text: chosenCountry"></span><br />
update_config=1<br />
ctrl_interface=/var/run/wpa_supplicant<br />
<br />
<div data-bind="visible: chosenSecurityType() === 'wpa'">
network={<br />
ssid="<span data-bind="text: ssid"></span>"<br />
psk="<span data-bind="text: netPass"></span>"<br />
key_mgmt=WPA-PSK<br />
}
</div>
<div data-bind="visible: chosenSecurityType() === 'open'">
network={<br />
ssid="<span data-bind="text: ssid"></span>"<br />
key_mgmt=NONE<br />
}
</div>
<div data-bind="visible: chosenSecurityType() === 'hidden'">
network={<br />
ssid="<span data-bind="text: ssid"></span>"<br />
key_mgmt=NONE<br />
scan_ssid=1<br />
}
</div>
<div data-bind="visible: chosenSecurityType() === 'hiddenPass'">
network={<br />
ssid="<span data-bind="text: ssid"></span>"<br />
psk="<span data-bind="text: netPass"></span>"<br />
scan_ssid=1<br />
}
</div>
</div>
</label>
</div>
<div class="float-center">
<a type="button" class="button" onclick="downloadInnerHtml('wpa_supplicant.conf', 'supplicantText', 'text/plain')">Download wpa_supplicant.conf</a>
<a type="button" class="button" onclick="downloadInnerHtml('octopi-wpa-supplicant.txt', 'supplicantText', 'text/plain')">Download octoprint-wpa-supplicant.txt</a>
</div>
</div>
</div>
var viewModel = {
countryOptions: [
{ text: 'Afghanistan', value: 'AF' },
{ text: 'Aland Islands', value: 'AX' },
{ text: 'Albania', value: 'AL' },
{ text: 'Algeria', value: 'DZ' },
{ text: 'American Samoa', value: 'AS' },
{ text: 'Andorra', value: 'AD' },
{ text: 'Angola', value: 'AO' },
{ text: 'Anguilla', value: 'AI' },
{ text: 'Antarctica', value: 'AQ' },
{ text: 'Antigua and Barbuda', value: 'AG' },
{ text: 'Argentina', value: 'AR' },
{ text: 'Armenia', value: 'AM' },
{ text: 'Aruba', value: 'AW' },
{ text: 'Australia', value: 'AU' },
{ text: 'Austria', value: 'AT' },
{ text: 'Azerbaijan', value: 'AZ' },
{ text: 'Bahamas', value: 'BS' },
{ text: 'Bahrain', value: 'BH' },
{ text: 'Bangladesh', value: 'BD' },
{ text: 'Barbados', value: 'BB' },
{ text: 'Belarus', value: 'BY' },
{ text: 'Belgium', value: 'BE' },
{ text: 'Belize', value: 'BZ' },
{ text: 'Benin', value: 'BJ' },
{ text: 'Bermuda', value: 'BM' },
{ text: 'Bhutan', value: 'BT' },
{ text: 'Bolivia', value: 'BO' },
{ text: 'Bosnia and Herzegovina', value: 'BA' },
{ text: 'Botswana', value: 'BW' },
{ text: 'Bouvet Island', value: 'BV' },
{ text: 'Brazil', value: 'BR' },
{ text: 'British Indian Ocean Territory', value: 'IO' },
{ text: 'British Virgin Islands', value: 'VG' },
{ text: 'Brunei Darussalam', value: 'BN' },
{ text: 'Bulgaria', value: 'BG' },
{ text: 'Burkina Faso', value: 'BF' },
{ text: 'Burundi', value: 'BI' },
{ text: 'Cambodia', value: 'KH' },
{ text: 'Cameroon', value: 'CM' },
{ text: 'Canada', value: 'CA' },
{ text: 'Cape Verde', value: 'CV' },
{ text: 'Cayman Islands', value: 'KY' },
{ text: 'Central African Republic', value: 'CF' },
{ text: 'Chad', value: 'TD' },
{ text: 'Chile', value: 'CL' },
{ text: 'China', value: 'CN' },
{ text: 'Christmas Island', value: 'CX' },
{ text: 'Cocos (Keeling) Islands', value: 'CC' },
{ text: 'Colombia', value: 'CO' },
{ text: 'Comoros', value: 'KM' },
{ text: 'Congo (Brazzaville)', value: 'CG' },
{ text: 'Congo, (Kinshasa)', value: 'CD' },
{ text: 'Cook Islands', value: 'CK' },
{ text: 'Costa Rica', value: 'CR' },
{ text: 'Cote d\'Ivoire', value: 'CI' },
{ text: 'Croatia', value: 'HR' },
{ text: 'Cuba', value: 'CU' },
{ text: 'Cyprus', value: 'CY' },
{ text: 'Czech Republic', value: 'CZ' },
{ text: 'Denmark', value: 'DK' },
{ text: 'Djibouti', value: 'DJ' },
{ text: 'Dominica', value: 'DM' },
{ text: 'Dominican Republic', value: 'DO' },
{ text: 'Ecuador', value: 'EC' },
{ text: 'Egypt', value: 'EG' },
{ text: 'El Salvador', value: 'SV' },
{ text: 'Equatorial Guinea', value: 'GQ' },
{ text: 'Eritrea', value: 'ER' },
{ text: 'Estonia', value: 'EE' },
{ text: 'Ethiopia', value: 'ET' },
{ text: 'Falkland Islands (Malvinas)', value: 'FK' },
{ text: 'Faroe Islands', value: 'FO' },
{ text: 'Fiji', value: 'FJ' },
{ text: 'Finland', value: 'FI' },
{ text: 'France', value: 'FR' },
{ text: 'French Guiana', value: 'GF' },
{ text: 'French Polynesia', value: 'PF' },
{ text: 'French Southern Territories', value: 'TF' },
{ text: 'Gabon', value: 'GA' },
{ text: 'Gambia', value: 'GM' },
{ text: 'Georgia', value: 'GE' },
{ text: 'Germany', value: 'DE' },
{ text: 'Ghana', value: 'GH' },
{ text: 'Gibraltar', value: 'GI' },
{ text: 'Greece', value: 'GR' },
{ text: 'Greenland', value: 'GL' },
{ text: 'Grenada', value: 'GD' },
{ text: 'Guadeloupe', value: 'GP' },
{ text: 'Guam', value: 'GU' },
{ text: 'Guatemala', value: 'GT' },
{ text: 'Guernsey', value: 'GG' },
{ text: 'Guinea', value: 'GN' },
{ text: 'Guinea-Bissau', value: 'GW' },
{ text: 'Guyana', value: 'GY' },
{ text: 'Haiti', value: 'HT' },
{ text: 'Heard and Mcdonald Islands', value: 'HM' },
{ text: 'Holy See (Vatican City State)', value: 'VA' },
{ text: 'Honduras', value: 'HN' },
{ text: 'Hong Kong, SAR China', value: 'HK' },
{ text: 'Hungary', value: 'HU' },
{ text: 'Iceland', value: 'IS' },
{ text: 'India', value: 'IN' },
{ text: 'Indonesia', value: 'ID' },
{ text: 'Iran, Islamic Republic of', value: 'IR' },
{ text: 'Iraq', value: 'IQ' },
{ text: 'Ireland', value: 'IE' },
{ text: 'Isle of Man', value: 'IM' },
{ text: 'Israel', value: 'IL' },
{ text: 'Italy', value: 'IT' },
{ text: 'Jamaica', value: 'JM' },
{ text: 'Japan', value: 'JP' },
{ text: 'Jersey', value: 'JE' },
{ text: 'Jordan', value: 'JO' },
{ text: 'Kazakhstan', value: 'KZ' },
{ text: 'Kenya', value: 'KE' },
{ text: 'Kiribati', value: 'KI' },
{ text: 'Korea (North)', value: 'KP' },
{ text: 'Korea (South)', value: 'KR' },
{ text: 'Kuwait', value: 'KW' },
{ text: 'Kyrgyzstan', value: 'KG' },
{ text: 'Lao PDR', value: 'LA' },
{ text: 'Latvia', value: 'LV' },
{ text: 'Lebanon', value: 'LB' },
{ text: 'Lesotho', value: 'LS' },
{ text: 'Liberia', value: 'LR' },
{ text: 'Libya', value: 'LY' },
{ text: 'Liechtenstein', value: 'LI' },
{ text: 'Lithuania', value: 'LT' },
{ text: 'Luxembourg', value: 'LU' },
{ text: 'Macao, SAR China', value: 'MO' },
{ text: 'Macedonia, Republic of', value: 'MK' },
{ text: 'Madagascar', value: 'MG' },
{ text: 'Malawi', value: 'MW' },
{ text: 'Malaysia', value: 'MY' },
{ text: 'Maldives', value: 'MV' },
{ text: 'Mali', value: 'ML' },
{ text: 'Malta', value: 'MT' },
{ text: 'Marshall Islands', value: 'MH' },
{ text: 'Martinique', value: 'MQ' },
{ text: 'Mauritania', value: 'MR' },
{ text: 'Mauritius', value: 'MU' },
{ text: 'Mayotte', value: 'YT' },
{ text: 'Mexico', value: 'MX' },
{ text: 'Micronesia, Federated States of', value: 'FM' },
{ text: 'Moldova', value: 'MD' },
{ text: 'Monaco', value: 'MC' },
{ text: 'Mongolia', value: 'MN' },
{ text: 'Montenegro', value: 'ME' },
{ text: 'Montserrat', value: 'MS' },
{ text: 'Morocco', value: 'MA' },
{ text: 'Mozambique', value: 'MZ' },
{ text: 'Myanmar', value: 'MM' },
{ text: 'Namibia', value: 'NA' },
{ text: 'Nauru', value: 'NR' },
{ text: 'Nepal', value: 'NP' },
{ text: 'Netherlands', value: 'NL' },
{ text: 'Netherlands Antilles', value: 'AN' },
{ text: 'New Caledonia', value: 'NC' },
{ text: 'New Zealand', value: 'NZ' },
{ text: 'Nicaragua', value: 'NI' },
{ text: 'Niger', value: 'NE' },
{ text: 'Nigeria', value: 'NG' },
{ text: 'Niue', value: 'NU' },
{ text: 'Norfolk Island', value: 'NF' },
{ text: 'Northern Mariana Islands', value: 'MP' },
{ text: 'Norway', value: 'NO' },
{ text: 'Oman', value: 'OM' },
{ text: 'Pakistan', value: 'PK' },
{ text: 'Palau', value: 'PW' },
{ text: 'Palestinian Territory', value: 'PS' },
{ text: 'Panama', value: 'PA' },
{ text: 'Papua New Guinea', value: 'PG' },
{ text: 'Paraguay', value: 'PY' },
{ text: 'Peru', value: 'PE' },
{ text: 'Philippines', value: 'PH' },
{ text: 'Pitcairn', value: 'PN' },
{ text: 'Poland', value: 'PL' },
{ text: 'Portugal', value: 'PT' },
{ text: 'Puerto Rico', value: 'PR' },
{ text: 'Qatar', value: 'QA' },
{ text: 'Réunion', value: 'RE' },
{ text: 'Romania', value: 'RO' },
{ text: 'Russian Federation', value: 'RU' },
{ text: 'Rwanda', value: 'RW' },
{ text: 'Saint Helena', value: 'SH' },
{ text: 'Saint Kitts and Nevis', value: 'KN' },
{ text: 'Saint Lucia', value: 'LC' },
{ text: 'Saint Pierre and Miquelon', value: 'PM' },
{ text: 'Saint Vincent and Grenadines', value: 'VC' },
{ text: 'Saint-Barthélemy', value: 'BL' },
{ text: 'Saint-Martin (French part)', value: 'MF' },
{ text: 'Samoa', value: 'WS' },
{ text: 'San Marino', value: 'SM' },
{ text: 'Sao Tome and Principe', value: 'ST' },
{ text: 'Saudi Arabia', value: 'SA' },
{ text: 'Senegal', value: 'SN' },
{ text: 'Serbia', value: 'RS' },
{ text: 'Seychelles', value: 'SC' },
{ text: 'Sierra Leone', value: 'SL' },
{ text: 'Singapore', value: 'SG' },
{ text: 'Slovakia', value: 'SK' },
{ text: 'Slovenia', value: 'SI' },
{ text: 'Solomon Islands', value: 'SB' },
{ text: 'Somalia', value: 'SO' },
{ text: 'South Africa', value: 'ZA' },
{ text: 'South Georgia and the South Sandwich Islands', value: 'GS' },
{ text: 'South Sudan', value: 'SS' },
{ text: 'Spain', value: 'ES' },
{ text: 'Sri Lanka', value: 'LK' },
{ text: 'Sudan', value: 'SD' },
{ text: 'Suriname', value: 'SR' },
{ text: 'Svalbard and Jan Mayen Islands', value: 'SJ' },
{ text: 'Swaziland', value: 'SZ' },
{ text: 'Sweden', value: 'SE' },
{ text: 'Switzerland', value: 'CH' },
{ text: 'Syrian Arab Republic (Syria)', value: 'SY' },
{ text: 'Taiwan, Republic of China', value: 'TW' },
{ text: 'Tajikistan', value: 'TJ' },
{ text: 'Tanzania, United Republic of', value: 'TZ' },
{ text: 'Thailand', value: 'TH' },
{ text: 'Timor-Leste', value: 'TL' },
{ text: 'Togo', value: 'TG' },
{ text: 'Tokelau', value: 'TK' },
{ text: 'Tonga', value: 'TO' },
{ text: 'Trinidad and Tobago', value: 'TT' },
{ text: 'Tunisia', value: 'TN' },
{ text: 'Turkey', value: 'TR' },
{ text: 'Turkmenistan', value: 'TM' },
{ text: 'Turks and Caicos Islands', value: 'TC' },
{ text: 'Tuvalu', value: 'TV' },
{ text: 'Uganda', value: 'UG' },
{ text: 'Ukraine', value: 'UA' },
{ text: 'United Arab Emirates', value: 'AE' },
{ text: 'United Kingdom', value: 'GB' },
{ text: 'United States of America', value: 'US' },
{ text: 'Uruguay', value: 'UY' },
{ text: 'US Minor Outlying Islands', value: 'UM' },
{ text: 'Uzbekistan', value: 'UZ' },
{ text: 'Vanuatu', value: 'VU' },
{ text: 'Venezuela (Bolivarian Republic)', value: 'VE' },
{ text: 'Viet Nam', value: 'VN' },
{ text: 'Virgin Islands, US', value: 'VI' },
{ text: 'Wallis and Futuna Islands', value: 'WF' },
{ text: 'Western Sahara', value: 'EH' },
{ text: 'Yemen', value: 'YE' },
{ text: 'Zambia', value: 'ZM' },
{ text: 'Zimbabwe', value: 'ZW' }
],
chosenCountry: ko.observable("US"),
securityOptions: [
{text: 'WPA/WPA2', value: 'wpa'},
{text: 'Open Network (No password)', value: 'open'},
{text: 'Hidden SSID WPA/WPA2', value: 'hiddenPass'},
{text: 'Hidden SSID (No password)', value: 'hidden'}
],
chosenSecurity: ko.observable("wpa"),
ssid: ko.observable(""),
netPass: ko.observable(""),
country: ko.observable("US"),
};
viewModel.chosenSecurityType = ko.computed(function () {
var code = viewModel.chosenSecurity();
for (var i = 0; i < viewModel.securityOptions.length; ++i) {
var item = viewModel.securityOptions[i];
if (item.value === code) return item.value;
}
});
viewModel.chosenCountryCode = ko.computed(function () {
var code = viewModel.chosenCountry();
for (var i = 0; i < viewModel.countryOptions.length; ++i) {
var item = viewModel.countryOptions[i];
if (item.value === code) return item.value;
}
});
ko.applyBindings(viewModel);
// Download files
function downloadInnerHtml(filename, elId, mimeType) {
var elHtml = document.getElementById(elId).innerText;
if (navigator.msSaveBlob) { // IE 10+
navigator.msSaveBlob(new Blob([elHtml], { type: mimeType + ';charset=utf-8;' }), filename);
} else {
var link = document.createElement('a');
mimeType = mimeType || 'text/plain';
link.setAttribute('download', filename);
link.setAttribute('href', 'data:' + mimeType + ';charset=utf-8,' + encodeURIComponent(elHtml));
link.click();
}
}
Also see: Tab Triggers