-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
underscore and templates for activity. issue #51
- Loading branch information
Showing
5 changed files
with
53 additions
and
38 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 |
---|---|---|
|
@@ -104,6 +104,7 @@ | |
|
||
BOWER_INSTALLED_APPS = ( | ||
'bootstrap', | ||
'underscore', | ||
) | ||
|
||
AUTH_USER_MODEL = 'rpg.Hero' | ||
|
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 |
---|---|---|
@@ -1,18 +1,41 @@ | ||
function chat_send(editor){ | ||
$.post("/activity/send", {message: editor.exportFile()}, function(){ | ||
editor.importFile(); | ||
}); | ||
} | ||
|
||
$(function(){ | ||
var editor = new EpicEditor({ | ||
|
||
theme: { | ||
base: "http://"+location.host+'/static/epiceditor/themes/base/epiceditor.css', | ||
preview: "http://"+location.host+'/static/epiceditor/themes/preview/preview-dark.css', | ||
editor: "http://"+location.host+'/static/epiceditor/themes/editor/epic-dark.css' | ||
}, | ||
focusOnLoad: true | ||
}).load(); | ||
var chat_message = _.template("<div class='chat_message'><strong><a href='/users/<%= user %>'><%= user %></a></strong> (<%= now %>): <br> <%= message %></div>") | ||
|
||
$("#msg_form").on("submit", function(e){ | ||
e.preventDefault(); | ||
$.post("/activity/send", {message: editor.exportFile()}, function(){}) | ||
editor.importFile() | ||
return false; | ||
}) | ||
var pusher = new Pusher('6bb5412badf09454aa87'); | ||
var channel = pusher.subscribe('activity'); | ||
channel.bind('my_event', function(data) { | ||
console.log(data); | ||
var now = new Date().toLocaleTimeString(); | ||
data.now = now; | ||
$("#events").append(chat_message(data)); | ||
}); | ||
|
||
var editor = new EpicEditor({ | ||
|
||
theme: { | ||
base: "http://"+location.host+'/static/epiceditor/themes/base/epiceditor.css', | ||
preview: "http://"+location.host+'/static/epiceditor/themes/preview/preview-dark.css', | ||
editor: "http://"+location.host+'/static/epiceditor/themes/editor/epic-dark.css' | ||
}, | ||
focusOnLoad: true | ||
}).load(); | ||
|
||
$("#msg_form").on("submit", function(e){ | ||
e.preventDefault(); | ||
chat_send(editor); | ||
return false; | ||
}); | ||
|
||
//TODO: shortcut in editor | ||
Mousetrap.bind(['ctrl+enter'], function(e) { | ||
console.log("Ctrl + Enter"); | ||
chat_send(editor); | ||
}); | ||
}); |
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 |
---|---|---|
@@ -1,17 +1 @@ | ||
$(".level_info").tooltip({placement: "bottom", html: true}) | ||
|
||
var pusher = new Pusher('6bb5412badf09454aa87'); | ||
var channel = pusher.subscribe('activity'); | ||
channel.bind('my_event', function(data) { | ||
console.log(data) | ||
var now = new Date().toLocaleTimeString(); | ||
$("#events").append(data.user + ' (' + now + "): " + data.message + "<br>"); | ||
$("#msg_text").val("") | ||
}); | ||
|
||
$("#msg_form").on("submit", function(e){ | ||
e.preventDefault(); | ||
$.post("/activity/send", {message:$('#msg_text').val()}, function(){}) | ||
$('#msg_text').val('') | ||
return false; | ||
}) |
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
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