//! Modifications by Arian K and Lane B var splatoon = true; if(innerWidth <= 480 || navigator.userAgent.indexOf('Nintendo') > 0) { splatoon = false; } //var loading_animate = false; var loading_animate = true; var pjax_container = '#container'; // Edge lies about being WebKit but it works anyway // Edit: This used to match 'WebKit' but it's now Gecko because WebKit will have that in here anyway var webkit = navigator.userAgent.indexOf('WebKit') > 0 || navigator.userAgent.indexOf('Firefox') > 0; function setupDrawboard() { var canvas = document.getElementById("artwork-canvas"); var ctx = canvas.getContext('2d'); var haval = $("input[type=hidden][name=painting]"); if(haval.length) { dds = new Image(); dds.src = haval.val(); dds.onload = function() { ctx.drawImage(dds,0,0); }; } var undoCanvas = document.getElementById('artwork-canvas-undo'); var undoCtx = undoCanvas.getContext('2d'); var redoCanvas = document.getElementById('artwork-canvas-redo'); var redoCtx = redoCanvas.getContext('2d'); undoCanvas.width = 320; undoCanvas.height = 120; redoCanvas.width = 320; redoCanvas.height = 120; canvas.width = 320; canvas.height = 120; var mousePosOld = 0; var artworkTool = {type: 0, size: 1}; var sizeSmall = 1; var sizeMedium = 2; var sizeLarge = 4; var artworkColor = "#000000"; var artworkZoomFactor = 1; function getMousePos(evt) { var rect = canvas.getBoundingClientRect(); if(evt.type == 'touchmove') { var clientX = evt.touches[0].clientX; var clientY = evt.touches[0].clientY; } else { var clientX = evt.clientX; var clientY = evt.clientY; } return { x: (clientX - rect.left) / artworkZoomFactor, y: (clientY - rect.top) / artworkZoomFactor }; } function drawLineNoAliasing(ctx, sx, sy, tx, ty) { var dist = Math.sqrt((tx-sx)*(tx-sx)+(ty-sy)*(ty-sy)); var ang = Math.atan((ty-sy)/((tx-sx)==0?0.01:(tx-sx)))+((tx-sx)<0?Math.PI:0); for(var i=0;i input").on("click", function(e) { if (openDrawboardModal()) { var menu = $("div.textarea-with-menu"); var memo = $("div.textarea-memo"); var text = $("div.textarea-container"); var poll = $("div.textarea-poll"); if (menu.hasClass("active-text") || menu.hasClass("active-poll")) { menu.removeClass("active-text"); menu.removeClass("active-poll"); menu.addClass("active-memo"); memo.removeClass("none"); text.addClass("none"); poll.addClass("none"); $(".character-count").addClass("none"); } if($("#drawing").length) { Olv.Form.toggleDisabled($("input.post-button"), false); } else { Olv.Form.toggleDisabled($("input.post-button"), true); } setupDrawboard(); } }); var maxlength; if($(".textarea-text").attr("maxlength")) { maxlength = $(".textarea-text").attr("maxlength"); } else { maxlength = 2000; } $(".textarea-text").on("input", function() { // © 2016 Miiverse+ https://openuserjs.org/scripts/PF2M/Miiverse+ var length = $(this).val().length; var remaining = maxlength - length; $(".character-count").text(remaining); if(remaining < 200) { $(".character-count").addClass("red"); } else { $(".character-count").removeClass("red"); } }); $("label.textarea-menu-text").on("click", switchtext); $("label.textarea-menu-poll").on("click", switchpoll); $('button.add-option').on('click', addOption); $('button.delete').on('click', deleteOption); $(".post-button").on("click", switchtext); function switchtext() { var menu = $("div.textarea-with-menu"); menu.removeClass("active-memo"); menu.removeClass("active-poll"); menu.addClass("active-text"); $("div.textarea-container").removeClass("none"); $("div.textarea-memo").addClass("none"); $("div.textarea-poll").addClass("none"); $(".character-count").removeClass("none"); $("textarea[name=body]").attr("data-required", ""); Olv.EntryForm.setupFormStatus($("#post-form"), $.Deferred()); } function switchpoll() { var menu = $("div.textarea-with-menu"); menu.removeClass("active-text"); menu.removeClass("active-memo"); menu.addClass("active-poll"); $("div.textarea-poll").removeClass("none"); $("div.textarea-container").removeClass("none"); $("div.textarea-memo").addClass("none"); $(".character-count").removeClass("none"); $("textarea[name=body]").removeAttr("data-required"); Olv.EntryForm.setupFormStatus($("#post-form"), $.Deferred()); } function addOption() { var options = $(".option").length; // lol it's Nintendo Switch switch(options) { case 2: $(this).before(''); $(".delete").removeClass("none"); break; case 3: $(this).before(''); break; case 4: $(this).before(''); $(this).attr("disabled", "true"); break; default: $('.textarea-poll').html(''); $("button.add-option").on("click", addOption); break; } $("button.delete").off().on("click", deleteOption); Olv.EntryForm.setupFormStatus($("#post-form"), $.Deferred()); } function deleteOption() { var options = $(".option").length; if(options == 5 || options == 4) { $(".add-option").removeAttr("disabled"); $(".option[name=" + $(this).attr("option") + "]").remove(); $(this).remove(); for(var i = 0; i < options - 1; i++) { $(".option").eq(i).attr("name", "option-" + letters[i]); $(".option").eq(i).attr("placeholder", "Option " + letters[i].toUpperCase()); $(".delete").eq(i).attr("option", "option-" + letters[i]); } } else if(options == 3) { $(".option[name=" + $(this).attr("option") + "]").remove(); $(this).remove(); for(var i = 0; i < options - 1; i++) { $(".option").eq(i).attr("name", "option-" + letters[i]); $(".option").eq(i).attr("placeholder", "Option " + letters[i].toUpperCase()); $(".delete").not(this).eq(i).attr("option", "option-" + letters[i]); } $(".delete").addClass("none"); } else { $('.textarea-poll').html(''); $("button.add-option").on("click", addOption); $("button.delete").on("click", deleteOption); } Olv.EntryForm.setupFormStatus($("#post-form"), $.Deferred()); } } function checkGroupForm() { if($("#members .input").length > 0) { $("#members .no-content").addClass("none"); Olv.Form.toggleDisabled($(".post-button"), false); } else { $("#members .no-content").removeClass("none"); Olv.Form.toggleDisabled($(".post-button"), true); } if($("#friends .input").length > 0) { $("#friends .no-content").addClass("none"); } else { $("#friends .no-content").removeClass("none"); } } //!© Nintendo/Hatena 2012-2017 copyright@hatena.com var Olv = Olv || {}; (function(a, b) { b.init || (b.init = a.Deferred(function() { a(this.resolve) }).promise(), b.Router = function() { this.routes = [], this.guard = a.Deferred() } , a.extend(b.Router.prototype, { connect: function(a, b) { a instanceof RegExp || (a = new RegExp(a)), this.routes.push([a, b]) }, dispatch: function(b) { a("#global-menu-list > ul > li.selected").removeClass("selected"); this.guard.resolve(b), this.guard = a.Deferred(); for (var c, d = b.pathname, e = 0; c = this.routes[e]; e++) { var f = d.match(c[0]); f && c[1].call(this, f, b, this.guard.promise()) } } }), b.router = new b.Router, a(document).on("pjax:end", function(c, d) { a(document).trigger("olv:pagechange", [d]), b.router.dispatch(location) }), b.init.done(function() { b.init.done(function() { b.router.dispatch(location) }) }), b.Locale = { Data: {}, text: function(a) { var c = Array.prototype.slice.call(arguments); return c.splice(1, 0, -1), b.Locale.textN.apply(this, c) }, textN: function(a, c) { //if (b.Cookie.get("plain_msgid")) // return a; c = +c || 0; var d = b.Locale.Data[a]; if (!d) return a; var e, f, g = d.quanttype || "o", h = "1_o" === g && 1 === c || "01_o" === g && (0 === c || 1 === c); if (h ? (e = d.text_value_1 || d.value_1, f = d.text_args_1 || d.args_1) : (e = d.text_value || d.value, f = d.text_args || d.args), !f) return e; var i = Array.prototype.slice.call(arguments, 2) , j = 0; return e.replace(/%s/g, function() { return i[f[j++] - 1] }) } }, b.loc = b.Locale.text, b.loc_n = b.Locale.textN, b.print = function(a) { "undefined" != typeof console && console.log(a) } , b.deferredAlert = function(b) { var c = a.Deferred(); return setTimeout(function() { alert(b), c.resolve() }, 0), c.promise() } , b.deferredConfirm = function(b) { var c = a.Deferred(); return setTimeout(function() { var a = confirm(b); c.resolve(a) }, 0), c.promise() } , b.Closed = { blank: /^[\s\u00A0\u3000]*$/, open_spinner: '', lights: function() { $('#darkness').prop('disabled', function(a, b) { return !b }); document.cookie = "light=" + $('#darkness').prop('disabled') + "; path=/; expires=Fri, 31 Dec 9999 23:59:59 UTC" }, prlinkConf: function() { $('#container').prepend('

Confirm link

Are you sure you want to visit '+ass+'?

'); var g = new Olv.ModalWindow($('.linkc'));g.open(); }, changesel: function(a) { $("li#global-menu-" + a).addClass("selected"); } /*, chksum: function(r) { for(var e=0,t=new Array(256),a=0;256!=a;++a)e=1&(e=1&(e=1&(e=1&(e=1&(e=1&(e=1&(e=1&(e=a)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1,t[a]=e;for(var o,c="undefined"!=typeof Int32Array?new Int32Array(t):t,f=-1^0,A=0,d=r.length;A>>8^c[255&(f^e)]:e<2048?f=(f=f>>>8^c[255&(f^(192|e>>6&31))])>>>8^c[255&(f^(128|63&e))]:e>=55296&&e<57344?(e=64+(1023&e),o=1023&r.charCodeAt(A++),f=(f=(f=(f=f>>>8^c[255&(f^(240|e>>8&7))])>>>8^c[255&(f^(128|e>>2&63))])>>>8^c[255&(f^(128|o>>6&15|(3&e)<<4))])>>>8^c[255&(f^(128|63&o))]):f=(f=(f=f>>>8^c[255&(f^(224|e>>12&15))])>>>8^c[255&(f^(128|e>>6&63))])>>>8^c[255&(f^(128|63&e))]; return (-1^f) + '----/' } */ }, b.Net = { ajax: function(c) { var d = a.ajax(c) , e = b.Net._pageId , f = d.then(function(c, d, f) { var g = b.Net._pageId === e /*, h = c && "object" == typeof c && !c.success || !g*/ , i = [c, d, f, g]; return a.Deferred().resolveWith(this, i) }, function(c, d) { var f = b.Net.getDataFromXHR(c); void 0 === f && (f = c.responseText); var g = b.Net._pageId === e; return a.Deferred().rejectWith(this, [f, d, c, g]) }); return f.fail(b.Net.errorFeedbackHandler), f.promise(d), d }, _pageId: 1, getDataFromXHR: function(b) { var c = b.responseText , d = b.getResponseHeader("Content-Type"); if (c && d && /^application\/json(?:;|$)/.test(d)) try { return a.parseJSON(c) } catch (e) {} return void 0 }, getErrorFromXHR: function(a) { var c = b.Net.getDataFromXHR(a) , d = c && c.errors && c.errors[0]; if (d && "object" == typeof d) return d; var e = a.status; if((!('responseText' in a) || a.responseText.length < 2) && e == 400) { if(innerWidth <= 480) { errmsg += a.responseText.substr(0, 400); } else { errmsg += a.responseText.substr(0, 1000); } return { error_code: "Bad Request", message: errmsg }} switch(e) { case 400: if(a.getResponseHeader('Content-Type').indexOf('html') < 0) { if(innerWidth <= 480) { errmsg = a.responseText.substr(0, 400); } else { errmsg = a.responseText.substr(0, 1000); } } else { errmsg = "There was an error with your request."; } return { error_code: "Bad Request", message: errmsg } case 404: return { error_code: "Not Found", message: "The resource or action couldn't be found.\n" } break; case 403: return { error_code: "Not Allowed (Forbidden)", message: "Try refreshing the page or logging back in.\n" } break; case 500: errmsg = "An error has been encountered in the server.\n"; if(a.getResponseHeader('Content-Type').indexOf('html') < 0) { errmsg += "Error information is available; please send this to an administrator:\n"; if(innerWidth <= 480) { errmsg += a.responseText.substr(0, 400); } else { errmsg += a.responseText.substr(0, 1000); } } return { error_code: "Internal server error", message: errmsg } break; case 503: return { error_code: "Service temporarily unavailable", message: "Unfortunately, it's down now. Come back later, or try reloading for now.\n" } break; case 420: return { error_code: "Service is probably down", message: "You've just recieved an error code that's usually recieved after a shutdown or some kind of service downage. So, don't refresh!\n" } break; case 502: return { error_code: "Bad gateway", message: "There's an issue with the application server right now. Wait for it to come back later, and inform an admin about this (because they probably don't do and therefore cannot fix it).\n" } break; case 521: return { error_code: "Web server is down", message: "Oops, something has probably gone terminally wrong. Come back later?\n" } break; default: return e ? 500 > e ? { error_code: e, message: b.loc("olv.portal.error.failed_to_connect.for_offdevice") } : { error_code: 1219999, message: b.loc("olv.portal.error.500.for_offdevice") } : { error_code: "Connection error", message: "Couldn't connect to the server, try again later." } break; } }, _isLeavingPage: !1, willLeavePage: function() { b.Net._isLeavingPage = !0, setTimeout(function() { b.Net._isLeavingPage = !1 }, 100) }, errorFeedbackHandler: function(a, c, d, e) { if ("abort" !== c && e && (d.status || !b.Net._isLeavingPage)) { var f = this , g = arguments; setTimeout(function() { b.Net._errorFeedbackHandler.apply(f, g) }, d.status ? 0 : 1507) } }, _errorFeedbackHandler: function(c, d, e, f) { var g = b.Net.getErrorFromXHR(e); this.silent || b.ErrorViewer.open(g), a(document).trigger("olv:ajax:error", [g, d, e]) }, get: function(a, c, d, e) { return b.Net.ajax({ method: "GET", url: a, data: c, success: d, dataType: e, beforeSend:function(){NProgress.start()},complete:function(){NProgress.done()} }) }, post: function(a, c, d, e) { return b.Net.ajax({ method: "POST", url: a, data: c, success: d, dataType: e, beforeSend:function(){NProgress.start()},complete:function(){NProgress.done()} }) }, go: function(a) { $.pjax({url: a, container: pjax_container}); }, lo: function(cation) { location.href = cation; }, reload: function() { $.pjax.reload(pjax_container); } }, b.Browsing = { setup: function() { a(document).on("click", "[data-href]", this.onDataHrefClick), a(window).on("click submit", this.onMayLeavePage) }, onDataHrefClick: function(c) { if (a(c.target).attr("data-href")) { b.Net.go($(this).attr("data-href")); return; } if (!c.isDefaultPrevented() && !a(c.target).closest("a,button").length) { var d = a(this); if (!d.hasClass("disabled")) { var e = d.attr("data-href"); b.Net.go(e); } } }, onMayLeavePage: function(c) { c.isDefaultPrevented() || "click" === c.type && !a(c.target).closest("[href]").length || b.Net.willLeavePage() } }, b.init.done(function() { b.Browsing.setup() }), b.Utils = {}, b.Utils.toJSONString = "undefined" != typeof JSON ? JSON.stringify : function() { function a(a) { return "\\u" + (65536 + a.charCodeAt(0)).toString(16).substring(1) } function b(c) { switch (typeof c) { case "string": return '"' + c.replace(/[\u0000-\u001f\"\\\u2028\u2029]/g, a) + '"'; case "number": case "boolean": return "" + c; case "object": if (!c) return "null"; var d = Object.prototype.toString.call(c).slice(8, -1); switch (d) { case "String": case "Number": case "Boolean": return b(c.valueOf()); case "Array": for (var e = [], f = 0; f < c.length; f++) e.push(b(c[f])); return "[" + e.join(",") + "]"; case "Object": var e = []; for (var f in c) c.hasOwnProperty(f) && e.push(b(f) + ":" + b(c[f])); return "{" + e.join(",") + "}" } return "null" } return "null" } return b }(), b.Utils._staticRoot = null, b.Utils.staticURL = function(c) { if (/^https?:/.test(c)) return c; var d = b.Utils._staticRoot; return null === d && document.getElementById("main-body") && (d = b.Utils._staticRoot = (a("#main-body").attr("data-static-root") || "").replace(/\/$/, "")), (d || "") + c.replace(/^(?!\/)/, "/") } , b.Utils.isIE8AndEarlierStyle = !!document.createStyleSheet && "undefined" == typeof document.documentElement.style.opacity, b.Utils.isIEStyle = !!window.TextRange, b.Utils.addPlatformClass = function() { var c = a(document.documentElement) , d = navigator.userAgent , e = /\bWin/.test(d) ? "win" : /\bMac/.test(d) ? "mac" : "other"; c.addClass("os-" + e), b.Utils.isIE8AndEarlierStyle && c.addClass("ie8-earlier"), b.Utils.isIEStyle && c.addClass("ie") } , b.Utils.addPlatformClass(), b.Utils.fixWebFontLoadTiming = function() { var a = document.createStyleSheet(); a.cssText = ":before, :after { content: none !important; }", setTimeout(function() { var b = a.owningElement; b.parentNode.removeChild(b) }, 20) } , b.Utils.isIE8AndEarlierStyle && b.init.done(b.Utils.fixWebFontLoadTiming), b.Utils.triggerHandlers = { keypress: function(b) { 13 !== b.which || b.isDefaultPrevented() || (b.preventDefault(), a(this).click()) }, mouseup: function(a) { this.blur() } }, b.init.done(function(a) { a(document).on(b.Utils.triggerHandlers, ".trigger") }), b.Content = {}, b.Content.autopagerize = function(c, d) { function e() { if (!(k._disabledCount || h.scrollTop() + h.height() + 200 < f.offset().top + f.outerHeight())) { // remove existing post-list-loading element because this houses the load more posts button that isn't used when this code is running. a('.post-list-loading').remove(); var d = a("
").attr("class", "post-list-loading").append(a(b.Closed.open_spinner)).appendTo(f); i = a.ajax({ url: g, headers: { "X-AUTOPAGERIZE": !0 } }).done(function(b) { var h = a("
" + b + "
").find(c); g = h.attr("data-next-page-url") || "", g || j.resolve(), f.trigger("olv:autopagerize", [h, g, d]), h.children().each(function() { this.id && a("#" + this.id).length && a(this).detach() }), f.attr("data-next-page-url", g), f.append(h.children()), g && setTimeout(e, 0); if(c == ".js-post-list") { setupPolls(); } if($(c).hasClass("has-masonry")) { $(".js-post-list").imagesLoaded(function() { $(".js-post-list").masonry("reloadItems").masonry(); }); } }).always(function() { d.remove(), i = null }), k.disable(i); } } var f = a(c) , g = f.attr("data-next-page-url"); if (g) { a("#main-body").addClass("is-autopagerized"); var h = a(window) , i = null , j = a.Deferred() , k = b.Content.autopagerize; h.on("scroll", e), j.done(function() { h.off("scroll", e), i && i.abort(), a("#main-body").removeClass("is-autopagerized") }), setTimeout(e, 0), d.done(j.resolve) } } , b.Content.autopagerize._disabledCount = 0, b.Content.autopagerize.disable = function(a) { var c = b.Content.autopagerize; c._disabledCount++, a.always(function() { c._disabledCount-- }) } , b.Content.preloadImages = function() { for (var a = arguments.length, b = a; b--; ) { var c = document.createElement("img"); c.src = arguments[b] } } , b.Form = { toggleDisabled: function(c, d) { var e = void 0 === d; return c.each(function() { var c = a(this) , f = e ? !b.Form.isDisabled(c) : d; if (c.toggleClass("disabled", f), "undefined" != typeof this.form) c.prop("disabled", f); else { var g = f ? "href" : "data-disabled-href" , h = f ? "data-disabled-href" : "href" , i = c.attr(g); void 0 !== i && (c.removeAttr(g), c.attr(h, i)) } }), c }, isDisabled: function(a) { return a.length && "undefined" != typeof a[0].form ? a.prop("disabled") : a.hasClass("disabled") }, disable: function(a, c) { return b.Form.toggleDisabled(a, !0), c.always(function() { b.Form.toggleDisabled(a, !1) }), a }, disableSoon: function(a, c) { return setTimeout(function() { "pending" === c.state() && b.Form.toggleDisabled(a, !0) }, 0), c.always(function() { b.Form.toggleDisabled(a, !1) }), a }, emulateInputEvent: function(b, c) { if (b.length && "undefined" == typeof b[0].oninput) { var d = a.map(b, function(a) { return a.value }) , e = setInterval(function() { for (var c = 0, e = b.length; e > c; c++) { var f = b[c].value; f !== d[c] && (d[c] = f, a(b[c]).trigger("input")) } }, 100); c.always(function() { clearInterval(e) }) } }, submit: function(b, c) { b.trigger("olv:form:submit", [c || a()]); if(a('input[type=file]').length) { var d = new FormData(b[0]) d.append('screen', $('input[type=file]')[0].files[0]) sucky = true } else { var d = b.serializeArray() sucky = false } var e = c && c.is("input, button") && c.prop("name"); e && d.push({ name: e, value: c.val() }); var f = { method: b.prop("method"), url: b.attr("action"), data: d }; if(sucky) { f.processData = false; f.contentType = false; } return this.send(f, c) }, get: function(a, b, c) { var d = { method: "GET", url: a, data: b }; return this.send(d, c) }, _csrfmiddlewaretoken: null, csrfmiddlewaretoken: function() { return null === b.Form._csrfmiddlewaretoken && (b.Form._csrfmiddlewaretoken = a("body").attr("csrf-token")), b.Form._csrfmiddlewaretoken }, csrftoken: function(a) { a.csrfmiddlewaretoken = b.Form.csrfmiddlewaretoken() return a }, post: function(c, d, e) { d || (d = {}), a.isArray(d) ? d.push({ name: "csrfmiddlewaretoken", value: b.Form.csrfmiddlewaretoken() }) : d.csrfmiddlewaretoken = b.Form.csrfmiddlewaretoken(); var f = { method: "POST", url: c, data: d }; return this.send(f, e) }, send: function(c, d) { var e = b.Net.ajax(c); return a(document).trigger("olv:form:send", [e, c, d || a()]), d && (b.Form.disableSoon(d, e), d.addClass("loading"), e.always(function() { d.removeClass("loading") })), e }, updateParentClass: function(c) { switch (c.type) { case "radio": var d = a(c.form ? c.form.elements[c.name] : 'input[name="' + c.name + '"]'); d.each(function() { a(this).parent().toggleClass("checked", this.checked) }), b.Utils.isIE8AndEarlierStyle && d.parent().addClass("changing").removeClass("changing"); break; case "checkbox": a(c).parent().toggleClass("checked", c.checked) } }, setup: function() { a(document).on("click", "input", function(a) { a.isDefaultPrevented() || b.Form.updateParentClass(this) }) }, setupForPage: function() { a("input:checked").each(function() { b.Form.updateParentClass(this) }) }, reset: function(c) { c.each(function() { this.reset(), a(this).find("input").each(function() { b.Form.updateParentClass(this) }) }) }, validateValueLength: function(b) { var c = a(this); c.find("[minlength], [maxlength]").each(function() { var c = a(this) , d = +c.attr("minlength"); isNaN(d) && (d = -(1 / 0)); var e = +c.attr("maxlength"); isNaN(e) && (e = 1 / 0); var f = c.val(); return f.length >= d && f.length <= e ? void 0 : void b.preventDefault() }) } }, b.init.done(b.Form.setup), b.router.connect("", b.Form.setupForPage), b.Guest = { isGuest: function() { return a("main-body").hasClass("guest") } }, b.DecreasingTimer = function(a, b, c) { this.callback_ = a, this.initialInterval_ = b || 1e4, this.maxInterval_ = c || 1 / 0, this.interval_ = this.initialInterval_, this.timeouts_ = [] } , b.DecreasingTimer.prototype.resetInterval = function() { this.interval_ = this.initialInterval_, this.clearAllTimeouts(), this.invoke() } , b.DecreasingTimer.prototype.clearAllTimeouts = function() { a(this.timeouts_).each(a.proxy(function(a, b) { this.clearTimeout(b) }, this)) } , b.DecreasingTimer.prototype.clearTimeout = function(a) { for (var b = 0, c = this.timeouts_.length; c > b; ++b) if (this.timeouts_[b] == a) { clearTimeout(this.timeouts_[b]), this.timeouts_.splice(b, 1); break } } , b.DecreasingTimer.prototype.invoke = function() { this.callback_(); var b; b = setTimeout(a.proxy(function() { this.invoke(), this.clearTimeout(b) }, this), this.interval_), this.timeouts_.push(b), this.interval_ = Math.min(Math.floor(1.5 * this.interval_), this.maxInterval_) } , b.UpdateChecker = function(a, c) { this._settings = {}, b.DecreasingTimer.call(this, this.callback_, a, c) } , b.UpdateChecker.prototype = new b.DecreasingTimer, b.UpdateChecker.getInstance = function() { return void 0 == b.UpdateChecker.instance && (b.UpdateChecker.instance = new b.UpdateChecker(2e4,18e5)), b.UpdateChecker.instance } , b.UpdateChecker.prototype.callback_ = function() { if(!websocketsEnabled || first) { first = false; var c = {}; a.each(this._settings, a.proxy(function(d) { void 0 != this._settings[d].pathname && this._settings[d].pathname != location.pathname ? delete this._settings[d] : a.each(this._settings[d].params, a.proxy(function(a, d) { c[a] = b.Utils.toJSONString(d) }, this)) }, this)); b.Net.ajax({ url: "/check_update.json", silent: !0, cache: !1 }).done(a.proxy(function(b) { a(this).triggerHandler("update", [b]); }, this)); } } , b.UpdateChecker.prototype.onUpdate = function(a, b, c, d) { this._settings[a] = { params: b, update: c }, d && (this._settings[a].pathname = location.pathname) } , b.OpenTruncatedTextButton = {}, b.OpenTruncatedTextButton.setup = function(b) { var c = a(b); c.on("click", ".js-open-truncated-text-button", function(a) { a.preventDefault(), c.find(".js-truncated-text, .js-open-truncated-text-button").addClass("none"), c.find(".js-full-text").removeClass("none") }) } , b.ModalWindowManager = {}, b.ModalWindowManager._windows = [], b.ModalWindowManager.currentWindow = null, b.ModalWindowManager.closeAll = function() { //b.ModalWindowManager._windows = []; for (; this.currentWindow; ) this.currentWindow.close() } , b.ModalWindowManager.closeUntil = function(a) { if (a.guard) for (var b; (b = this.currentWindow) && (b.close(), b !== a); ) ; } , b.ModalWindowManager.register = function(a) { var b = this._windows; b.length ? b[b.length - 1].element.removeClass("active-dialog") : this.toggleMask(!0), a.element.addClass("active-dialog"), b.push(a), this.currentWindow = a } , b.ModalWindowManager.unregister = function(a) { if (this.currentWindow !== a) throw new Error("Failed to unregister modal window"); var b = this._windows; b.pop().element.removeClass("active-dialog"); var c = b.length ? b[b.length - 1] : null; c ? c.element.addClass("active-dialog") : this.toggleMask(!1), this.currentWindow = c } , b.ModalWindowManager._mask = null, b.ModalWindowManager.toggleMask = function(b) { if(a(".mask").length) { a('body').css('position', ''); a(".mask").remove(); } else { if(fixe) { a('body').css('position', 'fixed'); } a("#main-body").append("
"); } } , b.ModalWindowManager.setup = function() { a(document).on("click", "[data-modal-open]", function(c) { var d = a(this); if (!b.Form.isDisabled(d) && !c.isDefaultPrevented()) { c.preventDefault(); var e = a.Event("olv:modalopen"); if (d.trigger(e), !e.isDefaultPrevented()) { var f = a(d.attr("data-modal-open")); f.attr("data-is-template") && (f = f.clone().removeAttr("id")); var g = new b.ModalWindow(f,this); g.open() } } }), a(document).on("click", ".olv-modal-close-button", function(a) { if (!a.isDefaultPrevented()) { a.preventDefault(); var c = b.ModalWindowManager.currentWindow; c && c.close() } }), a(document).on("olv:modal", function(a, c, d) { b.Content.autopagerize.disable(d) }) } , b.init.done(function() { b.ModalWindowManager.setup() }), a(document).on("olv:pagechange", function() { b.ModalWindowManager.closeAll(); }), b.ModalWindow = function(b, c) { this.element = a(b), this.triggerElement = a(c), this.temporary = !this.element.parent().length; var d = a.trim(this.element.attr("data-modal-types")); this.types = d ? d.split(/\s+/) : [], this.guard = null } , b.ModalWindow.prototype.open = function() { return this.guard ? void 0 : (document.activeElement && document.activeElement.blur(), b.ModalWindowManager.register(this), b.Form.toggleDisabled(this.triggerElement, !0), this.element.addClass("modal-window-open").removeClass("none"), this.temporary && this.element.appendTo(document.getElementById("main-body")), this.triggerOpenHandlers(a.Deferred()), this) } , b.ModalWindow.prototype.triggerOpenHandlers = function(a) { this.guard = a; for (var b, c = [this, a.promise()], d = 0; b = this.types[d]; d++) this.element.trigger("olv:modal:" + b, c); this.element.trigger("olv:modal", c) } , b.ModalWindow.prototype.close = function() { return this.guard ? (this.guard.resolve(), this.guard = null, b.ModalWindowManager.unregister(this), this.temporary && this.element.remove(), this.element.addClass("none").removeClass("modal-window-open"), b.Form.toggleDisabled(this.triggerElement, !1), this) : void 0 } , b.SimpleDialog = { _element: null, element: function() { var b = this._element || (this._element = a("
", { "class": "dialog" }).append(a("
", { "class": "dialog-inner" }).append(a("
", { "class": "window" }).append(a("

", { "class": "window-title" }), a("
", { "class": "window-body" }).append(a("

", { "class": "window-body-content" }), a("

", { "class": "form-buttons" }).append(a("

'); var g = new b.ModalWindow($('.acc-set')); g.open(); $('.ac-send').on('click', function() { b.Form.post('/settings/account', $('#feedback-form').serializeArray()) g.close(); $('.acc-set').remove(); }) }, error: function() { b.showMessage('', "Can't open your account preferences because getting your current preferences failed.") } }); }); } , b.init.done(function() { $('#wrapper').attr('class', $('#main-body').attr('class')); b.Global.setupMyMenu() }), b.init.done(function(a) { if (a("#global-menu-news").length) { a("#global-menu-news > a").on("click", function(b) { first = true; }); var c = b.UpdateChecker.getInstance(); a(c).on("update", function(b, d) { a.each(c._settings, function(b, c) { var e = !0; a.each(c.params, function(a, b) { void 0 === d[a] && (this.success = !1) }), e && c.update.call(void 0, d, c.params); getNewFaviconBadge(); }) }), c.onUpdate("check_update", { n: {}, msg: {} }, function(b, c) { // If the response is blank, set both of the counts as 0. if(!b || b.length > 2) { b = [unescape('\x00'), unescape('\x00')]; } // Notification var d = a("#global-menu-news"), e = d.find(".badge"); 0 === e.length && (e = a("", {"class": "badge"}), e.hide().appendTo(d.find("a"))); var f = 0; f += b["n"]; e.text(f); e.toggle(f > 0); // Message var g = a("#global-menu-message"), h = g.find(".badge"); 0 === h.length && (h = a("", { "class": "badge" }), h.hide().appendTo(g.find("a"))); var j = 0; j += b["msg"]; h.text(j), h.toggle(j > 0); }), a(document).on("pjax:complete", function(a) { c.resetInterval() }), c.invoke() } }), b.router.connect("^/activity$", function(c, d, e) { b.Closed.changesel("feed"); function f() { var c = a("#post-form"); b.Form.setupForPage(), b.EntryForm.setupSubmission(c, e), b.EntryForm.setupFormStatus(c, e), b.EntryForm.setupFoldedForm(c, e); if($('#post-form').length) { setupPostForm2(); } b.User.setupFollowButton(e), c.hasClass("for-identified-user") && b.EntryForm.setupIdentifiedUserForm(c, e), c.on("olv:entryform:post:done", g), e.done(function() { a("form.search").off("submit", b.Form.validateValueLength); setupPolls(); }); } function g(b, c) { var d = a(".js-post-list"); d.length || (d = a("
", { "class": "list post-list js-post-list" }).replaceAll(".no-content")); var e = a(a.parseHTML(c)).filter("*"); e.hide().fadeIn(400).prependTo(d); a(".no-post-content").addClass("none"); var f = a(window); f.scrollTop(e.offset().top + e.outerHeight() / 2 - f.height() / 2) } $('form.search').on('submit', function(s) { s.preventDefault(); b.Net.go($(this).attr('action') + '?'+$(this).serialize()); }); b.Entry.setupYeahButtons(e); a("form.search").on("submit", b.Form.validateValueLength); var h, i, j = a(".content-loading-window"); if (j.length) { var k = d.search.substring(1); k && (k = "&" + k), h = b.Net.ajax({ type: "GET", url: window.location.href,/* url: d.pathname + "?" + a.param({ fragment: "activityfeed" }) + k,*/ silent: !0, beforeSend:function(){NProgress.start()},complete:function(){NProgress.done()}, }).done(function(l) { a("#js-main").html(l), a(document).trigger("olv:activity:success", [l, c, d]) pf = $('div.post-form') if(pf.length) { $('#js-main').prepend($('div.post-form')) pf.removeClass('none') f() } b.Content.autopagerize(".js-post-list", e), b.Entry.setupHiddenContents(e); }).fail(function() { setTimeout(function() { j.remove(), a(".content-load-error-window").removeClass("none") }, 5e3) }); /* var l = "friend" !== b.Cookie.get("view_activity_filter"); i = l ? b.Net.ajax({ type: "GET", url: "/my/latest_following_related_profile_posts", silent: !0 }) : a.Deferred().resolve().promise() */ } else h = a.Deferred().resolve().promise(), //i = a.Deferred().resolve().promise(); h.then(function() { f() }); /* a.when(h).done(function(b) { var d = a(a.parseHTML(a.trim(c[0]))); e.each(function(b, c) { var e = d.get(b); e && (a(c).html(e), f.push(c)) }), a(f).removeClass("none") }), e.done(function() { h.abort && h.abort() }) */ $('div.post-filter > form > input[type=checkbox]').on('click', function() { b.Net.go(d.pathname + "?" + $(this).attr('name') + "=" + $(this).attr('value')) }); }), b.router.connect("^(?:/|/communities)$", function(c, d, e) { b.Closed.changesel("community"); /* if(a("#header-news").length) { o = a("#header-news"); l = a(".header-news-button").attr("href") + "/read.json"; a(".close-button").on("click", function(s) { s.preventDefault(); a.post(o); alert("POSTed to " + l); o.remove(); }); o.on("click", function(){ a.post(o); alert("POSTed to " + l); b.Net.go(o.attr("href")); }); } */ function f(b) { a(".tab-body").addClass("none"), a("#tab-" + b + "-body").removeClass("none"), a(".platform-tab a").removeClass("selected"), a("#tab-" + b).addClass("selected") } function g(c) { var d = a(this); if (!b.Form.isDisabled(d) && !c.isDefaultPrevented()) { c.preventDefault(); var e = a(this).attr("data-platform"); f(e); //b.Cookie.set("view_platform", e) } } function h(b) { if (!b.isDefaultPrevented()) { b.preventDefault(); var c = a(this).find('select[name="category"]').val(); window.location.href = c } } //var i = b.Cookie.get("view_platform"); //i && f(i), // !! RE-ENABLE THIS WHEN WE WAND the HoT Diary Post Slide Show //b.Community.setupHotDiaryPostSlideShow(e), a(".platform-tab a").on("click", g), a(".filter-select-page form").on("submit", h), a("form.search").on("submit", b.Form.validateValueLength), e.done(function() { a(".platform-tab a").off("click", g), a(".filter-select-page form").off("submit", h), a("form.search").off("submit", b.Form.validateValueLength) }) $('form.search').on('submit', function(s) { s.preventDefault(); b.Net.go($(this).attr('action') + '?'+$(this).serialize()) }) }), b.router.connect("^/communities/all$", function(c, d, e) { /* AAAAAAAAAAAAAAAAAAAAA BURN IT WITH FIRE b.Closed.changesel("community"); gsl = function(e) { e.preventDefault(); $('.community-switcher-tab.selected').removeClass('selected'); $(this).addClass('selected'); cl = $(this).attr('class').split(' ')[1], $('.' + cl).removeClass('none') $('.communities:not(.none):not(.'+ cl +')').addClass('none') } $('.community-switcher-tab.gen').on('click',gsl), $('.community-switcher-tab.game').on('click',gsl), $('.community-switcher-tab.special').on('click',gsl); */ b.Content.autopagerize('.community-list', e); }), b.router.connect("^/communities.search$", function(c) { $('form.search').on('submit', function(s) { s.preventDefault(); b.Net.go($(this).attr('action') + '?'+$(this).serialize()) }) $("form.search").off("submit", b.Form.validateValueLength); }), b.router.connect("^/(identified_user_posts|notifications)+$", function(a, c, d) { b.Guest.isGuest() || b.User.setupFollowButton(d), b.Content.autopagerize(".js-post-list", d) }), b.router.connect("/notifications(\/)?$", function(a, c, d) { first = true; b.Closed.changesel("news"); }), b.router.connect('/notifications/friend_requests(\/)?$', function(a, c, d) { first = true; b.Closed.changesel("news"); $('.received-request-button').on('click', function(a) { a.preventDefault() fr = new b.ModalWindow($('div[data-modal-types=accept-friend-request][uuid='+ $(this).parent().parent().attr('id') +']'));fr.open(); }) $('div[data-modal-types=accept-friend-request] .ok-button.post-button').on('click', function(a){ a.preventDefault(); b.Form.toggleDisabled($(this), true); b.Form.post($(a.target).parents().eq(4).attr('data-action')).done(function(){ b.Form.toggleDisabled($(this), false); fr.close(); b.Net.reload(); }) }) $('div[data-modal-types=accept-friend-request] .cancel-button').on('click', function(a){ a.preventDefault(); b.showConfirm('Reject Friend Request', 'Are you sure you really want to reject '+ b.SimpleDialog.htmlLineBreak($(a.target).parents().eq(4).attr('data-screen-name')) +'\'s friend request?', { cancelLabel: "No", okLabel: "Yes" }) $('.ok-button.black-button').on('click', function() { b.Form.toggleDisabled($(this), true); b.Form.post($(a.target).parents().eq(4).attr('data-reject-action')).done(function(){ b.Form.toggleDisabled($(this), false); fr.close(); b.Net.reload() }) }) }) }), b.router.connect("^/messages(\/)?$", function(a, c, d) { b.Closed.changesel("message"); b.Content.autopagerize(".list-content-with-icon-and-text", d); $('form.search').on('submit', function(s) { s.preventDefault(); b.Net.go($(this).attr('action') + '?'+$(this).serialize()); }); $('h2 > span > input[type=checkbox]').on('click', function() { b.Net.go(location.pathname + "?" + $(this).attr('name') + "=" + $(this).attr('value')) }); }), b.router.connect("^/conversations/(create|([0-9]+)/edit)$", function(a, c, d) { $(".follow-button").on("click", function() { if($("#members .input").length <= 10) { $(this).addClass("none"); $(this).siblings(".follow-done-button").removeClass("none"); $(this).siblings(".input").attr("name", "user" + ($("#members .input").length + 1)); $(this).parents(".trigger").appendTo("#members"); checkGroupForm(); } else { Olv.showMessage("Error", "You can only add a maximum of 10 users to a friend group."); } }); $(".follow-done-button").on("click", function() { $(this).addClass("none"); $(this).siblings(".follow-button").removeClass("none"); $(this).parents(".trigger").appendTo("#friends"); checkGroupForm(); }); checkGroupForm(); }), b.router.connect("^/(messages|conversations)/([^\/]+)/?$", function(a, c, d) { b.Closed.changesel("message"); b.Content.autopagerize(".list.messages", d) var ff = $('#post-form') b.EntryForm.setupSubmission(ff, d), b.EntryForm.setupFormStatus(ff, d), b.EntryForm.setupFoldedForm(ff, d), b.EntryForm.setupIdentifiedUserForm(ff, d) ff.on("olv:entryform:post:done", g) function g(k, c) { var p = $(".list.messages"); p.length || (p = $("
", { "class": "list post-list js-post-list" }).replaceAll(".no-content")); var e = $($.parseHTML(c)).filter("*"); e.hide().fadeIn(400).prependTo(p); msg_rm_load(); $(".no-content").remove(); var f = $(window); f.scrollTop(e.offset().top + e.outerHeight() / 2 - f.height() / 2) } $("form.search.folded input").on("click", function() { $(this).parents("form.search.folded").removeClass("folded"); }); if($("#post-form").length) { var mode_post = 0; $("label.textarea-menu-memo > input").on("click", function() { if(openDrawboardModal()) { var menu = $("div.textarea-with-menu"); var memo = $("div.textarea-memo"); var text = $("div.textarea-container"); if(menu.hasClass("active-text")) { menu.removeClass("active-text"); menu.addClass("active-memo"); memo.removeClass("none"); text.addClass("none"); $(".character-count").addClass("none"); } if($("#drawing").length) { b.Form.toggleDisabled($("input.post-button"), false); } else { b.Form.toggleDisabled($("input.post-button"), true); } mode_post = 1; setupDrawboard(); } }); $("label.textarea-menu-text").on("click", switchtext); var maxlength; if($(".textarea-text").attr("maxlength")) { maxlength = $(".textarea-text").attr("maxlength"); } else { maxlength = 2000; } $(".textarea-text").on("input", function() { // © 2016 Miiverse+ https://openuserjs.org/scripts/PF2M/Miiverse+ var length = $(this).val().length; var remaining = maxlength - length; $(".character-count").text(remaining); if(remaining < 200) { $(".character-count").addClass("red"); } else { $(".character-count").removeClass("red"); } }); $(".post-button").on("click", switchtext); function switchtext() { var menu = $("div.textarea-with-menu"); menu.removeClass("active-memo"); menu.addClass("active-text"); $("div.textarea-container").removeClass("none"); $("div.textarea-memo").addClass("none"); $(".character-count").removeClass("none"); mode_post = 0; if($("textarea[name=body]").val().length > 0 || $("input[name=image]").val().length > 0) { Olv.Form.toggleDisabled($("input.post-button"), false); Olv.Form.toggleDisabled($("input.reply-button"), false); } else { Olv.Form.toggleDisabled($("input.post-button"), true); Olv.Form.toggleDisabled($("input.reply-button"), true); } } } function msg_rm_load() { var rm_btn = $('.rm-post-button') if(rm_btn.length) { rm_btn.off().on('click',function(){ var thingy = $(this); b.showConfirm("Delete Message", "Delete this message?") $('.ok-button').on('click',function() { b.Form.post(thingy.attr('data-action')); thingy.parent().parent().remove(); }) }) } } msg_rm_load(); $('button.msg-update').on('click',function(e){ b.Net.reload(); }); }), b.router.connect("^/communities/(?:favorites|played)$", function(a, c, d) { b.Closed.changesel("community"); b.Content.autopagerize(".community-list", d) }), b.router.connect("^/communities/search$", function(c, d, e) { b.Closed.changesel("community"); a("form.search").on("submit", b.Form.validateValueLength), e.done(function() { a("form.search").off("submit", b.Form.validateValueLength) }) }), b.router.connect("^/communities/[0-9]+(/diary|/new|/hot|/in_game|/old)?$", function(c, d, e) { b.Closed.changesel("community"); function f() { var b = a(".multi_timeline-topic-filter"); b.addClass("open") } function g(b, c) { var d = a(b.currentTarget).attr("data-post-list-container-selector") , e = !!d , f = e ? d + " .js-post-list" : ".js-post-list" , g = a(f); e ? g.hasClass("empty") && g.removeClass("empty").children().remove() : g.length || (g = a("
", { "class": "list post-list js-post-list" }).replaceAll(".no-content")); var h = a(a.parseHTML(c)).filter("*"); h.hide().fadeIn(400).prependTo(g); a(".no-post-content").addClass("none"); if(!h.hasClass("pinned")) { a(".pinned:not(.repost)").prependTo(g); } var i = a(window); i.scrollTop(h.offset().top + h.outerHeight() / 2 - i.height() / 2); setupPolls(); } b.Entry.setupHiddenContents(e), b.Content.autopagerize(".js-post-list", e), b.Community.setupPostFilter(e); var h = a("#post-form"); b.Guest.isGuest() || (b.Entry.setupYeahButtons(e), b.EntryForm.setupSubmission(h, e), b.EntryForm.setupFormStatus(h, e), b.EntryForm.setupFoldedForm(h, e), b.EntryForm.setupAlbumImageSelector(h, e), h.hasClass("for-identified-user") && b.EntryForm.setupIdentifiedUserForm(h, e), a(".toggle-button").length && b.User.setupFollowButton(e), a(document).on("click", ".js-topic-post-button", f), e.done(function() { a(document).off("click", ".js-topic-post-button", f) })), a(".age-gate-dialog").length && b.Community.setupAgeGateDialog(e), h.on("olv:entryform:post:done", g), e.done(function() { h.off("olv:entryform:post:done", g) }); $("form.search.folded input").on("click", function() { $(this).parents("form.search.folded").removeClass("folded"); }); // I might do this again later /* $('button.reload-btn').on('click',function(e){ NProgress.start(); $.ajax({ url: window.location.href, headers: { "X-AUTOPAGERIZE": !0 } }).done(function(m) { NProgress.done(); $('.js-post-list').replaceWith(m); }); }); */ }), b.router.connect("^/communities/[0-9]+(/artwork(/hot|/new)?|/topic(/new|/open)?)$", function(c, d, e) { b.Closed.changesel("community"); function f(d, f) { var h = a(".js-post-list"); h.length || (h = a("
", { "class": "list multi-timeline-post-list js-post-list" }).replaceAll(".no-content")); var i = a(a.parseHTML(f)).filter("*"); i.hide().fadeIn(400).prependTo(h), /^\/topic(?:\/(?:new|open))?$/.test(c[1]) && (b.EntryForm.onTopicPostCreated(g, e), b.EntryForm.setupFoldedForm(g, e)); var j = a(window); j.scrollTop(i.offset().top + i.outerHeight() / 2 - j.height() / 2) } b.Entry.setupHiddenContents(e), b.Content.autopagerize(".js-post-list", e), b.Community.setupPostFilter(e); var g = a("#post-form"); b.Guest.isGuest() || (b.Entry.setupYeahButtons(e), b.EntryForm.setupSubmission(g, e), b.EntryForm.setupFormStatus(g, e), b.EntryForm.setupFoldedForm(g, e), b.EntryForm.setupAlbumImageSelector(g, e), g.hasClass("for-identified-user") && b.EntryForm.setupIdentifiedUserForm(g, e), a(".toggle-button").length && b.User.setupFollowButton(e)), a(".age-gate-dialog").length && b.Community.setupAgeGateDialog(e), g.on("olv:entryform:post:done", f), e.done(function() { g.off("olv:entryform:post:done", f) }) }), b.router.connect(/^\/posts\/([0-9A-Za-z\-_]+)$/, function(c, d, e) { function f(c, d) { var e = a(window) , f = a(a.parseHTML(d)).filter("*"); f.hide().fadeIn(400).appendTo(".reply-list"), e.scrollTop(f.offset().top + f.outerHeight() / 2 - e.height() / 2), b.Entry.incrementReplyCount(1) } function g(c, d) { var e = a(c.target); e.attr("data-is-post") ? b.Form.toggleDisabled(e, !0) : e.remove() } b.Entry.setupHiddenContents(e), b.Entry.setupMoreRepliesButtons(e); var h = a("#reply-form"); b.Guest.isGuest() || (b.Entry.setupPostYeahButton(e), b.Entry.setupEditButtons(e), b.EntryForm.setupSubmission(h, e), b.EntryForm.setupFormStatus(h, e), b.EntryForm.setupAlbumImageSelector(h, e), h.hasClass("for-identified-user") && b.EntryForm.setupIdentifiedUserForm(h, e)), b.Entry.setupBodyLanguageSelector(e), b.Entry.setupMoreContentButton(e), a(document).on("olv:entryform:post:done", f), a(document).on("olv:report:done", g), e.done(function() { a(document).off("olv:entryform:post:done", f), a(document).off("olv:report:done", g) }) if($('.edit-post-button').length) { var t = $("#edit-form"); var submit_btn = $('#edit-form div.form-buttons button.post-button.black-button') function et() { $('#post-edit').toggleClass('none') $('#the-post').toggleClass('none') } $('.cancel-button').on('click',function(){et()}) b.EntryForm.setupFormStatus(t, e); $('.edit-post-button').on('click', function(){ if($('.reply-content-memo').length) { b.showMessage("Error", "You can't edit a drawing."); } else { et(); } }); submit_btn.on('click', function(a) { a.preventDefault(); b.Form.toggleDisabled($(this), true); cereal = t.serializeArray(); b.Form.post(t.attr('data-action'), cereal).done(function() { $('.post-content-text').html(cereal.body); b.Net.reload(); }) }); } rm_btn = $('.rm-post-button') if(rm_btn.length) { rm_btn.on('click',function() { b.showConfirm("Delete Post", "Delete this post?") $('.ok-button').on('click',function(){ b.Form.post(rm_btn.attr('data-action')).done(function() { window.location.reload(); }); }) }) } setupRepostButton(); fav_btn = $('.profile-post-button') if(fav_btn.length) { if(fav_btn.hasClass('done')) { fav_btn.on('click',function() { b.showConfirm("Favorite Post", "Unset your favorite post?") $('.ok-button').on('click', function() { b.Form.post(fav_btn.attr('data-action')).done(fav_btn.removeClass('done', b.Net.reload())) }) }) } else { fav_btn.on('click',function(){ b.showConfirm("Profile post", "Set this as your profile picture?") $('.ok-button').on('click',function(){ b.Form.post(fav_btn.attr('data-action')).done(fav_btn.addClass('done'),b.Net.reload()) }) }) } } if($("#reply-form").length) { var mode_post = 0; $("label.textarea-menu-memo > input").on("click", function() { if(openDrawboardModal()) { var menu = $("div.textarea-with-menu"); var memo = $("div.textarea-memo"); var text = $("div.textarea-container"); if(menu.hasClass("active-text")) { menu.removeClass("active-text"); menu.addClass("active-memo"); memo.removeClass("none"); text.addClass("none"); $(".character-count").addClass("none"); } b.Form.toggleDisabled($("input.reply-button"), false); mode_post = 1; setupDrawboard(); } }); $("label.textarea-menu-text").on("click", switchtext); var maxlength; if($(".textarea-text").attr("maxlength")) { maxlength = $(".textarea-text").attr("maxlength"); } else { maxlength = 2000; } $(".textarea-text").on("input", function() { // © 2016 Miiverse+ https://openuserjs.org/scripts/PF2M/Miiverse+ var length = $(this).val().length; var remaining = maxlength - length; $(".character-count").text(remaining); if(remaining < 200) { $(".character-count").addClass("red"); } else { $(".character-count").removeClass("red"); } }); $(".reply-button").on("click", switchtext); function switchtext() { var menu = $("div.textarea-with-menu"); menu.removeClass("active-memo"); menu.addClass("active-text"); $("div.textarea-container").removeClass("none"); $("div.textarea-memo").addClass("none"); $(".character-count").removeClass("none"); mode_post = 0; } } }), b.router.connect(/^\/comments\/([0-9A-Za-z\-_]+)$/, function(c, d, e) { function f(c, d) { var e = a(c.target); e.attr("data-is-post") ? b.Form.toggleDisabled(e, !0) : e.remove() } var g = a("#reply-form"); b.Guest.isGuest() || (b.Entry.setupPostYeahButton(e), b.Entry.setupEditButtons(e), b.EntryForm.setupSubmission(g, e), b.EntryForm.setupFormStatus(g, e)), b.Entry.setupBodyLanguageSelector(e), a(document).on("olv:report:done", f), e.done(function() { a(document).off("olv:report:done", f) }); if($('.edit-post-button').length) { var t = $("#edit-form"); var submit_btn = $('#edit-form div.form-buttons button.post-button.black-button') function et() { $('#post-edit').toggleClass('none') $('#the-post').toggleClass('none') } $('.cancel-button').on('click',function(){et()}) b.EntryForm.setupFormStatus(t, e); $('.edit-post-button').on('click', function() { if($('.post-content-memo').length) { b.showMessage("Error", "You can't edit a drawing."); } else { et(); } }); submit_btn.on('click',function(a) { a.preventDefault() b.Form.toggleDisabled($(this), true) cereal = t.serializeArray() b.Form.post(t.attr('data-action'), cereal).done(function() { $('.post-content-text').html(cereal.body); b.Net.reload() }) }) } rm_btn = $('.rm-post-button') if(rm_btn.length) { rm_btn.on('click',function(){ b.showConfirm("Delete Comment", "Delete this comment?") $('.ok-button').on('click',function(){ b.Form.post(rm_btn.attr('data-action')).done(function(){ window.location.reload(); }); }) }) } }), b.router.connect("^/users\.search$", function(c, d, e) { b.Closed.changesel("feed"); b.Content.autopagerize("#searched-user-list", e), b.Guest.isGuest() || b.User.setupFollowButton(e), a("form.search").on("submit", function(s) { b.Form.validateValueLength(s), s.preventDefault(); b.Net.go($(this).attr('action') + '?'+$(this).serialize()) }), e.done(function() { a("form.search").off("submit", b.Form.validateValueLength) }) }), b.router.connect("^/users/[^\/]+/(yeahs|posts|comments)$", function(a, c, d) { b.Content.autopagerize(".js-post-list", d); $("form.search.folded input").on("click", function() { $(this).parents("form.search.folded").removeClass("folded"); }); }), b.router.connect("^/users/[^\/]+(/friends|/following|/followers)$", function(a, c, d) { b.Content.autopagerize("#friend-list-content", d) }), b.router.connect("^/users/[^\/]+(/diary)$", function(c, d, e) { function f(b, c) { var e = a(".js-post-list"); e.find(".no-content").addClass("none"); var f = a(a.parseHTML(c)).filter("*"); f.hide().fadeIn(400).prependTo(e), i.remove(); // Why do we need to replace state???????? //window.history.replaceState(window.history.state, "", d.href.replace(/\?.*/, "")); var g = a(document).find("#js-my-post-count"); g[0] && g.text(+g.text() + 1); var h = a(window); h.scrollTop(f.offset().top + f.outerHeight() / 2 - h.height() / 2) } function g(a, b) { i.remove() } function h(c, d) { b.Form.toggleDisabled(a(c.target), !0) } b.Entry.setupHiddenContents(e), b.Content.autopagerize(".js-post-list", e); var i = a("#post-form"); b.Guest.isGuest() || (b.Entry.setupYeahButtons(e), b.EntryForm.setupSubmission(i, e), b.EntryForm.setupFormStatus(i, e), i.hasClass("for-identified-user") && b.EntryForm.setupIdentifiedUserForm(i, e)), a(document).on("olv:report:done", h), i.on("olv:entryform:post:done", f); var j = i.find(".cancel-button"); j.on("click", g), e.done(function() { //showButton.off("click"), a(document).off("olv:report:done", h), i.off("olv:entryform:post:done", f), j.off("click", g) }) }), b.router.connect("^/users/[^\/]+(/friends|/following|/followers|/yeahs|/posts|/comments)?$", function(c, d, e) { if(a("#edit-profile-settings").length) { b.Closed.changesel('mymenu'); } function f(c, d) { b.Form.toggleDisabled(a(c.target), !0) } function g(b, c) { a("#user-content.is-visitor").length && a("#js-following-count").text(c) } b.User.setupFollowButton(e, { container: ".main-column", noReloadOnFollow: !0 }); $('.block-button.block').on('click', function(a) { a.preventDefault() fr = new b.ModalWindow($('div[data-modal-types=post-block]'));fr.open(); }); $('.block-button.unblock').on('click', function(a) { a.preventDefault() fr = new b.ModalWindow($('div[data-modal-types=post-unblock]'));fr.open(); }); $('div[data-modal-types=post-block] input.post-button').on('click', function(g){ g.preventDefault(); b.Form.toggleDisabled($(this), true); b.Form.post($('div[data-modal-types=post-block] form').attr('data-action')).done(function() { fr.close(); b.Form.toggleDisabled($(this), false); b.Net.reload(); }); }); $('div[data-modal-types=post-unblock] input.post-button').on('click', function(g){ g.preventDefault(); b.Form.toggleDisabled($(this), true); b.Form.post($('div[data-modal-types=post-unblock] form').attr('data-action')).done(function() { fr.close(); b.Form.toggleDisabled($(this), false); b.Net.reload(); }); }); $('.friend-button.create').on('click', function(a) { a.preventDefault() fr = new b.ModalWindow($('div[data-modal-types=post-friend-request]'));fr.open(); }) $('div[data-modal-types=post-friend-request] input.post-button').on('click', function(g){ g.preventDefault(); b.Form.toggleDisabled($(this), true); b.Form.post($('.friend-button.create').attr('data-action'), $('div[data-modal-types=post-friend-request] form').serializeArray()).done(function() { fr.close(); b.Form.toggleDisabled($(this), false); b.Net.reload() }) }) $('.friend-button.accept').on('click', function(g) { g.preventDefault() fr = new b.ModalWindow($('div[data-modal-types=accept-friend-request]'));fr.open(); }) $('div[data-modal-types=accept-friend-request] .ok-button.post-button').on('click', function(g){ g.preventDefault(); b.Form.toggleDisabled($(this), true); b.Form.post($('div[data-modal-types=accept-friend-request]').attr('data-action')).done(function(){ b.Form.toggleDisabled($(this), false); fr.close(); b.Net.reload(); }) }) $('div[data-modal-types=accept-friend-request] .cancel-button').on('click', function(g){ g.preventDefault(); b.showConfirm('Reject Friend Request', 'Are you sure you really want to reject '+ b.SimpleDialog.htmlLineBreak($('div[data-modal-types=accept-friend-request]').attr('data-screen-name')) +'\'s friend request?', { cancelLabel: "No", okLabel: "Yes" }) $('.ok-button.black-button').on('click', function(g) { b.Form.post($('div[data-modal-types=accept-friend-request]').attr('data-reject-action')).done(function(){ fr.close(); b.Net.reload() }) }) }) $('.friend-button.cancel').on('click', function(g) { g.preventDefault() b.showConfirm('Cancel Friend Request', 'Are you sure you really want to cancel your friend request to '+ b.SimpleDialog.htmlLineBreak($('.friend-button.cancel').attr('data-screen-name')) +'?', { cancelLabel: "No", okLabel: "Yes" }) $('.ok-button.black-button').on('click', function(g) { b.Form.post($('.friend-button.cancel').attr('data-action')).done(function(){ b.Net.reload() }) }) }) $('.friend-button.delete').on('click', function(g) { g.preventDefault() b.showConfirm('Unfriend', 'Are you sure you really want to unfriend '+ b.SimpleDialog.htmlLineBreak($('.friend-button.delete').attr('data-screen-name')) +"? Your messages will not be deleted.", { cancelLabel: "No", okLabel: "Yes" }) $('.ok-button.black-button').on('click', function(g) { b.Form.toggleDisabled($(this), true); b.Form.post($('.friend-button.delete').attr('data-action')).done(function(){ b.Form.toggleDisabled($(this), false); b.Net.reload(); }) }) }) b.User.setupUserSidebar(e) b.Entry.setupHiddenContents(e), a(document).on("olv:report:done", f), a(document).on("olv:visitor:following-count:change", g), e.done(function() { //showButton.off("click"), a(document).off("olv:report:done", f), a(document).off("olv:visitor:following-count:change", g) }), b.Entry.setupYeahButtons(e) }), b.router.connect("^/users/[^\/]+/favorites$", function(a, c, d) { b.Content.autopagerize(".community-list", d) }), b.router.connect("^/signup$", function(c, d, e) { // Is there an NNID field? // TODO: Make this way better and don't have this duplicated like it is now if($('h3.label.nnid').length) { inp = $('input[type=text][name=nnid]') icon = $('h3.label.nnid > label > img') function getmiim() { if(b.Closed.blank.test(inp.val())) { icon.addClass('none'); icon.attr('src', ''); $('p.red').html(null); return false; } if(!inp.val().match(/^[^\/]{6,16}$/)) { $('p.red').html('The NNID provided is invalid.') return false; } else { $('p.red').html(null); } $.ajax({ url: inp.attr('data-action'), type: 'POST', data: b.Form.csrftoken({'a': inp.val()}), success: function(a) { if(a == '') { icon.addClass('none'); icon.attr('src', ''); $('input[name=mh]').val(''); } else { icon.removeClass('none'); icon.attr('src', 'https://mii-secure.cdn.nintendo.net/' + a + '_normal_face.png'); $('input[name=mh]').val(a); } }, error: function(a) { $('p.red').html(a.responseText); icon.addClass('none'); icon.attr('src', ''); $('input[name=mh]').val(''); }, beforeSend:function(){NProgress.start()},complete:function(){NProgress.done()} }) } var timer; inp.on('input', function() { clearTimeout(timer); timer = setTimeout(getmiim, 500); }) } }), b.router.connect("^/reset/$", function(d, c, f) { $("form[method=post]").on("submit", function(e) { e.preventDefault(); $.ajax({ type: 'POST', url: window.location.href, data: $("form").serialize(), success: function(s) { $("p.red").addClass("green"),$("p.red").text(s) }, error: function(s) { $("p.red").text(s.responseText) }, beforeSend: function() { NProgress.start(); }, complete: function() { NProgress.done(); } }); }) }), b.router.connect("^/server$", function() { $('button.reload-btn').on('click',function(e){ NProgress.start(); var thing = $.getJSON(window.location.href, { json: '1' }, function(tt) { NProgress.done(); $('#guide > div > ul > li:nth-child(1) > strong').html(tt['communities']), $('#guide > div > ul > li:nth-child(2) > strong').html(tt['posts']), $('#guide > div > ul > li:nth-child(3) > strong').html(tt['users']), $('#guide > div > ul > li:nth-child(4) > strong').html(tt['comments']), $('#guide > div > ul > li:nth-child(5) > strong').html(tt['messages']), $('#guide > div > ul > li:nth-child(6) > strong').html(tt['yeahs']), $('#guide > div > ul > li:nth-child(7) > strong').html(tt['complaints']), $('#guide > div > ul > li:nth-child(8) > strong').html(tt['notifications']), $('#guide > div > ul > li:nth-child(9) > strong').html(tt['follows']), $('#guide > div > ul > li:nth-child(10) > strong').html(tt['friendships']); }); }) }), b.router.connect("^/blocked$", function() { $('.received-request-button').on('click', function(a) { a.preventDefault() fr = new b.ModalWindow($('div#' + a.originalEvent.target.getAttribute('data-user-id')));fr.open(); }); $('div[data-modal-types=post-unblock] input.post-button').on('click', function(g){ g.preventDefault(); b.Form.toggleDisabled($(this), true); b.Form.post(g.target.form.dataset.action).done(function() { fr.close(); b.Form.toggleDisabled($(this), false); b.Net.reload(); }); }); }), b.router.connect("^/man/?$", function(c, d, e) { $('li.setting-pruge1 > form > button').click(function(a) { a.preventDefault(); if(confirm("Really? This is PERMANENT!!!!!!!!")) { Olv.Form.post(location.href, $('li.setting-pruge1 > form').serializeArray()).done(function(response) { Olv.showMessage('', response); }); } }); $('li.setting-pruge2 > form > button').click(function(a) { a.preventDefault(); if(confirm("Really? This is recoverable.")) { Olv.Form.post(location.href, $('li.setting-pruge2 > form').serializeArray()).done(function(response) { Olv.showMessage('', response); }); } }); $('li.setting-pruge3 > form > button').click(function(a) { a.preventDefault(); if(confirm("Really? Friendships can't be recovered.")) { Olv.Form.post(location.href, $('li.setting-pruge3 > form').serializeArray()).done(function(response) { Olv.showMessage('', response); }); } }); $('li.setting-pruge4 > form > button').click(function(a) { a.preventDefault(); if(confirm("Really? This is permanent.")) { Olv.Form.post(location.href, $('li.setting-pruge4 > form').serializeArray()).done(function(response) { Olv.showMessage('', response); }); } }); $('li.setting-pruge5 > form > button').click(function(a) { a.preventDefault(); if(confirm("Really? This is permanent.")) { Olv.Form.post(location.href, $('li.setting-pruge5 > form').serializeArray()).done(function(response) { Olv.showMessage('', response); }); } }); $('li.setting-pruge6 > form > button').click(function(a) { a.preventDefault(); if(confirm("Really? This is permanent.")) { Olv.Form.post(location.href, $('li.setting-pruge6 > form').serializeArray()).done(function(response) { Olv.showMessage('', response); }); } }); $('li.setting-unpurge1 > form > button').click(function(a) { a.preventDefault(); if(confirm("Really? This is permanent.")) { Olv.Form.post(location.href, $('li.setting-unpurge1 > form').serializeArray()).done(function(response) { Olv.showMessage('', response); }); } }); }), b.router.connect("^/man/users$", function(c, d, e) { function openUserModal(user) { $('#user-man-template > div > div > h1.window-title').text('Manage "' + user.username + '"'); $('div.user-info').html(user.html); $('input[name=username]').val(user.username); $('input[name=email]').val(user.email); $('input[name=addr]').val(user.addr); $('form.goodform').attr('data-action', user.manager); if(user.is_active) { $('input[name=active]').prop('checked', true); } else { $('input[name=active]').prop('checked', false); } var g = new b.ModalWindow($('#user-man-template'));g.open(); $('form.goodform').submit(function(a) { a.preventDefault(); //alert('doing it'); b.Form.post($('form.goodform').attr('data-action'), $('form.goodform').serializeArray()).done(g.close()); }) } b.Form.get('/man/users_list' + location.search).done(function(a) { $('.user-loads').html(a); b.Content.autopagerize('#user-man-list', e); $('button.user-manage').on('click',function() { NProgress.start(); b.Form.get($(this).parent().parent().attr('data-action')).done(function(a) { NProgress.done(); openUserModal(a); b.print(a); }); }); }); }), b.router.connect("^/settings/profile$", function(c, d, e) { b.Closed.changesel('mymenu') // If we are on profile settings.. if(c[0][10] == 'p') { $('.get-ipinfo').on('click', function(e){ e.preventDefault(); $.ajax({url: '/region', method: 'post', data: {csrfmiddlewaretoken: Olv.Form.csrfmiddlewaretoken}, beforeSend:function(){NProgress.start()},complete:function(){NProgress.done()}, success: function(a) { $('input[name=country]').val($.trim(a)) b.showMessage('Region', "Your region has been recieved as \"" + $.trim(a) + "\". Please note that this was taken from your IP. If it's inaccurate, you might be using a proxy.\n\nThis information has not been saved. Please be sure you want to share your region when you save.") }, error: function() { b.showMessage('Region', "Failed to get your region for some reason.") } }) }) var maxlength; if($(".textarea-text").attr("maxlength")) { maxlength = $(".textarea-text").attr("maxlength"); } else { maxlength = 2000; } $(".character-count").text(maxlength - $(".textarea-text").val().length); $(".textarea-text").on("input", function() { // © 2016 Miiverse+ https://openuserjs.org/scripts/PF2M/Miiverse+ var length = $(this).val().length; var remaining = maxlength - length; $(".character-count").text(remaining); if(remaining < 200) { $(".character-count").addClass("red"); } else { $(".character-count").removeClass("red"); } }); inp = $('input[type=text][name=nnid]') function getmiimtwo() { if(!inp.val().match(/^[^\/]{6,16}$/)) { $('p.error').html('The NNID provided is invalid.') return false } else { $('p.error').html(null) } $.ajax({ url: inp.attr('data-action'), type: 'POST', data: b.Form.csrftoken({'a': inp.val()}), success: function(a) { if(a == '') { $('.nnid-icon.mii').attr('src', ''); } else { $('.nnid-icon.mii').attr('src', 'https://mii-secure.cdn.nintendo.net/' + a + '_normal_face.png'); } $('input[name=mh]').val(a); }, error: function(a) { $('p.error').html(a.responseText); }, beforeSend:function(){NProgress.start()},complete:function(){NProgress.done()} }) } var timer; inp.on('input', function() { clearTimeout(timer); if(inp.val()) { timer = setTimeout(getmiimtwo, 500); } }) $(".migration .migrate-button:visible").on("click", function() { var popup = '

Import Posts

To begin, first enter your login details.'; if($(this).hasClass("password-required")) { popup += ' These will not be stored.'; } popup += '

'; if($(this).hasClass("password-required")) { popup += '
'; } popup += '
'; $('#wrapper').prepend(popup); var g = new b.ModalWindow($('.migrate')); g.open(); $('.migrate-send').on('click', function() { b.Form.post($(this).attr('data-action'), Olv.Form.csrftoken($('#feedback-form').serializeArray())).done(function() { Olv.showMessage("Success", "Post import complete!"); }); g.close(); $('.migrate').remove(); }); }); $(".past-imports-button").on("click", function() { var g = new b.ModalWindow($('.past-imports')); g.open(); $(".past-imports .migrate-button").on('click', function() { b.Form.post($(this).attr('data-action'), Olv.Form.csrftoken([])); $(this).parents(".migration").remove(); }); $(".past-imports .post-button").on("click", function() { g.close(); }); }); $('input[name=avatar][value=0]').change(function() { $('.setting-avatar > .icon-container > .nnid-icon.mii').addClass('none'); $('.nnid-icon.avatar').removeClass('none'); }) $('input[name=avatar][value=1]').change(function() { $('.setting-avatar > .icon-container > .nnid-icon.mii').removeClass('none'); $('.nnid-icon.avatar').addClass('none'); }) function changeColor(color, theme) { if(theme) { if($("#theme").length == 0) { $("head").append(""); $("head").append(""); } else { $("#theme:not([temp])").attr("temp", $("#theme").text()); } var tc = tinycolor(color); var hsv = tc.toHsv(); $("#theme").text(":root{--theme:" + color + ";--theme-light:" + formatHSL(hsv.h, hsv.s * 0.1, hsv.v) + ";--theme-dark:" + formatHSL(hsv.h, hsv.s, hsv.v * 0.25) + ";--theme-darker:" + formatHSL(hsv.h, hsv.s, hsv.v * 0.125) + "}"); $(document).on("pjax:end", function() { $("#theme[temp]").text($("#theme[temp]").attr("temp")); $(".delet").remove(); }); } else { $('#sidebar-profile-body .nick-name').attr('style', 'color:' + color); } } $(".color-value").on("change", function() { if($(this).attr("name") == "theme") { changeColor($(this).val(), true); } else { changeColor($(this).val(), false); } }); if(!supportsColorInput()) { $(".color-thing").removeClass("none"); $(".color-value").attr("type", "hidden"); $('.color-thing').click(function(a) { a.preventDefault(); $(this).spectrum({ color: $(this).siblings('.color-value'), preferredFormat: "hex", showInput: true, flat: true, change: function(color) { $(this).siblings('.color-value').val(color).change(); } }); $('div.form-buttons > input').click(function(a) { $(this).spectrum('destroy'); }); }); } $('.default-color').click(function(a) { a.preventDefault(); $(this).siblings('.color-thing').spectrum('destroy'); $(this).siblings('.color-value').val('').change(); if($(this).siblings('.color-value').attr('name') == "theme") { $(this).siblings('.color-value').val('#8000ff'); } else { $(this).siblings('.color-value').val('#000000'); } if($(this).siblings('.color-value').attr('name') == 'theme') { $("#theme:not([temp])").attr("temp", $("#theme").text()); $("#theme").text(":root {--theme:#8000ff;--theme-light:#f0f0ff;}"); $(document).on("pjax:end", function() { $("#theme[temp]").text($("#theme[temp]").attr("temp")); }); } else { $('#sidebar-profile-body .nick-name').attr('style', ''); } b.showMessage("", "Color reset to default."); }); $(".apply-button").on("click", function(){ $("#theme").removeAttr("temp"); $(".delete").removeAttr("delet"); }); $('input[name=background_url]').on('input', function(a) { var val = a.target.value; if(!val) { $('style#background').html(' ') return } var siz = $('input[type=range]').val(); console.log('#wrapper{background-image:url(' + val + ')!important;background-size:' + siz + '%}') $('style#background').html('#wrapper{background-image:url(' + val + ')!important;background-size:' + siz + '%}'); }) $('input[type=range]').on('change', function(a) { var val = $('input[name=background_url]').val(); if(!val) { $('style#background').html(' ') return } var siz = a.target.value; console.log('#wrapper{background-image:url(' + val + ')!important;background-size:' + siz + '%}') $('style#background').html('#wrapper{background-image:url(' + val + ')!important;background-size:' + siz + '%}'); }) // } } b.User.setupUserSidebar(e) function f(c) { var d = a(this) , e = d.closest("form"); b.Form.isDisabled(d) || c.isDefaultPrevented() || (c.preventDefault(), b.Form.submit(e, d).done(function(a) { b.Net.reload() })) } function g(c) { var d = a(this); b.showConfirm(b.loc("olv.portal.profile_post"), b.loc("olv.portal.profile_post.confirm_remove"), { okLabel: b.loc("olv.portal.button.remove"), cancelLabel: b.loc("olv.portal.stop") }).done(function(a) { a && b.Form.post("/settings/profile_post.unset.json", null, d).done(function() { d.trigger("olv:entry:profile-post:remove"), d.remove() }) }) } function h(b) { var c = a() , d = a() , e = a("#favorite-game-genre select"); e.each(function() { var b = a(this) , d = b.find("option[value=" + b.val() + "]").attr("data-is-configurable") , f = null != d && "0" != d; if (f) { var g = e.filter(function() { return !a(this).is(b) }); g.each(function() { var d = a(this) , e = d.find("option[value=" + b.val() + "]"); c = c.add(e) }) } }), d = e.find("option").filter(function() { return !a(this).is(c) }), c.prop("disabled", !0), d.prop("disabled", !1) } h(), a(document).on("click", ".apply-button", f), a(document).on("click", "#profile-post", g), a(document).on("change", "#favorite-game-genre select", h), e.done(function() { a(document).off("click", ".apply-button", f), a(document).off("click", "#profile-post", g), a(document).off("change", "#favorite-game-genre select", h) }) }), b.router.connect("^(/users/[^\/]+/communities/(favorites|played)|/my_menu)", function(a, c, d) { b.Closed.changesel('community'); b.User.setupUserSidebar(d) }), b.router.connect("^/communities/[0-9]+", function(a, c, d) { b.Closed.changesel("community"); if($("#post-form").length) { setupPostForm2() } b.Community.setupCommunitySidebar(d); }), b.router.connect("^/admin$", function(a, c, d) { $(".js-post-list").imagesLoaded(function() { $(".js-post-list").addClass("has-masonry"); $(".js-post-list").masonry({itemSelector: ".post:not(.repost)", "gutter": 8}); Olv.Entry.setupHiddenContents(d); Olv.Content.autopagerize(".js-post-list", d); }); $(".report-action-button").on("click", function() { $(this).siblings(".report-action-button").addBack().addClass("none"); $(this).parents(".form-buttons").append(""); var america = this; Olv.Form.post($(this).attr("data-action"), []).done(function() { $(america).parents(".report").addClass("none"); $(".js-post-list").masonry(); }).fail(function() { $(america).siblings(".report-action-button").addBack().removeClass("none"); $(america).siblings(".loading-spinner").remove(); }); }); }), /* b.router.connect("^/news/.*$", function(c, d, e) { b.Closed.changesel("news"); }), */ b.init.done(function(a) { a(document).on("olv:modal:report-violation olv:modal:report-violator", function(a, b, c) { function d() { var a = g.find("option:selected").attr("data-track-action"); e.attr("data-track-action", a) } var e = b.element.find(".post-button") , f = b.triggerElement.attr("data-can-report-spoiler") , g = "1" === f ? b.element.find("select.can-report-spoiler") : "0" === f ? b.element.find("select.cannot-report-spoiler") : b.element.find('select[name="type"]') , h = b.triggerElement.attr("data-track-label") , i = b.triggerElement.attr("data-url-id") || ""; e.attr("data-track-label", h), e.attr("data-url-id", i), g.on("change", d), c.done(function() { g.off("change", d) }) }); var c = function(a) { var b = a.find("input[type=submit]") , c = a.find('input[name="album_image_id"]').length && a.find('input[name="album_image_id"]').val().length > 0 , d = a.find('input[name="screenshot"]').length && a.find('input[name="screenshot"]').val().length > 0; b.attr("data-post-with-screenshot", c || d ? "screenshot" : "nodata") }; a(document).on("olv:entryform:updatescreenshot", function(b) { var d = a(b.target); c(d) }), a(document).on("olv:entryform:fileselect", function(b, c) { var d = a(b.target) , e = a(c).find('input[type="submit"]'); "screenshot" === d.attr("name") ? e.attr("data-post-with-screenshot", "screenshot") : "painting" === d.attr("name") && e.attr("data-post-content-type", "draw") }), a(document).on("olv:entryform:reset", function(b) { a(".preview-container").css("display", "none"); var d = a(b.target) , e = d.find("input[type=submit]"); e.attr("data-post-content-type", "text"), setTimeout(function() { c(d) }, 0) if($("input[name=painting]").val()) { $("#drawing").remove(); $("input[name=painting]").attr("value", ""); } if($("input[name=image]").val()) { $("input[name=image]").attr("value", ""); } $(".repost-notice").remove(); $("input[name=repost]").remove(); }) a(document).on("olv:entryform:post:done", function(b) { var d = $("span.remaining-today-post-count"); if(d.length) { d.text(+(d.text()) - 1); } }) })) } ).call(this, jQuery, Olv); // TODO: Make this locale way better, remove unnecessary things, actually use stuff from this Olv.Locale.Data={ "olv.portal.age_gate.select_label":{value:"Please enter your date of birth."},"olv.portal.album.delete_confirm":{value:"Are you sure you want to delete this?"},"olv.portal.button.remove":{value:"Yes"},"olv.portal.cancel":{value:"Cancel"},"olv.portal.close":{value:"Close"},"olv.portal.dialog.apply_settings_done":{value:"Settings saved."},"olv.portal.dialog.report_spoiler_done":{value:"Spoiler reported. Thank you for your help!"},"olv.portal.dialog.report_violation_done":{value:"Violation reported. Thank you for your help!"},"olv.portal.edit.action.close_topic_post":{value:"Close for Comments"},"olv.portal.edit.action.close_topic_post.confirm":{value:"It will no longer be possible to post comments on this discussion. Is that OK? (This action cannot be reversed.)"},"olv.portal.edit.edit_post":{value:"Edit Post"},"olv.portal.edit.edit_reply":{value:"Edit Comment"},"olv.portal.error.500.for_offdevice":{value:"An error occurred.\nPlease try again later."},"olv.portal.error.album_limit_exceeded":{value:"Unable to save because the maximum number of screenshots that can be saved has been reached. Please delete some saved screenshots, and then try again."},"olv.portal.error.code":{args:[1],value:"Error Code: %s"},"olv.portal.error.code %1":{args:[1],value:"Error Code: %s"},"olv.portal.error.code [_1]":{args:[1],value:"Error Code: %s"},"olv.portal.error.daily_post_limit_exceeded":{value:"You have already exceeded the number of posts that you can contribute in a single day. Please try again tomorrow."},"olv.portal.error.failed_to_connect.for_offdevice":{value:"An error occurred."},"olv.portal.error.network_unavailable.for_offdevice":{value:"Cannot connect to the Internet. Please check your network connection and try again."},"olv.portal.error.post_time_restriction":{args:[],value:"Multiple posts cannot be made in such a short period of time. Please try posting again later."},"olv.portal.error.post_time_restriction %1":{args:[],value:"Multiple posts cannot be made in such a short period of time. Please try posting again later."},"olv.portal.error.post_time_restriction [_1]":{args:[],value:"Multiple posts cannot be made in such a short period of time. Please try posting again later."},"olv.portal.followlist.confirm_unfollow_with_name":{args:[1],value:"Remove %s from your follow list?"},"olv.portal.followlist.confirm_unfollow_with_name %1":{args:[1],value:"Remove %s from your follow list?"},"olv.portal.followlist.confirm_unfollow_with_name [_1]":{args:[1],value:"Remove %s from your follow list?"},"olv.portal.miitoo.4":{value:"Yeah..."},"olv.portal.miitoo.4.delete":{value:"Unyeah"},"olv.portal.miitoo.1":{value:"Yeah!"},"olv.portal.miitoo.1.delete":{value:"Unyeah"},"olv.portal.miitoo.2":{value:"Yeah♥"},"olv.portal.miitoo.2.delete":{value:"Unyeah"},"olv.portal.miitoo.0":{value:"Yeah!"},"olv.portal.miitoo.0.delete":{value:"Unyeah"},"olv.portal.miitoo.5":{value:"Yeah..."},"olv.portal.miitoo.5.delete":{value:"Unyeah"},"olv.portal.miitoo.3":{value:"Yeah!?"},"olv.portal.miitoo.3.delete":{value:"Unyeah"},"olv.portal.miitoo.6":{value:"Epic!"},"olv.portal.miitoo.6.delete":{value:"Unepic"},"olv.portal.miitoo.7":{value:"Nyeah~♥"},"olv.portal.miitoo.7.delete":{value:"Unnyeah"},"olv.portal.miitoo.8":{value:"Yes!"},"olv.portal.miitoo.8.delete":{value:"Unyes"},"olv.portal.miitoo.9":{value:"olv.portal.miitoo."},"olv.portal.miitoo.9.delete":{value:"olv.portal.miitoo.delete"},"olv.portal.ok":{value:"OK"},"olv.portal.post.delete_confirm":{value:"Delete this post?"},"olv.portal.profile_post":{value:"Favorite Post"},"olv.portal.profile_post.confirm_remove":{value:"Remove this post from your profile?\nThe original post will not be deleted."},"olv.portal.profile_post.confirm_update":{value:"Set this post as your favorite?\nPlease note, it will replace any existing favorite post."},"olv.portal.profile_post.confirm_update.yes":{value:"OK"},"olv.portal.profile_post.done":{value:"Your favorite post has been set.\nWould you like to view your profile?"},"olv.portal.read_more_content":{value:"Read More"},"olv.portal.reply.delete_confirm":{value:"Delete this comment?"},"olv.portal.report.report_comment_id":{args:[1],value:"Comment ID: %s"},"olv.portal.report.report_comment_id %1":{args:[1],value:"Comment ID: %s"},"olv.portal.report.report_comment_id [_1]":{args:[1],value:"Comment ID: %s"},"olv.portal.report.report_post_id":{args:[1],value:"Post ID: %s"},"olv.portal.report.report_post_id %1":{args:[1],value:"Post ID: %s"},"olv.portal.report.report_post_id [_1]":{args:[1],value:"Post ID: %s"},"olv.portal.report.report_spoiler":{args:[],value:"Report Spoilers to Indigo Administrators"},"olv.portal.report.report_spoiler %1":{args:[],value:"Report Spoilers to Indigo Administrators"},"olv.portal.report.report_spoiler [_1]":{args:[],value:"Report Spoilers to Indigo Administrators"},"olv.portal.report.report_spoiler_comment":{args:[],value:"Report Spoilers to Indigo Administrators"},"olv.portal.report.report_spoiler_comment %1":{args:[],value:"Report Spoilers to Indigo Administrators"},"olv.portal.report.report_spoiler_comment [_1]":{args:[],value:"Report Spoilers to Indigo Administrators"},"olv.portal.report.report_violation":{args:[],value:"Report Violation to Indigo Administrators"},"olv.portal.report.report_violation %1":{args:[],value:"Report Violation to Indigo Administrators"},"olv.portal.report.report_violation [_1]":{args:[],value:"Report Violation to Indigo Administrators"},"olv.portal.report.report_violation_comment":{args:[],value:"Report Violation to Indigo Administrators"},"olv.portal.report.report_violation_comment %1":{args:[],value:"Report Violation to Indigo Administrators"},"olv.portal.report.report_violation_comment [_1]":{args:[],value:"Report Violation to Indigo Administrators"},"olv.portal.report.report_violation_message":{args:[],value:"Report Violation to Indigo Administrators"},"olv.portal.report.report_violation_message %1":{args:[],value:"Report Violation to Indigo Administrators"},"olv.portal.report.report_violation_message [_1]":{args:[],value:"Report Violation to Indigo Administrators"},"olv.portal.setup":{value:"Set Up"},"olv.portal.show_more_content":{value:"View Entire Post"},"olv.portal.stop":{value:"Cancel"},"olv.portal.unfollow":{value:"Unfollow"},"olv.portal.user.search.go":{value:"View Profile"},"olv.portal.yes":{value:"Yes"}}; $(document).pjax("a",pjax_container),$(document).on('pjax:timeout',function(){return false}); $(document).on('pjax:error', function(event, xhr, textStatus, errorThrown, options) { Olv.Net.errorFeedbackHandler(event, textStatus, xhr, options); if(textStatus != 'abort') history.back(); return false; }); if(loading_animate) { $(document).on('pjax:send',function(){NProgress.start()}); $(document).on('pjax:complete', function(){NProgress.done()}); } $(document).on('pjax:complete',function(){ Olv.init.done(); }); function recalculateVotes(pollOptions) { var voteArray = []; for(var j = 0; j < pollOptions.length; j++) { voteArray.push(parseInt(pollOptions.eq(j).attr('votes'))); } add = function(a, b){ return a + b; } var voteCount = voteArray.reduce(add, 0) pollOptions.siblings('.poll-votes').text(voteCount + ' vote' + (voteCount == 1 ? '' : 's')); for(var i = 0; i < pollOptions.length; i++) { var voteArrayCopy = voteArray; voteArrayCopy.slice(i, 1); var otherNumbers = voteArrayCopy.reduce(add, 0); var percentage = Math.abs(100 - (((otherNumbers - voteArray[i]) / otherNumbers) * 100)); if(Number.isNaN(percentage)) { percentage = 0; } pollOptions.eq(i).children('.poll-background').attr('style', 'width:' + percentage + '%'); pollOptions.eq(i).children('.percentage').html(Math.round(percentage) + "% (" + voteArray[i] + " vote" + (voteArray[i] == 1 ? '' : 's') + ")"); } if(voteCount > 0) { pollOptions.parents(".post-poll").addClass("has-votes"); } else { pollOptions.parents(".post-poll").removeClass("has-votes"); } } function setupPolls() { if($('.post-poll').length) { add = function(a, b) { return a + b; } $('.post-poll .poll-option').off().on('click', function() { if(!$("body").attr("sess-usern")) { Olv.showMessage("Error", "You must be logged in to vote on a poll."); return; } if(!$(this).hasClass('selected')) { $(this).siblings('.poll-option.selected').attr('votes', $(this).siblings('.poll-option.selected').attr('votes') - 1); $(this).siblings('.poll-option.selected').removeClass('selected'); $(this).addClass('selected'); $(this).attr('votes', parseInt($(this).attr('votes')) + 1); recalculateVotes($(this).siblings('.poll-option').addBack()); Olv.Form.post($(this).parents('.post-poll').attr('data-action'), {'option': parseInt($(this).attr("option-id"))}); } else { $(this).removeClass('selected'); $(this).attr('votes', $(this).attr('votes') - 1); recalculateVotes($(this).siblings('.poll-option').addBack()); Olv.Form.post($(this).parents('.post-poll').attr('data-action'), {'option': '0'}); } }); } } function setupRepostButton() { repost_btn = $('.repost-button') if(repost_btn.length) { repost_btn.on('click', function() { $('#wrapper').prepend('

Repost

Please select a community to repost to.
'); var g = new Olv.ModalWindow($('.repost-dialog')); g.open(); function getCommunities(success) { $(".loading-spinner").remove(); $(".recent-community-list").append($(success).find("li")); $(".recent-community-list .trigger").off().on("click", function() { $(this).siblings(".trigger").removeClass("selected"); $(this).addClass("selected"); $(".repost-form").attr("action", $(this).attr("data-action")); Olv.Form.toggleDisabled($(".repost-send"), false); }); if($(success).attr("data-next-page-url").length) { $(".recent-community-list").attr("data-next-page-url", $(success).attr("data-next-page-url")); function loadMoreCommunities(event) { if($(".overflow-scroll")[0].scrollHeight - $(".overflow-scroll").scrollTop() == $(".overflow-scroll").height()) { $(this).off(); var recentCommunityList = $(this).children(".recent-community-list"); recentCommunityList.append(''); $.get(recentCommunityList.attr("data-next-page-url"), getCommunities).fail(failGetCommunities); } } $(".overflow-scroll").on("scroll", loadMoreCommunities); } } function failGetCommunities() { $(".loading-spinner").remove(); $(".recent-community-list").append("

Failed to get community list. Refresh the page or try again later.

"); } $.get("/communities/recent", getCommunities).fail(failGetCommunities); }); } } function formatHSL(h, s, v) { var tc = tinycolor({h: h, s: s, v: v}); hsl = tc.toHsl(); return 'hsl(' + hsl.h + ', ' + hsl.s * 100 + '%, ' + hsl.l * 100 + '%)'; } var supportsColorInput = function() { // Taken from Modernizr: https://stackoverflow.com/questions/7787552/check-with-javascript-for-html5-type-color-support var inputElem = document.createElement('input'), bool, docElement = document.documentElement, smile = ':)'; inputElem.setAttribute('type', 'color'); bool = inputElem.type !== 'text'; if(bool) { inputElem.value = smile; inputElem.style.cssText = 'position:absolute;visibility:hidden;'; docElement.appendChild(inputElem); docElement.offsetWidth; bool = inputElem.value != smile; docElement.removeChild(inputElem); } return bool; } // https://stackoverflow.com/a/29853395 !function(o,n){var t=function(){var n=o(":target"),t=71;n.length>0&&o("html, body").stop().animate({scrollTop:n.offset().top-t},200)};o(n).on("hashchange load",function(){t()})}(jQuery,window); function updateTime() { var timestamps = $('.update'); for(var i = 0; i < timestamps.length; i++) { var timestamp = timestamps.eq(i); var since = new Date().getTime() - timestamp.attr('time'); var time = new Date(since); var timestampText; if(time < 1000) { timestampText = 'Less than a second ago'; } else if(time < 2000) { timestampText = '1 second ago'; } else if(time < 60000) { timestampText = Math.floor(since / 1000) + ' seconds ago'; } else if(time < 120000) { timestampText = '1 minute ago'; } else if(time < 3600000) { timestampText = Math.floor(since / 1000 / 60) + ' minutes ago'; } else if(time < 7200000) { timestampText = '1 hour ago'; } else if(time < 86400000) { timestampText = Math.floor(since / 1000 / 60 / 60) + ' hours ago'; } else if(time < 172800000) { timestampText = '1 day ago'; } else if(time < 345600000) { timestampText = Math.floor(since / 1000 / 60 / 60 / 24) + ' days ago'; } else { var dateTime = new Date(parseInt(timestamp.attr('time'))); var twelveHourClockTime = dateTime.getHours() % 12; if(twelveHourClockTime === 0) { twelveHourClockTime = 12; } timestampText = (dateTime.getMonth() + 1).toString().padStart(2, "0") + "/" + dateTime.getDate().toString().padStart(2, "0") + "/" + dateTime.getFullYear() + " " + twelveHourClockTime + ":" + dateTime.getMinutes().toString().padStart(2, "0") + " " + (dateTime.getHours() >= 12 ? "PM" : "AM"); timestamp.removeClass('update'); } // only update the timestamp in the dom if it actually changed if(timestamp[0].innerHTML != timestampText) { timestamp.text(timestampText); } } } updateTime(); setTimeout(setInterval(updateTime, 1000), 1000 - (new Date().getTime() % 1000)); function toggleWebsocketses() { if(!$("#websockets").length) { $("#websockets").remove(); $('