mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-29 20:34:04 +02:00
Add template name check and safeguard empty ajax token in template plugin
This commit is contained in:
parent
7b91cb2e96
commit
2e4cb12817
@ -206,6 +206,10 @@ enabled(){
|
|||||||
evaluator = null;
|
evaluator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!url){
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
promises.push(doAjaxRequest(url, evaluator).then(result => {
|
promises.push(doAjaxRequest(url, evaluator).then(result => {
|
||||||
const placeholderLen = 5; // "(...)".length
|
const placeholderLen = 5; // "(...)".length
|
||||||
|
|
||||||
@ -373,13 +377,17 @@ enabled(){
|
|||||||
let name = $("[name='template-name']", editor).val();
|
let name = $("[name='template-name']", editor).val();
|
||||||
let identifier = name.toLowerCase().replace(/[^a-z0-9]/g, "")+"-"+(Math.random().toString(36).substring(2, 7));
|
let identifier = name.toLowerCase().replace(/[^a-z0-9]/g, "")+"-"+(Math.random().toString(36).substring(2, 7));
|
||||||
|
|
||||||
|
if (name.trim().length === 0){
|
||||||
|
alert("Please, include a name for your template.");
|
||||||
|
$("[name='template-name']", editor).focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
me.config.templates[identifier] = {
|
me.config.templates[identifier] = {
|
||||||
name: name,
|
name: name,
|
||||||
contents: $("[name='template-contents']", editor).val()
|
contents: $("[name='template-contents']", editor).val()
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO check validity
|
|
||||||
|
|
||||||
toggleEditor();
|
toggleEditor();
|
||||||
onTemplatesUpdated(true);
|
onTemplatesUpdated(true);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user