-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2f7877e
Showing
3 changed files
with
347 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,312 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>WiFi QR-code - Javascript</title> | ||
|
||
<!-- 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: 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 #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; | ||
width: 256px; | ||
height: 256px; | ||
} | ||
|
||
#qrsub { | ||
margin: 0 auto; | ||
font-family: Courier New; | ||
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%; | ||
display:block; | ||
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */ | ||
-moz-box-sizing: border-box; /* Firefox, other Gecko */ | ||
box-sizing: border-box; /* Opera/IE 8+ */ | ||
} | ||
|
||
.radio { | ||
display: inline; | ||
} | ||
|
||
a { | ||
text-decoration: none; | ||
color: #0000cc; | ||
} | ||
|
||
a:visited { | ||
color: #0000cc; | ||
} | ||
|
||
a:hover { | ||
text-decoration: underline; | ||
background: #eeeeff; | ||
} | ||
|
||
tr:last-child td { | ||
height: 4em; | ||
vertical-align: bottom; | ||
} | ||
</style> | ||
|
||
<script> | ||
// http://jeromeetienne.github.io/jquery-qrcode/ | ||
// https://code.google.com/p/zxing/wiki/BarcodeContents | ||
|
||
// H:true vs B:true for hidden networks: | ||
// https://code.google.com/p/zxing/issues/detail?id=1218 | ||
// https://code.google.com/p/zxing/issues/detail?id=1455 | ||
|
||
$(function() { | ||
$("input:submit, input:checkbox, button").button(); | ||
$(".radio").buttonset(); | ||
$('input').addClass("ui-corner-all"); | ||
$('input:text, input:password') | ||
.button() | ||
.css({ | ||
'font-size' : 'inherit', | ||
'color' : 'inherit', | ||
'text-align' : 'left', | ||
'outline' : 'none', | ||
'cursor' : 'text' | ||
}) | ||
.focus(function() { $(this).select() }) | ||
.mouseup(function(e) { e.preventDefault(); }); | ||
|
||
$("#H").click(function() { | ||
$(this).button('option', 'label', $(this).is(':checked') ? 'Hidden' : 'Visible'); | ||
}); | ||
}); | ||
|
||
function mecard_escape(str) { | ||
str = str.replace(/\\/g, "\\\\"); | ||
str = str.replace(/\"/g, "\\\""); | ||
str = str.replace(/;/g, "\\;"); | ||
str = str.replace(/:/g, "\\:"); | ||
str = str.replace(/,/g, "\\,"); | ||
return str; | ||
} | ||
|
||
function generateQR(divCanvas, divText) { | ||
var type = $("input:radio[name=T]:checked").val(); | ||
var ssid = mecard_escape($("#S").val()); | ||
var key = mecard_escape($("#P").val()); | ||
|
||
var url = "WIFI:" + | ||
"T:" + type + ";" + | ||
"S:" + ssid + ";" + | ||
"P:" + key + ";" + | ||
($("#H").is(":checked") ? "H:true;B:true;" : "") + | ||
";"; | ||
|
||
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> | ||
<div id="content"> | ||
<div id="qrresult"> | ||
<div id="qrcode"></div> | ||
<div id="qrsub"> </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> </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" target="_blank">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/" target="_blank">jQuery</a></li> | ||
<li><a href="http://jqueryui.com/" target="_blank">jQuery UI</a></li> | ||
<li><a href="http://jeromeetienne.github.io/jquery-qrcode/" target="_blank">jquery.qrcode.js</a></li> | ||
<li><a href="http://meyerweb.com/eric/tools/css/reset/" target="_blank">CSS Reset</a></li> | ||
<li><a href="https://code.google.com/p/zxing/wiki/BarcodeContents" target="_blank">ZXing documentation</a></li> | ||
</ul> | ||
<p> | ||
The source is available on <a href="https://github.com/qistoph/WiFiQR" target="_blank">GitHub</a> | ||
</p> | ||
<h1>License</h1> | ||
<p> | ||
<a href="LICENSE">MIT license</a> | ||
</p> | ||
</div> | ||
|
||
</div> | ||
|
||
<a href="https://github.com/qistoph/WiFiQR" target="_blank"><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> |
Oops, something went wrong.