uniScore/public/js/jquery.bracket.min.js

3 lines
29 KiB
JavaScript
Raw Normal View History

2018-11-24 17:35:23 +00:00
/* jQuery Bracket | Copyright (c) Teijo Laine 2011-2018 | Licenced under the MIT licence */
var __extends = this && this.__extends || function () { var t = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function (t, e) { t.__proto__ = e } || function (t, e) { for (var n in e) e.hasOwnProperty(n) && (t[n] = e[n]) }; return function (e, n) { t(e, n); function r() { this.constructor = e } e.prototype = null === n ? Object.create(n) : (r.prototype = n.prototype, new r) } }(); !function (t) { var e, n = function () { function t(e) { if (this.val = e, e instanceof t) throw new Error("Trying to wrap Option into an Option"); if (void 0 === this.val) throw new Error("Option cannot contain undefined") } return t.of = function (e) { return new t(e) }, t.empty = function () { return new t(null) }, t.prototype.get = function () { if (null === this.val) throw new Error("Trying to get() empty Option"); return this.val }, t.prototype.orElse = function (t) { return null === this.val ? t : this.val }, t.prototype.orElseGet = function (t) { return null === this.val ? t() : this.val }, t.prototype.map = function (e) { return null === this.val ? t.empty() : new t(e(this.val)) }, t.prototype.forEach = function (t) { return null !== this.val && t(this.val), this }, t.prototype.toNull = function () { return null === this.val ? null : this.val }, t.prototype.isEmpty = function () { return null === this.val }, t }(), r = function (t) { __extends(e, t); function e() { return null !== t && t.apply(this, arguments) || this } return e.of = function (e) { var n = typeof e; if (null !== e && "number" !== n) throw new Error("Invalid score format, expected number, got " + n); return t.of.call(this, e) }, e.empty = function () { return n.empty() }, e }(n), i = function () { return function (t, e, n) { if (this.first = t, this.second = e, this.userData = n, !t || !e) throw new Error("Cannot create ResultObject with undefined scores") } }(); (o = e || (e = {}))[o.TBD = 0] = "TBD", o[o.BYE = 1] = "BYE", o[o.END = 2] = "END"; var o, s = function () { function t(t) { this.isFirst = t } return t.first = function () { return new t(!0) }, t.second = function () { return new t(!1) }, t.prototype.map = function (t, e) { return this.isFirst ? t : e }, t }(), a = function () { function t(t, e, n, r, i) { this.source = t, this.nameOrGetter = e, this.order = n, this.seed = r, this.score = i, this.sibling = function () { throw new Error("No sibling asigned") } } return Object.defineProperty(t.prototype, "name", { get: function () { return "function" == typeof this.nameOrGetter ? this.nameOrGetter() : this.nameOrGetter }, set: function (t) { this.nameOrGetter = t }, enumerable: !0, configurable: !0 }), t.prototype.emptyBranch = function () { if (!this.name.isEmpty()) return this.sibling().name.isEmpty() ? e.BYE : e.TBD; try { var t = this.source().emptyBranch(); if (t === e.TBD) return e.TBD; if (t === e.END) return e.BYE; return this.source().sibling().emptyBranch() === e.TBD ? e.TBD : e.BYE } catch (t) { if (t instanceof c) return e.END; throw new Error('Unexpected exception type (message: "' + t.message + '")') } }, t }(); function h(t) { return !isNaN(parseFloat(t)) && isFinite(t) } function c() { this.message = "Root of information for this team", this.name = "EndOfBranchException" } var u, l = function () { function t(t, e) { this.a = t, this.b = e } return t.teamsInResultOrder = function (t) { var n = t.a.name.isEmpty(), r = t.b.name.isEmpty(); if (r && !n) return t.b.emptyBranch() === e.BYE ? [t.a, t.b] : []; if (n && !r) return t.a.emptyBranch() === e.BYE ? [t.b, t.a] : []; if (!t.a.score.isEmpty() && !t.b.score.isEmpty()) { if (t.a.score.get() > t.b.score.get()) return [t.a, t.b]; if (t.a.score.get() < t.b.score.get()) return [t.b, t.a] } return [] }, t.emptyTeam = function (t, e) { var i = new a(t, n.empty(), n.empty(), n.empty(), r.empty()); return i.sibling = function () { return e }, i }, t.prototype.winner = function () { return t.teamsInResultOrder(this)[0] || t.emptyTeam(this.a.source, this.b) }, t.prototype.loser = function () { return t.teamsInResultOrder(this)[1] || t.emptyTeam(this.b.source, this.a) }, t }(); (p = u || (u =