Created
April 29, 2014 02:06
-
-
Save exclusiveTanim/11389131 to your computer and use it in GitHub Desktop.
Site manager project
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Ti.UI.createWindow({ | |
layout : 'vertical', | |
title : 'login Window', | |
backgroundColor : "#000" | |
}); | |
// Create a Label. | |
var name = Ti.UI.createLabel({ | |
text : 'Enter your user ID:', | |
color : '#FFF', | |
font : { | |
fontSize : 15 | |
}, | |
height : Ti.UI.SIZE, | |
width : Ti.UI.SIZE, | |
top : 130, | |
left : 10, | |
}); | |
// Add to the parent view. | |
win.add(name); | |
// Create a TextField. | |
var aTextField = Ti.UI.createTextField({ | |
height : 45, | |
top : 10, | |
left : 10, | |
width : Ti.UI.FILL, | |
hintText : 'Insert user name', | |
softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS, // Android only | |
keyboardType : Ti.UI.KEYBOARD_DEFAULT, | |
returnKeyType : Ti.UI.RETURNKEY_DEFAULT, | |
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED | |
}); | |
win.add(aTextField); | |
var password = Ti.UI.createLabel({ | |
text : 'Enter your password:', | |
color : '#FFF', | |
font : { | |
fontSize : 15 | |
}, | |
height : Ti.UI.SIZE, | |
width : Ti.UI.SIZE, | |
top : 10, | |
left : 10, | |
}); | |
win.add(password); | |
// Create a TextField. | |
var bTextField = Ti.UI.createTextField({ | |
height : 45, | |
top : 10, | |
left : 10, | |
width : Ti.UI.FILL, | |
passwordMask : 'true', | |
hintText : 'Insert valid password', | |
softKeyboardOnFocus : Ti.UI.Android.SOFT_KEYBOARD_DEFAULT_ON_FOCUS, // Android only | |
keyboardType : Ti.UI.KEYBOARD_DEFAULT, | |
returnKeyType : Ti.UI.RETURNKEY_DEFAULT, | |
borderStyle : Ti.UI.INPUT_BORDERSTYLE_ROUNDED | |
}); | |
win.add(bTextField); | |
// Create a Button. | |
var btn = Ti.UI.createButton({ | |
title : 'login', | |
height : Ti.UI.SIZE, | |
width : Ti.UI.SIZE, | |
top : 10, | |
right : 10 | |
}); | |
// Listen for click events. | |
btn.addEventListener('click', function() { | |
var win2 = require('ui/common/viewdata'); | |
var info = new win2(); | |
var user = aTextField.value; | |
var pass = bTextField.value; | |
if (user == 'admin' && pass == '12345') { | |
info.open(); | |
} else { | |
alert('Insert valid user and password'); | |
aTextField.value = ''; | |
bTextField.value = ''; | |
} | |
}); | |
// Add to the parent view. | |
win.add(btn); | |
win.open(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var db = Ti.Database.open('information'); | |
db.execute('CREATE TABLE IF NOT EXISTS info(id integer PRIMARY KEY autoincrement not null,name TEXT,password TEXT,link TEXT)'); | |
db.close(); | |
exports.add = function(name, password, link) { | |
var db = Ti.Database.open('information'); | |
db.execute('INSERT INTO info (name,password,link) VALUES(?,?,?)', name, password, link); | |
db.close(); | |
Ti.API.info(''); | |
alert('data insert successfull'); | |
}; | |
exports.getinfo = function() { | |
var stuInfo = []; | |
var db = Ti.Database.open('information'); | |
var result = db.execute('select * from info where name IS NOT NULL'); | |
while (result.isValidRow()) { | |
stuInfo.push({ | |
name : result.fieldByName('name'), | |
password : result.fieldByName('password'), | |
link : result.fieldByName('link'), | |
id : result.fieldByName('id'), | |
}); | |
result.next(); | |
} | |
result.close(); | |
db.close(); | |
//Ti.API.info('stuInfo'+ stuInfo); | |
return stuInfo; | |
}; | |
exports.getinformation = function(ids) { | |
var detailinfo = []; | |
var db = Ti.Database.open('information'); | |
var result = db.execute('select * FROM info where id=?', ids); | |
while (result.isValidRow()) { | |
detailinfo.push({ | |
name : result.fieldByName('name'), | |
password : result.fieldByName('password'), | |
link : result.fieldByName('link'), | |
id : result.fieldByName('id'), | |
}); | |
result.next(); | |
} | |
result.close(); | |
db.close(); | |
//Ti.API.info('stuInfo'+ stuInfo); | |
return detailinfo; | |
}; | |
exports.updateinfo = function(name,password,link, id) { | |
var db = Ti.Database.open('information'); | |
db.execute('UPDATE info set name=?,password=?,link=? where id=?', name,password,link, id); | |
db.close(); | |
}; | |
exports.deletinfo = function(a) { | |
var db = Ti.Database.open('information'); | |
db.execute('DELETE FROM info where id=?', a); | |
db.close(); | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function viewdata() { | |
var win = Ti.UI.createWindow({ | |
layout : 'vertical', | |
title : 'View Data Window', | |
backgroundColor : "#fff" | |
}); | |
var view = Titanium.UI.createView({ | |
borderRadius : 1, | |
backgroundColor : 'red', | |
width : Ti.UI.FILL, | |
height : 50, | |
}); | |
win.add(view); | |
var viewinfo = Ti.UI.createLabel({ | |
text : 'Information View', | |
color : 'blue', | |
textAlign : "center", | |
font : { | |
fontSize : 25 | |
}, | |
height : Ti.UI.SIZE, | |
width : Ti.UI.SIZE, | |
}); | |
view.add(viewinfo); | |
var add = Ti.UI.createButton({ | |
backgroundImage : "/image/addDefault.png", | |
//color : 'blue', | |
textAlign : "center", | |
height : 35, | |
width : 35, | |
right : 5 | |
}); | |
view.add(add); | |
var chng = Ti.UI.createButton({ | |
backgroundImage : "/image/pass.jpg", | |
//color : 'blue', | |
textAlign : "center", | |
height : 35, | |
width : 35, | |
left : 5 | |
}); | |
view.add(chng); | |
add.addEventListener('click', function(e) { | |
var win4 = require('ui/common/info'); | |
//var t = "false"; | |
//alert(f); | |
var info = new win4(); | |
info.open(); | |
}); | |
//............... Create a TableView............... | |
var tableData = []; | |
var tableView = Ti.UI.createTableView({ | |
data : tableData, | |
top : 20, | |
}); | |
Ti.App.addEventListener('tableUpdate', refresh); | |
refresh(); | |
function refresh() { | |
tableData = []; | |
var db = require('DB/tableViewDb'); | |
var infoData = db.getinfo(); | |
for (var i = 0; i < infoData.length; i++) { | |
var row = Ti.UI.createTableViewRow({ | |
className : 'forumEvent', // used to improve table performance | |
selectedBackgroundColor : 'white', | |
rowIndex : i, // custom property, useful for determining the row during events | |
height : 'auto', | |
name : infoData[i].name, | |
password : infoData[i].password, | |
link : infoData[i].link, | |
id : infoData[i].id, | |
}); | |
//alert(infoData[i].id); | |
var name = Ti.UI.createLabel({ | |
color : 'red', | |
font : { | |
fontFamily : 'Arial', | |
fontSize : 20, | |
fontWeight : 'normal' | |
}, | |
text : infoData[i].name, | |
id : "names", | |
left : 10, | |
right : 75 | |
}); | |
row.add(name); | |
var edit = Ti.UI.createButton({ | |
backgroundImage : "/image/5_content_edit.png", | |
//title : 'Delete', | |
height : 30, | |
width : 30, | |
right : 10, | |
id : "edit", | |
myrow : row | |
}); | |
row.add(edit); | |
tableData.push(row); | |
} | |
tableView.setData(tableData); | |
} | |
tableView.addEventListener('longpress', function(e) { | |
// e.source.hasCheck = true, | |
if (e.source.id == "names") { | |
var newData = e.rowData.id; | |
var nid = Ti.App.Properties.setString('nid', newData); | |
//alert('id='+newData); | |
var dialog = Ti.UI.createAlertDialog({ | |
cancel : 1, | |
buttonNames : ['Confirm', 'Cancel'], | |
message : 'Would you like to delete the file?', | |
title : 'Warning' | |
}); | |
dialog.addEventListener('click', function(e) { | |
if (e.index === e.source.cancel) { | |
} else { | |
// tableView.deleteRow(e.source.myrow); | |
var db = require('DB/tableViewDb'); | |
//alert(e.source); | |
var udid = Ti.App.Properties.getString('nid'); | |
db.deletinfo(udid); | |
Ti.App.fireEvent('tableUpdate'); | |
} | |
}); | |
dialog.show(); | |
} else { | |
var db = require('DB/tableViewDb'); | |
var name = e.rowData.name; | |
//aTextField.setValue(name); | |
var dd = e.rowData.id; | |
var id = Ti.App.Properties.setString('id', dd); | |
} | |
}); | |
tableView.addEventListener('click', function(e) { | |
if (e.source.id == "edit") { | |
//alert('I am Edit'); | |
var win4 = require('ui/common/update'); | |
var a = e.rowData.id; | |
var b = e.rowData.name; | |
var c = e.rowData.password; | |
var d = e.rowData.link; | |
var info = new win4(a,b,c,d); | |
info.open(); | |
} | |
}); | |
tableView.addEventListener('click', function(e) { | |
if (e.source.id == "names") { | |
var win4 = require('ui/common/ViewInDelails'); | |
var a = e.rowData.id; | |
//alert(a); | |
var info = new win4(a); | |
info.open(); | |
} | |
}); | |
//................End....... | |
//view.add(tableView); | |
// win.add(view); | |
win.add(tableView); | |
return win; | |
} | |
module.exports = viewdata; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function viewindetails(ids) { | |
var win = Ti.UI.createWindow({ | |
layout : 'vertical', | |
title : 'View Data In Details', | |
backgroundColor : "#663399" | |
}); | |
//alert(ids); | |
var viewinfo = Ti.UI.createLabel({ | |
text : 'Information View in Details:', | |
color : 'red', | |
font : { | |
fontSize : 20 | |
}, | |
height : Ti.UI.SIZE, | |
width : Ti.UI.SIZE, | |
top : 10, | |
left : 10, | |
right : 10 | |
}); | |
win.add(viewinfo); | |
//............... Create a TableView............... | |
var tableData = []; | |
var tableView = Ti.UI.createTableView({ | |
data : tableData, | |
top : 20, | |
}); | |
Ti.App.addEventListener('tableUpdate', refresh); | |
refresh(); | |
function refresh() { | |
tableData = []; | |
var db = require('DB/tableViewDb'); | |
//Ti.api.info("IDs="+ids); | |
var infoData = db.getinformation(ids); | |
for (var i = 0; i < infoData.length; i++) { | |
var row = Ti.UI.createTableViewRow({ | |
className : 'forumEvent', // used to improve table performance | |
selectedBackgroundColor : 'white', | |
rowIndex : i, // custom property, useful for determining the row during events | |
height : 'auto', | |
name : infoData[i].name, | |
password : infoData[i].password, | |
id : infoData[i].id, | |
link : infoData[i].link, | |
}); | |
var view = Ti.UI.createView({ | |
layout : "vertical" | |
}); | |
//alert(infoData[i].id); | |
var name = Ti.UI.createLabel({ | |
color : 'gray', | |
font : { | |
fontFamily : 'Arial', | |
fontSize : 20, | |
fontWeight : 'normal' | |
}, | |
text : "Name :" + infoData[i].name, | |
left : 10, | |
top : 5, | |
}); | |
view.add(name); | |
var password = Ti.UI.createLabel({ | |
color : 'red', | |
font : { | |
fontFamily : 'Arial', | |
fontSize : 20, | |
fontWeight : 'normal' | |
}, | |
text : "Password:" + infoData[i].password, | |
top : 10, | |
left : 10, | |
}); | |
view.add(password); | |
var link = Ti.UI.createLabel({ | |
color : 'white', | |
font : { | |
fontFamily : 'Arial', | |
fontSize : 20, | |
fontWeight : 'normal' | |
}, | |
text : "URL :" + infoData[i].link, | |
left : 10, | |
top : 10, | |
}); | |
var alink=infoData[i].link; | |
link.addEventListener('click', function() { | |
Ti.Platform.openURL("http://"+alink); | |
}); | |
view.add(link); | |
row.add(view); | |
// row.add(password); | |
// row.add(link); | |
tableData.push(row); | |
} | |
tableView.setData(tableData); | |
} | |
win.add(tableView); | |
return win; | |
} | |
module.exports = viewindetails; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment