From bd9fb5f94656cc5f62f1dc735b10c9a78007245d Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Sun, 4 Oct 2020 15:22:41 +0200 Subject: [PATCH 01/12] better import statements --- fleetpings/app_settings.py | 2 +- fleetpings/apps.py | 2 +- fleetpings/auth_hooks.py | 4 ++-- fleetpings/form.py | 1 + fleetpings/urls.py | 2 +- fleetpings/views.py | 4 ++-- 6 files changed, 8 insertions(+), 7 deletions(-) diff --git a/fleetpings/app_settings.py b/fleetpings/app_settings.py index 54e0bcd0..890c9fd2 100644 --- a/fleetpings/app_settings.py +++ b/fleetpings/app_settings.py @@ -8,7 +8,7 @@ from django.conf import settings -from .utils import clean_setting +from fleetpings.utils import clean_setting # set default panels if none are set in local.py AA_FLEETPINGS_USE_SLACK = clean_setting("AA_FLEETPINGS_USE_SLACK", False) diff --git a/fleetpings/apps.py b/fleetpings/apps.py index 8ea0b456..502494fe 100644 --- a/fleetpings/apps.py +++ b/fleetpings/apps.py @@ -6,7 +6,7 @@ from django.apps import AppConfig -from . import __version__ +from fleetpings import __version__ class AaFleetpingsConfig(AppConfig): diff --git a/fleetpings/auth_hooks.py b/fleetpings/auth_hooks.py index f816df32..1bac18b5 100644 --- a/fleetpings/auth_hooks.py +++ b/fleetpings/auth_hooks.py @@ -6,11 +6,11 @@ from django.utils.translation import ugettext_lazy as _ +from fleetpings import urls, __title__ + from allianceauth.services.hooks import MenuItemHook, UrlHook from allianceauth import hooks -from . import urls, __title__ - class AaFleetpingsMenuItem(MenuItemHook): # pylint: disable=too-few-public-methods """ This class ensures only authorized users will see the menu entry """ diff --git a/fleetpings/form.py b/fleetpings/form.py index 065e5c84..b4b6fbba 100644 --- a/fleetpings/form.py +++ b/fleetpings/form.py @@ -5,6 +5,7 @@ """ from django.forms import ModelForm, TextInput + from fleetpings.models import FleetType diff --git a/fleetpings/urls.py b/fleetpings/urls.py index f4f181e7..7f2615c7 100644 --- a/fleetpings/urls.py +++ b/fleetpings/urls.py @@ -6,7 +6,7 @@ from django.urls import path -from . import views +from fleetpings import views app_name: str = "fleetpings" diff --git a/fleetpings/views.py b/fleetpings/views.py index 141fd291..0ae2edcc 100644 --- a/fleetpings/views.py +++ b/fleetpings/views.py @@ -17,9 +17,9 @@ from django.contrib.auth.decorators import login_required, permission_required from django.db.models import Q -from . import __title__ +from fleetpings import __title__ -from .app_settings import ( +from fleetpings.app_settings import ( AA_FLEETPINGS_USE_SLACK, AA_FLEETPINGS_USE_DOCTRINES_FROM_FITTINGS_MODULE, get_site_url, From 28c0caf496aa884607afa3c7aa8809986175fb9a Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Fri, 9 Oct 2020 18:49:40 +0200 Subject: [PATCH 02/12] [FIX] Parameters differ from overridden method warning --- fleetpings/models.py | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/fleetpings/models.py b/fleetpings/models.py index 7e153b5e..2a87a245 100644 --- a/fleetpings/models.py +++ b/fleetpings/models.py @@ -110,11 +110,9 @@ class FleetDoctrine(models.Model): help_text=_("Whether this doctrine is enabled or not"), ) - def clean(self, *args, **kwargs): + def clean(self): """ check if the doctrine link is an actual link to a website - :param args: - :param kwargs: """ doctrine_link = self.link @@ -129,7 +127,7 @@ def clean(self, *args, **kwargs): _("Your doctrine URL is not valid.") ) from exception - super().clean(*args, **kwargs) + super().clean() def __str__(self) -> str: return str(self.name) @@ -239,12 +237,10 @@ class DiscordPingTargets(models.Model): help_text=_("Whether this formup location is enabled or not"), ) - def clean(self, *args, **kwargs): + def clean(self): """ check if the group has already been synched to Discord, if not, raise an error - :param args: - :param kwargs: """ # check if the Discord service is active @@ -266,18 +262,16 @@ def clean(self, *args, **kwargs): _("This group has not been synched to Discord yet.") ) - super().clean(*args, **kwargs) + super().clean() - def save(self, *args, **kwargs): + def save(self): """ Add the Discord group ID and save the whole thing - :param args: - :param kwargs: """ discord_group_info = DiscordUser.objects.group_to_role(self.name) self.discord_id = discord_group_info["id"] - super().save(*args, **kwargs) # Call the "real" save() method. + super().save() # Call the "real" save() method. def __str__(self) -> str: return str(self.name) From b5822bb42cdcee770fe0592320a7d3086191b810 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Fri, 9 Oct 2020 18:50:31 +0200 Subject: [PATCH 03/12] clipboard.js removed Will be using the bundles version provided by AA --- .../fleetpings/libs/clipboard.js/2.0.6/clipboard.min.js | 7 ------- 1 file changed, 7 deletions(-) delete mode 100644 fleetpings/static/fleetpings/libs/clipboard.js/2.0.6/clipboard.min.js diff --git a/fleetpings/static/fleetpings/libs/clipboard.js/2.0.6/clipboard.min.js b/fleetpings/static/fleetpings/libs/clipboard.js/2.0.6/clipboard.min.js deleted file mode 100644 index b9ed143b..00000000 --- a/fleetpings/static/fleetpings/libs/clipboard.js/2.0.6/clipboard.min.js +++ /dev/null @@ -1,7 +0,0 @@ -/*! - * clipboard.js v2.0.6 - * https://clipboardjs.com/ - * - * Licensed MIT © Zeno Rocha - */ -!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return o={},r.m=n=[function(t,e){t.exports=function(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var o=window.getSelection(),r=document.createRange();r.selectNodeContents(t),o.removeAllRanges(),o.addRange(r),e=o.toString()}return e}},function(t,e){function n(){}n.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){var o=this;function r(){o.off(t,r),e.apply(n,arguments)}return r._=e,this.on(t,r,n)},emit:function(t){for(var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,r=n.length;o Date: Fri, 9 Oct 2020 18:50:43 +0200 Subject: [PATCH 04/12] changelog updated --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 016083d1..6886b920 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ so have your Auth updated before installing this version. ### Fixed - mySQL text fields can't have default values +- Parameters differ from overridden method warning ### Added @@ -27,7 +28,7 @@ so have your Auth updated before installing this version. - Use clipboard.js bundled with Alliance Auth - Minimum required Alliance Auth version set to 2.8.0 due to us using clipboard.js bundled with Alliance Auth -- Unused lib removed from templates +- Unused lib removed ## [2.2.2] - 2020-09-23 From 7e6f3bb493aa84c24f337b37f1067732a2124283 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Mon, 12 Oct 2020 10:40:19 +0200 Subject: [PATCH 05/12] v2.3.0-alpha.2 Added: - Compatibility to AA Timezones (v1.2.1) new link style - Backwards compatibility to versions of AA Timezones before 1.2.1, so the old link style is still generated when using an older version --- .gitignore | 1 + CHANGELOG.md | 2 + fleetpings/__init__.py | 2 +- fleetpings/app_settings.py | 40 ++++++++++++++++++- fleetpings/static/fleetpings/js/fleetpings.js | 6 ++- .../static/fleetpings/js/fleetpings.min.js | 2 +- fleetpings/templates/fleetpings/form.html | 1 + fleetpings/views.py | 2 + 8 files changed, 52 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 91906ed8..6be7264d 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ __pycache__ fleetpings/static/fleetpings/js/fleetpings.dev.js +fleetpings/static/fleetpings/js/fleetpings.dev.min.js diff --git a/CHANGELOG.md b/CHANGELOG.md index 6886b920..39230d30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,6 +23,8 @@ so have your Auth updated before installing this version. - Filter to the admin backend - More checks for Discord. Now checking if the Discord Service s actually activated and setup properly +- Compatibility to AA Timezones (v1.2.1) new link style +- Backwards compatibility to versions of AA Timezones before 1.2.1, so the old link style is still generated when using an older version ### Changed diff --git a/fleetpings/__init__.py b/fleetpings/__init__.py index 9f4369b8..24b41fa9 100644 --- a/fleetpings/__init__.py +++ b/fleetpings/__init__.py @@ -6,5 +6,5 @@ default_app_config: str = "fleetpings.apps.AaFleetpingsConfig" -__version__ = "2.3.0a1" +__version__ = "2.3.0-alpha.2" __title__ = "Fleet Pings" diff --git a/fleetpings/app_settings.py b/fleetpings/app_settings.py index 890c9fd2..a6b8dd27 100644 --- a/fleetpings/app_settings.py +++ b/fleetpings/app_settings.py @@ -10,6 +10,8 @@ from fleetpings.utils import clean_setting +from packaging import version + # set default panels if none are set in local.py AA_FLEETPINGS_USE_SLACK = clean_setting("AA_FLEETPINGS_USE_SLACK", False) AA_FLEETPINGS_USE_DOCTRINES_FROM_FITTINGS_MODULE = clean_setting( @@ -25,6 +27,7 @@ def get_site_url(): # regex sso url get the site url :return: string """ + regex = r"^(.+)\/s.+" matches = re.finditer(regex, settings.ESI_SSO_CALLBACK_URL, re.MULTILINE) url = "http://" @@ -40,14 +43,47 @@ def timezones_installed() -> bool: check if aa-timezones is installed :return: bool """ + return "timezones" in settings.INSTALLED_APPS +def get_timzones_version(): + """ + get the version of aa-timezones, when installed + :return: string or None + """ + + if timezones_installed(): + from timezones import __version__ as timezones_version + + return timezones_version + + return None + + +def use_new_timezone_links() -> bool: + """ + determins whether to use then new link format from aa-timezones or not + the new link format has been introduced with aa-timezones v1.2.1 + :return: bool + """ + + return_value = True + + if get_timzones_version() and version.parse(get_timzones_version()) < version.parse( + "1.2.1" + ): + return_value = False + + return return_value + + def fittings_installed() -> bool: """ check if fittings is installed :return: bool """ + return "fittings" in settings.INSTALLED_APPS @@ -56,12 +92,14 @@ def avoid_cdn() -> bool: check if we should aviod CDN usage :return: bool """ + return AVOID_CDN def discord_service_installed() -> bool: """ check if the Discord service is installed - :return: + :return: bool """ + return "allianceauth.services.modules.discord" in settings.INSTALLED_APPS diff --git a/fleetpings/static/fleetpings/js/fleetpings.js b/fleetpings/static/fleetpings/js/fleetpings.js index 463cbd51..ebb2c3a0 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.js +++ b/fleetpings/static/fleetpings/js/fleetpings.js @@ -156,7 +156,11 @@ jQuery(document).ready(function($) { var formupDateTime = new Date(formupTime) var formupTimestamp = (formupDateTime.getTime() - formupDateTime.getTimezoneOffset() *60 * 1000) / 1000; - var timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/?#' + formupTimestamp; + if(fleetpingsSettings.useNewTimezoneLinks === true) { + var timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/' + formupTimestamp + '/'; + } else { + var timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/?#' + formupTimestamp; + } return timezonesUrl; }; diff --git a/fleetpings/static/fleetpings/js/fleetpings.min.js b/fleetpings/static/fleetpings/js/fleetpings.min.js index 3ecf2f00..8d331844 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.min.js +++ b/fleetpings/static/fleetpings/js/fleetpings.min.js @@ -1 +1 @@ -jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp;return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file +jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;if(fleetpingsSettings.useNewTimezoneLinks===true){var timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{var timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file diff --git a/fleetpings/templates/fleetpings/form.html b/fleetpings/templates/fleetpings/form.html index 10bae378..b09e524e 100644 --- a/fleetpings/templates/fleetpings/form.html +++ b/fleetpings/templates/fleetpings/form.html @@ -49,6 +49,7 @@ var fleetpingsSettings = { platformUsed: '{{ platformUsed }}', timezonesInstalled: {{ timezones_installed|yesno:"true,false" }}, + useNewTimezoneLinks: {{ use_new_timezone_links|yesno:"true,false" }}, siteUrl: '{{ site_url }}/', pingCreator: '{{ mainCharacter|safe|addslashes }}' }; diff --git a/fleetpings/views.py b/fleetpings/views.py index 0ae2edcc..d642583c 100644 --- a/fleetpings/views.py +++ b/fleetpings/views.py @@ -24,6 +24,7 @@ AA_FLEETPINGS_USE_DOCTRINES_FROM_FITTINGS_MODULE, get_site_url, timezones_installed, + use_new_timezone_links, fittings_installed, avoid_cdn, ) @@ -120,6 +121,7 @@ def index(request): "fleetFormupLocations": formup_locations, "site_url": get_site_url(), "timezones_installed": timezones_installed(), + "use_new_timezone_links": use_new_timezone_links(), "fittings_installed": fittings_installed(), "mainCharacter": request.user.profile.main_character, "platformUsed": platform_used, From 76aa929e93e5e3dcb5da465a1cbeb4e890cc0755 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Mon, 12 Oct 2020 10:44:36 +0200 Subject: [PATCH 06/12] [FIX] 'timezonesUrl' used outside of binding context --- fleetpings/static/fleetpings/js/fleetpings.js | 5 +++-- fleetpings/static/fleetpings/js/fleetpings.min.js | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/fleetpings/static/fleetpings/js/fleetpings.js b/fleetpings/static/fleetpings/js/fleetpings.js index ebb2c3a0..ab6f5da9 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.js +++ b/fleetpings/static/fleetpings/js/fleetpings.js @@ -155,11 +155,12 @@ jQuery(document).ready(function($) { var getTimezonesUrl = function(formupTime) { var formupDateTime = new Date(formupTime) var formupTimestamp = (formupDateTime.getTime() - formupDateTime.getTimezoneOffset() *60 * 1000) / 1000; + var timezonesUrl = ''; if(fleetpingsSettings.useNewTimezoneLinks === true) { - var timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/' + formupTimestamp + '/'; + timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/' + formupTimestamp + '/'; } else { - var timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/?#' + formupTimestamp; + timezonesUrl = fleetpingsSettings.siteUrl + 'timezones/?#' + formupTimestamp; } return timezonesUrl; diff --git a/fleetpings/static/fleetpings/js/fleetpings.min.js b/fleetpings/static/fleetpings/js/fleetpings.min.js index 8d331844..43d700c4 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.min.js +++ b/fleetpings/static/fleetpings/js/fleetpings.min.js @@ -1 +1 @@ -jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;if(fleetpingsSettings.useNewTimezoneLinks===true){var timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{var timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file +jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl="";if(fleetpingsSettings.useNewTimezoneLinks===true){timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file From b0b3f93a19ccf80d6329da7fe5d7fff0d9cec15f Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Mon, 12 Oct 2020 10:58:02 +0200 Subject: [PATCH 07/12] [FIX] 'selectedLink' is not defined --- fleetpings/static/fleetpings/js/fleetpings.js | 2 +- fleetpings/static/fleetpings/js/fleetpings.min.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/fleetpings/static/fleetpings/js/fleetpings.js b/fleetpings/static/fleetpings/js/fleetpings.js index ab6f5da9..c6b34611 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.js +++ b/fleetpings/static/fleetpings/js/fleetpings.js @@ -191,7 +191,7 @@ jQuery(document).ready(function($) { // let's see if we can find a doctrine link var fleetDoctrineLink = null; if(fleetDoctrine !== '') { - selectedLink = $('#fleetDoctrineList [value="' + fleetDoctrine + '"]').data('doctrine-url'); + var selectedLink = $('#fleetDoctrineList [value="' + fleetDoctrine + '"]').data('doctrine-url'); if(undefined !== selectedLink && selectedLink !== '') { // Houston, we have a link! diff --git a/fleetpings/static/fleetpings/js/fleetpings.min.js b/fleetpings/static/fleetpings/js/fleetpings.min.js index 43d700c4..9fddcc6a 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.min.js +++ b/fleetpings/static/fleetpings/js/fleetpings.min.js @@ -1 +1 @@ -jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl="";if(fleetpingsSettings.useNewTimezoneLinks===true){timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file +jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl="";if(fleetpingsSettings.useNewTimezoneLinks===true){timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){var selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file From 3bb15be446a9806ba7f81e9539c056020dcc83fc Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Mon, 12 Oct 2020 10:59:39 +0200 Subject: [PATCH 08/12] [FIX] 'webhookPingTarget' is not defined --- fleetpings/static/fleetpings/js/fleetpings.js | 1 + fleetpings/static/fleetpings/js/fleetpings.min.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fleetpings/static/fleetpings/js/fleetpings.js b/fleetpings/static/fleetpings/js/fleetpings.js index c6b34611..1bfa6007 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.js +++ b/fleetpings/static/fleetpings/js/fleetpings.js @@ -221,6 +221,7 @@ jQuery(document).ready(function($) { } // determine pingTarget + var webhookPingTarget = ''; if(pingTarget.indexOf('@') > -1) { webhookPingTarget = pingTarget; } else { diff --git a/fleetpings/static/fleetpings/js/fleetpings.min.js b/fleetpings/static/fleetpings/js/fleetpings.min.js index 9fddcc6a..50a99f5a 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.min.js +++ b/fleetpings/static/fleetpings/js/fleetpings.min.js @@ -1 +1 @@ -jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl="";if(fleetpingsSettings.useNewTimezoneLinks===true){timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){var selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file +jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl="";if(fleetpingsSettings.useNewTimezoneLinks===true){timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){var selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}var webhookPingTarget="";if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file From 4af3c3e961fd9b27b915d5699e4eb39700aa3c2e Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Mon, 12 Oct 2020 11:02:05 +0200 Subject: [PATCH 09/12] [FIX] 'discordPingTarget' is not defined --- fleetpings/static/fleetpings/js/fleetpings.js | 1 + fleetpings/static/fleetpings/js/fleetpings.min.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/fleetpings/static/fleetpings/js/fleetpings.js b/fleetpings/static/fleetpings/js/fleetpings.js index 1bfa6007..6ba46788 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.js +++ b/fleetpings/static/fleetpings/js/fleetpings.js @@ -214,6 +214,7 @@ jQuery(document).ready(function($) { var pingText = ''; // determine pingTargetText + var discordPingTarget = ''; if(pingTargetText.indexOf('@') > -1) { discordPingTarget = pingTargetText; } else { diff --git a/fleetpings/static/fleetpings/js/fleetpings.min.js b/fleetpings/static/fleetpings/js/fleetpings.min.js index 50a99f5a..f5a70211 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.min.js +++ b/fleetpings/static/fleetpings/js/fleetpings.min.js @@ -1 +1 @@ -jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl="";if(fleetpingsSettings.useNewTimezoneLinks===true){timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){var selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}var webhookPingTarget="";if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file +jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl="";if(fleetpingsSettings.useNewTimezoneLinks===true){timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){var selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";var discordPingTarget="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}var webhookPingTarget="";if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file From 84107043b535d49a40f35b6d01fd8f7aedf98f81 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Mon, 12 Oct 2020 11:09:12 +0200 Subject: [PATCH 10/12] [FIX] Strings must use singlequote --- fleetpings/static/fleetpings/js/fleetpings.js | 44 +++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/fleetpings/static/fleetpings/js/fleetpings.js b/fleetpings/static/fleetpings/js/fleetpings.js index 6ba46788..42a5a3ad 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.js +++ b/fleetpings/static/fleetpings/js/fleetpings.js @@ -257,34 +257,34 @@ jQuery(document).ready(function($) { webhookPingTextHeader += 'Fleet is up'; } - pingText += '**' + "\n"; + pingText += '**' + '\n'; // check if FC name is available if(fcName !== '') { - pingText += "\n" + '**FC:** ' + fcName; - webhookPingTextContent += "\n" + '**FC:** ' + fcName; + pingText += '\n' + '**FC:** ' + fcName; + webhookPingTextContent += '\n' + '**FC:** ' + fcName; } // check if fleet name is available if(fleetName !== '') { - pingText += "\n" + '**Fleet Name:** ' + fleetName; - webhookPingTextContent += "\n" + '**Fleet Name:** ' + fleetName; + pingText += '\n' + '**Fleet Name:** ' + fleetName; + webhookPingTextContent += '\n' + '**Fleet Name:** ' + fleetName; } // check if form-up location is available if(formupLocation !== '') { - pingText += "\n" + '**Formup Location:** ' + formupLocation; - webhookPingTextContent += "\n" + '**Formup Location:** ' + formupLocation; + pingText += '\n' + '**Formup Location:** ' + formupLocation; + webhookPingTextContent += '\n' + '**Formup Location:** ' + formupLocation; } // check if form-up time is available if($('input#formupTimeNow').is(':checked')) { - pingText += "\n" + '**Formup Time:** NOW'; - webhookPingTextContent += "\n" + '**Formup Time:** NOW'; + pingText += '\n' + '**Formup Time:** NOW'; + webhookPingTextContent += '\n' + '**Formup Time:** NOW'; } else { if(formupTime !== '') { - pingText += "\n" + '**Formup Time:** ' + formupTime; - webhookPingTextContent += "\n" + '**Formup Time:** ' + formupTime; + pingText += '\n' + '**Formup Time:** ' + formupTime; + webhookPingTextContent += '\n' + '**Formup Time:** ' + formupTime; // get the timestamp and build the link to the timezones module if it's installed if(fleetpingsSettings.timezonesInstalled === true) { @@ -305,14 +305,14 @@ jQuery(document).ready(function($) { // check if fleet comms is available if(fleetComms !== '') { - pingText += "\n" + '**Comms:** ' + fleetComms; - webhookPingTextContent += "\n" + '**Comms:** ' + fleetComms; + pingText += '\n' + '**Comms:** ' + fleetComms; + webhookPingTextContent += '\n' + '**Comms:** ' + fleetComms; } // check if doctrine is available if(fleetDoctrine !== '') { - pingText += "\n" + '**Ships / Doctrine:** ' + fleetDoctrine; - webhookPingTextContent += "\n" + '**Ships / Doctrine:** ' + fleetDoctrine; + pingText += '\n' + '**Ships / Doctrine:** ' + fleetDoctrine; + webhookPingTextContent += '\n' + '**Ships / Doctrine:** ' + fleetDoctrine; // grab the doctrine link if there is one if(fleetDoctrineLink !== null) { @@ -330,14 +330,14 @@ jQuery(document).ready(function($) { // check if srp is available if(fleetSrp !== '') { - pingText += "\n" + '**SRP:** ' + fleetSrp; - webhookPingTextContent += "\n" + '**SRP:** ' + fleetSrp; + pingText += '\n' + '**SRP:** ' + fleetSrp; + webhookPingTextContent += '\n' + '**SRP:** ' + fleetSrp; } // check if additional information is available if(additionalInformation !== '') { - pingText += "\n\n" + '**Additional Information**:' + "\n" + additionalInformation; - webhookPingTextContent += "\n\n" + '**Additional Information**:' + "\n" + additionalInformation; + pingText += '\n\n' + '**Additional Information**:' + '\n' + additionalInformation; + webhookPingTextContent += '\n\n' + '**Additional Information**:' + '\n' + additionalInformation; } if(fleetpingsSettings.platformUsed === 'Discord') { @@ -352,7 +352,7 @@ jQuery(document).ready(function($) { if(webhookUrl !== false && webhookUrl !== '') { // add ping creator at the end if(fleetpingsSettings.pingCreator !== '') { - pingText += "\n\n" + '*(Ping sent by: ' + fleetpingsSettings.pingCreator + ')*'; + pingText += '\n\n' + '*(Ping sent by: ' + fleetpingsSettings.pingCreator + ')*'; webhookPingTextFooter = '(Ping sent by: ' + fleetpingsSettings.pingCreator + ')'; } @@ -375,7 +375,7 @@ jQuery(document).ready(function($) { if(undefined !== webhookEmbedPing && webhookEmbedPing === 'True') { sendEmbeddedDiscordPing( webhookUrl, - webhookPingTarget + ' :: **' + webhookPingTextHeader + '**' + "\n" + '** **', + webhookPingTarget + ' :: **' + webhookPingTextHeader + '**' + '\n' + '** **', // embedded content » https://discohook.org/ - https://leovoel.github.io/embed-visualizer/ { 'title': '**.: Fleet Details :.**', @@ -406,7 +406,7 @@ jQuery(document).ready(function($) { 'fallback': pingText, 'color': embedColor, 'pretext': '<' + slackEmbedPingTarget + '>' + ' :: *' + webhookPingTextHeader + '*', - 'text': '*.: Fleet Details :.*' + "\n" + webhookPingTextContent.split('**').join('*'), + 'text': '*.: Fleet Details :.*' + '\n' + webhookPingTextContent.split('**').join('*'), 'footer': webhookPingTextFooter, // 'footer_icon': 'https://platform.slack-edge.com/img/default_application_icon.png' } From 5236bda4756fb83b7ac3c093d02eeead84aa43e7 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Mon, 12 Oct 2020 11:12:32 +0200 Subject: [PATCH 11/12] [FIX] function names need to start with lowercase letter --- fleetpings/static/fleetpings/js/fleetpings.js | 8 ++++---- fleetpings/static/fleetpings/js/fleetpings.min.js | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/fleetpings/static/fleetpings/js/fleetpings.js b/fleetpings/static/fleetpings/js/fleetpings.js index 42a5a3ad..941fa0e8 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.js +++ b/fleetpings/static/fleetpings/js/fleetpings.js @@ -1,4 +1,4 @@ -/* global fleetpingsSettings, fleetpingsTranslations */ +/* global fleetpingsSettings, fleetpingsTranslations, ClipboardJS */ jQuery(document).ready(function($) { /* Functions @@ -153,7 +153,7 @@ jQuery(document).ready(function($) { * @param {string} formupTime */ var getTimezonesUrl = function(formupTime) { - var formupDateTime = new Date(formupTime) + var formupDateTime = new Date(formupTime); var formupTimestamp = (formupDateTime.getTime() - formupDateTime.getTimezoneOffset() *60 * 1000) / 1000; var timezonesUrl = ''; @@ -427,7 +427,7 @@ jQuery(document).ready(function($) { /** * copy the fleet ping to clipboard */ - var CopyFleetPing = function() { + var copyFleetPing = function() { /** * copy text to clipboard * @@ -505,6 +505,6 @@ jQuery(document).ready(function($) { * copy ping text */ $('button#copyFleetPing').on('click', function() { - CopyFleetPing(); + copyFleetPing(); }); }); diff --git a/fleetpings/static/fleetpings/js/fleetpings.min.js b/fleetpings/static/fleetpings/js/fleetpings.min.js index f5a70211..25d5a3c1 100644 --- a/fleetpings/static/fleetpings/js/fleetpings.min.js +++ b/fleetpings/static/fleetpings/js/fleetpings.min.js @@ -1 +1 @@ -jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl="";if(fleetpingsSettings.useNewTimezoneLinks===true){timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){var selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";var discordPingTarget="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}var webhookPingTarget="";if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var CopyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){CopyFleetPing()})}); \ No newline at end of file +jQuery(document).ready(function($){var nl2br=function(string,isXhtml){var breakTag=isXhtml||typeof isXhtml==="undefined"?"
":"
";return(string+"").replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g,"$1"+breakTag+"$2")};var closeCopyMessageElement=function(element){$(element).fadeTo(1e4,500).slideUp(500,function(){$(this).slideUp(500,function(){$(this).remove()})})};var showSuccess=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-success");return};var showError=function(message,element){$(element).html('
'+message+"
");closeCopyMessageElement(".alert-copy-error");return};var sanitizeInput=function(input){if(input){return input.replace(/<(|\/|[^>\/bi]|\/[^>bi]|[^\/>][^>]+|\/[^>][^>]+)>/g,"")}else{return input}};var sendEmbeddedDiscordPing=function(webhookUrl,content,embeds){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:content,embeds:[embeds]};request.send(JSON.stringify(params))};var sendDiscordPing=function(webhookUrl,pingText){var request=new XMLHttpRequest;request.open("POST",webhookUrl);request.setRequestHeader("Content-type","application/json");var params={username:"",avatar_url:"",content:pingText};request.send(JSON.stringify(params))};var sendSlackPing=function(webhookUrl,payload){$.ajax({data:"payload="+JSON.stringify(payload),dataType:"json",processData:false,type:"POST",url:webhookUrl})};var hexToDecimal=function(hexValue){return parseInt(hexValue.replace("#",""),16)};var getTimezonesUrl=function(formupTime){var formupDateTime=new Date(formupTime);var formupTimestamp=(formupDateTime.getTime()-formupDateTime.getTimezoneOffset()*60*1e3)/1e3;var timezonesUrl="";if(fleetpingsSettings.useNewTimezoneLinks===true){timezonesUrl=fleetpingsSettings.siteUrl+"timezones/"+formupTimestamp+"/"}else{timezonesUrl=fleetpingsSettings.siteUrl+"timezones/?#"+formupTimestamp}return timezonesUrl};var generateFleetPing=function(){var pingTarget=sanitizeInput($("select#pingTarget option:selected").val());var pingTargetText=sanitizeInput($("select#pingTarget option:selected").text());var webhookType=sanitizeInput($("select#pingChannel option:selected").data("webhook-type"));var webhookEmbedPing=sanitizeInput($("select#pingChannel option:selected").data("webhook-embed"));var fleetType=sanitizeInput($("select#fleetType option:selected").val());var webhookEmbedColor=sanitizeInput($("select#fleetType option:selected").data("embed-color"));var fcName=sanitizeInput($("input#fcName").val());var fleetName=sanitizeInput($("input#fleetName").val());var formupLocation=sanitizeInput($("input#formupLocation").val());var formupTime=sanitizeInput($("input#formupTime").val());var fleetComms=sanitizeInput($("input#fleetComms").val());var fleetDoctrine=sanitizeInput($("input#fleetDoctrine").val());var fleetSrp=sanitizeInput($("select#fleetSrp option:selected").val());var additionalInformation=sanitizeInput($("textarea#additionalInformation").val());var fleetDoctrineLink=null;if(fleetDoctrine!==""){var selectedLink=$('#fleetDoctrineList [value="'+fleetDoctrine+'"]').data("doctrine-url");if(undefined!==selectedLink&&selectedLink!==""){fleetDoctrineLink=selectedLink}}var webhookUrl=false;if($("select#pingChannel").length){webhookUrl=sanitizeInput($("select#pingChannel option:selected").val())}$(".aa-fleetpings-ping").show();var webhookPingTextHeader="";var webhookPingTextContent="";var webhookPingTextFooter="";var pingText="";var discordPingTarget="";if(pingTargetText.indexOf("@")>-1){discordPingTarget=pingTargetText}else{discordPingTarget="@"+pingTargetText}var webhookPingTarget="";if(pingTarget.indexOf("@")>-1){webhookPingTarget=pingTarget}else{webhookPingTarget="<@&"+pingTarget+">"}pingText+=" :: ";pingText+="**";if($("input#prePing").is(":checked")){pingText+="### PRE PING ###";webhookPingTextHeader+="### PRE PING ###";if(fleetType!==""){pingText+=" / "+fleetType+" Fleet";webhookPingTextHeader+=" / "+fleetType+" Fleet"}else{pingText+=" / Fleet";webhookPingTextHeader+=" / Fleet"}}else{if(fleetType!==""){pingText+=fleetType+" ";webhookPingTextHeader+=fleetType+" "}pingText+="Fleet is up";webhookPingTextHeader+="Fleet is up"}pingText+="**"+"\n";if(fcName!==""){pingText+="\n"+"**FC:** "+fcName;webhookPingTextContent+="\n"+"**FC:** "+fcName}if(fleetName!==""){pingText+="\n"+"**Fleet Name:** "+fleetName;webhookPingTextContent+="\n"+"**Fleet Name:** "+fleetName}if(formupLocation!==""){pingText+="\n"+"**Formup Location:** "+formupLocation;webhookPingTextContent+="\n"+"**Formup Location:** "+formupLocation}if($("input#formupTimeNow").is(":checked")){pingText+="\n"+"**Formup Time:** NOW";webhookPingTextContent+="\n"+"**Formup Time:** NOW"}else{if(formupTime!==""){pingText+="\n"+"**Formup Time:** "+formupTime;webhookPingTextContent+="\n"+"**Formup Time:** "+formupTime;if(fleetpingsSettings.timezonesInstalled===true){var timezonesUrl=getTimezonesUrl(formupTime);pingText+=" - "+timezonesUrl;if(webhookType==="Discord"){webhookPingTextContent+=" ([Time Zone Conversion]("+timezonesUrl+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+timezonesUrl+"|Time Zone Conversion>)"}}}}if(fleetComms!==""){pingText+="\n"+"**Comms:** "+fleetComms;webhookPingTextContent+="\n"+"**Comms:** "+fleetComms}if(fleetDoctrine!==""){pingText+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;webhookPingTextContent+="\n"+"**Ships / Doctrine:** "+fleetDoctrine;if(fleetDoctrineLink!==null){pingText+=" - "+fleetDoctrineLink;if(webhookType==="Discord"){webhookPingTextContent+=" ([Doctrine Link]("+fleetDoctrineLink+"))"}if(webhookType==="Slack"){webhookPingTextContent+=" (<"+fleetDoctrineLink+"|Doctrine Link>)"}}}if(fleetSrp!==""){pingText+="\n"+"**SRP:** "+fleetSrp;webhookPingTextContent+="\n"+"**SRP:** "+fleetSrp}if(additionalInformation!==""){pingText+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation;webhookPingTextContent+="\n\n"+"**Additional Information**:"+"\n"+additionalInformation}if(fleetpingsSettings.platformUsed==="Discord"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText)+"

")}if(fleetpingsSettings.platformUsed==="Slack"){$(".aa-fleetpings-ping-text").html("

"+nl2br(discordPingTarget+pingText.split("**").join("*"))+"

")}if(webhookUrl!==false&&webhookUrl!==""){if(fleetpingsSettings.pingCreator!==""){pingText+="\n\n"+"*(Ping sent by: "+fleetpingsSettings.pingCreator+")*";webhookPingTextFooter="(Ping sent by: "+fleetpingsSettings.pingCreator+")"}var embedColor="#faa61a";if(fleetType!==""&&embedColor!==""){embedColor=webhookEmbedColor}if(fcName!==""){webhookPingTextHeader+=" under "+fcName}var copyPasteText="";if(webhookType==="Discord"){if(undefined!==webhookEmbedPing&&webhookEmbedPing==="True"){sendEmbeddedDiscordPing(webhookUrl,webhookPingTarget+" :: **"+webhookPingTextHeader+"**"+"\n"+"** **",{title:"**.: Fleet Details :.**",description:webhookPingTextContent,color:hexToDecimal(embedColor),footer:{text:webhookPingTextFooter}})}else{sendDiscordPing(webhookUrl,webhookPingTarget+pingText)}}if(webhookType==="Slack"){var slackEmbedPingTarget=webhookPingTarget.replace("@","!");var payload={attachments:[{fallback:pingText,color:embedColor,pretext:"<"+slackEmbedPingTarget+">"+" :: *"+webhookPingTextHeader+"*",text:"*.: Fleet Details :.*"+"\n"+webhookPingTextContent.split("**").join("*"),footer:webhookPingTextFooter}]};sendSlackPing(webhookUrl,payload)}showSuccess(fleetpingsTranslations.ping.success,".aa-fleetpings-ping-copyresult")}};var copyFleetPing=function(){var clipboardFleetPingData=new ClipboardJS("button#copyFleetPing");clipboardFleetPingData.on("success",function(e){showSuccess(fleetpingsTranslations.copyToClipboard.success,".aa-fleetpings-ping-copyresult");e.clearSelection();clipboardFleetPingData.destroy()});clipboardFleetPingData.on("error",function(){showError(fleetpingsTranslations.copyToClipboard.error,".aa-fleetpings-ping-copyresult");clipboardFleetPingData.destroy()})};$("#prePing").on("change",function(){if($("input#prePing").is(":checked")){$("#formupTimeNow").removeAttr("checked");$("#formupTimeNow").prop("disabled",true);$("#formupTime").removeAttr("disabled")}else{$("#formupTimeNow").prop("checked",true);$("#formupTimeNow").removeAttr("disabled");$("#formupTime").prop("disabled",true)}});$("#formupTimeNow").on("change",function(){if($("input#formupTimeNow").is(":checked")){$("#formupTime").prop("disabled",true)}else{$("#formupTime").removeAttr("disabled");$("#prePing").prop("checked",true)}});$("button#createPingText").on("click",function(){generateFleetPing()});$("button#copyFleetPing").on("click",function(){copyFleetPing()})}); \ No newline at end of file From 125c7c971f781776892a20ca7d5b064525511e42 Mon Sep 17 00:00:00 2001 From: Peter Pfeufer Date: Sat, 24 Oct 2020 01:10:41 +0200 Subject: [PATCH 12/12] pushing v2.3.0 --- CHANGELOG.md | 2 +- fleetpings/__init__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39230d30..a9e1017b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). -## [2.3.0] - xxxx-xx-xx +## [2.3.0] - 2020-10-14 ### Important! diff --git a/fleetpings/__init__.py b/fleetpings/__init__.py index 24b41fa9..86bc019b 100644 --- a/fleetpings/__init__.py +++ b/fleetpings/__init__.py @@ -6,5 +6,5 @@ default_app_config: str = "fleetpings.apps.AaFleetpingsConfig" -__version__ = "2.3.0-alpha.2" +__version__ = "2.3.0" __title__ = "Fleet Pings"