Monday, December 19, 2011

Titanium Table creation with click event


http://developer.appcelerator.com/question/122206/double-click-textfield-in-tableview-to-fire-click-event
win = Titanium.UI.createWindow({
    backgroundColor:'white',
    fullscreen:false
});
 
tableView = Titanium.UI.createTableView();
 
var dataArray = [];
for(var i=0; i<10; i++){
    var row = Titanium.UI.createTableViewRow();
 
    var label = Titanium.UI.createLabel({
        text:'THIS IS LABEL  ' + i,
        width:100,
        height:'auto'
    });
    var textBox = Titanium.UI.createTextField({
        right:5,
        width:30
    })
 
    row.add(label);
    row.add(textBox);
 
    dataArray.push(row);
}
 
var lastRow;
tableView.addEventListener('click', function(e){
    lastRow = e.row;
    if(lastRow){
        lastRow.backgroundColor='white';
    }
    e.row.backgroundColor='red';
})
 
 
tableView.setData(dataArray);
 
win.add(tableView);
win.open();

titanium Tableview Supported Links

http://developer.appcelerator.com/question/118419/how-to-get-rowdata-from-custom-tableviewrow

alert(e.row.children[0].text);


var thisRow = Ti.UI.createTableViewRow({
        className:"itemOptions",
        layout:"vertical",
        height:50,
        myProperty1:'somevalue',
        myProperty2:1234
        });

table.addEventListener('click', function(e) {
  alert(e.rowData.myProperty1);
});

http://developer.appcelerator.com/question/96441/passing-row-data-to-new-widow


Saturday, December 17, 2011

Titanium Appcelerator Web services method like AJAX

https://wiki.appcelerator.org/display/guides/HTTPClient+and+the+Request+Lifecycle


GET

var url = "https://www.appcelerator.com" ;
var xhr = Ti.Network.createHTTPClient({
    onload: function(e) {
        // this function is called when data is returned from the server and available for use
        // this.responseText holds the raw text return of the message (used for text/JSON)
        // this.responseXML holds any returned XML (including SOAP)
        // this.responseData holds any returned binary data
        Ti.API.debug(this.responseText);
        alert('success');
    },
    onerror: function(e) {
        // this function is called when an error occurs, including a timeout
        Ti.API.debug(e.error);
        alert('error');
    },
    timeout:5000  /* in milliseconds */
});
xhr.open("GET", url);
xhr.send();  // request is actually sent with this statement




POST


var xhr = Ti.Network.createHTTPClient();

xhr.onload = function(e) {
    //handle response, which at minimum will be an HTTP status code
};

xhr.open('POST','http://www.myblog.com/post.php' );
xhr.send({
    title:'My awesome blog',
    body:'Today I met Susy at the laundromat.  Best day EVAR\!'
});




Ready State Monitoring


var xhr = Ti.Network.createHTTPClient({
    onload: function(e) {
        // function called in readyState DONE (4)
        Ti.API.info('onload called, readyState = '+this.readyState);
    },
    onerror: function(e) {
        // function called in readyState DONE (4)
        Ti.API.info('onerror called, readyState = '+this.readyState);
    },
    ondatastream: function(e) {
        // function called as data is downloaded
        Ti.API.info('ondatastream called, readyState = '+this.readyState);
    },
    onsendstream: function(e) {
        // function called as data is uploaded
        Ti.API.info('onsendstream called, readyState = '+this.readyState);
    },
    onreadystatechange: function(e) {
        switch(this.readyState) {
            case 0:
                // after HTTPClient declared, prior to open()
                // though Ti won't actually report on this readyState
                Ti.API.info('case 0, readyState = '+this.readyState);
            break;
            case 1:
                // open() has been called, now is the time to set headers
                Ti.API.info('case 1, readyState = '+this.readyState);
            break;
            case 2:
                // headers received, xhr.status should be available now
                Ti.API.info('case 2, readyState = '+this.readyState);
            break;
            case 3:
                // data is being received, onsendstream/ondatastream being called now
                Ti.API.info('case 3, readyState = '+this.readyState);
            break;
            case 4:
                // done, onload or onerror should be called now
                Ti.API.info('case 4, readyState = '+this.readyState);
            break;
        }
    },
    timeout:5000  /* in milliseconds */
});
xhr.open("GET", 'http://training.appcelerator.com.s3.amazonaws.com/atp_doc.pdf');
xhr.send();  // request is actually sent with this statement



Titanium Appcelerator Remember me

http://developer.appcelerator.com/question/117952/remember-me--session-implementation


Ti.App.Properties.setString('login_name','kamal');
my_property_value = Ti.App.Properties.getString('login_name');

If it's never been set before it will naturally return undefined.
You can also set booleans, integers, lists and doubles. See : http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.App.Properties-module
hope this helps! ;)
As commented, hopefully your app is posting the login to the server securely. If you don't have https, there are some cunning ways to use MD5 to create a 'challenge and response' pair of hashes on login (etc.) which is pretty secure.




Friday, December 9, 2011

Drupal set different theme for admin only

Go to Administer > Site configuration > Administration theme.

Tuesday, December 6, 2011

Drupal 6 Installation Error Solved

Warning: ini_set() has been disabled for security reasons


Try some of these:
Open .htaccess file in your Drupal install. Near the top, put a '#' before 'Options +FollowSymLinks' (# Options +FollowSymLinks).
Create a text/notepad file called 'php.ini' and put inside it 'register_globals = 0'. Put this file straight in public_html (main/root directory)


http://drupal.org/node/842316

fopen and modifying header errors

when I was having problems I had simply renamed default.settings.php. So I went back and copied that file and renamed it so I had default.settings.php and settings.php and it worked

http://drupal.org/node/284063


Friday, December 2, 2011

Check Too many connection issues for MYSQL

-- This command will return you the value of max_connections variable
SHOW VARIABLES LIKE '%max_connections%';

-- This command will show you all processes and connections.
SHOW FULL PROCESSLIST;


http://www.microshell.com/database/mysql/mysql-too-many-connection-errors/

http://dev.mysql.com/doc/refman/5.5/en/too-many-connections.html

http://dev.mysql.com/doc/refman/5.5/en/show-processlist.html



Thursday, December 1, 2011

Fb Like Button

<div dir="ltr" style="text-align: left;" trbidi="on">

<script src="http://connect.facebook.net/en_US/all.js#xfbml=1">
</script>

<div style="float: right; padding-right: 80px; padding-top: 125px; text-align: center; width: 100px;">
<div id="fb-root">
</div>
<fb:like font="" href="http://www.facebook.com/pages/Suba-Muhurtham-Matrimony/254980637898369" layout="button_count" send="false" show_faces="false" width="200"></fb:like></div>

</div>

Monday, November 28, 2011

Titanium Appcelerator Password field creation


var formElement = Titanium.UI.createTextField({
  value: "",
  width: 100,
  height: "auto",
  hintText: "Password",
  passwordMask: true
});

Thursday, November 17, 2011

Titanium Android Iphone Text Field submit

// this sets the background color of the master UIView (when there are no windows/tab groups on it)
Titanium.UI.setBackgroundColor('#000');

// create tab group
var tabGroup = Titanium.UI.createTabGroup();


//
// create base UI tab and root window
//
var win1 = Titanium.UI.createWindow({
title:'Tab 1',
backgroundColor:'#fff',
tabBarHidden:true
});
var tab1 = Titanium.UI.createTab({
icon:'KS_nav_views.png',
title:'Tab 1',
window:win1
});

var input_1 = Titanium.UI.createTextField({
color:'#787878',
height:45,
top:20,
width:250,
hintText:'test hint',
borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
});
win1.add(input_1);

var button1 = Titanium.UI.createButton( {
title : "Go",
top: 150,
width: 200,
height: 44
});
win1.add(button1);
button1.addEventListener('click', function (e){
alert('Hello \n You have logged in with a username of '+input_1.value+'.');
});

//
// add tabs
//
tabGroup.addTab(tab1);


// open tab group
tabGroup.open();

Thursday, October 27, 2011

Android app.js code for blog rss

Titanium.UI.setBackgroundColor('#000');

var win = Titanium.UI.createWindow({  
    title:'Query7 RSS Feed',
    backgroundColor:'#000'
});

var data = [];

// create table view
var tableview = Titanium.UI.createTableView({
 data:data,
 headerTitle: 'Query7 RSS',
 backgroundColor:'#000'
});

win.add(tableview);


var xhr = Titanium.Network.createHTTPClient();

xhr.onload = function()
{
 
 try
 {
  var doc = this.responseXML.documentElement;
  var items = doc.getElementsByTagName('item');
  var doctitle = doc.evaluate("//channel/title/text()").item(0).nodeValue;
  
  var urls = new Array();
  
  for(var c=0; c>>>>' + e.index);

   var intent = Titanium.Android.createIntent({
   
    action: Titanium.Android.ACTION_VIEW,
    data: urls[e.index],
   
   });
   
   intent.addCategory(Titanium.Android.CATEGORY_BROWSABLE);
   Ti.Android.currentActivity.startActivity(intent);
   
   
   });
  
   tableview.appendRow(row);
   

   
  }
 
 }
 catch(E)
 {
  alert(E);
 }
 
};

xhr.open('GET', 'http://feeds.feedburner.com/query7blog.rss');
xhr.send();

win.open();

http://query7.com/titanium-mobile-android-development-first-application

Android JSON data extract

http://stackoverflow.com/questions/7722830/unable-to-delete-data-from-json-object-in-titanium

http://stackoverflow.com/questions/7526860/unable-to-connect-to-json-service-in-android-application-of-titanium-studio



alert(jsontext.feeds[0].username) // abc

  // shift the beginning of the array
  jsontext.feeds.shift();

alert(jsontext.feeds[0].username) //bcd  ?