Skip to content

Commit

Permalink
Merge pull request #523 from yomybaby/serverHostHistory
Browse files Browse the repository at this point in the history
Server host history
  • Loading branch information
dbankier committed Mar 4, 2017
2 parents 77ef384 + 5860349 commit c733180
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 13 deletions.
59 changes: 48 additions & 11 deletions app/Resources/appify.js
Expand Up @@ -7,6 +7,7 @@
* This is a template used when TiShadow "appifying" a titanium project.
* See the README.
*/
var _ = require("/lib/underscore");

Titanium.App.idleTimerDisabled = true;

Expand Down Expand Up @@ -49,18 +50,15 @@ if(Ti.App.deployType !== 'production' && Ti.App.Properties.getString('tishadow_h
var isShakeWinOpened = false;
var win = Ti.UI.createWindow({
backgroundColor : 'white',
title : 'tishadow setting'
title : 'tishadow setting',
layout: 'vertical'
});
win.addEventListener('open', function (e) {
isShakeWinOpened = true;
});
win.addEventListener('close', function (e) {
isShakeWinOpened = false;
});
var view = Ti.UI.createView({
layout: 'vertical',
height : Ti.UI.SIZE
});
var field = Ti.UI.createTextField({
height : 44,
borderColor : 'gray',
Expand All @@ -69,25 +67,64 @@ if(Ti.App.deployType !== 'production' && Ti.App.Properties.getString('tishadow_h
hintText: 'host for tishadow',
textAlign : Ti.UI.TEXT_ALIGNMENT_CENTER,
suppressReturn : true,
color : 'black'
color : 'black',
top : 10
});

var btn = Ti.UI.createButton({
title : 'Save & Close',
left : 40,
right : 40,
height: 44,
top : 44
top : 10
});
var saveAndClose = function () {
Ti.App.Properties.setString('tishadow_host',field.value);
var history = Ti.App.Properties.getList('tishaodw_host_history',[]);
history.unshift(field.value);
history = _.uniq(history);
Ti.App.Properties.setList('tishaodw_host_history',history);
win.close();
};
btn.addEventListener('click', saveAndClose);
field.addEventListener('return', saveAndClose);
view.add(field);
view.add(btn);
win.add(view);

win.add(Ti.UI.createLabel({
font:{
fontSize : 15,
fontWeight : 'bold'
},
text: 'TiShadow Server IP',
top : 30
}))
win.add(field);
win.add(btn);

var listView = Ti.UI.createListView({
defaultItemTemplate : Titanium.UI.LIST_ITEM_TEMPLATE_SUBTITLE
});
var section = Ti.UI.createListSection();
listView.sections = [section];
var items = _.map(Ti.App.Properties.getList('tishaodw_host_history',[]),function (ip) {
return {
properties:{
itemId : ip,
title : ip
}
}
});
var currentIp = Ti.Platform.address;
items.unshift({
properties: {
itemId : currentIp,
title : currentIp,
subtitle : 'Current IP'
}
})
section.items = items;
listView.addEventListener('itemclick', function (e) {
field.value = e.itemId;
});
win.add(listView);

Ti.Gesture.addEventListener('shake', function (e) {
if(isShakeWinOpened == false){
Expand Down
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -2,7 +2,7 @@
"name": "tishadow",
"version": "2.9.0",
"dependencies": {
"archiver": "^0.4.8",
"archiver": "^1.3.0",
"async": "^0.2.10",
"body-parser": "^1.14.1",
"chokidar": "^1.6.0",
Expand All @@ -24,7 +24,7 @@
"socket.io": "^0.9.17",
"socket.io-client": "^0.9.17",
"tiapp": "0.0.3",
"uglify-js": "^2.4.24",
"uglify-js": "^2.7.5",
"underscore": "^1.8.3",
"update-notifier": "^0.1.10",
"wrench": "~1.4.4",
Expand Down

0 comments on commit c733180

Please sign in to comment.