2017-02-25 11:34:58 +00:00
|
|
|
module.exports = {
|
|
|
|
name: "Letters to Numbers",
|
|
|
|
inputs: {
|
2017-03-13 12:41:56 +00:00
|
|
|
letters: {
|
|
|
|
name: "Letters",
|
|
|
|
type: "text",
|
|
|
|
required: true,
|
|
|
|
inline: false
|
|
|
|
},
|
|
|
|
offset: {
|
|
|
|
name: "Offset",
|
|
|
|
type: "text",
|
|
|
|
required: true,
|
|
|
|
inline: false
|
|
|
|
}
|
2017-02-25 11:34:58 +00:00
|
|
|
},
|
|
|
|
output: true,
|
|
|
|
execute: function({letters, offset}, elem){
|
|
|
|
if(!offset){
|
|
|
|
offset = 0;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
offset = parseInt(offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
return letters
|
|
|
|
.split("")
|
|
|
|
.map((char)=>(char.charCodeAt(0)))
|
|
|
|
.filter((asciiVal)=>(((asciiVal >= 65) && (asciiVal <= 90)) || ((asciiVal >= 97) && (asciiVal <= 122))))
|
|
|
|
.map((asciiVal)=>{
|
|
|
|
if(asciiVal <= 90){
|
|
|
|
return asciiVal - 65;
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
return asciiVal - 97;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.map((num)=>(num + offset))
|
2017-02-28 08:58:18 +00:00
|
|
|
.map((num)=>(((num%26)+26)%26))
|
2017-02-25 11:34:58 +00:00
|
|
|
.join(",");
|
|
|
|
},
|
|
|
|
pageBlock: {
|
|
|
|
html: "",
|
|
|
|
js: function(){}
|
|
|
|
}
|
|
|
|
}
|