Page 27 of 28

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Posted: Mon Jul 09, 2012 2:27 pm
by Roberto Lopez
luisvasquezcl wrote:Estimado Roberto,
te informo que en esta versión los metodos getValue no funcionan en CoolNovo version 2.0.2.26 (Chrome) pero en Firefox funcionan correctamente.
Probé la versión r31b.

Saludos cordiales,
Luis Vasquez.
No sabía de la existencia de este navegador (Coolnovo) por eso pensé que me hablabas de Chrome.

Lo descargué y probé los demos.

Todo funciona correctamente, así que el problema está en el equipo que estás usando para hacer las pruebas.

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Posted: Mon Jul 09, 2012 4:46 pm
by luisvasquezcl
Estimado,
Coolnovo es la nueva versión de chrome por eso lo puse entre paréntesis, y es la misma con la cual revisé las versiones anteriores de hmgscript al igual que el mismo pc.
Lo que no me queda claro es el error que me arroja la consola javascript del navegador que indica que "el server no responde" cuando solicito el valor del textbox del demo.

saludos cordiales,
Luis Vásquez.

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Posted: Mon Jul 09, 2012 4:56 pm
by Roberto Lopez
luisvasquezcl wrote:Estimado,
Coolnovo es la nueva versión de chrome por eso lo puse entre paréntesis, y es la misma con la cual revisé las versiones anteriores de hmgscript al igual que el mismo pc.
Lo que no me queda claro es el error que me arroja la consola javascript del navegador que indica que "el server no responde" cuando solicito el valor del textbox del demo.

saludos cordiales,
Luis Vásquez.
Coolnovo no es la nueva versión de Chrome. Es una versión alternativa (NO OFICIAL) de Chrome.

De:http://chromeplus.softonic.com/
CoolNovo es un navegador derivado de Chrome. Usa el mismo código del navegador de Google, pero añade funciones extra que se pueden configurar desde el panel de herramientas.
La versión OFICIAL y ACTUALIZADA de Chrome es la: 20.01132 (que es la que estoy usando).

http://en.wikipedia.org/wiki/Google_Chr ... se_history

Más allá de eso, como te decía en el mensaje anterior, descargué Coolnovo y todo funciona bien en mi equipo.

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Posted: Mon Jul 09, 2012 4:59 pm
by luisvasquezcl
Estimado,
pido mis disculpas por el falso/positivo 8).
Acabo de volver a ejecutar el demo y me encuentro que ahora funciona ...
lo que no había hecho es pedir el puerto localhost:80/
Nuevamente mis disculpas.
Saludos cordiales,
Luis Vasquez.

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Posted: Mon Jul 09, 2012 5:05 pm
by Roberto Lopez
luisvasquezcl wrote:Estimado,
pido mis disculpas por el falso/positivo 8).
Acabo de volver a ejecutar el demo y me encuentro que ahora funciona ...
lo que no había hecho es pedir el puerto localhost:80/
Nuevamente mis disculpas.
Saludos cordiales,
Luis Vasquez.
No problem :)

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Posted: Tue Jul 10, 2012 10:44 am
by luisfrancisco62
Hola a todos:

Yo solucione cambiando el numero del puerto en el ini, pues interferia.

Ej: Localhost:81

gracias muchas gracias

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Posted: Tue Jul 10, 2012 3:21 pm
by Rathinagiri
Now I could connect with MySQL database via PHP. :)

Please have this as mysql.php in php folder: (ie., www/php/mysql.php)

Code: Select all

<?php

$host       = request_var( 'cHost', '');
$user       = request_var( 'cUser', '' );
$password   = request_var( 'cPassword', '');
$port       = intval( request_var( 'nPort', '') );
$db         = request_var( 'cDB', '' );
$query      = request_var( 'cQuery', '' );
$innerwidth = request_var( 'nInnerWidth', '');
$id         = request_var( 'cID', '');

$rows = 0;
$cols = 0;

//echo $query;

/* create a connection object which is not connected */
$link = mysqli_init();

/* set connection options */
mysqli_options($link, MYSQLI_INIT_COMMAND, "SET AUTOCOMMIT=0");
mysqli_options($link, MYSQLI_OPT_CONNECT_TIMEOUT, 5);

/* connect to server */
mysqli_real_connect( $link, $host, $user, $password, $db, $port );

/* check connection */
if (mysqli_connect_errno()) {
    printf("Connect failed: %s\n", mysqli_connect_error());
    exit();
}

//printf ("Connection: %s\n.", mysqli_get_host_info($link));

if ($result = mysqli_query($link, $query)) {

   $rows = mysqli_num_rows($result);
   $cols = mysqli_num_fields($result);   
   $res = '';
   $res = $res . '<table border="0" class="browse" width="' . $innerwidth . '" id="' . $id . '">';
   echo $res;
   $res = '';
   $res = $res . '<tr>';
   $res = $res . '<th>#</th>';
   $i = 1;
    /* Get field information for all fields */
    while ($finfo = mysqli_fetch_field($result)) {
      $res = $res . '<th>' . $finfo->name . '</th>';
      $i++;
    }
   $res = $res . '</tr>';
   echo $res;
   $res = '';
   $i = 1;
   while ($row = mysqli_fetch_row($result)) {
      $res = '';
      $res = $res . '<tr>';
      $res = $res . '<td> <input type="checkbox" onclick="changeState( this )" > </td>';
      for ($j = 0; $j < $cols; $j++){
         $res = $res . '<td>' . $row[$j] . '</td>' ;
        }
       $i++;
      $res = $res . '</tr>';
      echo $res;
   }
    mysqli_free_result($result);
}

mysqli_close($link);



function request_var($var_name, $default, $multibyte = false, $cookie = false)
    {
        if (!$cookie && isset($_COOKIE[$var_name]))
        {
            if (!isset($_GET[$var_name]) && !isset($_POST[$var_name]))
            {
                return (is_array($default)) ? array() : $default;
            }
            $_REQUEST[$var_name] = isset($_POST[$var_name]) ? $_POST[$var_name] : $_GET[$var_name];
        }
   
        if (!isset($_REQUEST[$var_name]) || (is_array($_REQUEST[$var_name]) && !is_array($default)) || (is_array($default) && !is_array($_REQUEST[$var_name])))
        {
            return (is_array($default)) ? array() : $default;
        }
   
        $var = $_REQUEST[$var_name];
        if (!is_array($default))
        {
            $type = gettype($default);
        }
        else
        {
            list($key_type, $type) = each($default);
            $type = gettype($type);
            $key_type = gettype($key_type);
            if ($type == 'array')
            {
                reset($default);
                $default = current($default);
                list($sub_key_type, $sub_type) = each($default);
                $sub_type = gettype($sub_type);
                $sub_type = ($sub_type == 'array') ? 'NULL' : $sub_type;
                $sub_key_type = gettype($sub_key_type);
            }
        }
   
       if (is_array($var))
       {
           $_var = $var;
           $var = array();
   
           foreach ($_var as $k => $v)
           {
               set_var($k, $k, $key_type);
               if ($type == 'array' && is_array($v))
               {
                   foreach ($v as $_k => $_v)
                   {
                       if (is_array($_v))
                       {
                           $_v = null;
                       }
                       set_var($_k, $_k, $sub_key_type);
                       set_var($var[$k][$_k], $_v, $sub_type, $multibyte);
                   }
               }
               else
               {
                   if ($type == 'array' || is_array($v))
                   {
                       $v = null;
                   }
                   set_var($var[$k], $v, $type, $multibyte);
               }
           }
       }
       else
       {
           set_var($var, $var, $type, $multibyte);
       }
   
       return $var;
   }
   
   function set_var(&$result, $var, $type, $multibyte = false)
    {
        settype($var, $type);
        $result = $var;
   
        if ($type == 'string')
        {
            $result = trim(htmlspecialchars(str_replace(array("\r\n", "\r"), array("\n", "\n"), $result), ENT_COMPAT, 'UTF-8'));
   
            if (!empty($result))
            {
                // Make sure multibyte characters are wellformed
                if ($multibyte)
                {
                    if (!preg_match('/^./u', $result))
                    {
                        $result = '';
                    }
                }
                else
                {
                    // no multibyte, allow only ASCII (0-127)
                    $result = preg_replace('/[\x80-\xFF]/', '?', $result);
                }
            }
   
            $result = stripslashes($result);
        }
    }


?>
This is mysql.html (in www folder)

Code: Select all

<html>

   <head>
      <title></title>
      <link rel="stylesheet" type="text/css" href="themes/hmgs.xp.css">
      <script type="text/javascript" src="lib/hmgscript.js"></script>
      <script type="text/javascript" src="app/mysqldemo.js"></script>
   </head>

   <body>

   <center>

   <br>
   <p>You must start the WAMP / LAMP server prior to begin testing and allow it when Windows Firewall ask.</p>
   <p>You must login prior to test MySQLBrowse demo.</p>
   <p>If you plan make the server available via the Internet, you must to connect the server machine to a dynamic dns service like no-ip.org and forward port 80 in your router.</p>
   <br>
   <input type="button" value="Demo"                  onClick="test_0()"               style="width:150;height:60" >
   <br>
   </center>

   </body>

</html>
This is mysqldemo.js

Code: Select all

///////////////////////////////////////////////////////////////////////////////////////////////
// MySQLBROWSE DEMO
///////////////////////////////////////////////////////////////////////////////////////////////


function MySQLBrowse( oParent , nRow , nCol , nWidth , nHeight , cHost, cUser, cPassword, nPort, cDB, cQuery, nInnerWidth )
{

	var cId = 'control' + (nControlCount).toString() ; nControlCount++ ;

	var query = 'cHost=' + cHost + '&'
               + 'cUser=' + cUser + '&'
               + 'cPassword=' + cPassword + '&'
               + 'nPort=' + nPort + '&'
               + 'cDB=' + cDB + '&' 
               + 'cQuery=' + cQuery + '&' 
               + 'cId=' + cId + '&'
               + 'nInnerWidth=' + nInnerWidth + '&';

	var control = document.createElement( "div" )        ;

	var panel = cId + '_panel';

	control.className      = "browse"                    ;      
	control.style.position = "absolute"                  ;
	control.style.top      = nRow                        ;
	control.style.left     = nCol                        ;
	control.style.width    = nWidth                      ;
	control.style.height   = nHeight                     ;
	control.id             = panel                       ;
	control.innerHTML      = "Loading..."                ;
	control.style.border   = "solid 1px rgb(200,200,200)"    ;
	control.style.overflow = "scroll"                    ;
    
	document.getElementById( oParent.getId() ).appendChild( control )                ;

	xmlHttp=new XMLHttpRequest();
	xmlHttp.open( "POST" , "/php/mysql.php"  , false ) ;
	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	xmlHttp.send( query );
	document.getElementById(panel).innerHTML = xmlHttp.responseText;

	this.getPageSize = function()
	{
		return nPageSize ;
	}

	this.getSelectedRowCount = function()
	{
		var i, n ;

		n = 0 ;

		for ( i=1 ; i < document.getElementById(cId).rows.length ; i++ )
		{
			if ( document.getElementById(cId).rows[i].cells[0].getElementsByTagName("input")[0].checked == true ) 
			{
				n++ ;
			}			 
		}
		return n;
	};

	this.getSelectedRows = function()
	{
		var selectedRows=new Array();
		var i, code, first, last, n ;

		n = 0 ;

		for ( i=1 ; i < document.getElementById(cId).rows.length ; i++ )
		{
			if ( document.getElementById(cId).rows[i].cells[0].getElementsByTagName("input")[0].checked == true ) 
			{
				selectedRows[n] = i ;
				n++ ;
			}			 
		}
		return selectedRows;
	};

	this.getRowCount = function()
	{
		return document.getElementById(cId).rows.length;
	}

	this.getCell = function( nRow , nCOl )
	{
		return trim(document.getElementById(cId).rows[nRow].cells[nCOl].childNodes[0].data);
	}

	this.select = function( nRow )
	{
		document.getElementById(cId).rows[nRow].cells[0].getElementsByTagName("input")[0].checked = true ;
		changeState( document.getElementById(cId).rows[nRow].cells[0].getElementsByTagName("input")[0] );
	}

	this.unSelect = function( nRow )
	{
		document.getElementById(cId).rows[nRow].cells[0].getElementsByTagName("input")[0].checked = false ;
		changeState( document.getElementById(cId).rows[nRow].cells[0].getElementsByTagName("input")[0] );
	}

	this.refresh = function(  )
	{ 

		xmlHttp=new XMLHttpRequest();
		xmlHttp.open( "POST" , "/php/mysql.php"  , false ) ;
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send( query );
		document.getElementById(panel).innerHTML = xmlHttp.responseText;
	}


	this.getId = function ()
	{
		return cId;		
	}


}   




function test_0()
{
   oWin = new Form( "MySQLBrowse Test", 590 , 480 );

   oBrowse = new MySQLBrowse( oWin , 
	050 , 050 , 510 , 340 , 'localhost', 'root', 'pass', '3306', 'test', 'select * from test_table', 250 );

   Button( oWin , 390 , 40  , "Refresh"         , "oBrowse.refresh()"      );  
   Button( oWin , 390 , 170 , "Show Selected"   , "ShowSelected(oBrowse)"  );  
   Button( oWin , 390 , 300 , "Append"          , "AppendTest( oBrowse )"  );  
                                                                                          
   Button( oWin , 430 , 40  , "Delete Selected" , "DeleteTest(oBrowse)"    );  
   Button( oWin , 430 , 170 , "Select All"      , "SelectAll( oBrowse )"   );  
   Button( oWin , 430 , 300 , "UnSelect All"    , "UnSelectAll( oBrowse )" );  
   Button( oWin , 430 , 430 , "Close"           , "oWin.release()"         );  

}
//---------------------------------------------------------------------------------------------//
function ShowSelected( oBrowse )
{

	if ( oBrowse.getSelectedRowCount() == 0 )
	{
		alert('No Rows Selected!');
		return;
	}

	var aSelection = oBrowse.getSelectedRows();

	for ( var i = 0 ; i < aSelection.length ; i++ )
	{
		nRow = aSelection [i] ;

		code  = oBrowse.getCell( nRow , 1 );
		first = oBrowse.getCell( nRow , 2 );
		last  = oBrowse.getCell( nRow , 3 );

		alert ( code + ' ' + first + last );
	}

}


Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Posted: Tue Jul 10, 2012 7:45 pm
by Roberto Lopez
rathinagiri wrote:Now I could connect with MySQL database via PHP. :)

Please have this as mysql.php in php folder: (ie., www/php/mysql.php)
<...>
Fantastic!

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Posted: Wed Jul 11, 2012 2:24 am
by Roberto Lopez
rathinagiri wrote:Now I could connect with MySQL database via PHP. :)

Please have this as mysql.php in php folder: (ie., www/php/mysql.php)
I'm testing it.

It needs a little fix: There is no a "browse" class. Browse uses grid class, so, you should change:

Code: Select all

   $res = $res . '<table border="0" class="browse" width="' . $innerwidth . '" id="' . $id . '">';
with:

Code: Select all

   $res = $res . '<table border="0" class="grid" width="' . $innerwidth . '" id="' . $id . '">';
So, the MySql Browse should look at the Harbour one.


In its final form, we should have only one Browse (at least from the user POV).

We should have a function that sets a global array (ie: _DEFAULT_SERVER) in such way that a wrapper function decides how server type/procedure use.

I mean (user code):

Code: Select all

SetDefaultServer ( "PHP_MYSQL" , cUser , cPassword , cDataBase ); // this function sets _DEFAULT_SERVER array

Browse(....);
In the library:

Code: Select all


function Browse(...)
{
   if ( _DEFAULT_SERVER [0] == 'PHP_MYSQL' )
   {
      <create an adequate SQL query from received parameters (cTable,aColumns,cForExpr) >
      MySqlBrowse(...)
   }
   else if ( _DEFAULT_SERVER [0] == 'HRB_DBFCDX' )
   {
      DbfCdxBrowse(...) // this is the current one
   }
}

This way, the experience for the user will be consistent with different back ends.

Of course will be differences, since (ie) WHERE condition is different from FOR condition (among others) that must be noticed to the users.

What do you think?

Re: HMGSCRIPT 2012: Programming For The Web in The Right Way

Posted: Wed Jul 11, 2012 3:36 am
by Roberto Lopez
New theme inspired in Windows 7 basic.