};
+ this.json_debug = function(url) {
+ $.getJSON(url,function(data) {
+ var tag = '';
+ if (typeof(data) == 'string') {
+ tag = 'span';
+ } else if ($.isArray(data)) {
+ tag = 'ul';
+ } else {
+ tag = 'fieldset';
+ }
+ var items = [];
+ $.each( data, function( key, val ) {
+ //console.log(key+' = '+val);
+ if (tag == 'span') {
+ tag = 'span class="'+key+'"'
+ items.push( v );
+ } else if (tag == 'ul') {
+ items.push( '<li class="'+val+'">'+val+'</li>' );
+ } else if (tag == 'fieldset') {
+ items.push( '<dl class="'+key+'"><dt>'+key+'</dt><dd>'+val+'</dd>' );
+ }
+ });
+ $( '<'+tag+'/>', {
+ //"class": "my-new-list",
+ html: items.join( "" )
+ }).prependTo( "#msg" );
+ //console.log(typeof(data));
+ });
+ }
+
};
//NB.prototype.your_method = function() { }
return '"'.$value.'"';
}
+ function action() {
+ $action = $this->p('action');
+ if (strpos($action,'db.') !== 0) return false;
+ $action = substr($action,3);
+
+ $data = null;
+
+ if ($action == 'tables') {
+ $data = $this->tables();
+
+ } elseif ($action == 'html_menu') {
+ echo $this->html_menu();
+ return true;
+
+ } elseif ($action == 'fields') {
+ $data = $this->table($this->p('table'))->fields();
+
+ } elseif ($action == 'table' and $this->p('format') and $this->p('table')) {
+
+ $this->print_header($this->p('format'));
+ $this->table($this->p('table'))->rows(array( 'format' => $this->p('format'),));
+ return true;
+ }
+ #bye( $action );
+ if (isset($data)) {
+
+ $this->print_header('json');
+ echo json_encode($data);
+ return true;
+ }
+
+ $this->bye("Db.action: Unknow action \"$action\"");
+ return false;
+ }
+
}
?>
return ($_REQUEST[$name] = $value);
}
+ /*
+ * Function: bye
+ * Set a value for param, delete it if null
+ */
+ static function bye($msg='') {
+ return bye($msg);
+ }
+
}
?>
}
function path() {
+ if (empty($_SERVER['REQUEST_URI'])) return '';
return preg_replace('/\?.*$/','',$_SERVER['REQUEST_URI']);
}