Advertisement
h0x0d

Windows 10 Mobile 10563 devicepair.js

Oct 14th, 2015
506
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function DevicePairControl(g) {
  2.     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">&#xe1f6; Pair</button>         </div>';
  3.     $("#" + g).html(f);
  4.     $("#requestPairing").click(d);
  5.     $("#doPair").click(a);
  6.     $("#password").keyup(b);
  7.     $("#confirmPassword").keyup(b);
  8.  
  9.     function b(b) {
  10.         b.which == 13 && a()
  11.     }
  12.  
  13.     function d() {
  14.         $("#requestPairing").attr("disabled", true);
  15.         $.post("/api/authorize/startpair").done(function() {
  16.             e()
  17.         }).fail(function() {
  18.             alert("Failed to start pairing");
  19.             c()
  20.         })
  21.     }
  22.  
  23.     function a() {
  24.         var g = $("#pin").val(),
  25.             d = $("#userName").val(),
  26.             a = $("#password").val(),
  27.             b = $("#confirmPassword").val();
  28.         if (a != b) {
  29.             alert("Passwords do not match! Unable to start device pairing.");
  30.             return
  31.         }
  32.         $("#doPair").attr("disabled", true);
  33.         var f = {
  34.                 pin: g,
  35.                 username: d,
  36.                 password: a
  37.             },
  38.             e = "/api/authorize/pair?" + $.param(f);
  39.         $.post(e).done(function() {
  40.             window.location.href = "/default.htm"
  41.         }).fail(function(d) {
  42.             var a = "";
  43.             try {
  44.                 var b = jQuery.parseJSON(d.responseText);
  45.                 if (b.Reason != undefined) a = b.Reason
  46.             } catch (e) {}
  47.             if (a.length != 0) alert("Failed to pair with device: " + a);
  48.             else alert("Failed to pair with device");
  49.             c()
  50.         })
  51.     }
  52.  
  53.     function c() {
  54.         $("#requestPairing").attr("disabled", false);
  55.         $("#initiatePairGroup").show();
  56.         $("#doPairGroup").hide()
  57.     }
  58.  
  59.     function e() {
  60.         $("#pin").val("");
  61.         $("#doPair").attr("disabled", false);
  62.         $("#initiatePairGroup").hide();
  63.         $("#doPairGroup").show()
  64.     }
  65. }
  66.  
  67. function SSLCertDownloadControl(d) {
  68.     var a = this;
  69.     a.parentId = d;
  70.     $.ajax({
  71.         url: "/config/rootcertificate",
  72.         cache: true,
  73.         type: "head"
  74.     }).done(function(f, d, a) {
  75.         if (a.status == 200) e();
  76.         else if (a.status == 404) c();
  77.         else b()
  78.     }).error(function(a) {
  79.         if (a.status == 404) c();
  80.         else b()
  81.     });
  82.  
  83.     function e() {
  84.         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>';
  85.         $("#" + d).html(a)
  86.     }
  87.  
  88.     function c() {
  89.         $("#" + a.parentId).html("<p>This device does not have a certificate</p>")
  90.     }
  91.  
  92.     function b() {
  93.         $("#" + a.parentId).html("<p>No certificate information available!</p>")
  94.     }
  95. }
  96. $(function() {
  97.     new DevicePairControl("devicePairingSection");
  98.     new SSLCertDownloadControl("sslCertificateSection")
  99. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement