I've build this website recently, just for fun because I had this PHP library I was using for a different project for a while and I thought that this tool might be quite useful.
Website has a something like a webservice, but it's actually just a script which is generating unique id of the link ... request like that http://ffsurl.com/api/create-url/?url=http://www.example.com/ will return just number 62.
The URL you are passing trough needs to be encoded of course ... in JavaScript I've used the url = encodeURIComponent(url);
The current source code (main.js from the dashcode project) is below. And I've imported jQuery to do all the important stuff.
function getIdCode(event)
{
var url = document.getElementById('myUrl').value;
url = encodeURIComponent(url);
$('#sUrl').val(url);
$.ajax({
type: 'POST',
url: 'http://ffsurl.com/admin/system/tinyurl/ajax/createUrl.php',
data: 'url=' + $('#sUrl').val(),
success: function(id){
$('#newUrl').val('http://ffsurl.com/u' + id + '/');
$('#newUrl').attr('style', 'color: black;');
if (id == 0) {
setMessage('Please enter valid URL');
}
},
error: function(xreq, stErr, err) {
setMessage( 'Data not saved, error: ' + xreq.status + ', ' + xreq.statusText );
}
});
}
function setMessage(text) {
$('#newUrl').val(text);
$('#newUrl').attr('style', 'color: red;');
}
function myGoToFFS(event)
{
// Insert Code Here
}
function myGoToFfsUrl(event)
{
// Insert Code Here
}
Maybe you'll find useful that if you want to access anything on the network from the DashCode you need to allow network access in the Info.plist file. You can do it by adding <key>AllowNetworkAccess</key> with value <true/>. Info.plist file will look something like that:
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict>CFBundleDevelopmentRegion English CFBundleDisplayName ffsUrl CFBundleIdentifier com.ondrej.widget.ffsUrl CFBundleName ffsUrl CFBundleShortVersionString 1.0 CFBundleVersion 1.0 CloseBoxInsetX 15 CloseBoxInsetY 15 Height 182 MainHTML main.html Width 342 <!-- here it starts -->AllowNetworkAccess <true /> <!-- here it ends --> </dict> </plist>
Just download the installer in the top right corner. I'll be happy to hear some feedback from you :-)


