From b459dee4ce8d0c9442c759a185f48c3f5be56190 Mon Sep 17 00:00:00 2001 From: ryan Date: Sun, 18 Jul 2021 21:42:15 -0400 Subject: [PATCH] sample script working. remove privacy page --- BinaryDad.Coding/Pages/Index.cshtml | 6 ++++ BinaryDad.Coding/Pages/Privacy.cshtml | 8 ----- BinaryDad.Coding/Pages/Privacy.cshtml.cs | 24 ------------- BinaryDad.Coding/wwwroot/js/hub.js | 43 ++++++++++++------------ 4 files changed, 28 insertions(+), 53 deletions(-) delete mode 100644 BinaryDad.Coding/Pages/Privacy.cshtml delete mode 100644 BinaryDad.Coding/Pages/Privacy.cshtml.cs diff --git a/BinaryDad.Coding/Pages/Index.cshtml b/BinaryDad.Coding/Pages/Index.cshtml index c6fac9d..e0c5277 100644 --- a/BinaryDad.Coding/Pages/Index.cshtml +++ b/BinaryDad.Coding/Pages/Index.cshtml @@ -12,6 +12,12 @@
+ + + + @**@ + +
diff --git a/BinaryDad.Coding/Pages/Privacy.cshtml b/BinaryDad.Coding/Pages/Privacy.cshtml deleted file mode 100644 index 46ba966..0000000 --- a/BinaryDad.Coding/Pages/Privacy.cshtml +++ /dev/null @@ -1,8 +0,0 @@ -@page -@model PrivacyModel -@{ - ViewData["Title"] = "Privacy Policy"; -} -

@ViewData["Title"]

- -

Use this page to detail your site's privacy policy.

diff --git a/BinaryDad.Coding/Pages/Privacy.cshtml.cs b/BinaryDad.Coding/Pages/Privacy.cshtml.cs deleted file mode 100644 index d1ff679..0000000 --- a/BinaryDad.Coding/Pages/Privacy.cshtml.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Microsoft.AspNetCore.Mvc; -using Microsoft.AspNetCore.Mvc.RazorPages; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace BinaryDad.Coding.Pages -{ - public class PrivacyModel : PageModel - { - private readonly ILogger _logger; - - public PrivacyModel(ILogger logger) - { - _logger = logger; - } - - public void OnGet() - { - } - } -} diff --git a/BinaryDad.Coding/wwwroot/js/hub.js b/BinaryDad.Coding/wwwroot/js/hub.js index 1157a82..571c01a 100644 --- a/BinaryDad.Coding/wwwroot/js/hub.js +++ b/BinaryDad.Coding/wwwroot/js/hub.js @@ -1,28 +1,29 @@ -var connection = new signalR.HubConnectionBuilder().withUrl("/chatHub").build(); +$(function () { -//Disable send button until connection is established -document.getElementById("sendButton").disabled = true; + var connection = new signalR.HubConnectionBuilder().withUrl("/codeHub").build(); -connection.on("ReceiveMessage", function (user, message) { - var li = document.createElement("li"); - document.getElementById("messagesList").appendChild(li); - // We can assign user-supplied strings to an element's textContent because it - // is not interpreted as markup. If you're assigning in any other way, you - // should be aware of possible script injection concerns. - li.textContent = `${user} says ${message}`; -}); + let $code = $('#code'); + let $mirror = $('#mirror'); -connection.start().then(function () { - document.getElementById("sendButton").disabled = false; -}).catch(function (err) { - return console.error(err.toString()); -}); + $('#code').keyup(function () { -document.getElementById("sendButton").addEventListener("click", function (event) { - var user = document.getElementById("userInput").value; - var message = document.getElementById("messageInput").value; - connection.invoke("SendMessage", user, message).catch(function (err) { + let user = 'ryan'; + let message = $code.val(); + + connection.invoke("SendMessage", user, message).catch(function (err) { + return console.error(err.toString()); + }); + }); + + connection.on("ReceiveMessage", function (user, message) { + + $mirror.val(message); + + }); + + connection.start().then(function () { + //$('#send').prop('disabled', false); + }).catch(function (err) { return console.error(err.toString()); }); - event.preventDefault(); }); \ No newline at end of file