User Tools

Site Tools


sample_code:database_navigate

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
sample_code:database_navigate [2015/04/17 00:44]
yep created
sample_code:database_navigate [2015/04/23 20:59] (current)
Line 1: Line 1:
-**Application: Droidscript databases**.+======Application: view Droidscript databases======
 I created this simple application to learn and play Databases and Dialogs I created this simple application to learn and play Databases and Dialogs
-  * Identify the sqlite databases in the default folder.+  * Identify the sqlite databases in the default folder used by Droidscript(var target)
   * List the tables   * List the tables
   * List Columns of tables   * List Columns of tables
Line 7: Line 7:
   * And could also delete a database   * And could also delete a database
  
- --- //[[bis40@free.fr|thierry DERICK]] 2015/04/17 00:40// 
  
- +On My local Version, I have also 3 icons in subdirectory Img/ 
 + 
 +The code is now both for icons or text... see the 3 tCol 
 + 
 +And if you do not have a database, use the Sample, and verify the database : MyData.  
 + 
 +enjoy. Sorry few French comments. 
 + 
 +<code JavaScript AdminDB.js>
  
 // thierry . 2015 04 15 // thierry . 2015 04 15
Line 75: Line 82:
   remindColumn.SetTextColor( colorTitle );   remindColumn.SetTextColor( colorTitle );
          
- //tColGauche=app.CreateText("db files",0.33); +  // titles 3 columns,  text or image if found 
- tColGauche= app.CreateImage("Img/database.png",0.07); +  colorTitle="#0033dd"; 
 +  if (app.FileExists( "Img/database.png")){ 
 +    tColGauche= app.CreateImage("Img/database.png",0.07);  
 +    tColGauche.SetMargins( 0.1,0.003,0,0.004 );  
 +  } else { 
 +    tColGauche=app.CreateText("db files",0.33); 
 +    tColGauche.SetTextColor( colorTitle ); 
 +  }
   lh1.AddChild(tColGauche);   lh1.AddChild(tColGauche);
-  tColGauche.SetMargins( 0.1,0.003,0,0.004 );  +    tColGauche.SetOnTouch( btnD_OnTouch ); 
-  tColGauche.SetOnTouch( btnD_OnTouch ); +   
- //tColCentre=app.CreateText("tables",0.33); +  if (app.FileExists( "Img/table.png")){ 
- tColCentre=app.CreateImage("Img/table.png",0.07);+    tColCentre=app.CreateImage("Img/table.png",0.07);  
 +    tColCentre.SetMargins( 0.29,0.003,0.29,0.004 ); 
 +   } else { 
 +    tColCentre=app.CreateText("tables",0.33); 
 +    tColCentre.SetTextColorcolorTitle ); 
 +  }
   lh1.AddChild(tColCentre);   lh1.AddChild(tColCentre);
-  tColCentre.SetMargins( 0.29,0.003,0.29,0.004 ); +    tColCentre.SetOnTouchbtnT_OnTouch ); 
-  tColCentre.SetOnTouch( btnT_OnTouch ); +     
- //tColDroite=app.CreateText("column",0.33); + if (app.FileExists( "Img/column.png")){ 
- tColDroite=app.CreateImage("Img/column.png",0.07);+    tColDroite=app.CreateImage("Img/column.png",0.07);  
 +    tColDroite.SetMargins( 0,0.003,0.1,0.004 ); 
 +   } else { 
 +    tColDroite=app.CreateText("column",0.33); 
 +    tColDroite.SetTextColorcolorTitle ); 
 +  }
   lh1.AddChild(tColDroite);   lh1.AddChild(tColDroite);
-  tColDroite.SetMargins( 0,0.003,0.1,0.004 );  +    tColDroite.SetOnTouch( btnF_OnTouch ); 
-  tColDroite.SetOnTouch( btnF_OnTouch ); +     
-  //var colorTitle="#0033dd"; +
-  //tColGauche.SetTextColor( colorTitle ); +
-  //tColCentre.SetTextColor( colorTitle ); +
-  //tColDroite.SetTextColor( colorTitle ); +
-  +
  // faire des listes  // faire des listes
  lstLeft = app.CreateList( "", 0.7, 0.6 );   lstLeft = app.CreateList( "", 0.7, 0.6 ); 
Line 113: Line 133:
   //Create buttons width columns.   //Create buttons width columns.
  btnD = app.CreateButton( "Db", 0.3 ,-1,"alumn");  btnD = app.CreateButton( "Db", 0.3 ,-1,"alumn");
-   //lh3.AddChild( btnD );+   lh3.AddChild( btnD );
    btnD.SetOnTouch( btnD_OnTouch );    btnD.SetOnTouch( btnD_OnTouch );
  btnT = app.CreateButton( "Table", 0.3 ,-1,"alumn");  btnT = app.CreateButton( "Table", 0.3 ,-1,"alumn");
-   //lh3.AddChild( btnT );+   lh3.AddChild( btnT );
    btnT.SetOnTouch( btnT_OnTouch );    btnT.SetOnTouch( btnT_OnTouch );
  btnF = app.CreateButton( "Column", 0.3 ,-1,"alumn");  btnF = app.CreateButton( "Column", 0.3 ,-1,"alumn");
-   //lh3.AddChild( btnF );+   lh3.AddChild( btnF );
    btnF.SetOnTouch( btnF_OnTouch );    btnF.SetOnTouch( btnF_OnTouch );
    
Line 150: Line 170:
  
  
-function emptyList(list) {+function emptyListSlow(list) {
  // pas certain des separateurs: virgule ou CR ou autre?  // pas certain des separateurs: virgule ou CR ou autre?
  var itemString=list.GetList(",");  var itemString=list.GetList(",");
Line 163: Line 183:
  }  }
 } }
 +function emptyList(list)  {
 +  // I learnt this is possible 
 +  list.SetList("") ;
 + 
  
  
Line 198: Line 222:
    //layDlg.SetPadding( 0.02, 0, 0.02, 0.02 );    //layDlg.SetPadding( 0.02, 0, 0.02, 0.02 );
    dlgTxt.AddLayout( layDlg );    dlgTxt.AddLayout( layDlg );
- descItem=app.CreateText("confirm delete database "+item, 1, 0.06);+ descItem=app.CreateText( item, 1, 0.06);
    layDlg.AddChild(descItem);    layDlg.AddChild(descItem);
    descItem.SetTextSize( txtSize );    descItem.SetTextSize( txtSize );
Line 255: Line 279:
 { {
  var objet = results.rows.item(0)  ;  var objet = results.rows.item(0)  ;
- emptyList( lstRight );+ //emptyList( lstRight );
  var arraytext= parseSqliteMasterSql( objet['sql']);  var arraytext= parseSqliteMasterSql( objet['sql']);
  for(var column in arraytext )   for(var column in arraytext ) 
Line 331: Line 355:
 function closeDialog02(){dlgContent.Hide()} function closeDialog02(){dlgContent.Hide()}
  
- }+</code> 
 + 
 +enjoyed? 
 + --- //[[bis40@free.fr|thierry DERICK]] 2015/04/17 00:40//
  
sample_code/database_navigate.1429231440.txt.gz · Last modified: 2015/04/17 08:44 (external edit)