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) { document.addEventListener("DOMContentLoaded", function(event) {
sortByAlpha(); sortMode = docCookies.getItem("levelup-sort")
buildList(); updateScreen();
B('#btnAlphaSort').on('click', function() { B('#btnAlphaSort').on('click', function() {
if(sortMode == "ALPHA") { if(sortMode == "ALPHA") {
sortMode = "ALPHA-REV"; sortMode = "ALPHA-REV";
B('#btnAlphaSort>i').removeClass('fa-sort-asc').addClass('fa-sort-desc');
} else { } else {
sortMode = "ALPHA"; sortMode = "ALPHA";
B('#btnAlphaSort>i').removeClass('fa-sort-desc').addClass('fa-sort-asc');
} }
sortUsers(); docCookies.setItem("levelup-sort", sortMode);
buildList(); updateScreen();
}); });
B('#btnXpSort').on('click', function() { B('#btnXpSort').on('click', function() {
if(sortMode == "XP") { if(sortMode == "XP") {
sortMode = "XP-REV"; sortMode = "XP-REV";
B('#btnXpSort>i').removeClass('fa-sort-desc').addClass('fa-sort-asc');
} else { } else {
sortMode = "XP"; sortMode = "XP";
B('#btnXpSort>i').removeClass('fa-sort-asc').addClass('fa-sort-desc');
} }
sortUsers(); docCookies.setItem("levelup-sort", sortMode);
buildList(); 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() { function clearList() {
B(".levelup-user").remove(); B(".levelup-user").remove();

View File

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

View File

@ -65,7 +65,7 @@ func statBotMain(slack *Slack) {
registerStatProcessor(new(levelUpStatProcessor)) registerStatProcessor(new(levelUpStatProcessor))
registerStatProcessor(new(generalStatProcessor)) registerStatProcessor(new(generalStatProcessor))
levelUpAchievements := new(levelUpAchieveStatProcessor) //levelUpAchievements := new(levelUpAchieveStatProcessor)
// Register Achievements // Register Achievements
registerMessageProcessor(new(generalProcessor)) 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/highcharts.js")
site.Scripts = append(site.Scripts, "/assets/js/B.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_purecss.js")
site.Scripts = append(site.Scripts, "/assets/js/B_cookies.js")
site.InlineScript = "" site.InlineScript = ""