mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-12-27 10:31:22 +08:00
showing popup with config if copying to clipboard failed. part of #2044
This commit is contained in:
parent
d2636d6410
commit
1e90fd80e2
4 changed files with 17 additions and 11 deletions
|
|
@ -147,7 +147,7 @@ const refactoredSrc = [
|
|||
"./src/js/popups/edit-tags-popup.js",
|
||||
"./src/js/popups/edit-preset-popup.js",
|
||||
"./src/js/popups/custom-theme-popup.js",
|
||||
"./src/js/popups/import-settings-popup.js",
|
||||
"./src/js/popups/import-export-settings-popup.js",
|
||||
"./src/js/popups/custom-background-filter.js",
|
||||
|
||||
"./src/js/settings/language-picker.js",
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import "./caps-warning";
|
|||
import "./support-popup";
|
||||
import "./version-popup";
|
||||
import "./custom-theme-popup";
|
||||
import "./import-settings-popup";
|
||||
import "./input-controller";
|
||||
import "./ready";
|
||||
import "./about-page";
|
||||
|
|
|
|||
|
|
@ -2,8 +2,17 @@ import * as UpdateConfig from "./config";
|
|||
import * as Settings from "./settings";
|
||||
import * as Notifications from "./notifications";
|
||||
|
||||
function show() {
|
||||
export function show(mode, config) {
|
||||
if ($("#settingsImportWrapper").hasClass("hidden")) {
|
||||
$("#settingsImportWrapper").attr("mode", mode);
|
||||
|
||||
if (mode === "export") {
|
||||
$("#settingsImportWrapper .button").addClass("hidden");
|
||||
$("#settingsImportWrapper input").val(config);
|
||||
} else if (mode === "import") {
|
||||
$("#settingsImportWrapper .button").removeClass("hidden");
|
||||
}
|
||||
|
||||
$("#settingsImportWrapper")
|
||||
.stop(true, true)
|
||||
.css("opacity", 0)
|
||||
|
|
@ -39,10 +48,6 @@ function hide() {
|
|||
}
|
||||
}
|
||||
|
||||
$("#importSettingsButton").click((e) => {
|
||||
show();
|
||||
});
|
||||
|
||||
$("#settingsImport .button").click((e) => {
|
||||
hide();
|
||||
});
|
||||
|
|
@ -13,6 +13,7 @@ import * as SimplePopups from "./simple-popups";
|
|||
import * as EditTagsPopup from "./edit-tags-popup";
|
||||
import * as EditPresetPopup from "./edit-preset-popup";
|
||||
import * as ThemePicker from "./theme-picker";
|
||||
import * as ImportExportSettingsPopup from "./import-export-settings-popup";
|
||||
|
||||
export let groups = {};
|
||||
async function initGroups() {
|
||||
|
|
@ -732,6 +733,10 @@ $("#resetSettingsButton").click((e) => {
|
|||
SimplePopups.list.resetSettings.show();
|
||||
});
|
||||
|
||||
$("#importSettingsButton").click((e) => {
|
||||
ImportExportSettingsPopup.show("import");
|
||||
});
|
||||
|
||||
$("#exportSettingsButton").click((e) => {
|
||||
let configJSON = JSON.stringify(Config);
|
||||
navigator.clipboard.writeText(configJSON).then(
|
||||
|
|
@ -739,10 +744,7 @@ $("#exportSettingsButton").click((e) => {
|
|||
Notifications.add("JSON Copied to clipboard", 0);
|
||||
},
|
||||
function (err) {
|
||||
Notifications.add(
|
||||
"Something went wrong when copying the settings JSON: " + err,
|
||||
-1
|
||||
);
|
||||
ImportExportSettingsPopup.show("export");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue