Skip to content

Commit

Permalink
Windowize calendar_name
Browse files Browse the repository at this point in the history
  • Loading branch information
V13Axel committed Jul 7, 2024
1 parent 010294e commit 2dd42f2
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion resources/js/calendar-events-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -2409,7 +2409,7 @@ export default () => ({
this.worker_event_tester = new Worker('/js/webworkers/worker_event_tester.js')

this.worker_event_tester.postMessage(JSON.parse(JSON.stringify({
calendar_name: calendar_name,
calendar_name: window.calendar_name,
static_data: window.static_data,
dynamic_data: preview_date,
events: events,
Expand Down
8 changes: 4 additions & 4 deletions resources/js/calendar-presets.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ export default () => ({
if (calendar.success) {
prev_dynamic_data = {}
prev_static_data = {}
calendar_name = clone(calendar.name);
window.calendar_name = clone(calendar.name);
window.static_data = clone(calendar.static_data);
window.dynamic_data = clone(calendar.dynamic_data);
event_categories = clone(calendar.event_categories);
Expand Down Expand Up @@ -203,7 +203,7 @@ export default () => ({
.then((result) => {
if (result.value) {

calendar_name = "Random Calendar";
window.calendar_name = "Random Calendar";
window.static_data = RandomCalendar.randomize(static_data);
window.dynamic_data = {
"year": 1,
Expand Down Expand Up @@ -255,13 +255,13 @@ export default () => ({

apply_preset: function(data) {

calendar_name = data.name;
window.calendar_name = data.name;
window.static_data = data.static_data;
window.dynamic_data = data.dynamic_data;
events = data.events;
event_categories = data.categories;

if (calendar_name.indexOf("Gregorian Calendar") > -1) {
if (window.calendar_name.indexOf("Gregorian Calendar") > -1) {
let current_date = new Date();
window.dynamic_data.year = current_date.getFullYear();
window.dynamic_data.timespan = current_date.getMonth();
Expand Down
10 changes: 5 additions & 5 deletions resources/js/calendar/calendar_ajax_functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ export function do_update_all(calendar_hash, success_callback, failure_callback)
success: function(result) {

if (!calendar_name_same) {
prev_calendar_name = clone(calendar_name);
document.title = calendar_name + " - Fantasy Calendar";
prev_calendar_name = clone(window.calendar_name);
document.title = window.calendar_name + " - Fantasy Calendar";
}

if (!static_same) {
Expand Down Expand Up @@ -520,7 +520,7 @@ export function delete_calendar(calendar_hash, calendar_name, callback) {

if (result.dismiss || !result.value) throw null;

if (result.value !== calendar_name) throw `Sorry! "${result.value}" isn't the same as "${calendar_name}"`;
if (result.value !== window.calendar_name) throw `Sorry! "${result.value}" isn't the same as "${calendar_name}"`;

return axios.delete(window.apiurl + '/calendar/' + calendar_hash);

Expand All @@ -533,7 +533,7 @@ export function delete_calendar(calendar_hash, calendar_name, callback) {
swal.fire({
icon: "success",
title: "Deleted!",
text: "The calendar " + calendar_name + " has been deleted.",
text: "The calendar " + window.calendar_name + " has been deleted.",
button: true
})
.then(success => {
Expand All @@ -558,7 +558,7 @@ export function create_calendar(callback) {
type: "post",
dataType: 'json',
data: {
name: calendar_name,
name: window.calendar_name,
dynamic_data: JSON.stringify(window.dynamic_data),
static_data: JSON.stringify(window.static_data),
events: JSON.stringify(events),
Expand Down
22 changes: 11 additions & 11 deletions resources/js/calendar/calendar_inputs_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export var changes_applied = true;

export function set_up_edit_inputs() {

prev_calendar_name = clone(calendar_name);
prev_calendar_name = clone(window.calendar_name);
prev_dynamic_data = clone(window.dynamic_data);
prev_static_data = clone(window.static_data);
prev_events = clone(events);
Expand All @@ -68,7 +68,7 @@ export function set_up_edit_inputs() {

owned_calendars = {};

calendar_name_same = calendar_name == prev_calendar_name;
calendar_name_same = window.calendar_name == prev_calendar_name;
static_same = JSON.stringify(window.static_data) === JSON.stringify(prev_static_data);
dynamic_same = JSON.stringify(window.dynamic_data) === JSON.stringify(prev_dynamic_data);
events_same = JSON.stringify(events) === JSON.stringify(prev_events);
Expand All @@ -77,7 +77,7 @@ export function set_up_edit_inputs() {

window.onbeforeunload = function(e) {

calendar_name_same = calendar_name == prev_calendar_name;
calendar_name_same = window.calendar_name == prev_calendar_name;
static_same = JSON.stringify(window.static_data) === JSON.stringify(prev_static_data);
dynamic_same = JSON.stringify(window.dynamic_data) === JSON.stringify(prev_dynamic_data);
events_same = JSON.stringify(events) === JSON.stringify(prev_events);
Expand Down Expand Up @@ -145,7 +145,7 @@ export function set_up_edit_inputs() {
delete_button = $('#btn_delete');

delete_button.click(function() {
delete_calendar(window.hash, calendar_name, function() { self.location = '/calendars' });
delete_calendar(window.hash, window.calendar_name, function() { self.location = '/calendars' });
});

calendar_container = $('#calendar');
Expand Down Expand Up @@ -314,7 +314,7 @@ export function set_up_edit_inputs() {
/* ------------------- Dynamic and static callbacks ------------------- */

$('#calendar_name').change(function() {
calendar_name = $(this).val();
window.calendar_name = $(this).val();
do_error_check();
});

Expand Down Expand Up @@ -4232,7 +4232,7 @@ function get_errors() {

var errors = [];

if (calendar_name == "") {
if (window.calendar_name == "") {
errors.push("The calendar name cannot be empty.")
}

Expand Down Expand Up @@ -4325,7 +4325,7 @@ export const creation = {
this.text = [];

if (this.current_step >= 1) {
if (calendar_name == "") {
if (window.calendar_name == "") {
this.text.push(`<span><i class="mr-2 fas fa-calendar"></i> Your calendar must have a name</span>.`)
this.current_step = 1;
} else {
Expand Down Expand Up @@ -5385,7 +5385,7 @@ export function evaluate_save_button(override) {

} else {

calendar_name_same = calendar_name == prev_calendar_name;
calendar_name_same = window.calendar_name == prev_calendar_name;
static_same = JSON.stringify(window.static_data) === JSON.stringify(prev_static_data);
dynamic_same = JSON.stringify(window.dynamic_data) === JSON.stringify(prev_dynamic_data);
events_same = JSON.stringify(events) === JSON.stringify(prev_events);
Expand Down Expand Up @@ -5550,7 +5550,7 @@ var block_inputs = false;
export function set_up_edit_values() {
block_inputs = true;

$('#calendar_name').val(calendar_name);
$('#calendar_name').val(window.calendar_name);

$('.static_input').each(function() {

Expand Down Expand Up @@ -5827,7 +5827,7 @@ export function empty_edit_values() {

function autosave() {
var saved_data = JSON.stringify({
calendar_name: calendar_name,
calendar_name: window.calendar_name,
static_data: window.static_data,
dynamic_data: window.dynamic_data,
events: events,
Expand Down Expand Up @@ -5895,7 +5895,7 @@ export function autoload(popup) {
swal.fire({
icon: "success",
title: "Loaded!",
text: "The calendar " + calendar_name + " has been loaded."
text: "The calendar " + window.calendar_name + " has been loaded."
});
}

Expand Down

0 comments on commit 2dd42f2

Please sign in to comment.