57
那些年,我們用 Javascript 幹了一套 POS Base on XULRunner Rack Lin 阿土伯 @HDM9 V2

Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Embed Size (px)

DESCRIPTION

Introduction XULRunner Javascript Full-Stack Framework Plugin-able design

Citation preview

Page 1: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

那些年,我們用 Javascript    幹了一套  POS

Base  on  XULRunner    

Rack  Lin  阿土伯      @HDM9    V2

Page 2: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

about:me

•  ViViPOS  Co.,  Ltd    技術總監  –  利用 javascript  寫 〞收銀機〞(傳統產業,全新感受)  

•  CoCo  都可、50嵐、歇腳亭、Yamaha  、星聚點KTV……    

•  PHP  /  Javascript  /  Java  Programmer  (目前移情於 Scala  )    

•  [email protected]  •  hSps://twiSer.com/racklin  •  hSp://www.plurk.com/racklin  •  hSps://www.facebook.com/racklin1002  •  hSp://racklin.blogspot.tw/      (生小孩後就變癈墟)  

Page 3: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

NOT  Web-­‐Based  POS

Standalone  Applica.on  Running  on  Client  Terminal  

Page 4: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

NOT  Only  POS  So[ware

POS  SDK  

Page 5: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

What  is  POS

Page 6: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

What  is  POS

Page 7: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

What  is  POS

Page 8: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

POS  Development

•  Delphi  – 曾經王者 ,目前依然是  

•  Java  –   非 Windows  Solu\ons  首選    

•  VIVIPOS  SDK  –  Javascript  /  html  /  xul        based  on  XULRunner  

Page 9: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

WHY  XULRunner •  Cross-­‐Pla_orm  •  Update  and  Packages  mechanism  •  XPCOM  *  •  Networking  *  •  Storage  -­‐  SQLite  interface  *  •  Chrome  Registra\on  *  •  Gecko  rendering  engine  – HTML5  /  CSS3  –  XBL  /  XUL  /  Javascript  1.8  –  XML  (XSLT,  XMLHSpRequest,  DOMParser,  etc.)  

•  Coding  For  Fun  

Page 10: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Cloc  for  VIVIPOS  SDK

Page 11: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Cloc  for  VIVIPOS  Exts

Page 12: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Coding  For  Fun  ?

•  over  100,000  lines  javascript    •  over  300,000  lines  XUL  

Page 13: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

WHY  NOT  blablabla…

•  Before  2010  – Why  not  Delphi  /  VB  /  Java  

•  A[er  2010  – Why  not  Nodejs  

•  v0.1.102.zip  —  2010.07.25,  Version  0.1.102    – Why  not  Chrome  

•  0.2.149    2008.09.08  

•  VIVIPOS  Start  at  2008  

Page 14: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

About  VIVIPOS  (2008)  

•  Hardware:  Via  Eden  1G  512MB  Ram    •  OS:  Ubuntu  Linux  8.04  •  DB:  SQLite3  /  JSON  •  XULRunner  1.8.1  •  Languages:  C(vala)  /  Javascript    

Page 15: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Start  Hard  Coding  ?

POS  Applica\on  Look  Simply…  

Page 16: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

別急著硬幹!!    

除非你想 75 天賣掉整個商業模式!!    

而不是產品!

Page 17: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Project  or  Product

•  經常 Branch  /  Code  Generator    

•  流行名言:你以為在創新、其實是在代工

Customer  A

Customer  B

Customer  C

Page 18: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Components  Based

•  Upstream  Core  Components    

•  Customiza\on  – Customer  A  (  SDK  +  POS  +  A1  +  B1  +  C1  ….)  – Customer  B  (  SDK    +  POS  +  A1  +  C1  +  D1  …)  – Customer  C  (  SDK  +  POS  +  A1  +  E1  +  F1  …)  

VIVIPOS  SDK

VIVIECR  (POS  Main  UI)

Page 19: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

自給自足,豐衣足食

•  當 POS  主流開發是 WinForm  /  JFrame  /  TForm  時,我在 VIM.  

•  #1:GREU\ls  and  XPCOM    •  #2:GeckoJS  •  #3:SDK  and  XBLs  

Page 20: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

VIVIPOS  SDK

Page 21: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

VIVIPOS  SDK

WTF  !    

Gray  Screen  ?

Page 22: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

老板:

SDK  是嗎!! OK!  那你至少告訴我 SDK  怎麼應用!

Page 23: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Hello  World

Page 24: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

GREU\ls

•  2007.09  Released  and  open  source  •  Object  Namespace  •  Charset  Conversion  •  Crypto  Hash  U\li\es  –  md5  /  sha1  /sha256  •  File  And  Directory  IO    •  JSON  encode  /  decode  use  na\ve  C++  implemented.  

•  Threading  –  Na\ve  Mul\-­‐Threading  support  •  XPCOM  Helper

Page 25: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

GeckoJS

•  MVC  Architecture  –  Dispatcher  /  Controller  – Model  –  Ac\veRecord  Like  and  Associa.ons  Support  –  VIVIPOS  Query  Language  (VQL)    

•  Database  Adapter  –  SQLite  and  JSON  

•  Configure  /  Registry  System  –  Preference  System  

•  Applica\on  Scope  Session  •  Logging  –  Log4js  !?  •  i18n  /  l10n  •  Event  System  –  NOT  DOM  Event

Page 26: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

C++  XPCOM

•  On-­‐Screen-­‐Display  (OSD)  •  DBUS  No\fica\on  •  Matchbox  Virtual  Keyboard  •  IO  Control  –  Serial  Port  /  USB    –  Parallel  Port  – DIO  – GPIO    

•  JSLoader    

Page 27: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

XBL  Components

•  ACL  /  Config  /  Session  aware  containers  •  Data  aware  UI  components  – Label    – BuSon    

– BuSons  Group  

Page 28: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

XBL  Components

•  Scrollable  BuSons  Group  

Page 29: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

XBL  Components

•  Tree  and  scrollable  tree  

Page 30: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Debug  Tools

•  JS  Console  •  JS  Debuger  •  DOM  Inspector  •  SQLite  Manager  •  SDK  Console  #

Page 31: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Start  Hard  Coding  Now  ?

Wait!!  SDK  /  Framework  were  tools,  not  core  values.  

Page 32: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Core  Values

•  Pla_orm  For  3rd  Party  Developers  •  Plugins  Anywhere  – User  Interface  /  Layouts  /  Skins  –  I18n/l10n  – Devices  – Reports  – Promo\ons  Modules  – Second  Display  Modules  –  Inventory  System  

Page 33: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Core  Values

•  Services  Registry  – Binding  To  UI  – Binding  To  Hotkey  – Remove  Invoke  (  IPC  /  Protocol)  

•  NO  Linux  Na\ve  UI  •  Open  Source  Addons  

Page 34: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Reports

•  Reports  – CSV  –  Template  Engine  – HTML  –  Template  Engine  – PDF  • Print  To  PDF  By  Gecko  – Export  about  100  pages  PDF  more  than  30mins  

• Print  To  PDF  By  WebKit  (libwkhtmltox)  – Export  about  100  pages  PDF  less  than  3mins  – But  Buggy  –  NOT  Support  thead/tbody/_oot.  

Page 35: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Promo\on  framework

•  Cart  is  Simple  !?  好的 PM  勝過好的 Programmers  – 二件九折 -­‐>  第二件八折  -­‐>  第三件七折 …..  

•  Promo\on  Modules  *  – Base  Condi\ons  – Product  Trigger  –  Plugin-­‐able  – Discount  Type  –  Plugin-­‐able    

Page 36: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

VIVIPOS  Architecture

VIVIPOS  APP  

ECR-­‐like  User  Interface  /  Func;ons  

LINUX  BASE  Display  Driver  USB  Driver  

Keypad  Driver  Touch  Driver  

Audio  Driver  LAN  Driver  

Power  Management  

Others  

LIBRARIES                                                        XPCOM  

GPIO  Database  

Serial  IO   Parallel  IO  

Network  

Others  

VIVIPOS  SDK  

Core  Libraries  

Signature  Func.on  

FRAMEWORK  

Plug-­‐in  /  Add-­‐on  Manager  

Network  Manager  

Backup  Manager  

Restore  Manager   Others  

Peripheral  Manager  

UI  Manager  

Func.on  Manager  

Language  Manager  

Update  Manager  

Window  Manager  

Content  Manager  

View  System  

Message  Dispatch  

Database  Interface  

Report  Module  

Cart  Module  

APPLICATIONS  Clerk  

Opera.ons  Stock  Control   Repor.ng   System  

Func.on   Others  

Add-­‐on    -­‐  Member  Management  -­‐  SMS  Promo.on  -­‐  Special  Discount  -­‐  …  etc.  

               Add-­‐on                    -­‐  Cash  Flow  Report                  -­‐  Gi]  Card  Payment                  -­‐  …  etc.  

Page 37: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

VIVIPOS  POS

Page 38: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Binding  Service  To  UI

Page 39: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Binding  Service  Hotkey

Page 40: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

I18n  /  l10n

Page 41: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

VIVIPOS  Add-­‐ons  For  Produc\on

•  Main  POS  Add-­‐on    -­‐  VIVIECR  – 690  pages  PDF  Manual    – En  /  zhTW  /  zhCN  /  Jp  /  Thai  /  Fr    

•  Taiwan  Invoice  Add-­‐on  •  Customer  Management  Add-­‐on  •  Taiwan  Receipts  Format  Add-­‐on  •  Simple  Browser  •  Second  Display  Add-­‐on  

   Open

 Source

Page 42: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Simple  Web  Browser  Add-­‐on

•  Embedded  Firefox  browser  •  Gecko  1.9.2  Engine  – HTML5  Support  – CSS3  Support  

•  Binding  To  BuSon  •  Binding  To  Hotkey  •  Disable  Popup  Window

Page 43: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

DEMO  VIVIPOS  

VIDEO:  hSp://youtu.be/-­‐z26mGeynok  •  Next  Page  is  DEMO  Descrip\on

Page 44: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

DEMO  Descrip\on

•  A  Produc\on  POS  Solu\on  is  combina\on  of  many  add-­‐ons  not  ONE  App.  

•  Every  individual  Add-­‐ons  CAN  online  update.  •  Add-­‐on  can  hook  the  event  and  change  the  shopping  flow.  

•  EX.  ONLY  ONE  Customer  Need  BEEP  when  product  not  found  !?  Add  a  add-­‐on  for  him,  Not  add  BEEP  feature  in  upstream  version.

Page 45: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

IPC

•  DBUS    •  Javascript  implemented  HSp  server  – Binding  on  localhost:8888  

•  Dispatch  Command    •  No\fy  Observer  •  Session  Opera\on  •  ...    

Page 46: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

IPC  Samples

•  AddItem  To  Cart  –  curl  hSp://localhost:8888/dispatch?

controller=Cart&command=addItemByBarcode&data=123456789  

•  Get  Current  Login  Clerk  –   curl  hSp://localhost:8888/session?ac\on=get&key=user.username  

•  Shutdown  –  Trigger  Event/Observe  –   curl  hSp://localhost:8888/observer?topic=shutdown  

•  Ex.  Installed  HelloWorld.xpi  –   curl  hSp://localhost:8888/dispatch?

controller=Helloworld&command=sayHello&data=Rack  

Page 47: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Last  Mile  of  the  O2O

•  Add  a  Protocol  Handler,  ‘vivipos’  scheme.  – Proxy  to  exists  JS  HSpd  Services.  

•  Remote/Local  Website  CAN  – Callback  VIVIPOS  Func\ons  – Use  VIVIPOS  Hardwares  (  Printer  /  Cash  Drawer)  – Use  VIVIPOS  Cart  and  Promo\ons  – Use  VIVIPOS  Reports  

 

Page 48: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

VIVIPOS  Scheme  Samples

•  Remote  website  HTML  – AddItem  To  Cart  

<a  href=“vivipos:dispatch?  controller=Cart&command=addItemByBarcode&data=123456789”>AddItem</a>  

– Shutdown  –  Trigger  Event/Observe  <a  href=“vivipos:observer?topic=shutdown”>Shutdown</a>

Page 49: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Open  PCHOME24  Example

•  Click  ACER  E1-­‐531  Will  Add  Item  to  VIVIPOS  Cart  And  Prin\ng  Receipt.

Page 50: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

What  is  Online2OffLine

•  線上訂位  /  線上團購 <>實體消費  •  會員積點 /  折扣  •  線上促銷<>實體促銷  •  線上銷售<>實體銷售  •  消費分析  

Page 51: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

SDK  -­‐  Last  Mile  of  O2O

•  Online  Services  開發者不用重覆造輪子,為了整合服務而開發陽春 POS 系統.  VIVIPOS 是完整的收銀系統且 Open  Source  

•  除了整合服務,更可開發自己的 POS  系統  •  使用您熟悉的平台語言開發 POS    JAVA  /  PHP  /  RAILS  /  NODEJS  ……..    

•  可以不需要學習 VIVIPOS  SDK.  (盡量啦)

Page 52: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

3rd  Party  interes.ng  Addons

•  Singapore  Bugis  Street  – NetPayment  /  EZLinks  

•  Microprogram 悠遊卡 and  Life+  •  OpenLife  •  24卷 (大陸團購-好像掛了 orz  )  •  USA  -­‐  KIOSK  •  Media  Player  

Page 53: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

About  Cloud?

•  Running  Web  Based  Applica\on  in  Cloud  –  Yes  ,  Simple  Web  Browser  with    HTML5  /  CSS3  Supported  

•  Sending  Data  to  Cloud  real\me  –  Yes,  Using  AJAX  

•  Packing  Data  to  Cloud  when  Day-­‐End  –  YES  ,  VIVIConnect  Add-­‐on  support  Client-­‐Side  ETL  to  packing  Databases  to  your  own  Back-­‐End  Server.  

–  HTTP/HTTPs  –  FTP  –  S3  

•  Running  your  own  scripts  –  PHP  /  Python    installed  on  every  VIVIPOS  Terminal.  

Page 54: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

JS  Loader

•  Javascript  Encoder  For  3rd  party  Developer  – NOT  obfuscator  

•  Add  Trial  Version  to  your  Add-­‐on  •  Add  Expire  Date  to  your  Add-­‐on  •  Lock  your  Add-­‐on  on  a  special  Terminal  

Page 55: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Any  Ideas  are  welcome

POS  or  POS

Page 56: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Thank  You  

Coding  For  Fun

Page 57: Plugin-able POS Solutions by Javascript @HDM9 Taiwan

Resources

•  Slide:    hSp://goo.gl/TlHKf    

•  GREU\ls:  hSps://github.com/racklin/greu\ls  

•  XULRunner  –  MDN  hSps://developer.mozilla.org/en-­‐US/docs/XULRunner