if [ -n "$NB_ROOT" ]; then
#[ -e "$NB_ROOT/etc/profile.d/envs" ] && . "$NB_ROOT/etc/profile.d/envs"
+ #alias which=in_path
for i in \
${NB_ROOT}/etc/profile.d/envs \
${NB_ROOT}/etc/profile.d/aliases \
[ -n "$NB_DEBUG" ] && $NB_DEBUG ". $i"
[ -r "$i" -a -f "$i" ] && . "$i"
done
+ #unalias which
fi
[ -z "$DOCKER_HUB" ] && DOCKER_HUB=""
# Docker env only if `is_prompt` !!!
-if is_prompt && which docker-machine > /dev/null && [ -z "$MYVIMRC" ]; then
+# NB 26.12.16 if is_prompt && which docker-machine > /dev/null && [ -z "$MYVIMRC" ]; then
+if which docker-machine >/dev/null; then
if [ -z "$DOCKER_CERT_PATH" -o ! -e "$DOCKER_CERT_PATH" ] \
&& [ _$(docker-machine status "$DOCKER_MACHINE_NAME" 2>/dev/null) = _Running ] \
[ "$encrypt" == "1" ] && password="$password "`echo "$password" | makepasswd --clearfrom=- --crypt-md5 | sed 's/^.*\(\$.*\)$/\1/'`
echo "$password"
}
+
+# NB 27.12.16 in_path() {
+# NB 27.12.16 local IFS=':'
+# NB 27.12.16 local p
+# NB 27.12.16 for p in $PATH; do
+# NB 27.12.16 test -x "$p/$1" || continue
+# NB 27.12.16 #echo "$p/$1"
+# NB 27.12.16 #echo "$p/$1" 1>&2
+# NB 27.12.16 return
+# NB 27.12.16 done
+# NB 27.12.16 #/usr/bin/which
+# NB 27.12.16 return 1
+# NB 27.12.16 }
$html = '';
- #$html .= '<table data-role="table" class="ui-responsive rows '.$this->name.'">'.NB_EOL;
$html .= '<table class="rows wp-list-table widefat fixed striped">'.NB_EOL;
#if (!empty($opt)) $html .= '<caption>' . $this->nav($opt['count'],$opt['tot'],$opt['limit']) . '</caption>' .NB_EOL;
+ $this->__rows_table_attr = [];
+ $this->__rows_table_keys = [];
+ foreach ($fields as $name => $f) {
+ $this->__rows_table_attr[$name] = ''
+ . ' class="' . $name . ($f->key?' key':'') . (isset($this->extras[$name])?' extra':'') . '"'
+ ;
+ if ($f->key) $this->__rows_table_keys[] = $name;
+ }
+
if ($this->show_header) {
- $html .= '<thead>'.NB_EOL.'<tr class="head">'.NB_EOL;
+ $html .= '<thead>'.NB_EOL;
+ // Columns names
+ $html .= '<tr class="head">'.NB_EOL;
if ($this->buttons() and DB_HTML_EDIT) $html .= '<th class="edit"></th>'.NB_EOL;
+ foreach ($fields as $name => $f) {
+ $html .= '<th'.$this->__rows_table_attr[$name].'>'.$this->url_sort($name).'</th>'.NB_EOL;
+ }
+ if ($this->buttons() and DB_HTML_DELETE) $html .= '<th class="delete"></th>'.NB_EOL;
+ $html .= '</tr>'.NB_EOL;
+ // Filters - beta
+ /*
+ if (0) {
+ $html .= '<tr class="head">'.NB_EOL;
+ if ($this->buttons() and DB_HTML_EDIT) $html .= '<th class="edit"></th>'.NB_EOL;
foreach ($fields as $name => $f) {
- $html .= '<th class="'.$name.($f->key?' key':'').'">'.$this->url_sort($name).'</th>'.NB_EOL;
+ $html .= '<th class="'.$name.($f->key?' key':'').'">'
+ . (preg_match('/^\w/',$name) ? '<input type="text" id="t-'.$name.'" name="'.$name.'" value="'.$name.$f->p($name).'" />' : '')
+ .'</th>'.NB_EOL;
}
if ($this->buttons() and DB_HTML_DELETE) $html .= '<th class="delete"></th>'.NB_EOL;
- $html .= '</tr>'.NB_EOL.'</thead>'.NB_EOL;
+ $html .= '</tr>'.NB_EOL;
+ }
+ */
+
+ $html .= '</thead>'.NB_EOL;
}
$html .= '<tbody>'.NB_EOL;
$buttons = $this->html_row_buttons($row);
- $html = '<tr class="row">'.NB_EOL;
+ $id = [];
+ foreach ($this->__rows_table_keys as $k) {
+ $id[] = $row[$k];
+ }
+ $id = empty($id) ? '' : ' '.'__'.join('__',$id).'__';
+
+ $html = '<tr class="row'.$id.'">'.NB_EOL;
if ($this->buttons() and !empty($buttons[0])) $html .= '<td class="action">'.$buttons[0].'</td>'.NB_EOL;
foreach ($row as $k => $v) {
- if (isset($this->extras[$k])) $k .= " extra";
- $html .= '<td class="'.$k.'">'.$v.'</td>'.NB_EOL;
+ $html .= '<td'.$this->__rows_table_attr[$k].'>'.$v.'</td>'.NB_EOL;
}
if ($this->buttons() and !empty($buttons[1])) $html .= '<td class="action">'.$buttons[1].'</td>'.NB_EOL;
}
public function rows_end_table() {
+ unset($this->__rows_table_attr,$this->__rows_table_keys);
$html = '';
$html .= '</tbody>'.NB_EOL;
$html .= '</table>'.NB_EOL;
public function html_menu($opt=[]) {
- $buttons = '<input type="submit" class="button button-small" value="GO"/>';
+ $buttons = '<input type="submit" class="button button-small" value="Go"/>';
if (!empty($opt['buttons'])) $buttons = $opt['buttons'];
$r = '<form class="menu" method="get" action="?">'.NB_EOL;
'html' => 'class="format" name="format" id="format"',
'selected' => $this->db()->format,
'prettyText' => true,
- 'sort' => 'natcasesort',
+# NB 26.12.16 'sort' => 'natcasesort',
]);
$r .= '</span>';
'html' => 'class="limit" name="limit" id="limit"',
'selected' => $this->p('limit'),
'prettyText' => true,
+ 'sort' => 'sort',
]);
$r .= '</span>';
}
<?php
if (!defined('NB_ROOT')) define('NB_ROOT',realpath(dirname(__FILE__).'/../..'));
-if (defined('PRODUCTION') and !defined('NB_PROD')) define('NB_PROD',PRODUCTION);
-if (!defined('NB_EOL')) define('NB_EOL',defined('NB_PROD') ? '' : "\n");
+if (!defined('NB_PROD') and defined('PRODUCTION')) define('NB_PROD',PRODUCTION);
+if (!defined('NB_EOL')) define('NB_EOL',(defined('NB_PROD') and NB_PROD) ? '' : "\n");
-require_once(realpath(dirname(__FILE__).'/functions.php'));
-#$nb = new NB(); debug($nb->test());
-#if (!defined('NB_PARAMS')) define('NB_PARAMS',$_REQUEST);
-if (class_exists('NB')) return;
+require_once(NB_ROOT.'/lib/php/functions.php');
+if (class_exists('NB')) return; # protect against double include
class NB {
const ROOT_DIR = NB_ROOT;
private static function yaml_init() {
static $Spyc;
if (empty($Spyc) and !function_exists('yaml_emit')) {
- require_once(realpath(dirname(__FILE__).'/Spyc.php'));
+ require_once(NB_ROOT.'/lib/php/Spyc.php');
function yaml_emit($data) { return Spyc::YAMLDump($data, false, false, true); }
function yaml_parse_file($file) { return Spyc::YAMLLoad($file); }
$Spyc = true;
public static function md2html($txt) {
static $_txt2md = null;
if ($_txt2md === null) {
- require_once(dirname(__FILE__).'/parsedown/Parsedown.php');
+ require_once(NB_ROOT.'/lib/php/parsedown/Parsedown.php');
$_txt2md = new Parsedown();
}
return $_txt2md->text($txt);
ARG WWW_ROOT
ENV WWW_ROOT=${WWW_ROOT:-/var/www/html}
-ARG PHP_HOST
-ENV PHP_HOST=${PHP_HOST:-php}
-
-ARG PHP_PORT
-ENV PHP_PORT=${PHP_PORT:-9000}
+ARG FASTCGI_PASS
+ENV FASTCGI_PASS=${FASTCGI_PASS:-php:9000}
COPY ./default.conf /etc/nginx/conf.d/default.conf
# Set DOCUMENT_ROOT
RUN test "$WWW_ROOT" && sed -i -e 's,^\([\t ]*root \).*$,\1'$WWW_ROOT';,' /etc/nginx/conf.d/default.conf
-# Set PHP_HOST
-RUN test "$PHP_HOST" && sed -i -e 's,^\([\t ]*fastcgi_pass \)\([^:]\+\)\(:.*\)$,\1'$PHP_HOST'\3,' /etc/nginx/conf.d/default.conf
-
-# Set PHP_PORT
-RUN test "$PHP_PORT" && sed -i -e 's,^\([\t ]*fastcgi_pass [^:]\+:\)\([0-9]\+\),\1'$PHP_PORT',' /etc/nginx/conf.d/default.conf
+# Set FASTCGI_PASS
+RUN test "$FASTCGI_PASS" && sed -i -e 's,^\([\t ]*fastcgi_pass[\t ]*\).*,\1'$FASTCGI_PASS';,' /etc/nginx/conf.d/default.conf
# Create default index.html
-RUN mkdir -p $WWW_ROOT && echo '<html><head><title>Welcom to Nginx Php Fpm</title></head><body><h1>Welcom to Nginx Php Fpm</h1></body></html>' > $WWW_ROOT/index.html
+RUN mkdir -p $WWW_ROOT && echo '<html><head><title>Welcom to Nginx Php Fpm</title></head><body><h1>Welcom to Nginx Php Fpm</h1><p>You are connected to '$FASTCGI_PASS'</p></body></html>' > $WWW_ROOT/index.html
# Run daemon
CMD nginx -g "daemon off; error_log /dev/stdout info;"
<?php
+define(PRODUCTION,empty($_SERVER['PRODUCTION']) ? false : (bool)$_SERVER['PRODUCTION']);
+
require_once(realpath(dirname(__FILE__).'/../../lib/php/nb.php'));
require_once(NB_ROOT.'/lib/php/http.php');
require_once(NB_ROOT.'/lib/php/mime.php');
-/*
- Default action
-*/
-define('DBQ_PARAM_DEFAULT',(string)(isset($_SERVER['DBQ_PARAM_DEFAULT'])
- ? $_SERVER['DBQ_PARAM_DEFAULT']
- : 'ls')
-);
-
class DbQ extends nb {
public $perm = 9; // Minimum permission access 0 = readonly
public $title = 'Dbq';
public $sep_title = ' / ';
- const HTML_FORMAT = 'table';
- const CLI_FORMAT = 'human';
- public $human_ua_exp = '/^\S+\s+.Windows|iPhone|Android|Macintosh|Linux/';
- public $formats = []; # for Db web list
-
-
- const PARAM_ARGS_SEP = '|';
- const PARAM_EXP = '[\w\._:-]{2,100}';
- const PARAM_DB_DEFAULT = DBQ_PARAM_DEFAULT;
+ public $format_html = 'table';
+ public $format_cli = 'human';
+ public $format_cli_ua_exp = '/^\S+\s+.Windows|iPhone|Android|Macintosh|Linux/';
+ public $limits = [];
+ # to overwrite Db web list
+ public $formats = [ 'html','csv','xml','json','yaml','sh','sql','php' ];
+
+ public $param_args_sep = '|';
+ public $param_exp_value = '[\w\._:-]{2,100}';
+ const PARAM_DB_DEFAULT = 'ls';
+ #public $action = 'ls';
public $params = [
'format' => '',
'db' => self::PARAM_DB_DEFAULT,
- 'table' => 'ls',
- 'action' => 'ls',
+ 'table' => self::PARAM_DB_DEFAULT,
+ 'action' => self::PARAM_DB_DEFAULT,
'args' => '',
];
# NB 23.12.16 public $params_deep = [];
- public $css = '/default.css';
- public $js = '/default.js';
+ public $css = '/default'.(PRODUCTION ? '.min' : '').'.css';
+ public $js = '/default'.(PRODUCTION ? '.min' : '').'.js';
public $ext;
public $uri;
'title',
'css',
'js',
- 'human_ua_exp'
+ 'format_cli_ua_exp'
] as $k) {
$env = 'DBQ_'.strtoupper($k);
if (!empty($_SERVER[$env])) $this->$k = $_SERVER[$env];
if ($run) $this->run();
}
+ public function limit($set=false) {
+ static $limit=false;
+ if ($set !== false) return ($limit=$set);
+
+ if ($limit !== false) return $limit;
+
+ if ($limit=$this->p('limit')) return $limit;
+ if ($this->page->is('html')) return ($limit=$this->default_limit);
+
+ }
+
public function page($obj,$meth=null,$head=[],$fct=null) {
// Write output
- $this->default_limit = $this->db->limits[0];
- $this->pdef('limit',$this->default_limit);
- $this->db->limit = $this->p('limit');
+ if (empty($this->default_limit)) $this->default_limit = $this->db->limits[0];
+ $this->db->limit = $this->limit();
+
if (empty($this->_nopage)) {
$this->page->headers_no_cache();
$this->page->js = $this->js;
$this->page->js_code = 'window._dbq = '
. json_encode([
- 'HTML_FORMAT' => self::HTML_FORMAT,
- 'default.format' => self::HTML_FORMAT,
+ 'db.base' => ( empty($this->db) ? '' : $this->db->base ),
+ 'table.base' => ( empty($this->table) ? '' : $this->table->base ),
+ 'default.format' => $this->format_html,
'default.limit' => $this->default_limit,
'param.format' => $this->params['format'],
'param.db' => $this->params['db'],
])
.'';
+ list($title,$nav) = $this->title_nav();
+ $this->page->title = join($this->sep_title,$title);
+ $this->page->nav = $nav;
+
$this->page->begin();
}
if (!$keys) $keys = $all;
$keys = array_keys($keys);
- $values = explode(self::PARAM_ARGS_SEP,$this->params['args']);
+ $values = explode($this->param_args_sep,$this->params['args']);
$this->table->html_edit(array_combine($keys,$values),$this->table->base.($add ? 'insert/' : 'update/').$this->params['args'],$add);
}
and ($this->perm >= self::VIEW)
and $this->table->type() != 'sql'
) ? [
- 'buttons' => join(' ',[
- '<input type="submit" class="button button-small" value="GO"/>',
- '<input type="button" class="button button-small" onclick="window.location=\''.$this->table->base.'add/'.'\'" value="Add"/>',
- '<input type="button" class="button button-small" onclick="form_clean(this.form)" value="X"/>',
- ]),
'row_parse_pre' => function(&$r){
- $GLOBALS['dbq_args'] = urlencode( join(self::PARAM_ARGS_SEP,$this->table->fields_keys_values($r)) );
+ $GLOBALS['dbq_args'] = urlencode( join($this->param_args_sep,$this->table->fields_keys_values($r)) );
},
'row_parse_post' => function(&$r){
] : [];
$this->table->rows($opt);
+ unset($GLOBALS['dbq_args']);
}
$params = $this->params;
$ext = $this->ext;
+ /*
+ $title = array_unique(array_slice(array_values($params),1));
+ */
$title = array_filter(array_unique(array_slice(array_values($params),1)),
function($v){
return($v==self::PARAM_DB_DEFAULT ? '' : $v);
# Sanitize
if ($values[$i]!=='') {
+
$values[$i] = urldecode($values[$i]);
+
if (
$this->perm < self::ADMIN
and
- !preg_match('/^'.self::PARAM_EXP.'$/',$values[$i])
+ !preg_match('/^'.$this->param_exp_value.'$/',$values[$i])
) $this->error('Wrong value');
+
$this->params[$p] = $values[$i];
+
}
}
} else {
$format =
- (!empty($_SERVER['HTTP_USER_AGENT']) and preg_match($this->human_ua_exp,$_SERVER['HTTP_USER_AGENT']))
+ (!empty($_SERVER['HTTP_USER_AGENT']) and preg_match($this->format_cli_ua_exp,$_SERVER['HTTP_USER_AGENT']))
? 'html'
- : self::CLI_FORMAT
+ : $this->format_cli
;
}
// Post defaults values
if (empty($this->ext)) $this->ext = $format;
- list($title,$nav) = $this->title_nav();
- $this->page->title = join($this->sep_title,$title);
- $this->page->nav = $nav;
-
if (!empty($this->formats)) $this->db->formats = $this->formats;
+ if (!empty($this->limits)) $this->db->limits = $this->limits;
// Then content type
- if (empty($content_type)) $content_type = Mime::fromExt($format==self::CLI_FORMAT ? 'txt' : $format);
+ if (empty($content_type)) $content_type = Mime::fromExt($format==$this->format_cli ? 'txt' : $format);
if (empty($content_type) and $this->db->out->is_html($format)) $content_type = 'text/html';
if (empty($content_type)) $content_type = 'text/plain';
if ($content_type) $this->page->content_type($content_type);
// Affect values to objects
- if ($format == 'html') $format = self::HTML_FORMAT;
+ if ($format == 'html') $format = $this->format_html;
$this->params['format'] = $format;
$this->db->format = $format;
[ 'ls', 'List configured databases' ],
[ 'databases', 'List others databases' ],
[ 'cryptkey', 'Generate a random encryption key' ],
+ [ 'status', 'Status infos page' ],
],['command','description'],function(&$r) {
- $r['command'] = $this->page->tag('a',$r['command'],'href="'.$this->db->base.$r['command'].'.'.$this->ext.'"');
+ $r['command'] = $this->page->tag('a',$r['command'],'href="'
+ .$this->db->base.($r['command'] == self::PARAM_DB_DEFAULT
+ ? ''
+ : $r['command'].'.'.$this->ext
+ )
+ .'"');
});
} elseif ($action == 'ls') {
+ #$this->params += [ 'db' => '', 'table' => '', 'action' => '' ];
+ #$this->params = array_merge($this->params,[ 'db' => '', 'table' => '', 'action' => '' ]);
$this->page($this->db,'ls',[],function(&$r){
$r['id'] = $this->page->tag('a',$r['id'],'href="'.$this->db->base.$r['id'].'.'.$this->ext.'"');
});
[ 'status', 'Database status' ],
[ 'ls', 'List tables' ],
],['command','description'],function(&$r){
- $r['command'] = $this->page->tag('a',$r['command'],'href="'.$this->db->base.$r['command'].'.'.$this->ext.'"');
+ $r['command'] = $this->page->tag('a',$r['command'],'href="'
+ .$this->db->base.($r['command'] == self::PARAM_DB_DEFAULT
+ ? ''
+ : $r['command'].'.'.$this->ext
+ )
+ .'"');
});
} elseif ($action == 'ls') {
[ 'help', 'This help' ],
[ 'ls', 'List records' ],
[ 'fields', 'List fields' ],
+ [ 'status', 'Status page' ],
],['command','description'],function(&$r){
- $r['command'] = $this->page->tag('a',$r['command'],'href="'.$this->db->base.$r['command'].'.'.$this->ext.'"');
+ $r['command'] = $this->page->tag('a',$r['command'],'href="'
+ .$this->table->base.($r['command'] == self::PARAM_DB_DEFAULT
+ ? ''
+ : $r['command'].'.'.$this->ext
+ )
+ .'"');
});
} elseif ($action == 'ls') {
$this->page($this,'table_rows');
- } elseif ($action == 'status') {
- $this->page($this->table->status()+$this->table->status(['fields']));
-
} elseif ($action == 'fields') {
$this->page($this->table,'fields_rows');
+ } elseif ($action == 'status') {
+ $this->page($this->table->status()+$this->table->status(['fields']));
+
} elseif ($action == 'add') {
$this->page($this,'table_html_add');
context: ../Docker/nginx/
args:
- WWW_ROOT=$NB_ROOT/www/dbq/html
+ - FASTCGI_PASS=php:9000
+ #- CONF=$NB_ROOT/www/dbq/etc/nginx/default.conf
volumes_from:
- php
links:
fastcgi_param DBQ_CONF_FILE $document_root/../../../etc/dbq/000-local.php;
fastcgi_param DBQ_PERM 0;
- fastcgi_param DBQ_PARAM_DEFAULT ls;
+ fastcgi_param DBQ_PARAM_DB ls;
+ fastcgi_param PRODUCTION 1;
#fastcgi_param DBQ_TITLE 'Local Db';
}
table.rows,
div.row,
+ul.row,
form.edit,
.menu,
.block,
}
.rows { padding: 0; }
-div.row div, table.rows th, table.rows td { border-bottom: solid 1px #ccc; }
-div.row div, table.rows tr:last-child td { border-bottom: none; }
-div.row div {
- margin: 0;
+ul.row li, div.row div, table.rows th, table.rows td {
+ border-bottom: solid 1px #ccc;
}
+ul.row li, div.row div, table.rows tr:last-child td { border-bottom: none; }
+
+div.row div { margin: 0; }
-div.row div label {
+ul.row li label, div.row div label {
padding: 0.1em 0.5em 0.1em 0;
min-width: 20%;
display: inline-block;
opacity: 0.8;
}
-.menu { padding: 0.5em; }
+form.menu {
+ padding: 0.5em;
+ background-color: #F9F9F9;
+}
+
+form.menu .button.add {
+ float: right;
+}
form.menu .criterias {
border-top: dashed 1px #ccc;
}
form.menu .criterias span.label {
- /*
- width: 23%;
- */
- display: inline-block;
- border: solid 1px #fff;
- padding: 0.1em 0.3em;
+ border-right: solid 1px #fff;
+ padding: 0.2em 0.1em;
margin: 0.2em 0.2em 0 0;
border-radius: 3px;
}
+form.menu .criterias span.label:last-child {
+ border-right: none;
+}
+
+form.menu select:focus {
+ max-width: auto;
+}
+form.menu select {
+ max-width: 15%;
+}
+
+form.menu .criterias input[type=text]:focus {
+ width: auto;
+}
+form.menu .criterias input[type=text] {
+ width: 4em;
+}
/*
form.menu .criterias label {
width: 60%;
-// NB 25.12.16: TODEL
/*
+NB 25.12.16: TODEL
function form_submit_clean(form) {
form_clean(form);
form.submit();
}
+*/
function form_clean(form) {
var e;
for(i=0;i<form.length;i++) {
e = form.elements[i];
if (e.style.display == "none") continue;
- if (e.type != "text") continue;
- e.value = ""
+
+ if (e.type == "text") {
+ e.value = "";
+ } else if (e.type.match(/^select/) && (0
+ || e.name == 'limit'
+ || e.name == 'format'
+ )) {
+ e.selectedIndex = 0;
+ /*
+ */
+ }
}
}
-*/
function form_submit_clean(f) {
var i = 0;
url += (url ? "&" : "?") + encodeURI(p.name) + "=" + encodeURI(p.value);
}
- //alert(url);
url = (action == "?" ? "" : action) + url;
window.location = url;
document.addEventListener("DOMContentLoaded", function() {
- // Clean when submit
- for (var e of document.querySelectorAll("form")) {
+ //console.log('LOADED');
+ NodeList.prototype.forEach = Array.prototype.forEach;
+
+ /* Clean when submit */
+ document.querySelectorAll("form").forEach(function(e) {
e.onsubmit = function() {
return form_submit_clean(this);
};
- }
+ });
/*
Menu
*/
- for (var form of document.querySelectorAll("form.menu")) {
+ document.querySelectorAll("form.menu").forEach(function(form) {
form.setAttribute('action',window.location.toString().replace(/\?.*$/,''));
- // Format
- for (var e of form.querySelectorAll("form.menu select.format")) {
+ /* Format */
+ form.querySelectorAll("form.menu select.format").forEach(function(e) {
e.removeAttribute('name');
e.onchange = function() {
- var format = this.value;
- if (format == window._dbq["HTML_FORMAT"]) format = "html";
- this.form.setAttribute('action',this.form.getAttribute('action').replace(/(\/|\.\w+)$/,'.'+format));
+ this.form.setAttribute('action',this.form.getAttribute('action').replace(/^(.*\/[^\.?\/]+)(\.\w+)?/,'$1.'+this.value));
this.form.onsubmit();
return false;
}
- }
+ });
- // Table
- for (var e of form.querySelectorAll("form.menu select.tables")) {
+ /* Table */
+ form.querySelectorAll("form.menu select.tables").forEach(function(e) {
e.removeAttribute('name');
e.onchange = function() {
- this.form.setAttribute('action',this.form.getAttribute('action').replace(/([^\/\.]+)(\.\w+)?$/,this.value+'$2'));
+ this.form.setAttribute('action',this.form.getAttribute('action').replace(/^(.*\/)[^\/\.\?]+/,'$1'+this.value));
return this.form.onsubmit();
}
- }
+ });
- // Limit
- for (var e of form.querySelectorAll("form.menu select.limit option")) {
+ /* Limit */
+ form.querySelectorAll("form.menu select.limit option").forEach(function(e) {
if (e.value == window._dbq["default.limit"]) e.setAttribute('value','');
- }
+ });
- // Auto submit
- for (var e of form.querySelectorAll("form.menu select.limit")) {
+ /* Auto submit */
+ form.querySelectorAll("form.menu select.limit").forEach(function(e) {
e.onchange = function() {
return this.form.onsubmit();
};
- }
+ });
- }
+ });
if (document.querySelector(".nav.bottom") && document.querySelector("table.rows")) {
document.querySelector("table.rows").insertAdjacentHTML("beforebegin","<div class=\"nav top\">"+document.querySelector(".nav.bottom").innerHTML+"</div>");
}
+ /*
+ document.querySelectorAll("form.menu input[type=text]").forEach(function(e) {
+ e.onfocus = function() {
+ this.setAttribute('style','border:solid 1px red');
+ };
+ });
+ */
+
+ document.querySelectorAll("form.menu input[type=submit]").forEach(function(e) {
+ e.insertAdjacentHTML("afterend",''
+ +' <input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)" value="Clear"/>'
+ +(window._dbq['table.base'] ? ' <input type="button" class="add '+e.className+'" onclick="window.location=\''+window._dbq['table.base']+'add/\'" value="Add"/>' : '')
+ );
+ });
+
});
--- /dev/null
+html{font:90% 'Trebuchet MS',sans-serif;background-color:#eee}body{display:table;margin-left:auto;margin-right:auto;padding-left:1em;padding-right:1em;color:#444}h1{margin:0 0 0.2em 0}a{color:inherit}a,a:visited{text-decoration:none}ul{padding:0;margin:0}li{list-style:none;padding:0 0 0 0.3em}table{border-collapse:collapse}td,th{padding:0.2em 0.7em}th a.sort{padding:0 0.3em}textarea,select,input:not([type]),input[type='text'],input[type='password'],input[type='date'],input[type='email'],input[type='url'],input[type='']{border-radius:3px;border:solid 1px #ddd;padding:0.3em 0.4em}input[size]{max-width:70%}div.row div label:after,form label:after{content:':'}form label,form input,form select{vertical-align:middle;margin:0.2em 0.4em 0.2em 0}table.rows,div.row,form.edit,.menu,.block,object,iframe,pre{border-radius:4px;border-collapse:separate;border-spacing:0;padding:0.5em 0.2em;margin-bottom:0.5em;border:solid 1px #ccc}.rows{padding:0}div.row div,table.rows th,table.rows td{border-bottom:solid 1px #ccc}div.row div,table.rows tr:last-child td{border-bottom:none}div.row div{margin:0}div.row div label{padding:0.1em 0.5em 0.1em 0;min-width:20%;display:inline-block}.menu,.nav,.rows,.buttons,.center{margin-left:auto;margin-right:auto;display:table}.button{font:inherit;display:inline-block;text-decoration:none;line-height:1.5em;cursor:pointer;border-radius:4px;white-space:nowrap;box-sizing:border-box;margin:0;padding:0 0.2em;color:#eee;border:solid 1px #000;background-color:#444}a:hover,.button:hover{opacity:0.8}form.menu{padding:0.5em;background-color:#F9F9F9}form.menu .button.add{float:right}form.menu .criterias{border-top:dashed 1px #ccc;margin-top:0.3em;padding-top:0.3em}form.menu .criterias span.label{border-right:solid 1px #fff;padding:0.2em 0.1em;margin:0.2em 0.2em 0 0;border-radius:3px}form.menu .criterias span.label:last-child{border-right:none}form.menu select:focus{max-width:auto}form.menu select{max-width:15%}form.menu .criterias input[type=text]:focus{width:auto}form.menu .criterias input[type=text]{width:4em}form.edit .fields label{width:25%;text-align:right;display:inline-block;margin-right:1em;vertical-align:top}form.edit .fields .label span{width:54%;display:inline-block;text-align:left}form.edit .fields input,form.edit .fields textarea,form.edit .fields select{width:65%}form.edit .fields label{width:25%;text-align:right;display:inline-block;margin-right:1em;vertical-align:top}form.edit .fields .label span{width:54%;display:inline-block;text-align:left}form.edit .fields input,form.edit .fields textarea,form.edit .fields select{width:65%}
\ No newline at end of file
--- /dev/null
+function form_clean(e){var t
+for(i=0;i<e.length;i++)t=e.elements[i],"none"!=t.style.display&&("text"==t.type?t.value="":!t.type.match(/^select/)||"limit"!=t.name&&"format"!=t.name||(t.selectedIndex=0))}function form_submit_clean(e){var t=0,n="",o=e.getAttribute("action"),r=e.getAttribute("method")
+if("get"!=r)return!0
+for(t=0;t<e.length;t++){var i=e[t]
+i.name&&""!=i.value&&"undefined"!=i.value&&(n+=(n?"&":"?")+encodeURI(i.name)+"="+encodeURI(i.value))}return n=("?"==o?"":o)+n,window.location=n,!1}document.addEventListener("DOMContentLoaded",function(){NodeList.prototype.forEach=Array.prototype.forEach,document.querySelectorAll("form").forEach(function(e){e.onsubmit=function(){return form_submit_clean(this)}}),document.querySelectorAll("form.menu").forEach(function(e){e.setAttribute("action",window.location.toString().replace(/\?.*$/,"")),e.querySelectorAll("form.menu select.format").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",this.form.getAttribute("action").replace(/^(.*\/[^\.?\/]+)(\.\w+)?/,"$1."+this.value)),this.form.onsubmit(),!1}}),e.querySelectorAll("form.menu select.tables").forEach(function(e){e.removeAttribute("name"),e.onchange=function(){return this.form.setAttribute("action",this.form.getAttribute("action").replace(/^(.*\/)[^\/\.\?]+/,"$1"+this.value)),this.form.onsubmit()}}),e.querySelectorAll("form.menu select.limit option").forEach(function(e){e.value==window._dbq["default.limit"]&&e.setAttribute("value","")}),e.querySelectorAll("form.menu select.limit").forEach(function(e){e.onchange=function(){return this.form.onsubmit()}})}),document.querySelector(".nav.bottom")&&document.querySelector("table.rows")&&document.querySelector("table.rows").insertAdjacentHTML("beforebegin",'<div class="nav top">'+document.querySelector(".nav.bottom").innerHTML+"</div>"),document.querySelectorAll("form.menu input[type=submit]").forEach(function(e){e.insertAdjacentHTML("afterend",' <input type="button" class="clear '+e.className+'" onclick="form_clean(this.form)" value="Clear"/>'+(window._dbq["table.base"]?' <input type="button" class="add '+e.className+'" onclick="window.location=\''+window._dbq["table.base"]+'add/\'" value="Add"/>':""))})})
--- /dev/null
+#!/usr/bin/env sh
+set -e
+cd "$(dirname $0)"
+
+minify -s '.min.' --no-comments html/
+exit
+
+# NB 27.12.16 alias minify='minify --no-comments'
+# NB 27.12.16
+# NB 27.12.16 echo Create html/default.min.css
+# NB 27.12.16 minify -o html/default.min.css html/default.css
+# NB 27.12.16 echo
+# NB 27.12.16
+# NB 27.12.16 echo Create html/default.min.js
+# NB 27.12.16 minify -o html/default.min.js html/default.js
+# NB 27.12.16 echo