diff --git a/src/content/themes/default/index.php b/src/content/themes/default/index.php index 259a7a1..929c9b8 100644 --- a/src/content/themes/default/index.php +++ b/src/content/themes/default/index.php @@ -23,20 +23,7 @@ diff --git a/src/includes/class.lang.php b/src/includes/class.lang.php index 6f0d28e..5869497 100644 --- a/src/includes/class.lang.php +++ b/src/includes/class.lang.php @@ -90,7 +90,8 @@ class Lang return 0; } - function makeJS($pretty = 0) + /* minimal number of translated strings to use in js front-end */ + function jsStrings() { $a = array(); $a['daysMin'] = $this->get('days_min'); @@ -121,6 +122,12 @@ class Lang ]); $a['_rtl'] = $this->rtl() ? 1 : 0; + return $a; + } + + function makeJS($pretty = 0) + { + $a = $this->jsStrings(); $opts = JSON_UNESCAPED_UNICODE; if ($pretty) { $opts |= JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES; diff --git a/src/includes/mytinytodo.js b/src/includes/mytinytodo.js index cf68a74..51b058b 100644 --- a/src/includes/mytinytodo.js +++ b/src/includes/mytinytodo.js @@ -107,6 +107,12 @@ var mytinytodo = window.mytinytodo = _mtt = { flag: flag, // procs + setApi: function(storage) + { + this.db = new storage(this); + return this; + }, + init: function(options) { // required properties diff --git a/src/index.php b/src/index.php index 75e8909..6b0a3c7 100644 --- a/src/index.php +++ b/src/index.php @@ -47,3 +47,22 @@ function redirectWithHashRoute(array $q, array $hash) header("Location: ". $url); exit; } + +function js_options() +{ + $a = array( + "title" => get_mttinfo('title', false), + "lang" => Lang::instance()->jsStrings(), + "mttUrl" => get_mttinfo('mtt_url'), + "homeUrl" => get_mttinfo('url'), + "needAuth" => need_auth() ? true : false, + "isLogged" => is_logged() ? true : false, + "showdate" => Config::get('showdate') ? true : false, + "duedatepickerformat" => htmlspecialchars(Config::get('dateformat2')), + "firstdayofweek" => (int) Config::get('firstdayofweek'), + "calendarIcon" => get_mttinfo('template_url'). 'images/calendar.svg', + "autotag" => Config::get('autotag') ? true : false, + "markdown" => Config::get('markup') == 'v1' ? false : true + ); + echo json_encode($a, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); +} diff --git a/src/init.php b/src/init.php index 9e814ca..4526a04 100644 --- a/src/init.php +++ b/src/init.php @@ -143,7 +143,6 @@ function __($s) function mttinfo($v, $escape = true) { - global $_mttinfo; echo $escape ? get_mttinfo($v) : get_unsafe_mttinfo($v); }