+ alertAndQuit: function(text, wrongVname) {
+ // Soon after component creation, st.tr might be uninitialized.
+ // Set a timeout to let a chance for the message to show translated.
+ const newUrl =
+ "/variants" + (wrongVname ? "" : "/" + this.gameRef.vname);
+ setTimeout(() => {
+ alert(this.st.tr[text] || text);
+ this.$router.replace(newUrl);
+ }, 500);
+ },
+ initFromUrl: function() {
+ this.gameRef.vname = this.$route.params["vname"];
+ const routeFen = this.$route.query["fen"];
+ if (!routeFen) this.alertAndQuit("Missing FEN");
+ else {
+ this.gameRef.fen = routeFen.replace(/_/g, " ");
+ // orientation is optional: taken from FEN if missing.
+ // NOTE: currently no internal usage of 'side', but could be used by
+ // manually settings the URL (TODO?).
+ const orientation = this.$route.query["side"];
+ this.initialize(orientation);
+ }
+ },
+ initialize: async function(orientation) {