Top of the page
Close

This is a red error

This is a red error

This is a red error

ffsurl.com - URL shortener (something like TinyUrl)

Ondrej Rafaj on 2009.08.12 19:02:44

Attached files
ffsUrl.zip Download

Check this app out, it's quite easy to develop anything in DashCode on a Mac because it's a pure HTML and JavaScript

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);

http://ffsurl.com/

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 :-)

Ondrej Rafaj

Ondrej Rafaj

Independent iPhone developer @ ondrej-rafaj.co.uk

I am available to give you a free quote or start working on your project ... just give me a call or drop a line. Please find all my details on my portfolio site ondrej-rafaj.co.uk

Back to top Comment

Comments ... Why not to get involved!

We had to disable comments till the problem with spam will be solved, sorry for any inconvenience caused.

Back to top

IE SUCKS, DON'T USE IT :) Digg this page