Skip to content

Commit

Permalink
Release 2.2.0
Browse files Browse the repository at this point in the history
Wasn't expecting a new major release so soon, but the legendary @PlanetTheCloud took the time to rewrite Element Changer in a much more efficient way. We decided the numerical system wasn't cutting it, and decided to make changing elements much easier.

Thank you, @PlanetTheCloud!

Co-Authored-By: Planet Cloud <[email protected]>
  • Loading branch information
4yx and PlanetTheCloud committed Sep 15, 2022
1 parent 7fc2af7 commit ac5752e
Show file tree
Hide file tree
Showing 11 changed files with 66 additions and 80 deletions.
2 changes: 1 addition & 1 deletion altervp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const AlterVP = {
}
};
</script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.1.0/altervp/altervp.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.2.0/altervp/altervp.js" type="text/javascript"></script>
```
Alternatively, you can use our CDN:
```html
Expand Down
2 changes: 1 addition & 1 deletion change-language-link-text-changer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The full code, using jsDelivr:
var change_language_link = "your_website_url",
change_language_text = "your_text";
</script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.1.0/change-language-link-text-changer/change-language-link-text-changer.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.2.0/change-language-link-text-changer/change-language-link-text-changer.js" type="text/javascript"></script>
```
Alternatively, you can use our CDN:
```html
Expand Down
2 changes: 1 addition & 1 deletion change-password-link-text-changer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ The full code, using jsDelivr:
var change_password_link = "your_website_url",
change_password_text = "your_text";
</script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.1.0/change-password-link-text-changer/change-password-link-text-changer.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.2.0/change-password-link-text-changer/change-password-link-text-changer.js" type="text/javascript"></script>
```
Alternatively, you can use our CDN:
```html
Expand Down
2 changes: 1 addition & 1 deletion cpanel-logo-to-copyright/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ The full code, using jsDelivr:
}
</script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.1.0/cpanel-logo-to-copyright/cpanel-logo-to-copyright.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.2.0/cpanel-logo-to-copyright/cpanel-logo-to-copyright.js" type="text/javascript"></script>
```
Alternatively, you can use our CDN:
```html
Expand Down
2 changes: 1 addition & 1 deletion dropdown-bug-fix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ To solve this, we need an external service which adds the correct type, like jsD

The full code, using jsDelivr:
```html
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.1.0/dropdown-bug-fix/dropdown-bug-fix.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.2.0/dropdown-bug-fix/dropdown-bug-fix.js" type="text/javascript"></script>
```
Alternatively, you can use our CDN:
```html
Expand Down
80 changes: 21 additions & 59 deletions element-changer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,36 +8,15 @@ You can put it anywhere! We recommend avoiding the left advert area, as it will

## How can I install it?
You'll first need to declare an array with the name ``changeElements`` within a script tag.
The elements in vPanel are categorized numerically in 11 groups, as shown in the table below:
| No. | Group Names |
|-----|---------------------------- |
| 1 | Preferences |
| 2 | Files |
| 3 | Databases |
| 4 | Domains |
| 5 | Email |
| 6 | Metrics |
| 7 | Security |
| 8 | Software |
| 9 | Advanced |
| 10 | Softaculous Apps Installer |
| 11 | Support |

To change the elements of a group, you will need to declare an object named with the number of that group, which will contain a new array. For example, to modify an element belonging in "Preferences" your object will need to be named 1.
An example on how your code would look will be shown below:
To change the elements of a group, you will need to create an object with the following properties that we'll analyze afterwards:
```js
changeElements = [
{1: [
{contents here}
]}
```
Inside the new array, create an object with the following properties that we'll analyze afterwards:
```js
{item:, attr:, value:}
{name: "Element name", attr: "attribute", value: "new value"}
```

### Properties

In ``item``, you'll assign a numerical value that corresponds with the position of the element you want to modify. Elements are sorted from left to right, or in the order they appear on mobile view, for instance ``1`` is the value of ``Change Password`` in Preferences.
In ``name``, you'll assign a value that corresponds with the name of the element exactly as it appears on the panel. For instance ``"Change Password"`` is what you'll need to enter to modify the Change Password element.

``attr`` is the attribute you wish to modify. There are two main attributes:
``itemdesc`` and ``url``.
Expand All @@ -48,30 +27,24 @@ Finally, ``value`` holds the new value of the element you'll be changing, for ex
An example of the code modifying the name and URL of ``Change Password`` to ``Your Domain`` and ``https://yourdomain.com`` respectively can be seen below:
```js
changeElements = [
{1: [
{item: 1, attr: "itemdesc", value: "Your Domain"},
{item: 1, attr: "url", value: "https://yourdomain.com"}
]}
{name: "Change Password", attr: "itemdesc", value: "Your Domain"},
{name: "Change Password", attr: "url", value: "https://yourdomain.com"}
];
```
Objects are separated by commas, so don't forget to include them when adding a new one.

### What is all of this? Where is my ready-to-use code?
If you skipped to this section, I apologise for the length of the previous ones. I tried to analyze the process in the best way I could.
Please read the Properties section before attempting to make your own modifications.

We'll provide a ready code for modifying the URLs of the first two elements of the ``Support`` and ``Email`` groups. Try it out in your panel (with the script, of course) to be able to better understand the process in adding your own objects.
We'll provide a ready code for modifying the names and URLs of ``SiteBuilder`` and ``Softaculous Apps Installer``. Try it out in your panel (with the script, of course) to be able to better understand the process in adding your own objects.
```html
<script type="text/javascript">
changeElements = [
{5: [
{item: 1, attr: "url", value: "https://email.accounts"},
{item: 2, attr: "url", value: "https://forwarde.rs"}
]},
{11: [
{item: 1, attr: "url", value: "https://domain.types"},
{item: 2, attr: "url", value: "https://tutoria.ls"}
]}
]
{name: "SiteBuilder", attr: "itemdesc", value: "VistaPanel Themes"},
{name: "SiteBuilder", attr: "url", value: "https://vpt.cdn.wybenetwork.com"},
{name: "Softaculous Apps Installer", attr: "itemdesc", value: "VistaPanel Customizations"},
{name: "Softaculous Apps Installer", attr: "url", value: "https://vpc.cdn.wybenetwork.com"}
];
</script>
```
### So where's that script, anyway?
Expand All @@ -85,7 +58,7 @@ To solve this, we need an external service which adds the correct type, like jsD

The code, using jsDelivr:
```html
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.1.0/element-changer/element-changer.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.2.0/element-changer/element-changer.js" type="text/javascript"></script>
```
Alternatively, you can use our CDN:
```html
Expand All @@ -95,25 +68,14 @@ A full code utilizing our example and our CDN:
```html
<script type="text/javascript">
changeElements = [
{5: [
{item: 1, attr: "url", value: "https://email.accounts"},
{item: 2, attr: "url", value: "https://forwarde.rs"}
]},
{11: [
{item: 1, attr: "url", value: "https://domain.types"},
{item: 2, attr: "url", value: "https://tutoria.ls"}
]}
]
{name: "SiteBuilder", attr: "itemdesc", value: "VistaPanel Themes"},
{name: "SiteBuilder", attr: "url", value: "https://vpt.cdn.wybenetwork.com"},
{name: "Softaculous Apps Installer", attr: "itemdesc", value: "VistaPanel Customizations"},
{name: "Softaculous Apps Installer", attr: "url", value: "https://vpc.cdn.wybenetwork.com"}
];
</script>
<script src="https://vpc.cdn.wybenetwork.com/element-changer/element-changer.js" type="text/javascript"></script>
```
## Frequently Asked Questions
### Doesn't counting start at 0?
In JavaScript arrays like the one the script is modifying, indeed it does! I have modified the script (subtracting 1) so that counting starts at one, so make sure you don't use 0!
### Why is this so long and complicated?
I wish there was a more simple way to implement it. I don't know, there might be, but this is the easiest one I was able to come up with.
### Won't this break if iFastNet changes the item list?
~~[@BastelPichi, is this you?](https://github.com/WybeNetwork/VistaPanel-Customizations/issues/18#issuecomment-1235768587)~~
Yes, it will, although if iFastNet changes the item list and I/someone in our team/the MOFH community have the time, we will update it.
## Changelog
* Created on 15 August 2022 by [Anyx](https://github.com/4yx)
* Created on 15 August 2022 by [Anyx](https://github.com/4yx)
* Modified on 15 August 2022 by [PlanetCloud](https://github.com/PlanetTheCloud)
46 changes: 35 additions & 11 deletions element-changer/element-changer.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,40 @@
/* @preserve
* Created at 15 September 2022 by Anyx.
* Created at 15 September 2022 by Anyx and modified by PlanetCloud.
* DO NOT REMOVE CREDITS!
* Created for: Wybe Network.
*/
function updatePanelElements(group, item, attr, value) {
PAGE.appGroups[group].items[item][attr] = value;
}

changeElements.forEach(function(index) {
Object.entries(index).forEach(function(element) {
element[1].forEach(function(key) {
updatePanelElements((Object.keys(index)[0] - 1), (key.item - 1), key.attr, key.value)
if (typeof changeElements !== "undefined") {
((changeElements) => {
if (changeElements.length == 0) {
return console.log('ElementChanger: Nothing to modify.');
}
var panelElementsIndex = [],
groupIndex = 0;
PAGE.appGroups.forEach(group => {
var itemIndex = 0;
group.items.forEach(item => {
if (typeof panelElementsIndex[item.itemdesc] == 'undefined') {
panelElementsIndex[item.itemdesc] = [];
}
panelElementsIndex[item.itemdesc].push({
group: groupIndex,
item: itemIndex
});
itemIndex++;
});
});
});
groupIndex++;
});
changeElements.forEach(element => {
if (typeof panelElementsIndex[element.name] !== 'undefined') {
panelElementsIndex[element.name].forEach(e => {
PAGE.appGroups[e.group].items[e.item][element.attr] = element.value;
})
} else {
console.log(`ElementChanger: Trying to change element ${element.name} which does not exist.`);
}
});
console.log('ElementChanger: All modifications have been made.');
})(changeElements);
} else {
console.log("ElementChanger: changeElements variable is not defined. No elements changed.");
}
4 changes: 2 additions & 2 deletions element-changer/element-changer.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion responsive-domain-search/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The full code, using jsDelivr:
affCode = "AFFILIATE_CODE_HERE";
*/
</script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.1.0/responsive-domain-search/responsive-domain-search.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.2.0/responsive-domain-search/responsive-domain-search.js" type="text/javascript"></script>
```
Alternatively, you can use our CDN:
```html
Expand Down
2 changes: 1 addition & 1 deletion sidebar-bug-fix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ To solve this, we need an external service which adds the correct type, like jsD

The full code, using jsDelivr:
```html
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.1.0/sidebar-bug-fix/sidebar-bug-fix.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.2.0/sidebar-bug-fix/sidebar-bug-fix.js" type="text/javascript"></script>
```
Alternatively, you can use our CDN:
```html
Expand Down
2 changes: 1 addition & 1 deletion tutorial-link-changer/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The full code, using jsDelivr:
tutorial : "YOUR TUTORIAL LINK WITH HTTP(S) PROTOCOL",
}
</script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.1.0/tutorial-link-changer/tutorial-link-changer.js" type="text/javascript"></script>
<script src="https://cdn.jsdelivr.net/gh/WybeNetwork/VistaPanel-Customizations@2.2.0/tutorial-link-changer/tutorial-link-changer.js" type="text/javascript"></script>
```
Alternatively, you can use our CDN:
```html
Expand Down

0 comments on commit ac5752e

Please sign in to comment.