Nancy
This commit is contained in:
45
Adaptation/FileHandlers/json/StaticSite/js/simple.js
Normal file
45
Adaptation/FileHandlers/json/StaticSite/js/simple.js
Normal file
@ -0,0 +1,45 @@
|
||||
var _apiUrl = null;
|
||||
|
||||
function initIndex(url, apiUrl) {
|
||||
_apiUrl = apiUrl;
|
||||
|
||||
//Set the hubs URL for the connection
|
||||
$.connection.hub.url = url;
|
||||
$.connection.hub.logging = true;
|
||||
|
||||
// Declare a proxy to reference the hub.
|
||||
// var chat = $.connection.myHub;
|
||||
var chat = $.connection.weightedShortestJobFirstHub;
|
||||
|
||||
// Create a function that the hub can call to broadcast messages.
|
||||
chat.client.addNotification = function (name, message) {
|
||||
// Html encode display name and message.
|
||||
console.log(message);
|
||||
var encodedName = $('<div />').text(name).html();
|
||||
var encodedMsg = $('<div />').text("hash").html();
|
||||
// Add the message to the page.
|
||||
$('#discussion').append('<li><strong>' + encodedName
|
||||
+ '</strong>: ' + encodedMsg + '</li>');
|
||||
};
|
||||
// Get the user name and store it to prepend to messages.
|
||||
$('#displayname').val(prompt('Enter your name:', ''));
|
||||
// Set initial focus to message input box.
|
||||
$('#message').focus();
|
||||
// Start the connection.
|
||||
$.connection.hub.start({ transport: 'longPolling' }).done(function () {
|
||||
$('#sendmessage').click(function () {
|
||||
// Call the Send method on the hub.
|
||||
// chat.server.send($('#displayname').val(), $('#message').val());
|
||||
var notification = {
|
||||
"id": 110743,
|
||||
"page": "effort",
|
||||
"username": "user",
|
||||
"time": 1737573418926,
|
||||
"value": 1
|
||||
};
|
||||
chat.server.notifyAll(notification);
|
||||
// Clear text box and reset focus for next comment.
|
||||
$('#message').val('').focus();
|
||||
});
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user