Two Questions(Jiggy)

Discussion in 'Jiggy Runtime Development' started by The Ax, Apr 29, 2008.

  1. The Ax

    The Ax Banned

    Joined:
    Mar 11, 2008
    Messages:
    647
    Likes Received:
    22
    Heres the part of the code I need help with:
    Code:
    Plugins.load( "UIKit" );
    Plugins.load( "FileManager");
    Plugins.load( "Socket" );
    onLoad = function()
    {
      menu.popupAlertAnimated( true );
    }
    var window2 = new UIWindow( UIHardware.fullScreenApplicationContentRect );
    window2.setHidden( true );
    window2.orderFront();
    window2.makeKey();
    window2.backgroundColor = [ 01 , 01 , 01, 01 ];
    var mainView = new UIView();
    window2.setContentView( mainView );
    var menu = new UIAlertSheet("Donate", "OK");
    menu.setTitle("Swap Tools") 
    menu.setAlertSheetStyle(2) 
    menu.setBodyText("The Ax of TouchRevolution");
    menu.setDimsBackground(true) 
    menu.onButtonClicked = function(button){
    if (button == 1)
    menu.dismiss(true);
    }
    
    //***************************************************************************PreferencesTable
    
    // THIS IS THE HARD WAY
    
    // Create the preferences table
    
    var ptable = new UIPreferencesTable( [ + 0 , 40 , window2.bounds[ 2 ] -0 , 420]  );
    
    // Return the number of groups that will be in the table
    
    ptable.onGetNumberOfGroups = function( tbl )
    {
      return 3;
    }
    
    // Return the number of rows in each group
    
    ptable.onGetNumberOfRowsInGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return 3;
        case 1 : return 3;
        case 2 : return 1;
      }
    }
    
    // Tell the table that the third group is a label group
    
    ptable.onIsLabelGroup = function( tbl , group )
    {
      switch( group )
      {
        case 0 : return false;
        case 1 : return false;
        case 2 : return true;
      }
    }
    
    // Now, create the title cells - we only need 2 because the third
    // group is a label
    
    var titleCells = [];
    
    var titleCell;
    
    titleCell = new UIPreferencesTableCell();
    titleCell.title = "Applications";
    
    titleCells.push( titleCell );
    
    titleCell = new UIPreferencesTableCell();
    titleCell.title = "Information";
    
    titleCells.push( titleCell );
    
    titleCell = new UIPreferencesTableCell();
    titleCell.title = "Select an Application to run";
    titleCells.push( titleCell );
    
    // Add the event handler to return the title cells
    
    ptable.onGetCellForGroup = function( tbl , group )
    {
      if ( group >= 0 && group < titleCells.length )
        return titleCells[ group ];
      else
        return null;
    };
    
    // Return row heights
    
    ptable.onGetHeightForRow = function( tbl , group , row , proposedHeight )
    {
      if ( row == -1 )
      {
        // This is the height for title groups
    
        return 50;
      }
    
      if ( group == 0 && row == 2 )
      {
        // We'll make this one taller
    
        return 50;
      }
    
      // Otherwise, we return the height it wants
    
      return proposedHeight;
    };
    
    // Now we have to create the real cells
    
    // We create an array of groups - and each group
    // is an array of cells.
    
    var cells = [ [] , [] , [] ];
    
    var cell;
    var control;
    
    // group 0 , cell 0
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Swap Other";
    cell.setEnabled( true );
    cell.showSelection = true;
    cell.control = control;
    cells[0].push( cell );
    
    // group 0 , cell 1
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Swap Sources";
    cell.setEnabled( true );
    cell.showSelection = true;
    cell.control = control;
    cells[0].push( cell );
    
    // group 0 , cell 2
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Swap Firmware";
    cell.setEnabled( true );
    cell.showSelection = true;
    cell.showDisclosure = true;
    cell.setDisclosureStyle( 1 );
    cell.setUsesBlueDisclosureCircle( true );
    cell.setEnabled( true );
    cells[0].push( cell );
    
    // group 1 , cell 0
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Informational(F.A.Q.)";
    cell.showSelection = true;
    cells[1].push( cell );
    
    // group 1 , cell 1
    
    cell = new UIPreferencesControlTableCell();
    cell.title = "Donate";
    cell.showSelection = true;
    cell.control = control;
    cells[ 1 ].push( cell );
    
    // group 1 , cell 2
    
    cell = new UIPreferencesTextTableCell();
    cell.title = "Version:";
    cell.setEnabled( false );
    cell.value = "0.1(Pre Beta)";
    cell.showSelection = false;
    
    cells[ 1 ].push( cell );
    
    
    // group 2 , cell 0
    
    cell = new UIPreferencesTableCell();
    cell.title = "Made by:The Ax                     \nMember of: Touch Revolution";
    
    cells[ 2 ].push( cell );
    
    // Attach the event handler to dole out the cells
    
    ptable.onGetCell = 
      function( tbl , group , row )
      {
        return cells[ group ][ row ];
      };
    
    // And LOAD the table!
    
    ptable.reloadData();
    
    window2.addSubview( ptable );
    //***************************************************************************NavagationBar
    var bar = new UINavigationBar( [ 0 , 0 , window2.bounds[ 2 ] , 40 ] );
    bar.showButtonsWithStyle( "Respring"  , 1 , "    " , 4 ) 
    bar.setBarStyle(1) 
    mainView.addSubview( bar );
    var itemOne = new UINavigationItem( "Swap Tools" );
    bar.pushNavigationItem( itemOne );
    bar.onButtonClicked = 
    function( theBar , theButton )
    {
    if ( theButton == 1 )
    {
    executeShellCommand("launchctl stop com.apple.SpringBoard") 
    }
    if ( theButton == 0 )
    {
    {include("Help.js");}
    }
    }
    //***************************************************************************EndScript
    My Questions are
    1. How do I make the buttons in the prefs table open a new .js file.
    2. How do I make the buttons in the prefs table move a file and overwrite existing.​
  2. C0DeR_4_liFe

    C0DeR_4_liFe New Member

    Joined:
    Mar 3, 2008
    Messages:
    132
    Likes Received:
    10
    Device:
    iPod touch
    stop with these jiggy examples!!!
  3. Mint-Berry Crunch

    Mint-Berry Crunch Member

    Joined:
    Sep 19, 2007
    Messages:
    776
    Likes Received:
    7
    Device:
    iPhone 6 Plus
    The examples are good starting points for beginners.
  4. gojohnnyboi

    gojohnnyboi Well-Known Member

    Joined:
    Jan 25, 2008
    Messages:
    3,339
    Likes Received:
    55
    Ok, to assaign any function to a cell being pressed, you must use a delegate mehtod for preferencesTableCell selected
  5. The Ax

    The Ax Banned

    Joined:
    Mar 11, 2008
    Messages:
    647
    Likes Received:
    22
    Ok. Thst worked. But say I have 2 groups.

    If(Row=1)
    {include(main.js);}

    I want
    if (group=2 && row=1)
    {include(ggggh.js);}

    But that doesn't work

    On iPod

Share This Page