returnValues: {
action: string;
items?: {
- // They key is the `typeName`
+ // The key is the `typeName`
[key: string]: ClipboardItemData;
};
markedItems?: AjaxResponseMarkedItems;
}
// Collect additional request parameters.
- // TODO: Is still untested.
const parameters = {};
Object.entries(actionElement.dataset).forEach(([key, value]) => {
- if (/^objectActionParameterData.+/.exec(key)) {
- if (!("data" in parameters)) {
+ let matches = /^objectActionParameterData(.+)/.exec(key);
+ if (matches) {
+ if (!Object.prototype.hasOwnProperty.call(parameters, "data")) {
parameters["data"] = {};
}
- parameters[StringUtil.lcfirst(key.replace(/^objectActionParameterData/, ""))] = value;
- } else if (/^objectActionParameter.+/.exec(key)) {
- parameters[StringUtil.lcfirst(key.replace(/^objectActionParameter/, ""))] = value;
+ parameters["data"][StringUtil.lcfirst(matches[1])] = value;
+ } else {
+ matches = /^objectActionParameter(.+)/.exec(key);
+
+ if (matches) {
+ const key = StringUtil.lcfirst(matches[1]);
+
+ if (key === "data") {
+ throw new Error("Additional object action parameters may not use 'data' as key.");
+ }
+
+ parameters[key] = value;
+ }
}
});
if (toggleButton.classList.contains("fa-square-o")) {
toggleButton.classList.replace("fa-square-o", "fa-check-square-o");
- const newTitle = toggleButton.dataset.disableTitle
- ? toggleButton.dataset.disableTitle
- : Language.get("wcf.global.button.disable");
+ const newTitle = toggleButton.dataset.disableTitle || Language.get("wcf.global.button.disable");
toggleButton.title = newTitle;
} else {
toggleButton.classList.replace("fa-check-square-o", "fa-square-o");
- const newTitle = toggleButton.dataset.enableTitle
- ? toggleButton.dataset.enableTitle
- : Language.get("wcf.global.button.enable");
+ const newTitle = toggleButton.dataset.enableTitle || Language.get("wcf.global.button.enable");
toggleButton.title = newTitle;
}
}
objectId = actionElement.dataset.objectId;
}
// Collect additional request parameters.
- // TODO: Is still untested.
const parameters = {};
Object.entries(actionElement.dataset).forEach(([key, value]) => {
- if (/^objectActionParameterData.+/.exec(key)) {
- if (!("data" in parameters)) {
+ let matches = /^objectActionParameterData(.+)/.exec(key);
+ if (matches) {
+ if (!Object.prototype.hasOwnProperty.call(parameters, "data")) {
parameters["data"] = {};
}
- parameters[StringUtil.lcfirst(key.replace(/^objectActionParameterData/, ""))] = value;
+ parameters["data"][StringUtil.lcfirst(matches[1])] = value;
}
- else if (/^objectActionParameter.+/.exec(key)) {
- parameters[StringUtil.lcfirst(key.replace(/^objectActionParameter/, ""))] = value;
+ else {
+ matches = /^objectActionParameter(.+)/.exec(key);
+ if (matches) {
+ const key = StringUtil.lcfirst(matches[1]);
+ if (key === "data") {
+ throw new Error("Additional object action parameters may not use 'data' as key.");
+ }
+ parameters[key] = value;
+ }
}
});
function sendRequest() {
const toggleButton = objectElement.querySelector('.jsObjectAction[data-object-action="toggle"]');
if (toggleButton.classList.contains("fa-square-o")) {
toggleButton.classList.replace("fa-square-o", "fa-check-square-o");
- const newTitle = toggleButton.dataset.disableTitle
- ? toggleButton.dataset.disableTitle
- : Language.get("wcf.global.button.disable");
+ const newTitle = toggleButton.dataset.disableTitle || Language.get("wcf.global.button.disable");
toggleButton.title = newTitle;
}
else {
toggleButton.classList.replace("fa-check-square-o", "fa-square-o");
- const newTitle = toggleButton.dataset.enableTitle
- ? toggleButton.dataset.enableTitle
- : Language.get("wcf.global.button.enable");
+ const newTitle = toggleButton.dataset.enableTitle || Language.get("wcf.global.button.enable");
toggleButton.title = newTitle;
}
}