diff options
| -rw-r--r-- | fortune/admin-name | 16 | ||||
| -rw-r--r-- | public/assets/js/lib/views/admin/adminz.js | 39 | ||||
| -rw-r--r-- | public/assets/js/lib/views/admin/password.js | 53 | ||||
| -rw-r--r-- | views/partials/admin_password.ejs | 40 | ||||
| -rw-r--r-- | views/partials/lastlog.ejs | 6 |
5 files changed, 154 insertions, 0 deletions
diff --git a/fortune/admin-name b/fortune/admin-name new file mode 100644 index 0000000..89ee304 --- /dev/null +++ b/fortune/admin-name @@ -0,0 +1,16 @@ +bucky's +bucky's +bucky's +bucky's +bucky's +bucky's +bucky's +bucky's +bucky's +bucky's +bucky and the +bucky upon the +bucky brandishes +bucky twirls +bucky hails +bucky charges
\ No newline at end of file diff --git a/public/assets/js/lib/views/admin/adminz.js b/public/assets/js/lib/views/admin/adminz.js new file mode 100644 index 0000000..caed86d --- /dev/null +++ b/public/assets/js/lib/views/admin/adminz.js @@ -0,0 +1,39 @@ +var AdminView = View.extend({ + + events: { + }, + + action: "/api/admin", + + initialize: function(opt){ + // this.hootbox = new HootBox ({ parent: this }) + this.password = new ChangePasswordForm ({ parent: this }) + this.lastlog = new LastLog ({ parent: this }) + }, + + load: function(){ + $("body").addClass("index").addClass("admin") + $.get(this.action, this.populate.bind(this)) + }, + + populate: function(data){ + $("body").removeClass('loading') + console.log(data) + this.password.load(data.usernames) + this.lastlog.load(data.lastlog) + if (data.mail.count) { + $(".alert").show().html( + "<a href='/mail'>" + + "You have " + + data.mail.count + + " new message" + + courtesy_s(data.mail.count) + + "!</a>") + if (is_mobile) { + $("#content").prepend( $(".alert") ) + } + } + $(".search_form input").focus() + }, + +}) diff --git a/public/assets/js/lib/views/admin/password.js b/public/assets/js/lib/views/admin/password.js new file mode 100644 index 0000000..41d6ed6 --- /dev/null +++ b/public/assets/js/lib/views/admin/password.js @@ -0,0 +1,53 @@ +var ChangePasswordForm = FormView.extend({ + + el: "#admin_changePassword", + + events: { + }, + + action: "/api/admin/password/", + method: "put", + + initialize: function(opt){ + this.__super__.initialize.call(this, opt) + this.$select = this.$("select") + }, + + load: function(usernames){ + usernames = usernames || [] + usernames.forEach(username => { + option = document.createElement("option") + option.value = username + option.innerHTML = sanitize(username) + this.$select.append(option) + }) + this.$select.show() + }, + + validate: function(){ + var errors = [] + var pw = $("[name=password]").val() + var pw1 = $("[name=newpassword]").val() + var pw2 = $("[name=newpassword2]").val() + if (! pw) { + errors.push("Please enter your password.") + } + if (! pw1 || ! pw2) { + errors.push("Please enter the new password for this user.") + } + if (pw1 && pw2 && pw1 !== pw2) { + errors.push("Passwords don't match.") + } + return errors.length ? errors : null + }, + + success: function(data){ + this.$("[name]").val('') + this.$("select").val('Select a user...') + // window.location.reload() + console.log(this) + console.log(this.parent) + this.showErrors(['password changed']) + }, + +}) diff --git a/views/partials/admin_password.ejs b/views/partials/admin_password.ejs new file mode 100644 index 0000000..26fd32f --- /dev/null +++ b/views/partials/admin_password.ejs @@ -0,0 +1,40 @@ +<div class='bluebox' id="admin_changePassword"> + <big><b>reset password</b></big> + <hr /> + +<form> + <div> + <label for="admin-username">Username:</label> + <select name="username"> + <option>Select a user...</option> + </select> + </div> + + <div> + <label for="admin-password">Admin password:</label> + <input type="password" id="admin-password" name="password"> + </div> + + <div> + <label for="admin-password">New password?</label> + <input type="password" id="admin-newpassword" name="newpassword"> + </div> + + <div> + <label for="admin-password2">again:</label> + <input type="password" id="admin-newpassword2" name="newpassword2"> + </div> + + <div class="save_field"> + <label for="admin-submit"></label> + <button id="admin-submit">CHANGE PASSWORD</button> + <div class="loader"></div> + </div> + + <div> + <label></label> + <span class="errors"> </span> + </div> +</form> + +</div> diff --git a/views/partials/lastlog.ejs b/views/partials/lastlog.ejs new file mode 100644 index 0000000..0a4d393 --- /dev/null +++ b/views/partials/lastlog.ejs @@ -0,0 +1,6 @@ +<span class="lastlog bluebox"> + <script class="template" type="text/html"> + <a href="/profile/{{username}}">{{username}}</a> + [{{age}}] + </script> +</span> |
