mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
+ ability to see config params as json with #settings.json or ctrl+click on settings
This commit is contained in:
parent
1c0e07a156
commit
4988741e62
4 changed files with 45 additions and 10 deletions
|
|
@ -486,6 +486,7 @@ li.mtt-item-hidden { display:none; }
|
|||
.mtt-settings-table .th { width:30%; font-weight: bold; }
|
||||
.mtt-settings-table .descr { font-size:0.8rem; font-weight:normal; color:#222; }
|
||||
.mtt-settings-table .in350 { min-width:350px; }
|
||||
.mtt-settings-table textarea.in350 { height:400px; }
|
||||
.mtt-settings-table input { padding:3px; border:1px solid #ccc; border-radius:2px; }
|
||||
.mtt-settings-table select { padding:2px; border:1px solid #ccc; border-radius:2px; }
|
||||
.mtt-settings-table .form-bottom-buttons input { padding:4px; border:1px solid #ccc; border-radius:3px; background-color:#efefef; margin:2px; }
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ class Config
|
|||
if (self::$noDatabase) {
|
||||
return;
|
||||
}
|
||||
$j = self::requestDomain('config.json');
|
||||
$j = self::requestDefaultDomain();
|
||||
foreach ($j as $key=>$val) {
|
||||
// Ignore params for database config
|
||||
if ( !isset(self::$dbparams[$key]) ) {
|
||||
|
|
@ -202,7 +202,7 @@ class Config
|
|||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function requestDomain($key)
|
||||
public static function requestDomain(string $key)
|
||||
{
|
||||
$db = DBConnection::instance();
|
||||
$json = $db->sq("SELECT param_value FROM {$db->prefix}settings WHERE param_key = ?", array($key));
|
||||
|
|
@ -211,6 +211,18 @@ class Config
|
|||
return $j;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @return array
|
||||
* @throws Exception
|
||||
*/
|
||||
public static function requestDefaultDomain()
|
||||
{
|
||||
return self::requestDomain('config.json');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $key
|
||||
|
|
|
|||
|
|
@ -577,7 +577,7 @@ var mytinytodo = window.mytinytodo = _mtt = {
|
|||
|
||||
// Settings
|
||||
$("#settings_btn").click(function(event){
|
||||
showSettings();
|
||||
showSettings( (event.metaKey || event.ctrlKey) ? 1 : 0 );
|
||||
return false;
|
||||
});
|
||||
|
||||
|
|
@ -653,7 +653,7 @@ var mytinytodo = window.mytinytodo = _mtt = {
|
|||
updateAccessStatus();
|
||||
|
||||
if (path.settings) {
|
||||
showSettings();
|
||||
showSettings(path.settings == 'json' ? 1 : 0);
|
||||
}
|
||||
else if (path.search && path.list) {
|
||||
filter.search = path.search;
|
||||
|
|
@ -893,6 +893,7 @@ var mytinytodo = window.mytinytodo = _mtt = {
|
|||
case "list": if(a[++i].match(/^-?\d+$/)) { p[s] = a[i]; } break;
|
||||
case "alltasks": p.list = '-1'; break;
|
||||
case "settings": p.settings = true; break;
|
||||
case "settings.json": p.settings = 'json'; break;
|
||||
case "search": p.search = decodeURIComponent(a[++i]); break;
|
||||
}
|
||||
}
|
||||
|
|
@ -925,8 +926,9 @@ var mytinytodo = window.mytinytodo = _mtt = {
|
|||
return _mtt.mttUrl + 'feed.php?list='+l.id;
|
||||
},
|
||||
|
||||
urlForSettings: function()
|
||||
urlForSettings: function(json = 0)
|
||||
{
|
||||
if (json == 1) return '#settings.json';
|
||||
return '#settings';
|
||||
}
|
||||
|
||||
|
|
@ -2505,15 +2507,16 @@ function logout()
|
|||
Settings
|
||||
*/
|
||||
|
||||
function showSettings()
|
||||
function showSettings(json = 0)
|
||||
{
|
||||
if (_mtt.pages.current && _mtt.pages.current.page == 'ajax' && _mtt.pages.current.pageClass == 'settings') {
|
||||
return false;
|
||||
}
|
||||
$('#page_ajax').load(_mtt.mttUrl+'settings.php?ajax=yes', null, function(){
|
||||
var jsonParam = (json == 1) ? '&json=1' : '';
|
||||
$('#page_ajax').load(_mtt.mttUrl + 'settings.php?ajax=yes' + jsonParam, null, function(){
|
||||
_mtt.pageSet('ajax','settings');
|
||||
var newTitle = _mtt.lang.get('set_header') + ' - ' + _mtt.options.title;
|
||||
updateHistoryState( { settings:1 }, _mtt.urlForSettings(), newTitle );
|
||||
updateHistoryState( { settings:1, settingsJson:json }, _mtt.urlForSettings(json), newTitle );
|
||||
_mtt.doAction('settingsLoaded');
|
||||
})
|
||||
}
|
||||
|
|
@ -2617,7 +2620,7 @@ function historyOnPopState(event)
|
|||
}
|
||||
else if (event.state.settings) {
|
||||
flag.dontChangeHistoryOnce = true;
|
||||
showSettings();
|
||||
showSettings(event.state.settingsJson);
|
||||
}
|
||||
else {
|
||||
console.log("unexpected: nothing to pop");
|
||||
|
|
|
|||
|
|
@ -13,10 +13,11 @@ $lang = Lang::instance();
|
|||
if ( !is_logged() ) {
|
||||
die("Access denied!<br/> Disable password protection or Log in.");
|
||||
}
|
||||
check_token();
|
||||
|
||||
if(isset($_POST['save']))
|
||||
{
|
||||
check_token();
|
||||
|
||||
$t = array();
|
||||
$langs = getLangs();
|
||||
Config::$params['lang']['options'] = array_keys($langs);
|
||||
|
|
@ -134,6 +135,24 @@ header('Content-type:text/html; charset=utf-8');
|
|||
|
||||
<h3 class="page-title"><a class="mtt-back-button"></a><?php _e('set_header');?></h3>
|
||||
|
||||
|
||||
<?php
|
||||
if (isset($_GET['json'])) {
|
||||
$j = Config::requestDefaultDomain();
|
||||
if ($j['password'] != '') $j['password'] = "<not empty>";
|
||||
$j = json_encode($j, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT);
|
||||
?>
|
||||
<div class="mtt-settings-table">
|
||||
<div class="tr">
|
||||
<div class="th"> config.json </div>
|
||||
<div class="td"><textarea class="in350"><?php echo htmlspecialchars($j);?> </textarea></div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
||||
<div id="settings_msg" style="display:none"></div>
|
||||
|
||||
<form id="settings_form" method="post" action="settings.php">
|
||||
|
|
|
|||
Loading…
Reference in a new issue