2021-04-02 15:59:29 +02:00
/ * *
* @ name EditRoles
* @ author DevilBro
* @ authorId 278543574059057154
2024-03-15 14:52:38 +01:00
* @ version 1.1 . 9
2021-04-02 15:59:29 +02:00
* @ description Allows you to locally edit Roles
* @ invite Jx3TjNS
* @ donate https : //www.paypal.me/MircoWittrien
* @ patreon https : //www.patreon.com/MircoWittrien
* @ website https : //mwittrien.github.io/
* @ source https : //github.com/mwittrien/BetterDiscordAddons/tree/master/Plugins/EditRoles/
* @ updateUrl https : //mwittrien.github.io/BetterDiscordAddons/Plugins/EditRoles/EditRoles.plugin.js
* /
module . exports = ( _ => {
2022-09-01 14:40:11 +02:00
const changeLog = {
2022-09-02 12:37:10 +02:00
2021-04-02 15:59:29 +02:00
} ;
2022-02-05 21:14:17 +01:00
return ! window . BDFDB _Global || ( ! window . BDFDB _Global . loaded && ! window . BDFDB _Global . started ) ? class {
2022-09-01 14:55:22 +02:00
constructor ( meta ) { for ( let key in meta ) this [ key ] = meta [ key ] ; }
getName ( ) { return this . name ; }
getAuthor ( ) { return this . author ; }
getVersion ( ) { return this . version ; }
getDescription ( ) { return ` The Library Plugin needed for ${ this . name } is missing. Open the Plugin Settings to download it. \n \n ${ this . description } ` ; }
2021-04-02 15:59:29 +02:00
downloadLibrary ( ) {
2023-11-18 18:31:04 +01:00
BdApi . Net . fetch ( "https://mwittrien.github.io/BetterDiscordAddons/Library/0BDFDB.plugin.js" ) . then ( r => {
if ( ! r || r . status != 200 ) throw new Error ( ) ;
else return r . text ( ) ;
} ) . then ( b => {
if ( ! b ) throw new Error ( ) ;
else return require ( "fs" ) . writeFile ( require ( "path" ) . join ( BdApi . Plugins . folder , "0BDFDB.plugin.js" ) , b , _ => BdApi . showToast ( "Finished downloading BDFDB Library" , { type : "success" } ) ) ;
} ) . catch ( error => {
BdApi . alert ( "Error" , "Could not download BDFDB Library Plugin. Try again later or download it manually from GitHub: https://mwittrien.github.io/downloader/?library" ) ;
2021-04-02 15:59:29 +02:00
} ) ;
}
load ( ) {
if ( ! window . BDFDB _Global || ! Array . isArray ( window . BDFDB _Global . pluginQueue ) ) window . BDFDB _Global = Object . assign ( { } , window . BDFDB _Global , { pluginQueue : [ ] } ) ;
if ( ! window . BDFDB _Global . downloadModal ) {
window . BDFDB _Global . downloadModal = true ;
2022-09-01 14:55:22 +02:00
BdApi . showConfirmationModal ( "Library Missing" , ` The Library Plugin needed for ${ this . name } is missing. Please click "Download Now" to install it. ` , {
2021-04-02 15:59:29 +02:00
confirmText : "Download Now" ,
cancelText : "Cancel" ,
onCancel : _ => { delete window . BDFDB _Global . downloadModal ; } ,
onConfirm : _ => {
delete window . BDFDB _Global . downloadModal ;
this . downloadLibrary ( ) ;
}
} ) ;
}
2022-09-01 14:55:22 +02:00
if ( ! window . BDFDB _Global . pluginQueue . includes ( this . name ) ) window . BDFDB _Global . pluginQueue . push ( this . name ) ;
2021-04-02 15:59:29 +02:00
}
start ( ) { this . load ( ) ; }
stop ( ) { }
getSettingsPanel ( ) {
let template = document . createElement ( "template" ) ;
2022-09-01 14:55:22 +02:00
template . innerHTML = ` <div style="color: var(--header-primary); font-size: 16px; font-weight: 300; white-space: pre; line-height: 22px;">The Library Plugin needed for ${ this . name } is missing. \n Please click <a style="font-weight: 500;">Download Now</a> to install it.</div> ` ;
2021-04-02 15:59:29 +02:00
template . content . firstElementChild . querySelector ( "a" ) . addEventListener ( "click" , this . downloadLibrary ) ;
return template . content . firstElementChild ;
}
} : ( ( [ Plugin , BDFDB ] ) => {
2024-03-11 20:24:50 +01:00
var changedRoles = { } ;
2021-04-02 15:59:29 +02:00
return class EditRoles extends Plugin {
onLoad ( ) {
2022-11-05 00:15:17 +01:00
this . modulePatches = {
before : [
"AutocompleteRoleResult" ,
"ChannelMembers" ,
"MemberListItem" ,
2024-03-11 20:24:50 +01:00
"MessageContent"
2022-11-05 00:15:17 +01:00
] ,
after : [
"RichRoleMention"
]
2021-04-02 15:59:29 +02:00
} ;
}
onStart ( ) {
2021-07-24 19:57:55 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryModules . PermissionRoleUtils , "getHighestRole" , { after : e => {
if ( e . returnValue && changedRoles [ e . returnValue . id ] ) {
let data = changedRoles [ e . returnValue . id ] ;
e . returnValue = Object . assign ( { } , e . returnValue , {
name : data . name || e . returnValue . name ,
color : data . color ? BDFDB . ColorUtils . convert ( data . color , "INT" ) : e . returnValue . color ,
colorString : data . color ? BDFDB . ColorUtils . convert ( data . color , "HEX" ) : e . returnValue . colorString
} ) ;
}
2021-04-02 15:59:29 +02:00
} } ) ;
2022-09-27 16:53:10 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryStores . GuildMemberStore , "getMember" , { after : e => {
2021-04-02 15:59:29 +02:00
if ( e . returnValue ) {
2022-09-27 14:48:10 +02:00
let guild = BDFDB . LibraryStores . GuildStore . getGuild ( e . methodArguments [ 0 ] ) ;
2021-04-02 15:59:29 +02:00
if ( guild ) {
2021-09-20 21:11:00 +02:00
let colorRole , iconRole ;
for ( let id of e . returnValue . roles ) {
2024-03-11 20:24:50 +01:00
let roles = guild . roles || BDFDB . LibraryStores . GuildStore . getRoles ( guild . id ) ;
if ( roles && [ id ] && ( roles [ id ] . colorString || changedRoles [ id ] && changedRoles [ id ] . color ) && ( ! colorRole || colorRole . position < roles [ id ] . position ) ) colorRole = roles [ id ] ;
if ( roles && roles [ id ] && ( roles [ id ] . icon || changedRoles [ id ] && changedRoles [ id ] . icon ) && ( ! iconRole || iconRole . position < roles [ id ] . position ) ) iconRole = roles [ id ] ;
2021-09-20 21:11:00 +02:00
}
let color = colorRole && changedRoles [ colorRole . id ] && changedRoles [ colorRole . id ] . color ;
if ( color ) e . returnValue = Object . assign ( { } , e . returnValue , { colorString : BDFDB . ColorUtils . convert ( color , "HEX" ) } ) ;
if ( iconRole && changedRoles [ iconRole . id ] && changedRoles [ iconRole . id ] . icon ) e . returnValue = Object . assign ( { } , e . returnValue , { iconRoleId : iconRole . id } ) ;
2021-04-02 15:59:29 +02:00
}
}
} } ) ;
2024-03-11 20:24:50 +01:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryStores . GuildStore , "getRoles" , { after : e => {
if ( e . returnValue ) {
let roles = Object . assign ( { } , e . returnValue ) ;
for ( let id in roles ) {
let data = changedRoles [ id ] ;
if ( data ) {
roles [ id ] = Object . assign ( { } , roles [ id ] , {
name : data . name || roles [ id ] . name ,
icon : data . icon || roles [ id ] . icon ,
color : data . color ? BDFDB . ColorUtils . convert ( data . color , "INT" ) : roles [ id ] . color ,
colorString : data . color ? BDFDB . ColorUtils . convert ( data . color , "HEX" ) : roles [ id ] . colorString
} ) ;
}
}
e . returnValue = roles ;
}
} } ) ;
2021-10-01 16:10:36 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryModules . RoleIconUtils , "getRoleIconData" , { after : e => {
2022-08-03 00:21:40 +02:00
if ( e . returnValue && e . methodArguments [ 0 ] . id && changedRoles [ e . methodArguments [ 0 ] . id ] ) {
if ( changedRoles [ e . methodArguments [ 0 ] . id ] . icon ) return { customIconSrc : changedRoles [ e . methodArguments [ 0 ] . id ] . icon } ;
else if ( changedRoles [ e . methodArguments [ 0 ] . id ] . removeIcon ) return { customIconSrc : null } ;
}
2021-09-20 21:11:00 +02:00
} } ) ;
2021-10-01 16:10:36 +02:00
BDFDB . PatchUtils . patch ( this , BDFDB . LibraryModules . RoleIconUtils , "canGuildUseRoleIcons" , { after : e => {
2024-03-11 20:24:50 +01:00
if ( e . returnValue !== false ) return e . returnValue ;
let roles = e . methodArguments [ 0 ] . roles || BDFDB . LibraryStores . GuildStore . getRoles ( e . methodArguments [ 0 ] . id ) ;
if ( Object . keys ( roles ) . some ( roleId => changedRoles [ roleId ] && changedRoles [ roleId ] . icon ) ) return true ;
2021-09-20 21:11:00 +02:00
} } ) ;
2021-04-02 15:59:29 +02:00
this . forceUpdateAll ( ) ;
}
onStop ( ) {
this . forceUpdateAll ( ) ;
}
getSettingsPanel ( collapseStates = { } ) {
let settingsPanel ;
return settingsPanel = BDFDB . PluginUtils . createSettingsPanel ( this , {
collapseStates : collapseStates ,
children : _ => {
let settingsItems = [ ] ;
settingsItems . push ( BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsItem , {
type : "Button" ,
color : BDFDB . LibraryComponents . Button . Colors . RED ,
label : "Reset all Roles" ,
onClick : _ => {
BDFDB . ModalUtils . confirm ( this , this . labels . confirm _resetall , _ => {
2021-09-20 21:11:00 +02:00
this . resetRoles ( ) ;
2021-04-02 15:59:29 +02:00
this . forceUpdateAll ( ) ;
} ) ;
} ,
children : BDFDB . LanguageUtils . LanguageStrings . RESET
} ) ) ;
return settingsItems . flat ( 10 ) ;
}
} ) ;
}
onSettingsClosed ( ) {
if ( this . SettingsUpdated ) {
delete this . SettingsUpdated ;
this . forceUpdateAll ( ) ;
}
}
forceUpdateAll ( ) {
changedRoles = BDFDB . DataUtils . load ( this , "roles" ) ;
BDFDB . PatchUtils . forceAllUpdates ( this ) ;
BDFDB . MessageUtils . rerenderAll ( ) ;
}
2021-04-09 18:51:46 +02:00
onUserContextMenu ( e ) {
2022-11-05 00:15:17 +01:00
let [ children , index ] = BDFDB . ContextMenuUtils . findItem ( e . returnvalue , { id : "roles" } ) ;
if ( index > - 1 && children [ index ] . props && BDFDB . ArrayUtils . is ( children [ index ] . props . children ) ) for ( let child of children [ index ] . props . children ) {
if ( child && child . props && typeof child . props . label == "function" && changedRoles [ child . props . id ] ) {
let data = changedRoles [ child . props . id ] ;
let renderLabel = child . props . label ;
child . props . label = BDFDB . TimeUtils . suppress ( ( ... args ) => {
let label = renderLabel ( ... args ) ;
if ( data . color && label . props . children [ 0 ] && label . props . children [ 0 ] . props ) label . props . children [ 0 ] . props . color = BDFDB . ColorUtils . convert ( data . color , "hex" ) ;
if ( data . name && label . props . children [ 1 ] && label . props . children [ 1 ] . props && label . props . children [ 1 ] . props . children ) label . props . children [ 1 ] . props . children = data . name ;
return label ;
} , "Error in renderLabel of UserRolesItems" , this ) ;
2021-04-09 18:51:46 +02:00
}
}
}
2021-04-02 15:59:29 +02:00
onDeveloperContextMenu ( e ) {
2023-06-06 08:48:41 +02:00
if ( e . instance . props . label != BDFDB . LanguageUtils . LanguageStrings . COPY _ID _ROLE ) return ;
2021-04-09 18:13:38 +02:00
let guild = this . getGuildFromRoleId ( e . instance . props . id ) ;
2021-04-02 15:59:29 +02:00
if ( guild ) e . returnvalue . props . children = [
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
children : BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
label : this . labels . context _localrolesettings ,
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "settings-submenu" ) ,
children : BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuGroup , {
children : [
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
label : this . labels . submenu _rolesettings ,
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "settings-change" ) ,
2024-03-11 20:24:50 +01:00
action : _ => this . openRoleSettingsModal ( ( guild . roles || BDFDB . LibraryStores . GuildStore . getRoles ( guild . id ) || [ ] ) [ e . instance . props . id ] )
2021-04-02 15:59:29 +02:00
} ) ,
BDFDB . ContextMenuUtils . createItem ( BDFDB . LibraryComponents . MenuItems . MenuItem , {
label : this . labels . submenu _resetsettings ,
id : BDFDB . ContextMenuUtils . createItemId ( this . name , "settings-reset" ) ,
2022-09-30 14:18:20 +02:00
color : BDFDB . DiscordConstants . MenuItemColors . DANGER ,
2021-04-02 15:59:29 +02:00
disabled : ! changedRoles [ e . instance . props . id ] ,
action : event => {
let remove = _ => {
2021-09-20 21:11:00 +02:00
this . resetRoles ( e . instance . props . id ) ;
2021-04-02 15:59:29 +02:00
this . forceUpdateAll ( true ) ;
} ;
if ( event . shiftKey ) remove ( ) ;
else BDFDB . ModalUtils . confirm ( this , this . labels . confirm _reset , remove ) ;
}
} )
]
} )
} )
} ) ,
e . returnvalue . props . children
] . flat ( 10 ) . filter ( n => n ) ;
}
2022-11-05 00:15:17 +01:00
processMessageContent ( e ) {
if ( ! BDFDB . ArrayUtils . is ( e . instance . props . content ) ) return ;
for ( let ele of e . instance . props . content ) if ( BDFDB . ReactUtils . isValidElement ( ele ) && ele . props && ele . props . type == "mention" && ele . props . roleId && changedRoles [ ele . props . roleId ] ) {
ele . props . roleColor = changedRoles [ ele . props . roleId ] . color ? BDFDB . ColorUtils . convert ( changedRoles [ ele . props . roleId ] . color , "int" ) : ele . props . roleColor ;
if ( changedRoles [ ele . props . roleId ] . name ) ele . props . children = [ "@" + changedRoles [ ele . props . roleId ] . name ] ;
2022-09-09 15:42:15 +02:00
}
}
2022-11-05 00:15:17 +01:00
processRichRoleMention ( e ) {
if ( ! e . instance . props . id || ! changedRoles [ e . instance . props . id ] ) return ;
e . returnvalue . props . color = changedRoles [ e . instance . props . id ] . color ? BDFDB . ColorUtils . convert ( changedRoles [ e . instance . props . id ] . color , "int" ) : e . returnvalue . props . color ;
2023-11-02 18:20:52 +01:00
e . returnvalue . props . children [ 2 ] = changedRoles [ e . instance . props . id ] . name || e . returnvalue . props . children [ 1 ] ;
2022-09-09 15:42:15 +02:00
}
processAutocompleteRoleResult ( e ) {
2022-11-05 00:15:17 +01:00
if ( ! e . instance . props . role || ! changedRoles [ e . instance . props . role . id ] ) return ;
e . instance . props . role = Object . assign ( { } , e . instance . props . role ) ;
e . instance . props . role . color = changedRoles [ e . instance . props . role . id ] . color ? BDFDB . ColorUtils . convert ( changedRoles [ e . instance . props . role . id ] . color , "int" ) : e . instance . props . role . color ;
e . instance . props . role . colorString = changedRoles [ e . instance . props . role . id ] . color ? BDFDB . ColorUtils . convert ( changedRoles [ e . instance . props . role . id ] . color , "hex" ) : e . instance . props . role . colorString ;
e . instance . props . role . name = changedRoles [ e . instance . props . role . id ] . name || e . instance . props . role . name ;
2022-09-09 15:42:15 +02:00
}
2021-04-02 17:45:55 +02:00
processChannelMembers ( e ) {
e . instance . props . groups = [ ] . concat ( e . instance . props . groups ) ;
for ( let i in e . instance . props . groups ) if ( e . instance . props . groups [ i ] . type == "GROUP" ) {
let data = changedRoles [ e . instance . props . groups [ i ] . id ] ;
if ( data && data . name ) e . instance . props . groups [ i ] = Object . assign ( { } , e . instance . props . groups [ i ] , { title : data . name } ) ;
}
e . instance . props . rows = [ ] . concat ( e . instance . props . rows ) ;
for ( let i in e . instance . props . rows ) if ( e . instance . props . rows [ i ] . type == "GROUP" ) {
let data = changedRoles [ e . instance . props . rows [ i ] . id ] ;
if ( data && data . name ) e . instance . props . rows [ i ] = Object . assign ( { } , e . instance . props . rows [ i ] , { title : data . name } ) ;
}
}
2021-04-02 15:59:29 +02:00
2021-07-24 19:57:55 +02:00
processMemberListItem ( e ) {
2022-11-05 00:15:17 +01:00
if ( ! e . instance . props . user ) return ;
let member = BDFDB . LibraryStores . GuildMemberStore . getMember ( e . instance . props . guildId , e . instance . props . user . id ) ;
if ( member ) e . instance . props . colorString = member . colorString ;
2021-07-24 19:57:55 +02:00
}
2021-04-09 18:13:38 +02:00
getGuildFromRoleId ( roleId ) {
2024-03-15 14:52:38 +01:00
return BDFDB . LibraryStores . SortedGuildStore . getFlattenedGuildIds ( ) . map ( BDFDB . LibraryStores . GuildStore . getGuild ) . find ( guild => {
let roles = guild . roles || BDFDB . LibraryStores . GuildStore . getRoles ( guild . id ) ;
return roles && roles [ roleId ] ;
} ) ;
2021-04-09 18:13:38 +02:00
}
2021-09-20 21:11:00 +02:00
resetRoles ( id ) {
2024-03-11 20:24:50 +01:00
if ( id ) BDFDB . DataUtils . remove ( this , "roles" , id ) ;
else BDFDB . DataUtils . remove ( this , "roles" ) ;
2021-09-20 21:11:00 +02:00
}
2021-04-02 15:59:29 +02:00
openRoleSettingsModal ( role ) {
let data = changedRoles [ role . id ] || { } ;
let newData = Object . assign ( { } , data ) ;
2021-09-20 21:11:00 +02:00
let iconInput ;
2021-04-02 15:59:29 +02:00
BDFDB . ModalUtils . open ( this , {
size : "MEDIUM" ,
header : this . labels . modal _header ,
subHeader : role . name ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
2021-04-02 17:45:55 +02:00
title : BDFDB . LanguageUtils . LanguageStrings . FORM _LABEL _ROLE _NAME ,
className : BDFDB . disCN . marginbottom20 ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
value : data . name ,
placeholder : role . name ,
autoFocus : true ,
2021-09-20 21:11:00 +02:00
onChange : value => newData . name = value
2021-04-02 17:45:55 +02:00
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormDivider , {
className : BDFDB . disCN . dividerdefault
} )
]
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormItem , {
title : BDFDB . LanguageUtils . LanguageStrings . FORM _LABEL _ROLE _COLOR ,
2021-04-02 15:59:29 +02:00
className : BDFDB . disCN . marginbottom20 ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . ColorSwatches , {
color : data . color ,
2021-04-10 12:26:24 +02:00
defaultCustomColor : role . colorString ,
2021-04-02 15:59:29 +02:00
pickerConfig : {
alpha : false ,
gradient : false
} ,
2021-09-20 21:11:00 +02:00
onColorChange : value => newData . color = value
} )
]
} ) ,
BDFDB . ReactUtils . createElement ( "div" , {
className : BDFDB . disCN . marginbottom20 ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormDivider , {
className : BDFDB . disCNS . dividerdefault + BDFDB . disCN . marginbottom20
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . Flex , {
className : BDFDB . disCN . marginbottom8 ,
align : BDFDB . LibraryComponents . Flex . Align . CENTER ,
direction : BDFDB . LibraryComponents . Flex . Direction . HORIZONTAL ,
children : [
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . FormComponents . FormTitle , {
className : BDFDB . disCN . marginreset ,
2022-11-22 01:30:30 +01:00
tag : BDFDB . LibraryComponents . FormComponents . FormTags . H5 ,
2022-09-27 11:02:54 +02:00
children : BDFDB . LanguageUtils . LanguageStrings . FORM _LABEL _ROLE _ICON
2021-09-20 21:11:00 +02:00
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . SettingsItem , {
type : "Switch" ,
margin : 0 ,
grow : 0 ,
label : BDFDB . LanguageUtils . LanguageStrings . REMOVE ,
2022-11-22 01:30:30 +01:00
tag : BDFDB . LibraryComponents . FormComponents . FormTags . H5 ,
2021-09-20 21:11:00 +02:00
value : data . removeIcon ,
onChange : value => {
newData . removeIcon = value ;
if ( value ) {
delete iconInput . props . success ;
delete iconInput . props . errorMessage ;
iconInput . props . disabled = true ;
BDFDB . ReactUtils . forceUpdate ( iconInput ) ;
}
else {
iconInput . props . disabled = false ;
this . checkUrl ( iconInput . props . value , iconInput ) . then ( returnValue => newData . icon = returnValue ) ;
}
}
} )
]
} ) ,
BDFDB . ReactUtils . createElement ( BDFDB . LibraryComponents . TextInput , {
success : ! data . removeIcon && data . icon ,
maxLength : 100000000000000000000 ,
value : data . icon ,
placeholder : role . icon ,
disabled : data . removeIcon ,
ref : instance => { if ( instance ) iconInput = instance ; } ,
onChange : ( value , instance ) => {
this . checkUrl ( value , instance ) . then ( returnValue => newData . icon = returnValue ) ;
}
2021-04-02 15:59:29 +02:00
} )
]
} )
] ,
buttons : [ {
contents : BDFDB . LanguageUtils . LanguageStrings . SAVE ,
color : "BRAND" ,
close : true ,
onClick : _ => {
let changed = false ;
if ( Object . keys ( newData ) . every ( key => newData [ key ] == null || newData [ key ] == false ) && ( changed = true ) ) {
2021-09-20 21:11:00 +02:00
this . resetRoles ( role . id ) ;
2021-04-02 15:59:29 +02:00
}
else if ( ! BDFDB . equals ( newData , data ) && ( changed = true ) ) {
BDFDB . DataUtils . save ( newData , this , "roles" , role . id ) ;
}
if ( changed ) this . forceUpdateAll ( ) ;
}
} ]
} ) ;
}
2021-09-20 21:11:00 +02:00
checkUrl ( url , instance ) {
return new Promise ( callback => {
BDFDB . TimeUtils . clear ( instance . checkTimeout ) ;
url = url && url . trim ( ) ;
if ( ! url || instance . props . disabled ) {
delete instance . props . success ;
delete instance . props . errorMessage ;
callback ( "" ) ;
BDFDB . ReactUtils . forceUpdate ( instance ) ;
}
2022-12-01 21:38:21 +01:00
else if ( url . indexOf ( "data:" ) == 0 ) {
instance . props . success = true ;
delete instance . props . errorMessage ;
callback ( url ) ;
}
2021-09-20 21:11:00 +02:00
else instance . checkTimeout = BDFDB . TimeUtils . timeout ( _ => {
2022-01-11 18:13:34 +01:00
BDFDB . LibraryRequires . request ( url , { agentOptions : { rejectUnauthorized : false } } , ( error , response , result ) => {
2021-09-20 21:11:00 +02:00
delete instance . checkTimeout ;
if ( instance . props . disabled ) {
delete instance . props . success ;
delete instance . props . errorMessage ;
callback ( "" ) ;
}
else if ( response && response . headers [ "content-type" ] && response . headers [ "content-type" ] . indexOf ( "image" ) != - 1 ) {
instance . props . success = true ;
delete instance . props . errorMessage ;
callback ( url ) ;
}
else {
delete instance . props . success ;
instance . props . errorMessage = this . labels . modal _invalidurl ;
callback ( "" ) ;
}
BDFDB . ReactUtils . forceUpdate ( instance ) ;
} ) ;
} , 1000 ) ;
} ) ;
}
2021-04-02 15:59:29 +02:00
setLabelsByLanguage ( ) {
switch ( BDFDB . LanguageUtils . getLanguage ( ) . id ) {
case "bg" : // Bulgarian
return {
confirm _reset : "Наистина ли искате да нулирате тази роля?" ,
confirm _resetall : "Наистина ли искате да нулирате всички роли?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Настройки на местната роля" ,
2021-04-02 15:59:29 +02:00
modal _header : "Настройки на местната роля" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Нулиране на ролята" ,
submenu _rolesettings : "Промяна на настройките"
2021-04-02 15:59:29 +02:00
} ;
case "da" : // Danish
return {
confirm _reset : "Er du sikker på, at du vil nulstille denne rolle?" ,
confirm _resetall : "Er du sikker på, at du vil nulstille alle roller?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Lokale rolleindstillinger" ,
2021-04-02 15:59:29 +02:00
modal _header : "Lokale rolleindstillinger" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Nulstil rolle" ,
submenu _rolesettings : "Ændre indstillinger"
2021-04-02 15:59:29 +02:00
} ;
case "de" : // German
return {
confirm _reset : "Möchtest du diese Rolle wirklich zurücksetzen?" ,
confirm _resetall : "Möchtest du wirklich alle Rollen zurücksetzen?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Lokale Rolleneinstellungen" ,
2021-04-02 15:59:29 +02:00
modal _header : "Lokale Rolleneinstellungen" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Rolle zurücksetzen" ,
submenu _rolesettings : "Einstellungen ändern"
2021-04-02 15:59:29 +02:00
} ;
case "el" : // Greek
return {
confirm _reset : "Είστε βέβαιοι ότι θέλετε ν α επαναφέρετε αυτόν τον ρόλο;" ,
confirm _resetall : "Είστε βέβαιοι ότι θέλετε ν α επαναφέρετε όλους τους ρόλους;" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Ρυθμίσεις ρόλου {τοπικά)" ,
2023-04-19 10:39:58 +02:00
modal _header : "Ρυθμίσεις ρόλου (τοπικά)" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Επαναφορά ρόλου" ,
submenu _rolesettings : "Αλλαγή ρυθμίσεων"
2021-04-02 15:59:29 +02:00
} ;
case "es" : // Spanish
return {
confirm _reset : "¿Está seguro de que desea restablecer este rol?" ,
confirm _resetall : "¿Está seguro de que desea restablecer todos los roles?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Configuración de roles locales" ,
2021-04-02 15:59:29 +02:00
modal _header : "Configuración de roles locales" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Restablecer rol" ,
submenu _rolesettings : "Cambiar ajustes"
2021-04-02 15:59:29 +02:00
} ;
case "fi" : // Finnish
return {
confirm _reset : "Haluatko varmasti nollata tämän roolin?" ,
confirm _resetall : "Haluatko varmasti nollata kaikki roolit?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Paikalliset rooliasetukset" ,
2021-04-02 15:59:29 +02:00
modal _header : "Paikalliset rooliasetukset" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Nollaa rooli" ,
submenu _rolesettings : "Vaihda asetuksia"
2021-04-02 15:59:29 +02:00
} ;
case "fr" : // French
return {
confirm _reset : "Voulez-vous vraiment réinitialiser ce rôle?" ,
confirm _resetall : "Voulez-vous vraiment réinitialiser tous les rôles?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Paramètres de rôle locaux" ,
2021-04-02 15:59:29 +02:00
modal _header : "Paramètres de rôle locaux" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Réinitialiser le rôle" ,
submenu _rolesettings : "Modifier les paramètres"
2021-04-02 15:59:29 +02:00
} ;
case "hr" : // Croatian
return {
confirm _reset : "Jeste li sigurni da želite resetirati ovu ulogu?" ,
confirm _resetall : "Jeste li sigurni da želite resetirati sve uloge?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Postavke lokalne uloge" ,
2021-04-02 15:59:29 +02:00
modal _header : "Postavke lokalne uloge" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Resetiraj ulogu" ,
submenu _rolesettings : "Promijeniti postavke"
2021-04-02 15:59:29 +02:00
} ;
case "hu" : // Hungarian
return {
confirm _reset : "Biztosan vissza akarja állítani ezt a szerepet?" ,
confirm _resetall : "Biztosan vissza akarja állítani az összes szerepet?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Helyi szerepbeállítások" ,
2021-04-02 15:59:29 +02:00
modal _header : "Helyi szerepbeállítások" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "A szerepkör visszaállítása" ,
submenu _rolesettings : "Beállítások megváltoztatása"
2021-04-02 15:59:29 +02:00
} ;
case "it" : // Italian
return {
confirm _reset : "Sei sicuro di voler reimpostare questo ruolo?" ,
confirm _resetall : "Sei sicuro di voler reimpostare tutti i ruoli?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Impostazioni ruolo locale" ,
2021-04-02 15:59:29 +02:00
modal _header : "Impostazioni ruolo locale" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Reimposta ruolo" ,
submenu _rolesettings : "Cambia impostazioni"
2021-04-02 15:59:29 +02:00
} ;
case "ja" : // Japanese
return {
confirm _reset : "この役割をリセットしてもよろしいですか?" ,
confirm _resetall : "すべての役割をリセットしてもよろしいですか?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "ローカルロール設定" ,
2021-04-02 15:59:29 +02:00
modal _header : "ローカルロール設定" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "役割をリセット" ,
submenu _rolesettings : "設定を変更する"
2021-04-02 15:59:29 +02:00
} ;
case "ko" : // Korean
return {
confirm _reset : "이 역할을 재설정 하시겠습니까?" ,
confirm _resetall : "모든 역할을 재설정 하시겠습니까?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "로컬 역할 설정" ,
2021-04-02 15:59:29 +02:00
modal _header : "로컬 역할 설정" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "역할 재설정" ,
submenu _rolesettings : "설정 변경"
2021-04-02 15:59:29 +02:00
} ;
case "lt" : // Lithuanian
return {
confirm _reset : "Ar tikrai norite iš naujo nustatyti šį vaidmenį?" ,
confirm _resetall : "Ar tikrai norite iš naujo nustatyti visus vaidmenis?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Vietos vaidmens nustatymai" ,
2021-04-02 15:59:29 +02:00
modal _header : "Vietos vaidmens nustatymai" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Iš naujo nustatyti vaidmenį" ,
submenu _rolesettings : "Pakeisti nustatymus"
2021-04-02 15:59:29 +02:00
} ;
case "nl" : // Dutch
return {
confirm _reset : "Weet u zeker dat u deze rol wilt resetten?" ,
confirm _resetall : "Weet u zeker dat u alle rollen opnieuw wilt instellen?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Lokale rolinstellingen" ,
2021-04-02 15:59:29 +02:00
modal _header : "Lokale rolinstellingen" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Rol opnieuw instellen" ,
submenu _rolesettings : "Instellingen veranderen"
2021-04-02 15:59:29 +02:00
} ;
case "no" : // Norwegian
return {
confirm _reset : "Er du sikker på at du vil tilbakestille denne rollen?" ,
confirm _resetall : "Er du sikker på at du vil tilbakestille alle rollene?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Lokale rolleinnstillinger" ,
2021-04-02 15:59:29 +02:00
modal _header : "Lokale rolleinnstillinger" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Tilbakestill rolle" ,
submenu _rolesettings : "Endre innstillinger"
2021-04-02 15:59:29 +02:00
} ;
case "pl" : // Polish
return {
confirm _reset : "Czy na pewno chcesz zresetować tę rolę?" ,
confirm _resetall : "Czy na pewno chcesz zresetować wszystkie role?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Ustawienia roli lokalnej" ,
2021-04-02 15:59:29 +02:00
modal _header : "Ustawienia roli lokalnej" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Zresetuj rolę" ,
submenu _rolesettings : "Zmień ustawienia"
2021-04-02 15:59:29 +02:00
} ;
case "pt-BR" : // Portuguese (Brazil)
return {
confirm _reset : "Tem certeza de que deseja redefinir esta função?" ,
confirm _resetall : "Tem certeza de que deseja redefinir todas as funções?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Configurações de função local" ,
2021-04-02 15:59:29 +02:00
modal _header : "Configurações de função local" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Redefinir função" ,
submenu _rolesettings : "Mudar configurações"
2021-04-02 15:59:29 +02:00
} ;
case "ro" : // Romanian
return {
confirm _reset : "Sigur doriți să resetați acest rol?" ,
confirm _resetall : "Sigur doriți să resetați toate rolurile?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Setări rol local" ,
2021-04-02 15:59:29 +02:00
modal _header : "Setări rol local" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Resetați rolul" ,
submenu _rolesettings : "Schimbă setările"
2021-04-02 15:59:29 +02:00
} ;
case "ru" : // Russian
return {
confirm _reset : "Вы уверены, что хотите сбросить эту роль?" ,
confirm _resetall : "Вы уверены, что хотите сбросить все роли?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Настройки локальной роли" ,
2021-04-02 15:59:29 +02:00
modal _header : "Настройки локальной роли" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Сбросить роль" ,
submenu _rolesettings : "Изменить настройки"
2021-04-02 15:59:29 +02:00
} ;
case "sv" : // Swedish
return {
confirm _reset : "Är du säker på att du vill återställa denna roll?" ,
confirm _resetall : "Är du säker på att du vill återställa alla roller?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Lokala rollinställningar" ,
2021-04-02 15:59:29 +02:00
modal _header : "Lokala rollinställningar" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Återställ roll" ,
submenu _rolesettings : "Ändra inställningar"
2021-04-02 15:59:29 +02:00
} ;
case "th" : // Thai
return {
confirm _reset : "แน่ใจไหมว่าต้องการรีเซ็ตบทบาทนี้" ,
confirm _resetall : "แน่ใจไหมว่าต้องการรีเซ็ตบทบาททั้งหมด" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "การตั้งค่าบทบาทท้องถิ่น" ,
2021-04-02 15:59:29 +02:00
modal _header : "การตั้งค่าบทบาทท้องถิ่น" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "รีเซ็ตบทบาท" ,
submenu _rolesettings : "เปลี่ยนการตั้งค่า"
2021-04-02 15:59:29 +02:00
} ;
case "tr" : // Turkish
return {
confirm _reset : "Bu Rolü sı fı rlamak istediğinizden emin misiniz?" ,
confirm _resetall : "Tüm Rolleri sı fı rlamak istediğinizden emin misiniz?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Yerel Rol Ayarları " ,
2021-04-02 15:59:29 +02:00
modal _header : "Yerel Rol Ayarları " ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Rolü Sı fı rla" ,
submenu _rolesettings : "Ayarları değiştir"
2021-04-02 15:59:29 +02:00
} ;
case "uk" : // Ukrainian
return {
confirm _reset : "Ви впевнені, що хочете скинути цю роль?" ,
confirm _resetall : "Ви впевнені, що хочете скинути всі ролі?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Налаштування локальної ролі" ,
2021-04-02 15:59:29 +02:00
modal _header : "Налаштування локальної ролі" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Скинути роль" ,
submenu _rolesettings : "Змінити налаштування"
2021-04-02 15:59:29 +02:00
} ;
case "vi" : // Vietnamese
return {
confirm _reset : "Bạn có chắc chắn muốn đặt lại Vai trò này không?" ,
confirm _resetall : "Bạn có chắc chắn muốn đặt lại tất cả các Vai trò không?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Cài đặt vai trò cục bộ" ,
2021-04-02 15:59:29 +02:00
modal _header : "Cài đặt vai trò cục bộ" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Đặt lại vai trò" ,
submenu _rolesettings : "Thay đổi cài đặt"
2021-04-02 15:59:29 +02:00
} ;
case "zh-CN" : // Chinese (China)
return {
confirm _reset : "您确定要重置此角色吗?" ,
confirm _resetall : "您确定要重置所有角色吗?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "本地角色设置" ,
2021-04-02 15:59:29 +02:00
modal _header : "本地角色设置" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "重置角色" ,
submenu _rolesettings : "更改设置"
2021-04-02 15:59:29 +02:00
} ;
case "zh-TW" : // Chinese (Taiwan)
return {
confirm _reset : "您確定要重置此角色嗎?" ,
confirm _resetall : "您確定要重置所有角色嗎?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "本地角色設置" ,
2021-04-02 15:59:29 +02:00
modal _header : "本地角色設置" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "重置角色" ,
submenu _rolesettings : "更改設置"
2021-04-02 15:59:29 +02:00
} ;
default : // English
return {
confirm _reset : "Are you sure you want to reset this Role?" ,
confirm _resetall : "Are you sure you want to reset all Roles?" ,
2024-03-11 20:24:50 +01:00
context _localrolesettings : "Local Role Settings" ,
2021-04-02 15:59:29 +02:00
modal _header : "Local Role Settings" ,
2024-03-11 20:24:50 +01:00
submenu _resetsettings : "Reset Role" ,
submenu _rolesettings : "Change Settings"
2021-04-02 15:59:29 +02:00
} ;
}
}
} ;
2022-09-01 14:40:11 +02:00
} ) ( window . BDFDB _Global . PluginUtils . buildPlugin ( changeLog ) ) ;
2021-04-02 15:59:29 +02:00
} ) ( ) ;