Browse Source

make dark site a real setting instead of an easter egg

tags/v1.8.0
Morgan Bazalgette 1 year ago
parent
commit
805e95659e
4 changed files with 20 additions and 12 deletions
  1. 0
    1
      gulpfile.js
  2. 1
    1
      static/dist.min.js
  3. 13
    10
      static/ripple.js
  4. 6
    0
      templates/settings/profile.html

+ 0
- 1
gulpfile.js View File

@@ -29,7 +29,6 @@ gulp.task("minify-js", function() {
"static/licenseheader.js",
"node_modules/jquery/dist/jquery.min.js",
"node_modules/timeago/jquery.timeago.js",
"static/konami.js",
"static/semantic.min.js",
"node_modules/i18next/i18next.min.js",
"node_modules/i18next-xhr-backend/i18nextXHRBackend.min.js",

+ 1
- 1
static/dist.min.js
File diff suppressed because it is too large
View File


+ 13
- 10
static/ripple.js View File

@@ -176,9 +176,18 @@ var singlePageSnippets = {
else
$("#custom-badge-fields").slideUp();
});
var isDark = $("#dark-site").is(":checked");
$("form")
.submit(function(e) {
e.preventDefault();

var darkSetting = $("#dark-site").is(":checked")
if (darkSetting != isDark) {
var cflags = document.cookie.replace(/(?:(?:^|.*;\s*)cflags\s*\=\s*([^;]*).*$)|^.*$/, "$1");
cflags = darkSetting ? +cflags | 1 : +cflags & ~1;
document.cookie = "cflags=" + cflags + ";path=/;max-age=31536000";
}
var obj = formToObject($(this));
var ps = 0;
$(this)
@@ -192,6 +201,10 @@ var singlePageSnippets = {
obj.play_style = ps;
var f = $(this);
api("users/self/settings", obj, function(data) {
if (darkSetting != isDark) {
window.location.reload();
return;
}
showMessage("success", "Your new settings have been saved.");
f.removeClass("loading");
}, true);
@@ -463,16 +476,6 @@ $(document)
$.timeago.settings.allowFuture = true;
$("time.timeago").timeago();

// dark site
new Konami(function() {
var cflags = document.cookie.replace(
/(?:(?:^|.*;\s*)cflags\s*\=\s*([^;]*).*$)|^.*$/, "$1");
// toggle 1 (dark theme)
cflags = (+cflags) ^ 1;
document.cookie = "cflags=" + cflags + ";path=/;max-age=31536000";
window.location.reload();
});

$("#language-selector .item")
.click(function() {
var lang = $(this).data("lang");

+ 6
- 0
templates/settings/profile.html View File

@@ -72,6 +72,12 @@ MinPrivileges=2
</div>
{{ end }}
</div>
<h3 class="ui header">{{ .T "Preferences" }}</h3>
{{ $ds := band .ClientFlags 1 }}
<div class="ui checkbox">
<input type="checkbox" {{ if $ds }}checked{{ end }} id="dark-site">
<label>{{ .T "Dark site" }}</label>
</div>
<div class="ui divider"></div>
<div style="text-align: right">
<button type="submit" class="ui blue button">{{ .T "Save" }}</button>

Loading…
Cancel
Save