var statusMarketTrends = []; var statusGlobalSettings = []; var statusSingleMarketSettings = []; var checkedMTButtons = false; var checkedGSButtons = false; var checkedSMSButtons = false; const GSStandardTriggerTemplate = ({ settingType, settingName, trendName, marketTrends, minChange, maxChange }) => `
Market Trend name
Min. trend change % - Read the Wiki!
Max. trend change % - Read the Wiki!
`; const SMSStandardTriggerTemplate = ({ settingType, settingName, trendName, triggerPrefix, marketTrends, marketTrendRelations, minChange, maxChange }) => `
Market Trend name
Market Trend relation
Min. trend change % - Read the Wiki!
Max. trend change % - Read the Wiki!
`; const CoinAgeTriggerTemplate = ({ settingType, settingName, triggerIndex, coinAgeDays }) => `
Days since a coin was added to an exchange.
`; const SMS24hVolumeTriggerTemplate = ({ settingType, settingName, triggerIndex, triggerPrefix, mainMarket, min24hVolume, max24hVolume }) => `
Min. 24h Volume
Max. 24h Volume
`; const SMSHoursActiveTriggerTemplate = ({ settingType, settingName, triggerIndex, hoursSinceTriggered }) => `
Number of hours the setting will be max. active.
`; const PropertyTemplate = ({ settingType, settingName, propertyType, propertyKey, propertyKeySimple, value, valueModes}) => `
Any variable from PT's settings may be used!
The value for this setting.
Value mode - Read the Wiki!
`; function checkMTMoveButtons() { if (!checkedMTButtons) { $('.btn-move-MT').each(function (index) { var dataTarget = $(this).data('datatarget'); var dataDirection = $(this).data('datadirection'); var currentElement = $('#' + dataTarget).closest('.settings-markettrend'); if (dataDirection === 'up') { if ($(currentElement).is('.settings-markettrend:first-child')) { $(this).addClass('hidden'); } else { $(this).removeClass('hidden'); } } else if (dataDirection === 'down') { if ($(currentElement).is('.settings-markettrend:last-child')) { $(this).addClass('hidden'); } else { $(this).removeClass('hidden'); } } }); } checkedMTButtons = true; } function checkGSMoveButtons() { if (!checkedGSButtons) { $('.btn-move-GS').each(function (index) { var dataTarget = $(this).data('datatarget'); var dataDirection = $(this).data('datadirection'); var currentElement = $('#' + dataTarget).closest('.settings-globalsetting'); if (dataDirection === 'up') { if ($(currentElement).is('.settings-globalsetting:first-child')) { $(this).addClass('hidden'); } else { $(this).removeClass('hidden'); } } else if (dataDirection === 'down') { if ($(currentElement).is('.settings-globalsetting:last-child')) { $(this).addClass('hidden'); } else { $(this).removeClass('hidden'); // Get next element var nextElement = $(currentElement).next('.settings-globalsetting').find('div'); var nextElementId = $(nextElement).attr('id').toLowerCase().replace('globalsetting_', ''); if (nextElementId.startsWith('default')) { // Hide "Move Down" button when the next setting is the default setting $(this).addClass('hidden'); } } } }); } checkedGSButtons = true; } function checkSMSMoveButtons() { if (!checkedSMSButtons) { $('.btn-move-SMS').each(function (index) { var dataTarget = $(this).data('datatarget'); var dataDirection = $(this).data('datadirection'); var currentElement = $('#' + dataTarget).closest('.settings-singlemarketsetting'); if (dataDirection === 'up') { if ($(currentElement).is('.settings-singlemarketsetting:first-child')) { $(this).addClass('hidden'); } else { $(this).removeClass('hidden'); } } else if (dataDirection === 'down') { if ($(currentElement).is('.settings-singlemarketsetting:last-child')) { $(this).addClass('hidden'); } else { $(this).removeClass('hidden'); } } }); } checkedSMSButtons = true; } function checkBuildStatus() { var buildCompleted = true; for (key in statusMarketTrends) { if (!statusMarketTrends[key]) { buildCompleted = false; } } if (buildCompleted) { for (key in statusGlobalSettings) { if (!statusGlobalSettings[key]) { buildCompleted = false; } } } if (buildCompleted) { for (key in statusSingleMarketSettings) { if (!statusSingleMarketSettings[key]) { buildCompleted = false; } } } if (buildCompleted) { $('#div-loading-settings').addClass('hidden'); $('#div-save-settings').removeClass('hidden'); checkMTMoveButtons(); checkGSMoveButtons(); checkSMSMoveButtons(); } } $.fn.buildMarketTrendSettings = function () { return this.each(function (index) { var element = $(this); var marketTrendName = $(this).data('trendname'); var rootUrl = $(this).data('rooturl'); if (marketTrendName !== '') { statusMarketTrends[marketTrendName] = false; } $(this).load(rootUrl + '_get/SettingsMarketTrends?mt=' + encodeURIComponent(marketTrendName), '', function (responseText, textStatus, XMLHttpRequest) { if (textStatus === 'error') { $.Notification.notify('error', 'top left', 'Build MarketTrendSettings failed!', 'PTMagic Monitor failed to build MarketTrendSettings.') } else { statusMarketTrends[marketTrendName] = true; checkBuildStatus(); $(this).removeClass('new'); $('[data-toggle="tooltip"]').tooltip(); var elems = Array.prototype.slice.call(document.querySelectorAll('[data-plugin="switchery"][data-switchery="false"]')); elems.forEach(function (html) { var switchery = new Switchery(html, { size : 'small' }); }); } }); }); }; $.fn.buildGlobalSettings = function () { return this.each(function (index) { var element = $(this); var settingName = $(this).data('settingname'); var rootUrl = $(this).data('rooturl'); if (settingName !== '') { statusGlobalSettings[settingName] = false; } $(this).load(rootUrl + '_get/SettingsGlobalSettings?gs=' + encodeURIComponent(settingName), '', function (responseText, textStatus, XMLHttpRequest) { if (textStatus === 'error') { $.Notification.notify('error', 'top left', 'Build GlobalSettings failed!', 'PTMagic Monitor failed to build GlobalSettings.') } else { statusGlobalSettings[settingName] = true; checkBuildStatus(); $(this).removeClass('new'); $('[data-toggle="tooltip"]').tooltip(); var elems = Array.prototype.slice.call(document.querySelectorAll('[data-plugin="switchery"][data-switchery="false"]')); elems.forEach(function (html) { var switchery = new Switchery(html, { size: 'small' }); }); } }); }); }; $.fn.buildSingleMarketSettings = function () { return this.each(function (index) { var element = $(this); var settingName = $(this).data('settingname'); var rootUrl = $(this).data('rooturl'); if (settingName !== '') { statusSingleMarketSettings[settingName] = false; } $(this).load(rootUrl + '_get/SettingsSingleMarketSettings?gs=' + encodeURIComponent(settingName), '', function (responseText, textStatus, XMLHttpRequest) { if (textStatus === 'error') { $.Notification.notify('error', 'top left', 'Build SingleMarketSettings failed!', 'PTMagic Monitor failed to build SingleMarketSettings.') } else { statusSingleMarketSettings[settingName] = true; checkBuildStatus(); $(this).removeClass('new'); $('[data-toggle="tooltip"]').tooltip(); var elems = Array.prototype.slice.call(document.querySelectorAll('[data-plugin="switchery"][data-switchery="false"]')); elems.forEach(function (html) { var switchery = new Switchery(html, { size: 'small' }); }); } }); }); };