Converting Case

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Revnart

Converting Case

Post by Revnart »

Hello, I,ve tried to make an photoshop plugin which could change text written with caps lock into sentence case:

example:
"HI. I WORK HERE." to "Hi. I work here."

I,ve tried embedding html with script in Adobe Configurator, and creating standalone website and embedding it.
Site: http://www.grafin.pl/case/

None of the above worked.

Here is screenshot of what I've got already:
http://i7.minus.com/iNkmERZ96GqCp.jpg

and code I've embedded:
Code: Select all<html>
<head>
<script type="text/javascript">
function convert()
{
    var value = document.getElementById("text").value;
   var tregex = /\n|([^\r\n.!?]+([.!?]+|$))/gim;
   
    var sentences = value.match(tregex);
   
    var result = '';
    for(var i = 0; i<sentences.length; i++)
    {
        var txt = sentences.trim();
       
        result += txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase() + ' ';
    }
    document.getElementById('text').value = result;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body {
   background-color: #464646;
}
</style>
</head>
<body>
<br>
<center><form>
<textarea  id='text' style="width:300px; height: 200px"></textarea><br>
<input type='button' name='Convert' value="convert" onClick="convert()"/>
</form></center>
</body>
</html>

The idea was to create window where I can paste text, convert it, and put it back into the project or (harder for me) scritpt ignited by button which affects selected text/text layer.

Is it possible?

Thank you for your help.
Revnart