Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function DevicePairControl(g) {
- var f = '<div id="initiatePairGroup"> <p>Request a PIN to set your user name and password</p> <button id="requestPairing" class="commonButton">Request pin</button> </div> <div id="doPairGroup"> </br> <span>PIN displayed on your device:</span></br> <input type="text" name="pin" id="pin"/></br> </br> <span class="credentialsInput">New user name:</span></br> <input type="text" name="userName" id="userName"/><br/> <br/> <span>New password:</span></br> <input type="password" name="password" id="password"/></br> <span>Confirm password:</span></br> <input type="password" name="confirmPassword" id="confirmPassword"/></br> <br/> <button id="doPair" class="commonButton symbol"> Pair</button> </div>';
- $("#" + g).html(f);
- $("#requestPairing").click(d);
- $("#doPair").click(a);
- $("#password").keyup(b);
- $("#confirmPassword").keyup(b);
- function b(b) {
- b.which == 13 && a()
- }
- function d() {
- $("#requestPairing").attr("disabled", true);
- $.post("/api/authorize/startpair").done(function() {
- e()
- }).fail(function() {
- alert("Failed to start pairing");
- c()
- })
- }
- function a() {
- var g = $("#pin").val(),
- d = $("#userName").val(),
- a = $("#password").val(),
- b = $("#confirmPassword").val();
- if (a != b) {
- alert("Passwords do not match! Unable to start device pairing.");
- return
- }
- $("#doPair").attr("disabled", true);
- var f = {
- pin: g,
- username: d,
- password: a
- },
- e = "/api/authorize/pair?" + $.param(f);
- $.post(e).done(function() {
- window.location.href = "/default.htm"
- }).fail(function(d) {
- var a = "";
- try {
- var b = jQuery.parseJSON(d.responseText);
- if (b.Reason != undefined) a = b.Reason
- } catch (e) {}
- if (a.length != 0) alert("Failed to pair with device: " + a);
- else alert("Failed to pair with device");
- c()
- })
- }
- function c() {
- $("#requestPairing").attr("disabled", false);
- $("#initiatePairGroup").show();
- $("#doPairGroup").hide()
- }
- function e() {
- $("#pin").val("");
- $("#doPair").attr("disabled", false);
- $("#initiatePairGroup").hide();
- $("#doPairGroup").show()
- }
- }
- function SSLCertDownloadControl(d) {
- var a = this;
- a.parentId = d;
- $.ajax({
- url: "/config/rootcertificate",
- cache: true,
- type: "head"
- }).done(function(f, d, a) {
- if (a.status == 200) e();
- else if (a.status == 404) c();
- else b()
- }).error(function(a) {
- if (a.status == 404) c();
- else b()
- });
- function e() {
- var a = '<div class="indentSection"> <p>Seeing a "certificate error" in your browser? You can fix that and get a secure connection by creating a trust relationship with this device. Follow these steps:</p> <p class="warning indentSection">1. Make sure you are on a secure network (USB or a Wi-Fi network you trust)</p> <p class="indentSection">2. <a class="navigationLink" href="/config/rootcertificate">Download this device\'s certificate</a></p> <p class="indentSection">3. Install the certificate in the "Trusted Root Certification Authorities" store</p> <p class="indentSection">4. Restart your browser<p> <p>For more information, see the <a class="navigationLink" href="http://www.hololens.com">documentation</a>.</p> </div>';
- $("#" + d).html(a)
- }
- function c() {
- $("#" + a.parentId).html("<p>This device does not have a certificate</p>")
- }
- function b() {
- $("#" + a.parentId).html("<p>No certificate information available!</p>")
- }
- }
- $(function() {
- new DevicePairControl("devicePairingSection");
- new SSLCertDownloadControl("sslCertificateSection")
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement