Help & Documentation
How to use Sentenza Desktop and APIsSandbox
Some APIs are not Sandbox friendly for the moment, so you'll have to test your applications with Sandbox disabled. For example for all around files manipulation (read, write, delete, ...), the Sandbox requires that the user gives permissions to read/write the specified file. Otherwise you can manipulate files in application Sandbox directory. The path looks like that :
/Users/[username]/Library/Containers/[bundle identifier]/Data
Spaces in strings
If long strings like path or filename contains spaces, you have to include a backslash before the space. Example here.
Line breaks
To add or to catch a line break in a string, use \n (backslash + n), without space after. Example here.
New window
For the moment, opening a new window is not possible via APIs. So if you have to display content in another part of your application, I suggest you to take a look at this light and beautiful jQuery/CSS modal popup : Avgrund by Hakim El Hattab.
Quit the application. If confirmation prompt has been enabled, the user will have to confirm before exit.
Usage (JS)
Stz.quitApp_();
Miniaturize the window in Dock with system animation effect.
Usage (JS)
Stz.minimizeWindow_();
Toggle window between the full width/height and the previous size.
Usage (JS)
Stz.maximizeWindow_();
Toggle window between the fullscreen mode and the previous size.
Usage (JS)
Stz.fullscreenWindow_();
Close the current window. If "Quit application at window close" is enabled, this function will quit the application (with confirmation prompt if enabled).
Usage (JS)
Stz.closeWindow_();
Force to change the window title.
Usage (JS)
Stz.changeTitle_('I love Paris Hilton');
Resize and put the window in screen center (with smooth animations). Width and Height are in pixels.
Usage (JS)
Stz.resizeWindow_({width:400, height:200});
Move the window to a new position. X and Y are in pixels, from top left corner of the screen.
Usage (JS)
Stz.moveWindow_({x:100, y:200});
Open the default print settings window to print the current page.
Usage (JS)
Stz.printPage_();
Open a simple message box with OK button. Can replace basic JavaScript Alert.
Usage (JS)
Stz.messageBox_({title:'Hello World', message:'I am a simple message box.'});
Copy a string to clipboard easily. Can replace a Flash function.
Usage (JS)
Stz.copyStrToClipboard_('Now, I am in your clipboard !');
Create a real and native notification alert. Your application will be added to Notifications Settings system window for choosing what kind of notifications you want (alert, banners, none).
Usage (JS)
Stz.notifyMe_({title:'Hello', subtitle:'Email', content:'You have a message !'});
Launch an application from his name in Applications directory (without arguments).
Usage (JS)
Stz.openApp_('Terminal');
Stz.openApp_('Adobe Photoshop CS6');
Force to open an URL in the user default internet browser, rather than current window.
Usage (JS)
Stz.openURL_('http://www.parishilton.com');
Open and read the content of a file. Only text-type files are supported (txt, xml, html, css, ...).
Usage (JS)
Stz.openTextFile_('/Users/ChuckNorris/Documents/File.txt');
alert(Stz.openTextFile_('/Users/ChuckNorris/Docucments/File.txt'));
Create a file and write strings datas in. If the file already exists, it will be rewritting.
The result will be a boolean in future.
Usage (JS)
Stz.writeStringsToFile_({path:'/Users/ChuckNorris/Documents/', filename:'My File.txt', content:'Hello world'});
Add strings to an existing file. File targeted must exists. Use \n to add a line break.
Usage (JS)
Stz.addStringsToFile_({path:'/Users/ChuckNorris/Documents/', filename:'My File.txt', content:'Hello world \nA second line'});
Create all directories necessary to build the path you specified. Do not add a slash at the end.
The result will be a boolean in future.
Usage (JS)
Stz.newDirectory_('/Users/ChuckNorris/Desktop/One/Two/Three');
Delete a single file or a folder and his content. Warning, the deletion is irreversible.
The result will be a boolean in future.
Usage (JS)
Stz.deleteItem_('/Users/ChuckNorris/Desktop/Beurk.txt'));
Move a single file or a folder and his content to user Trash. User can recover the file/folder.
The result will be a boolean in future.
Usage (JS)
Stz.moveToTrash_('/Users/ChuckNorris/Desktop/My\ File.zip');
Copy a single file or a folder from a location to another one.
The result will be a boolean in future.
Usage (JS)
Stz.copyItem_({from:'/Users/ChuckNorris/Documents/File.txt', to:'/Users/ChuckNorris/Desktop/File.zip'});
Check if you can access a file, through Sandbox for example. The result is a Boolean.
Usage (JS)
if (Stz.fileAccessible_('/Users/ChuckNorris/Documents/File.txt') == true) {
alert('Accessible');
} else {
alert('Not accessible');
}
Launch a command line in Terminal. Use three spaces to separate arguments.
Warning : Be careful with this function ! Also I can not guarantee that Apple will love usage of this.
Usage (JS)
Stz.executeShellCmd_({ path:'/usr/bin/open', command:'-e /Users/ChuckNorris/Desktop/File.rtf' });
Launch the execution of a Shell script. Extenstion must be .sh or .command.
Warning : Be careful with this function ! Also I can not guarantee that Apple will love usage of this.
Usage (JS)
Stz.openShellScript_('path/to/script.sh');
Get the path to the main bundle application as string.
Usage (JS)
Stz.pathBundle_();
alert(Stz.pathBundle_());
Get the path to the Resources directory in the main bundle application as string.
Usage (JS)
Stz.pathResources_();
alert(Stz.pathResources_());
Get the path to the current user Documents as string.
Usage (JS)
Stz.pathDocuments_();
alert(Stz.pathDocuments_());
Get the path to the current user Desktop as string.
Usage (JS)
Stz.pathDesktop_();
alert(Stz.pathDesktop_());
Get the system language of the current user. Result is a string, two letters (fr, en, de, ...).
Usage (JS)
alert(Stz.sysLang_());
Should play WAV, AIFF and MP3 files, but some issues appears.
Usage (JS)
Stz.playExternalSound_('/Users/BarackObama/Documents/Sound.wav');
Proceed a GET procedure and catch target content as string. For the moment I have an issue with this API, so you can use a jQuery replacement with XMLHttpRequest.
jQuery replacement
$(document).ready(function () {
var client = new XMLHttpRequest();
client.open('GET', 'http://www.sentenzadesktop.com');
client.onreadystatechange = function () {
if (client.readyState == 4) {
Stz.copyStrToClipboard_(client.responseText);
}
}
client.send();
});
This API will allow you to compress a single file or a folder and his content as ZIP file. Crypted archives with password will be supported.
The result will be a boolean in future.
Usage (JS)
None
This API will allow you to uncompress a ZIP file. Crypted archives with password will be supported.
The result will be a boolean in future.
Usage (JS)
None
Execute an Open dialog and select a file. The selected path will be given as string. This API should be Sandbox compliant...
Usage (JS)
None
Execute a Save dialog. The selected path will be given as string. This API should be Sandbox compliant...
Usage (JS)
None