]> git.nbdom.net Git - nb.git/commitdiff
jpg2avi, big fix
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 7 Aug 2015 12:41:03 +0000 (13:41 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 7 Aug 2015 12:41:03 +0000 (13:41 +0100)
etc/profile.d/functions
lib/css/db.css
lib/php/db.php
lib/php/db/table.php
lib/php/page.php

index 04912a4c84ab34e8b2bb42a3b2ca49fc961fabdc..9c7e9c95109c22e27bb36f34ae8106d66ad3be20 100644 (file)
@@ -15,17 +15,22 @@ shell_help() {
   #
   local msg="$1"; shift
 
-  case "$@" in
-    *-h*|*-help*|*--help*)
-      case $OSTYPE in
-        darwin*) printf "$msg\n" ;;
-        *) echo -e "$msg" ;;
-      esac
-      return 0
-    ;;
-    *) return 1 ;;
-  esac
+  declare i
+  #while [ $# -gt 0 ]; do
+  for i in $@; do
+    case "$i" in
+      -h|-help|--help)
+        case $OSTYPE in
+          darwin*) printf "$msg\n" ;;
+          *) echo -e "$msg" ;;
+        esac
+        return 0
+      ;;
+    esac
+    shift
+  done
 
+  return 1
 }
 
 shell_help_noarg() {
@@ -37,7 +42,7 @@ shell_help_noarg() {
   local args=""; args="$@" # zsh compatible
   [ -z "$args" ] && args="--help"
 
-  sem_help "$msg" "$args"
+  shell_help "$msg" "$args"
 }
 
 shell_functions() {
@@ -251,3 +256,30 @@ print "[ $play - ".$_[0]." ]\n\n";
 exec "mplayer",$_[1];
 ' "$@"
 }
+
+jpg2avi() {
+
+  shell_help_noarg "Usage: $FUNCNAME [-h] JPG_FILES AVI_FILE" "$@" && return
+  declare still; still=/tmp/$FUNCNAME.$$.txt; [ -x /dev/shm ] && tmp=/dev/shm/$FUNCNAME.$$.txt
+  #declare still; still=$FUNCNAME.txt
+  declare tot; tot=$#
+  declare count; count=0
+
+  declare avi; #avi=${@:$#}
+  declare jpg; #jpg=${@:1:$(($# - 1))}
+
+  while [ $# -gt 0 ]; do
+    count=$(($count+1))
+
+    if [ "$count" = "$tot" ]; then
+      avi="$1"; shift; break
+    fi
+
+    echo "$1" >> "$still"
+    shift
+  done
+
+  #echo $(cat $still)" -> $avi"
+  mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -mf type=jpeg:fps=24 mf://@${still} -o $avi
+  rm -f "$still"
+}
index 6f64434ffc12680c5e3d7d510319517d5d3528eb..89b37cc65e6384a1ec1603abf9cf02f5ec0dbe41 100644 (file)
@@ -42,7 +42,9 @@ div.rows { text-align: center; }
 div.rows .row { text-align: left; }
 */
 
+div.rows { text-align: center; }
 div.rows .row {
+  text-align: left;
   vertical-align: top;
   /*
   margin: 0 0 0.5em 0;
@@ -51,7 +53,7 @@ div.rows .row {
   padding: 0.2em;
   display: inline-block;
   width: 21em;
-  width: 16em;
+  overflow: auto;
 }
 
 div.rows .nav {
@@ -77,7 +79,7 @@ div.rows .row label {
 div.rows .row span {
   width: 70%;
   display: inline-block;
-  white-space: pre;
+  white-space: normal;
   text-align: right;
 }
 /*
index 1533ceefda1b1f785b4a746919e4f17d918c19ab..e4f64e064a6bc7668183e1cb0db8d4ddff22fd77 100644 (file)
@@ -6,15 +6,14 @@
   from any database
 
 *****************************************************************************/
-require_once(dirname(__FILE__).'/functions.php');
+require_once(dirname(__FILE__).'/nb.php');
 require_once(dirname(__FILE__).'/db/table.php');
-require_once(dirname(__FILE__).'/db/field.php');
 if (!defined('DB_HTML_FORM_BUTTONS')) define('DB_HTML_FORM_BUTTONS',''
   #.'<input type="button" class="button" value="Add" onclick="this.setAttribute(\'type\',\'submit\');this.setAttribute(\'name\',\'edit\')?1:1"/>'
   #.'<input type="button" class="button" value="Add" onclick="this.setAttribute(\'name\',\'edit\');this.parentElement.submit()?0:0"/>'
   #.'<input type="button" class="button" onclick="return nb.form_clear(this.parentElement)" value="X"/>'
 // NB 04.08.15   .'<a class="button form_clear" href="#" onclick="nb.form_clear(this.parentElement)?0:0">X</a>'
-  .'<span style="display:inline-block;">'
+  .'<span class="buttons">'
   .'<input type="submit" class="button submit" value="GO"/>'
   .'<input type="button" class="button table_add" value="Add" onclick="window.location = \'?action=edit&amp;table=\'+this.parentElement.elements[\'table\'].value"/>'
   .'</span>'
@@ -23,7 +22,7 @@ if (!defined('DB_HTML_FORM_BUTTONS')) define('DB_HTML_FORM_BUTTONS',''
 #if (!defined('DB_HTML_BUTTON_ADD'))    define('DB_HTML_BUTTON_ADD','<a class="button" href="?" onclick="nb.form_clear(this.parentElement) ? 0: 0">Add</a>');
 #if (!defined('DB_HTML_BUTTON_ADD'))    define('DB_HTML_BUTTON_ADD','<input type="submit" class="button" value="Add" onclick="this.setAttribute(\'name\',\'edit\')?0:0"/>');
 
-class db {
+class db extends nb {
 
   public $pdo;
   public $conn;
@@ -268,13 +267,16 @@ EOF;
     $r = '<form class="db menu" method="get" action="">'.PHP_EOL;
 
     // Tables
+    $r .= '<span class="label">';
     $r .= '<label for="table">Tables</label>'.html_select_array($this->tables(),array(
       'html'       => 'class="tables" name="table" id="table"',
       'selected'   => $this->p('table'),
       'prettyText' => true,
     ));
+    $r .= '</span>';
 
     // Format
+    $r .= '<span class="label">';
     $r .= '<label for="format">Format</label>'.html_select_array(array(
       'table','div','csv','xml','json','yaml'
     ),array(
@@ -282,8 +284,10 @@ EOF;
       'selected'   => $this->p('format'),
       'prettyText' => true,
     ));
+    $r .= '</span>';
 
     // Limit
+    $r .= '<span class="label">';
     $r .= '<label for="limit">Limit</label>'.html_select_array(array(
       '10','20','50','100','500','1000'
     ),array(
@@ -291,6 +295,7 @@ EOF;
       'selected'   => $this->p('table'),
       'prettyText' => true,
     ));
+    $r .= '</span>';
 
     // Buttons
     $r .= DB_HTML_FORM_BUTTONS;
@@ -325,27 +330,6 @@ EOF;
     return $r;
   }
 
-  /*
-   * Function: pset
-   * Set a value for param, delete it if null
-   */
-  function pset($name,$value) {
-    if ($value === null) {
-      unset ($_REQUEST[$name]);
-      return null;
-    }
-    return ($_REQUEST[$name] = $value);
-  }
-
-  /*
-   * Function: p
-   * Return a param
-   */
-  function p($name=null,$default=null) {
-    if ($name === null) return isset($_REQUEST) ? $_REQUEST : array();
-    return isset($_REQUEST[$name]) ? $_REQUEST[$name] : $default;
-  }
-
   function sql_name($value) {
     if (preg_match('/^\w+$/',$value)) return $value;
     if ($this->type == 'mysql') return '`'.$value.'`';
index 708aa5f10007f5515b437904611e3d3aeb1607c5..6274151a1f6dbe0d99e095185f372fe821fc0814 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-require_once(dirname(__FILE__).'/../functions.php');
 require_once(dirname(__FILE__).'/../db.php');
 require_once(dirname(__FILE__).'/../db/field.php');
 
@@ -18,7 +17,8 @@ if (false and empty($_SERVER['DOCUMENT_ROOT'])) {
 if (!defined('DB_HTML_EDIT')) define('DB_HTML_EDIT','Edit');
 if (!defined('DB_HTML_DELETE')) define('DB_HTML_DELETE','Delete');
 if (!defined('DB_HTML_NAV_TOP')) define('DB_HTML_NAV_TOP','<div align="center" class="nav" id="nav_top"></div>'.PHP_EOL);
-class table {
+
+class table extends nb {
 
   public $name;
   public $db;
@@ -32,10 +32,6 @@ class table {
     'debug',
   );
 
-  function __destruct() {
-    foreach (get_object_vars($this) as $k=>$v) { unset($this->$k); };
-  }
-
   function __construct($name,$opt=array()) {
 
     // Connection
index 664608d01edbe903252c5f1ba48b1d295c0eb693..284a26c55af8f2e0f0798d6bea4ea965e7bdc001 100644 (file)
@@ -1,5 +1,5 @@
 <?php
-require_once(dirname(__FILE__).'/functions.php');
+require_once(dirname(__FILE__).'/nb.php');
 /*
 if (
   !@$_SERVER['DOCUMENT_ROOT'] and (realpath($argv[0]) == __FILE__)
@@ -16,7 +16,7 @@ $Page = new Page(array(
 }
 */
 
-class Page {
+class Page extends nb {
 
   public $call = array();
 # NB 04.08.15 wtf ??? public $output;