Merge branch 'master' of gogs.bullercodeworks.com:brian/statbot

This commit is contained in:
Brian Buller 2015-11-09 17:59:31 -06:00
commit 2820263379
4 changed files with 43 additions and 23 deletions

View File

@ -1,31 +1,55 @@
var sortMode = "ALPHA";
document.addEventListener("DOMContentLoaded", function(event) {
sortByAlpha();
buildList();
sortMode = docCookies.getItem("levelup-sort")
updateScreen();
B('#btnAlphaSort').on('click', function() {
if(sortMode == "ALPHA") {
sortMode = "ALPHA-REV";
B('#btnAlphaSort>i').removeClass('fa-sort-asc').addClass('fa-sort-desc');
} else {
sortMode = "ALPHA";
B('#btnAlphaSort>i').removeClass('fa-sort-desc').addClass('fa-sort-asc');
}
sortUsers();
buildList();
docCookies.setItem("levelup-sort", sortMode);
updateScreen();
});
B('#btnXpSort').on('click', function() {
if(sortMode == "XP") {
sortMode = "XP-REV";
B('#btnXpSort>i').removeClass('fa-sort-desc').addClass('fa-sort-asc');
} else {
sortMode = "XP";
B('#btnXpSort>i').removeClass('fa-sort-asc').addClass('fa-sort-desc');
}
sortUsers();
buildList();
docCookies.setItem("levelup-sort", sortMode);
updateScreen();
});
})
});
var sortMode = "ALPHA";
function updateScreen() {
sortUsers();
styleButtons();
buildList();
}
function styleButtons() {
var alphaBtn = B('#btnAlphaSort>i'),
xpBtn = B('#btnXpSort>i');
alphaBtn.removeClass('fa-sort-asc').removeClass('fa-sort-desc');
xpBtn.removeClass('fa-sort-asc').removeClass('fa-sort-desc');
switch(sortMode) {
case "ALPHA":
alphaBtn.addClass('fa-sort-desc');
break;
case "ALPHA-REV":
alphaBtn.addClass('fa-sort-asc');
break;
case "XP":
xpBtn.addClass('fa-sort-desc');
break;
default:
sortMode = "XP-REV";
xpBtn.addClass('fa-sort-asc');
break;
}
}
function clearList() {
B(".levelup-user").remove();

View File

@ -1,10 +1,6 @@
package main
import (
"net/http"
"github.com/gorilla/mux"
)
import "net/http"
type levelUpAchieveStatProcessor struct {
Achievements []levelUpAchievement
@ -38,15 +34,14 @@ func (p *levelUpAchieveStatProcessor) ProcessMessage(m *Message) {
}
var u *User
var err error
vars := mux.Vars(req)
if u, err = getUserInfo(m.User); err != nil {
return
}
p := UserLevelUpStats{Name: u.Name}
p.Xp, _ = getUserStat(u.ID, "levelup-xp")
p.ChannelStats = getAllLevelUpChannelXp(u.ID)
p.OtherStats = getAllNonLevelUpStats(u.ID)
userStat := UserLevelUpStats{Name: u.Name}
userStat.Xp, _ = getUserStat(u.ID, "levelup-xp")
userStat.ChannelStats = getAllLevelUpChannelXp(u.ID)
userStat.OtherStats = getAllNonLevelUpStats(u.ID)
}
func (p *levelUpAchieveStatProcessor) ProcessAdminMessage(m *Message) {}

View File

@ -65,7 +65,7 @@ func statBotMain(slack *Slack) {
registerStatProcessor(new(levelUpStatProcessor))
registerStatProcessor(new(generalStatProcessor))
levelUpAchievements := new(levelUpAchieveStatProcessor)
//levelUpAchievements := new(levelUpAchieveStatProcessor)
// Register Achievements
registerMessageProcessor(new(generalProcessor))

View File

@ -93,6 +93,7 @@ func initRequest(w http.ResponseWriter, req *http.Request) {
site.Scripts = append(site.Scripts, "/assets/js/highcharts.js")
site.Scripts = append(site.Scripts, "/assets/js/B.js")
site.Scripts = append(site.Scripts, "/assets/js/B_purecss.js")
site.Scripts = append(site.Scripts, "/assets/js/B_cookies.js")
site.InlineScript = ""