;(function() {
/* Panel */
window.Panel = function(finder, options) {
this.finder = finder
this.tree = options.tree || []
this.index = options.index || 0
this.name = options.name
this.item = options.item
this.render()
}
Panel.prototype.dispose = function() {
$('p' + this.index ).remove()
this.p = null
}
Panel.prototype.render = function() {
this.finder.psW.insert({ bottom: this.html() })
}
Panel.prototype.html = function() {
var it, css, recent, ix=this.index, t=this.tree,bH = this.finder.bW.offsetHeight,
h = '
',
'
',
'
',
'
',
'
',
'',
' | ', // repo
'Branch: | ', // branches
'Loading... | ',
'Github Finder | ',
'
',
'
',
'
', // .p
'
', // #r_w
'
', // browser wrapper
'
',
'
',
// '
',
'
', // #finder
'
', // file content wrapper
'
',
'
', // file content
'
', // padding
'
', // file wrapper
'
', // file
'
',
'
', // padding
'
',
'
',
'
', // #f_c_w
'',
'
' // # content
].join(' ')
}
/* openRepo */
Finder.prototype.openRepo = function() {
this.reset()
$('r').innerHTML = this.repo
var self = this
/* Load the master branch */
loading()
GITR.commits( this.repo, this.branch, function(err, cs) {
loaded()
if (err) {
console.log('GITR.commits failed: ' + err)
return
}
var tree_sha = cs[0].tree
self.renderPanel(tree_sha)
})
/* Show branches info */
loading()
GITR.branches( this.repo, function(err, bes) {
loaded()
if (err) {
console.log('GITR.branches failed: ' + err)
return
}
self.bes = $H(bes) // FIXME
self.renderBranches()
})
}
Finder.prototype.reset = function() {
$('f_c_w').hide()
this.cI = -1
this.pI = 0
while (this.ps.length > 0)
(this.ps.pop()).dispose()
}
/* render branches */
Finder.prototype.renderBranches = function() {
var h = '