Created
March 14, 2016 20:58
-
-
Save reportbase/34c104f768e641c06a24 to your computer and use it in GitHub Desktop.
github reports folder
This file contains hidden or 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
var Reportobj = (function () | |
{ | |
function init() | |
{ | |
this.data = [{name: "", title: "", describe: ""}] | |
this.ANCHOR = 0 | |
var http = new XMLHttpRequest() | |
http.onreadystatechange = function() | |
{ | |
if (http.readyState != http.DONE) | |
return | |
if (http.status != 200) | |
{ | |
jug(loginobj, http.status + " " + http.statusText) | |
return | |
} | |
this.data = http.response | |
this.ANCHOR = localStorage.get_integer("REPORTOBJ.ANCHOR", 0, this.data.length-1, 0) | |
}.bind(this) | |
http.open("GET", github_api_url("/contents/reports")) | |
http.setRequestHeader("Accept", "application/vnd.github.VERSION.raw") | |
http.responseType = "json" | |
http.send() | |
} | |
init.prototype = | |
{ | |
anchor : function() {return this.ANCHOR}, | |
start : function() {return 0}, | |
length : function() {return this.data.length}, | |
move : function (delta) {this.set(this.ANCHOR + delta)}, | |
name : function(index) {return this.data[this.ANCHOR].name}, | |
isname : function(name) {return this.data[this.ANCHOR].name == name}, | |
set : function(index){this.ANCHOR = Math.clamp(0, this.data.length-1, index)}, | |
save: function() {localStorage.set_integer("REPORTOBJ.ANCHOR", this.ANCHOR)}, | |
label: function() {return "Reports"}, | |
edit: function() {window.open(github_url("/tree/master/reports"), "_self")}, | |
add : function() {readme()}, | |
open: function(index) {window.open(github_url("/tree/master/reports/" + this.data[index].name), "_self")}, | |
} | |
return init; | |
})() | |
var reportobj = new Reportobj(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment