IUISectionList Launching Applications

Discussion in 'Jiggy Runtime Development' started by guaxinim, Jun 24, 2008.

  1. guaxinim

    guaxinim New Member

    Joined:
    Jan 25, 2008
    Messages:
    6
    Likes Received:
    0
    Hi people,

    I need help to make a Applications list to launch the chossen Applications. This is the code:

    Code:
    include( 'iuikit.js' );
    
    var window = new IUIWindow();
    var mainView = new UIView( window.bounds );
    
    window.setContentView( mainView );
    
    var appTable = new IUISectionList( [ 0 , 0 , 320 , 480] , mainView );
    
    var appList = dir_list( '/Applications/' );
    
    var sectionKeys = {
    A: 0, B: 1, C: 2, D: 3, E: 4, F: 5, G: 6,
    H: 7, I: 8, J: 9, K: 10, L: 11, M: 12, N: 13,
    O: 14, P: 15, Q: 16, R: 17, S: 18, T: 19,
    U: 20, V: 21, W: 22, X: 23, Y: 24, Z: 25, 123: 26,
    a: 0, b: 1, c: 2, d: 3, e: 4, f: 5, g: 6,
    h: 7, i: 8, j: 9, k: 10, l: 11, m: 12, n: 13,
    o: 14, p: 15, q: 16, r: 17, s: 18, t: 19,
    u: 20, v: 21, w: 22, x: 23, y: 24, z: 25
    };
    
    var sections = ['A','B','C','D','E','F','G','H','I','J','K','L','M ','N','O','P','Q','R','S','T','U','V','W','X','Y', 'Z','123'];
    
    for( var i = 0; i < sections.length; i++ ) {
    
    appTable.addSection({
    title: sections[ i ]
    });
    
    }
    
    for( var i = 0; i < appList.length; i++ ) {
    var myLetter = appList[ i ].substr( 0 , 1 );
    var mySection = eval( 'sectionKeys.' + myLetter );
    
    appTable.addRow({
    title: appList[ i ].replace( /.app/g , '' ),
    section: mySection
    });
    
    }
    (Made by geekygoodness)
  2. Ryan

    Ryan Well-Known Member

    Joined:
    Jan 19, 2008
    Messages:
    4,129
    Likes Received:
    28
    Device:
    Nexus 4
    Try this, not sure if it will work though

    appTable.onRowSelected = function( tbl , row )
    {
    what u want to do
    }
  3. rob spriggs

    rob spriggs New Member

    Joined:
    Jan 26, 2008
    Messages:
    28
    Likes Received:
    0
    hi, i am having the same problem, i have the tried inserting the code that was suggested from thehitman, not sure where i should insert this bit of code though, if any one could help in this matter that would be great.

    thanks in advance
  4. pabloppp

    pabloppp New Member

    Joined:
    Feb 21, 2008
    Messages:
    53
    Likes Received:
    0
    I try yhis:

    appTable.onSelected = 'myfunction'; function myfunction( tbl , row )
    {
    alert("You Chose " + appList)
    }

    but I get: "You Choose undefined"
    Any help?
  5. PAEz

    PAEz New Member

    Joined:
    Jan 29, 2008
    Messages:
    201
    Likes Received:
    10
    i isnt defined
    ...try...
    alert("You Chose " + appList[row])
  6. pabloppp

    pabloppp New Member

    Joined:
    Feb 21, 2008
    Messages:
    53
    Likes Received:
    0
    i get exactly the samething...
  7. PAEz

    PAEz New Member

    Joined:
    Jan 29, 2008
    Messages:
    201
    Likes Received:
    10
    sorry bout that, try....
    appTable.onSelected = 'myfunc';myfunc=function ( row )
    {
    alert("You Chose " + appList[row])
    }
    ....that will work, I tested it this time

    Please Register or Log in to view images

  8. pabloppp

    pabloppp New Member

    Joined:
    Feb 21, 2008
    Messages:
    53
    Likes Received:
    0
    Thank you veeery much!
    Now I can finish my application!
  9. PAEz

    PAEz New Member

    Joined:
    Jan 29, 2008
    Messages:
    201
    Likes Received:
    10
    Oh
    and you might wanna use this code instead.....

    Code:
    include( 'iuikit.js' );
    
    var window = new IUIWindow();
    var mainView = new UIView( window.bounds );
    
    window.setContentView( mainView );
    
    var appTable = new IUISectionList( [ 0 , 0 , 320 , 480] , mainView );
    
    var appList = dir_list( '/Applications/' );
    
    var sections = new Array();
    
    for( var i in appList){
      sections.push( appList[ i ].substr( 0 , 1 ) );
    }
    
    sections = array_unique( sections );
    
    for( var i in sections ) {
      appTable.addSection({
        title: sections[ i ]
      });
    }
    
    for( var i in appList){
      var s = appList[ i ].substr( 0 , 1 );
      
      for( var a in sections ){
        if( sections[ a ] == s ) {
          s = a;
          break;
        } else {
          continue;
        }
      }
      
      appTable.addRow({
        title: appList[ i ],
        data: { dir: appList[ i ]  },
        section: a
      });
    }
    
    appTable.onSelected = 'myfunc';myfunc=function ( row )
    {
    alert("You Chose " + appList[row])
    }
    appTable.reload();
    ...it does the same thing, comes from the same place (geekgoodnes, the iTab app), but it can handle numbers which the other can't.
    I think the reason the other one can't handle numbers is because of this line...
    var mySection = eval( 'sectionKeys.' + myLetter );
    ...variables in java script cant start with a number.....
    http://www.w3schools.com/js/js_variables.asp
  10. pabloppp

    pabloppp New Member

    Joined:
    Feb 21, 2008
    Messages:
    53
    Likes Received:
    0
    Thankyou very much!!!!!!!
    You solved my problem!

Share This Page