From 3ece8464b357fa7c2d5129e4aa54d0bb7cf1bcc3 Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Sun, 28 Jan 2018 04:16:13 +0000 Subject: [PATCH] www/dbq/dbq.php --- lib/php/functions.php | 38 ++++++++++++++------------------------ lib/php/nb.php | 10 +++++++++- www/dbq/dbq.php | 1 + www/dbq/html/default.js | 3 +-- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/lib/php/functions.php b/lib/php/functions.php index 9737a503..cf620df5 100644 --- a/lib/php/functions.php +++ b/lib/php/functions.php @@ -1,6 +1,7 @@ '.$msg.''.NB_EOL @@ -98,15 +99,15 @@ function err($msg='__err__',$preff='err',$backtrace_deep=0) { # NB 15.11.17 } function debug($msg,$level=0) { - return nb::debug($msg,$level); + return Nb::debug($msg,$level); } # NB 15.11.17 function debug($msg,$level=0) { -# NB 15.11.17 if ($level and $level>nb::p('debug')) return; +# NB 15.11.17 if ($level and $level>Nb::p('debug')) return; # NB 15.11.17 #$msg = is_scalar($msg) ? $msg : print_r($msg,true); # NB 15.11.17 $msg = is_scalar($msg) ? $msg : print_r($msg,true); # NB 15.11.17 -# NB 15.11.17 if (nb::client_header('Accept','ml')) { +# NB 15.11.17 if (Nb::client_header('Accept','ml')) { # NB 15.11.17 $msg = '
'
 # NB 15.11.17       .(isset($_SERVER['HTTP_HOST']) ? htmlentities($msg) : $msg)
 # NB 15.11.17       #.(isset($_SERVER['HTTP_HOST']) ? htmlspecialchars($msg) : $msg)
@@ -116,21 +117,10 @@ function debug($msg,$level=0) {
 # NB 15.11.17     $msg = "DEBUG: $msg\n";
 # NB 15.11.17 
 # NB 15.11.17   }
-# NB 15.11.17   nb::msg($msg);
+# NB 15.11.17   Nb::msg($msg);
 # NB 15.11.17 
 # NB 15.11.17 }
 
-function prettyText($text) {
-  $replace = array(
-    '/(\w)(,)(\w)/' => '$1$2 $3',
-    '/_/' => ' ',
-    '/[^\w,]+/' => ' ',
-  );
-  return ucwords(
-    preg_replace(array_keys($replace),array_values($replace),$text)
-  );
-}
-
 function rtf2txt($rtf) {
 	$cmd="unrtf --text";
   return cmd2str($cmd,$rtf);
@@ -184,7 +174,7 @@ function cmd2str($cmd,$write=null) {
 
 }
 
-function argv2request($args=null) { return nb::argv2request($args); }
+function argv2request($args=null) { return Nb::argv2request($args); }
 
 function html_select_array($data,$opt=[]) {
 
diff --git a/lib/php/nb.php b/lib/php/nb.php
index f7ce4fcc..af9ed5be 100644
--- a/lib/php/nb.php
+++ b/lib/php/nb.php
@@ -225,9 +225,17 @@ class NB {
 	 * Does what it says
 	 */
 	public static function prettyText($text) {
-		return prettyText($text);
+  	$exps = array(
+    	'/(\w)(,)(\w)/' => '$1$2 $3',
+    	'/_/' => ' ',
+    	'/[^\w,=]+/' => ' ',
+  	);
+  	return ucwords(
+    	preg_replace(array_keys($exps),array_values($exps),$text)
+  	);
 	}
 
+
 # NB 19.01.18 	public static function mime2ext($mime) {
 # NB 19.01.18 		require_once(NB_ROOT.'/lib/php/mime.php');
 # NB 19.01.18 		return Mime::ext($mime);
diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php
index 2c5dea85..a94e299f 100644
--- a/www/dbq/dbq.php
+++ b/www/dbq/dbq.php
@@ -285,6 +285,7 @@ class DbQ extends nb {
 			$this->page->body_class = ''
 				.(empty($this->params['db']) ? '' : ' db-'.$this->params['db'])
 				.(empty($this->params['table']) ? '' : ' table-'.$this->params['table'])
+				.( (empty($this->db) or empty($this->table)) ? '' : ' h1-to-select' )
 				.(empty($this->params['action']) ? ' action-'.self::PARAM_DB_DEFAULT : ' action-'.($this->params['action'] == 'add' ? 'vi' : $this->params['action']))
 
 			;
diff --git a/www/dbq/html/default.js b/www/dbq/html/default.js
index 351d694e..71ef3f13 100644
--- a/www/dbq/html/default.js
+++ b/www/dbq/html/default.js
@@ -133,9 +133,8 @@ document.addEventListener("DOMContentLoaded", function() {
 		document.querySelector("th.delete").appendChild(a);
 	}
 
-	if (document.querySelector("body.action-ls")) document.querySelectorAll("body > h1 a.db, body > h1 a.table").forEach(function(e) {
+	if (document.querySelector("body.h1-to-select")) document.querySelectorAll("body > h1 a.db, body > h1 a.table").forEach(function(e) {
 		var base = window._dbq[e.className+'.base'].replace(/\/[^\/]+$/,'');
-		//if (base == '') base = '/';
 		var url = base + (base == '' ? '/ls' : '') + '.json';
 		console.log(url);
 		var fields = e.className == 'db' ? ['id','id'] : ['name','name'];
-- 
2.47.3