Skip to content

Commit

Permalink
some UI optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierlacot committed Feb 22, 2011
1 parent 9db7cda commit dfccfb8
Show file tree
Hide file tree
Showing 4 changed files with 231 additions and 190 deletions.
19 changes: 14 additions & 5 deletions Resources/js/views/decode.js
Expand Up @@ -8,7 +8,7 @@ if (Titanium.Platform.name != 'android') {
// label and first field
var l1a = Titanium.UI.createLabel({
text:'Short url to decode*',
width:250,
width:260,
height:35,
top:90,
left:30,
Expand All @@ -29,17 +29,19 @@ var tf1 = Titanium.UI.createTextField({
height:35,
top:120,
left:130,
width:150,
width:160,
autocapitalization: Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
clearButtonMode:Titanium.UI.INPUT_BUTTONMODE_ONFOCUS
});

// second label, for the result
var l2 = Titanium.UI.createLabel({
text:'',
width:250,
width:260,
height:90,
left:30,
top:300,
color:'#fff',
textAlign:'left',
Expand All @@ -50,7 +52,7 @@ var l2 = Titanium.UI.createLabel({
var b1 = Titanium.UI.createButton({
title:'Decode this short url',
height:30,
width:250,
width:260,
left:30,
top:200
});
Expand Down Expand Up @@ -89,6 +91,13 @@ Ti.App.addEventListener('xavcc.decode.result', function(event) {
// put the expanded url in the clipboard
Titanium.UI.Clipboard.setText(url);
}

var shorturl = Titanium.App.Properties.getString('site_url', 'http://xav.cc/') + xavcc.trim(tf1.value);

if (Titanium.App.Properties.getBool('use_history', true) && !xavcc.url.has(shorturl)) {
// save in the local database
xavcc.url.save(url, shorturl);
}
} else if (url.length > 0) {
// something went wrong : display an alert message
alert(url);
Expand Down
24 changes: 15 additions & 9 deletions Resources/js/views/encode.js
Expand Up @@ -9,7 +9,7 @@ if (Titanium.Platform.name != 'android') {
// label and first field
var l1 = Titanium.UI.createLabel({
text:'Paste a long url*',
width:250,
width:260,
height:35,
top:40,
left:30,
Expand All @@ -22,11 +22,12 @@ var tf1 = Titanium.UI.createTextField({
height:35,
top:70,
left:30,
width:250,
width:260,
autocapitalization: Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE,
keyboardType:Titanium.UI.KEYBOARD_URL,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
clearButtonMode:Titanium.UI.INPUT_BUTTONMODE_ONFOCUS
});
if (Titanium.UI.Clipboard.hasText() && Titanium.App.Properties.getBool('auto_paste', false)) {
var text = Titanium.UI.Clipboard.getText();
Expand All @@ -38,7 +39,7 @@ if (Titanium.UI.Clipboard.hasText() && Titanium.App.Properties.getBool('auto_pas
// labels and field for the optionnal alias
var l2a = Titanium.UI.createLabel({
text:'Your own alias',
width:250,
width:260,
height:35,
top:120,
left:30,
Expand All @@ -61,7 +62,7 @@ var tf2 = Titanium.UI.createTextField({
height:35,
top:150,
left:130,
width:150,
width:160,
autocapitalization: Titanium.UI.TEXT_AUTOCAPITALIZATION_NONE,
returnKeyType:Titanium.UI.RETURNKEY_DEFAULT,
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED
Expand All @@ -70,7 +71,7 @@ var tf2 = Titanium.UI.createTextField({
// second label, for the result
var l3 = Titanium.UI.createLabel({
text:'',
width:250,
width:260,
height:'auto',
top:300,
color:'#fff',
Expand All @@ -82,7 +83,7 @@ var l3 = Titanium.UI.createLabel({
var b1 = Titanium.UI.createButton({
title:'Shorten this url',
height:30,
width:250,
width:260,
left:30,
top:220
});
Expand Down Expand Up @@ -121,12 +122,17 @@ Ti.App.addEventListener('xavcc.encode.result', function(event) {

if (Titanium.App.Properties.getBool('auto_copy', true)) {
// put the shortened url in the clipboard
alert(Titanium.App.Properties.getBool('auto_copy', true));
Titanium.UI.Clipboard.setText(url);
}

if (Titanium.App.Properties.getBool('use_history', true)) {
info('using history');
}
if (!xavcc.url.has(url)) {
info('do not have the url in memory');
}
if (Titanium.App.Properties.getBool('use_history', true) && !xavcc.url.has(url)) {
// save in the local database
info('saving url ' + url);
var longurl = xavcc.trim(tf1.value);
xavcc.url.save(longurl, url);
}
Expand Down

0 comments on commit dfccfb8

Please sign in to comment.