Skip to content

Commit

Permalink
Lots of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
qistoph committed Apr 25, 2013
1 parent 12d787b commit 4ed7a97
Show file tree
Hide file tree
Showing 2 changed files with 202 additions and 58 deletions.
7 changes: 7 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright (C) 2013, Chris van Marle

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
253 changes: 195 additions & 58 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,51 +1,139 @@
<!doctype html>
<html>
<head>
<title>Wifi QR code</title>
<title>WiFi QR-code - Javascript</title>

<!-- use //ajax for online web -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="jquery.qrcode.min.js"></script>

<!-- Reference the theme's stylesheet on the Google CDN -->
<!-- Reference scripts and theme stylesheet on the Google CDN -->
<!-- use //ajax... for online web to automatically switch between http and https -->
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/themes/ui-lightness/jquery-ui.css"
type="text/css" rel="Stylesheet" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"></script>

<script src="jquery.qrcode.min.js"></script>

<style>
/********** BEGIN RESET **********/
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/

html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/********** END RESET **********/

body {
font-family: "Trebuchet MS", "Helvetica", "Arial", "Verdana", "sans-serif";
font-size: 80%;
font-size: 100%;
margin: 10px;
line-height: 1.4;
}

b {
font-weight: bold;
}

ul {
list-style: disc inside none;
margin: -1.4em 0.4em 1.4em;
}

h1 {
font-size: 1.4em;
font-weight: bold;
}

p {
margin-bottom: 1.4em;
}

p:last-child {
margin-bottom: 0;
}

td {
border: 0px solid black;
padding: 2px;
}

#content {
border: 1px solid black;
border: 1px solid #000;
float: left;
padding: 10px;
margin: 10px;
display: inline-block;
}

#qrresult {
background: #ffffff;
display: table;
margin: 0 auto 1.4em;
padding: 0.8em;
}

#qrcode {
margin: 0 auto 20px;
margin: 0 auto;
width: 256px;
height: 256px;
background: #cccccc;
}

#qrsub {
margin: 0 auto;
display: table;
font-family: Courier New;
display: none;
display: table;
}

#about {
border: 1px solid black;
float: left;
padding: 10px;
margin: 10px;
min-width: 335px;
width: 50%;
}

input[type=text],
input[type=password] {
width: 100%;
Expand All @@ -61,15 +149,21 @@

a {
text-decoration: none;
color: #0000cc;
}

a:visited {
color: #0000ff;
color: #0000cc;
}

a:hover {
text-decoration: underline;
}

tr:last-child td {
height: 4em;
vertical-align: bottom;
}
</style>

<script>
Expand Down Expand Up @@ -109,8 +203,8 @@
str = str.replace(/,/g, "\\,");
return str;
}

function generateQR() {
function generateQR(divCanvas, divText) {
var type = $("input:radio[name=T]:checked").val();
var ssid = mecard_escape($("#S").val());
var key = mecard_escape($("#P").val());
Expand All @@ -122,52 +216,95 @@
($("#H").is(":checked") ? "H:true;B:true;" : "") +
";";

$("#qrcode").empty().qrcode({text: url});
$("#qrsub").text(url);
divCanvas.empty().qrcode(url);
divText.text("WiFi: " + $("#S").val() + " (" + type + ")");
}

function printQR() {
var printWin = window.open('', 'qrcodewifi', '');
printWin.document.write('<doctype html><html><head><title>WiFi: ' + $("#S").val() + '</title></head><body>');
printWin.document.write('<div id="qrresult">');
printWin.document.write('<div id="qrcode"></div>');
printWin.document.write('<div id="qrsub"></div>');
printWin.document.write('</div>');
printWin.document.write('WiFi QR-code generator - http://www.bladibla.com');
printWin.document.write('</body></html>');

$("link, style, script").each(function() {
$(printWin.document.head).append($(this).clone())
});

generateQR($("#qrcode", printWin.document), $("#qrsub", printWin.document));
printWin.print();
printWin.close();
}
</script>
</head>
<body>
<div id="content">
<div id="qrcode"></div>
<div id="qrsub">&nbsp;</div>
<table>
<tr>
<td><label>Encryption:</label></td>
<td><div class="radio">
<input type="radio" id="type_wep" name="T" value="WEP"/><label for="type_wep">WEP</label>
<input type="radio" id="type_wpa" name="T" value="WPA" checked="checked"/><label for="type_wpa">WPA/WPA2-PSK</label>
<input type="radio" id="type_none" name="T" value="none"/><label for="type_none">none</label>
</div></td>
</tr>
<tr>
<td>SSID:</td>
<td><input type="text" id="S" value="SSID"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" id="P" value="password"></td>
</tr>
<tr>
<td>Visibility:</td>
<td><input type="checkbox" id="H" value="true" /><label for="H">Visible</label></td>
</tr>
<tr>
<td></td>
<td>
<button onClick="generateQR()">Generate</button>
</td>
</tr>
</table>
</div>
<div id="about">
<b>About</b><br>
<ul>
<li>jQuery - <a href="http://jquery.com/">http://jquery.com</a></li>
<li>jQuery UI - <a href="http://jqueryui.com/">http://jqueryui.com</a></li>
<li>jquery.qrcode.js - <a href="http://jeromeetienne.github.io/jquery-qrcode/">http://jeromeetienne.github.io/jquery-qrcode</a></li>
<li>ZXing documentation - <a href="https://code.google.com/p/zxing/wiki/BarcodeContents">https://code.google.com/p/zxing/wiki/BarcodeContents</a></li>
</ul>
<div>
<div id="content">
<div id="qrresult">
<div id="qrcode"></div>
<div id="qrsub">&nbsp;</div>
</div>
<table>
<tr>
<td><label>Encryption:</label></td>
<td><div class="radio">
<input type="radio" id="type_wep" name="T" value="WEP"/><label for="type_wep">WEP</label>
<input type="radio" id="type_wpa" name="T" value="WPA" checked="checked"/><label for="type_wpa">WPA/WPA2-PSK</label>
<input type="radio" id="type_none" name="T" value="none"/><label for="type_none">none</label>
</div></td>
</tr>
<tr>
<td>SSID:</td>
<td><input type="text" id="S" value="YourSSID"></td>
</tr>
<tr>
<td>Password:</td>
<td><input type="password" id="P" value="somepassword"></td>
</tr>
<tr>
<td>Visibility:</td>
<td><input type="checkbox" id="H" value="true" /><label for="H">Visible</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><button onClick="generateQR($('#qrcode'), $('#qrsub'))">Generate</button> <button onClick="printQR()">Print</button></td>
</tr>
</table>
</div>
<div id="about">
<h1>WiFi QR-code - Javascript</h1>
<p>
With current (Android) mobiles it is possible to add a WiFi network by scanning a QR-code. <a href="https://play.google.com/store/apps/details?id=com.google.zxing.client.android">Barcode Scanner</a> by ZXing Team is one of the apps recognizing the WiFi QR-codes. Other QR-code generators online (that support WiFi-QR) generate the QR-code server side, which means the data, including the password, is sent over the internet. Since I wasn't comfortable with this, I have created an open source Javascript alternative.
</p>
<h1>Usage</h1>
<p>Select the encryption used in your network (WEP, WPA or none).<br/>
Enter your SSID.<br/>
Enter the password for the network.<br/>
If the SSID is hidden, set the visibility button to 'Hidden'.<br/>
Click 'Generate' and/or 'Print'<br/>
</p>
<h1>References</h1>
<p>Libraries and information used:</p>
<ul>
<li><a href="http://jquery.com/">jQuery</a></li>
<li><a href="http://jqueryui.com/">jQuery UI</a></li>
<li><a href="http://jeromeetienne.github.io/jquery-qrcode/">jquery.qrcode.js</a></li>
<li><a href="http://meyerweb.com/eric/tools/css/reset/">CSS Reset</a></li>
<li><a href="https://code.google.com/p/zxing/wiki/BarcodeContents">ZXing documentation</a></li>
</ul>
<p>
The source is available on <a href="http://www.github.com/qistoph/">GitHub</a>
</p>
<h1>License</h1>
<p>
<a href="LICENSE">MIT license</a>
</p>
</div>
</div>

<a href="https://github.com/qistoph/WiFiQR"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_red_aa0000.png" alt="Fork me on GitHub"></a>
</body>
</html>

0 comments on commit 4ed7a97

Please sign in to comment.