mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
+ can specify in URL the id of list to open.
This commit is contained in:
parent
8be18ac673
commit
8134fd3e71
6 changed files with 95 additions and 63 deletions
43
src/ajax.js
43
src/ajax.js
|
|
@ -1,3 +1,9 @@
|
|||
/*
|
||||
This file is part of myTinyTodo.
|
||||
(C) Copyright 2009-2010 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
|
||||
*/
|
||||
|
||||
theme = {
|
||||
newTaskFlashColor: '#ffffaa',
|
||||
editTaskFlashColor: '#bbffaa',
|
||||
|
|
@ -25,6 +31,9 @@ var mytinytodo = {
|
|||
actions: {},
|
||||
menus: {},
|
||||
mttUrl: '',
|
||||
options: {
|
||||
openList: 0
|
||||
},
|
||||
|
||||
addAction: function(action, proc)
|
||||
{
|
||||
|
|
@ -38,6 +47,10 @@ var mytinytodo = {
|
|||
for(var i in this.actions[action]) {
|
||||
this.actions[action][i](opts);
|
||||
}
|
||||
},
|
||||
|
||||
setOptions: function(opts) {
|
||||
jQuery.extend(this.options, opts);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -878,6 +891,7 @@ function toggleAllNotes(show)
|
|||
|
||||
function loadLists(onInit, updAccess)
|
||||
{
|
||||
if(updAccess) mytinytodo.parseAnchor();
|
||||
if(filter.search != '') {
|
||||
filter.search = '';
|
||||
$('#searchbarkeyword').text('');
|
||||
|
|
@ -889,11 +903,20 @@ function loadLists(onInit, updAccess)
|
|||
var ti = '';
|
||||
if(parseInt(json.total))
|
||||
{
|
||||
var openIdx = 0;
|
||||
if(mytinytodo.options.openList) {
|
||||
for(var i in json.list) {
|
||||
if(mytinytodo.options.openList == json.list[i].id) {
|
||||
openIdx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
$.each(json.list, function(i,item){
|
||||
item.i = i;
|
||||
tabLists[i] = item;
|
||||
ti += '<li id="list_'+item.id+'" class="'+(i==0?'mtt-tabs-selected':'')+'">'+
|
||||
'<a href="#list'+item.id+'" title="'+item.name+'" onClick="mttTabSelected('+item.id+','+i+');return false;"><span>'+item.name+'</span>'+
|
||||
ti += '<li id="list_'+item.id+'" class="'+(i==openIdx?'mtt-tabs-selected':'')+'">'+
|
||||
'<a href="#list/'+item.id+'" title="'+item.name+'" onClick="mttTabSelected('+item.id+','+i+');return false;"><span>'+item.name+'</span>'+
|
||||
'<div class="list-action" onClick="listMenu(this,'+i+');return stopBubble(arguments[0]);"></div></a></li>';
|
||||
});
|
||||
if(!curList) {
|
||||
|
|
@ -901,7 +924,7 @@ function loadLists(onInit, updAccess)
|
|||
$('#page_tasks h3').children().removeClass('invisible');
|
||||
$('#mylistscontainer .mtt-need-list').removeClass('mtt-disabled');
|
||||
}
|
||||
curList = tabLists[0];
|
||||
curList = tabLists[openIdx];
|
||||
loadTasks();
|
||||
//if(curList.published)
|
||||
$('#rss_icon').find('a').attr('href', mytinytodo.mttUrl+'feed.php?list='+curList.id);
|
||||
|
|
@ -914,6 +937,7 @@ function loadLists(onInit, updAccess)
|
|||
$('#mylistscontainer .mtt-need-list').addClass('mtt-disabled');
|
||||
$('#tasklist').html('');
|
||||
}
|
||||
mytinytodo.options.openList = 0;
|
||||
$('#lists ul').html(ti);
|
||||
$('#lists').show();
|
||||
mytinytodo.doAction('listsLoaded');
|
||||
|
|
@ -937,7 +961,7 @@ function addList()
|
|||
tabLists[i] = item;
|
||||
if(i > 0) {
|
||||
$('#lists ul').append('<li id="list_'+item.id+'">'+
|
||||
'<a href="#list'+item.id+'" title="'+item.name+'" onClick="mttTabSelected('+item.id+','+i+');return false;"><span>'+item.name+'</span>'+
|
||||
'<a href="#list/'+item.id+'" title="'+item.name+'" onClick="mttTabSelected('+item.id+','+i+');return false;"><span>'+item.name+'</span>'+
|
||||
'<div class="list-action" onClick="listMenu(this,'+i+');return stopBubble(arguments[0]);"></div></a></li>');
|
||||
mytinytodo.doAction('listAdded', item);
|
||||
}
|
||||
|
|
@ -1360,3 +1384,14 @@ function stopBubble(e)
|
|||
if(e.stopPropagation) e.stopPropagation();
|
||||
return false;
|
||||
}
|
||||
|
||||
mytinytodo.parseAnchor = function()
|
||||
{
|
||||
if(location.hash == '') return false;
|
||||
var h = location.hash.substr(1);
|
||||
var a = h.split("/");
|
||||
if(a.length < 2) return false;
|
||||
if(a[0] == 'list' && a[1].match(/^\d+$/)) {
|
||||
this.options.openList = a[1];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/*
|
||||
This file is part of myTinyTodo.
|
||||
(C) Copyright 2009 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
(C) Copyright 2009-2010 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
|
||||
*/
|
||||
|
||||
|
|
@ -46,7 +46,7 @@ printRss($listData, $data);
|
|||
|
||||
function printRss($listData, $data)
|
||||
{
|
||||
$link = htmlarray('http://'. $_SERVER['HTTP_HOST']. substr($_SERVER['REQUEST_URI'], 0, strrpos($_SERVER['REQUEST_URI'], '/') + 1));
|
||||
$link = get_mttinfo('url'). "?list=". $listData['id'];
|
||||
$buildDate = gmdate('r');
|
||||
|
||||
$s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<rss version=\"2.0\" xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n<channel>\n".
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
This file is part of myTinyTodo.
|
||||
(C) Copyright 2009 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
(C) Copyright 2009-2010 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
|
||||
*/
|
||||
|
||||
|
|
@ -13,51 +13,8 @@ if($lang->rtl()) Config::set('rtl', 1);
|
|||
|
||||
if(!is_int(Config::get('firstdayofweek')) || Config::get('firstdayofweek')<0 || Config::get('firstdayofweek')>6) Config::set('firstdayofweek', 1);
|
||||
|
||||
$_mttinfo = array();
|
||||
|
||||
define('TEMPLATEPATH', MTTPATH. 'themes/'.Config::get('template').'/');
|
||||
|
||||
require(TEMPLATEPATH. 'index.php');
|
||||
|
||||
|
||||
function _e($s)
|
||||
{
|
||||
global $lang;
|
||||
echo $lang->get($s);
|
||||
}
|
||||
|
||||
function mttinfo($v)
|
||||
{
|
||||
global $_mttinfo;
|
||||
if(!isset($_mttinfo[$v])) {
|
||||
echo get_mttinfo($v);
|
||||
} else {
|
||||
echo $_mttinfo[$v];
|
||||
}
|
||||
}
|
||||
|
||||
function get_mttinfo($v)
|
||||
{
|
||||
global $_mttinfo, $lang;
|
||||
if(isset($_mttinfo[$v])) return $_mttinfo[$v];
|
||||
switch($v)
|
||||
{
|
||||
case 'template_url':
|
||||
$_mttinfo['template_url'] = get_mttinfo('mtt_url'). 'themes/'. Config::get('template') . '/';
|
||||
return $_mttinfo['template_url'];
|
||||
case 'url':
|
||||
$_mttinfo['url'] = Config::get('url');
|
||||
if($_mttinfo['url'] == '')
|
||||
$_mttinfo['url'] = 'http://'.$_SERVER['HTTP_HOST'] .($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''). parse_url($url, PHP_URL_PATH);
|
||||
return $_mttinfo['url'];
|
||||
case 'mtt_url':
|
||||
$_mttinfo['mtt_url'] = Config::get('mtt_url');
|
||||
if($_mttinfo['mtt_url'] == '') $_mttinfo['mtt_url'] = url_dir($_SERVER['REQUEST_URI']);
|
||||
return $_mttinfo['mtt_url'];
|
||||
case 'title':
|
||||
$_mttinfo['title'] = (Config::get('title') != '') ? htmlarray(Config::get('title')) : $lang->get('My Tiny Todolist');
|
||||
return $_mttinfo['title'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
51
src/init.php
51
src/init.php
|
|
@ -1,4 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
This file is part of myTinyTodo.
|
||||
(C) Copyright 2009-2010 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
|
||||
*/
|
||||
|
||||
if(!defined('MTTPATH')) define('MTTPATH', dirname(__FILE__) .'/');
|
||||
|
||||
|
|
@ -32,6 +37,8 @@ $db->prefix = Config::get('prefix');
|
|||
require_once(MTTPATH. 'lang/class.default.php');
|
||||
require_once(MTTPATH. 'lang/'.Config::get('lang').'.php');
|
||||
|
||||
$_mttinfo = array();
|
||||
|
||||
$needAuth = (Config::get('password') != '') ? 1 : 0;
|
||||
if($needAuth && !isset($dontStartSession))
|
||||
{
|
||||
|
|
@ -82,4 +89,48 @@ function formatTime($format, $timestamp=0, $tz=null)
|
|||
return $s;
|
||||
}
|
||||
|
||||
function _e($s)
|
||||
{
|
||||
echo Lang::instance()->get($s);
|
||||
}
|
||||
|
||||
function __($s)
|
||||
{
|
||||
return Lang::instance()->get($s);
|
||||
}
|
||||
|
||||
function mttinfo($v)
|
||||
{
|
||||
global $_mttinfo;
|
||||
if(!isset($_mttinfo[$v])) {
|
||||
echo get_mttinfo($v);
|
||||
} else {
|
||||
echo $_mttinfo[$v];
|
||||
}
|
||||
}
|
||||
|
||||
function get_mttinfo($v)
|
||||
{
|
||||
global $_mttinfo, $lang;
|
||||
if(isset($_mttinfo[$v])) return $_mttinfo[$v];
|
||||
switch($v)
|
||||
{
|
||||
case 'template_url':
|
||||
$_mttinfo['template_url'] = get_mttinfo('mtt_url'). 'themes/'. Config::get('template') . '/';
|
||||
return $_mttinfo['template_url'];
|
||||
case 'url':
|
||||
$_mttinfo['url'] = Config::get('url');
|
||||
if($_mttinfo['url'] == '')
|
||||
$_mttinfo['url'] = 'http://'.$_SERVER['HTTP_HOST'] .($_SERVER['SERVER_PORT'] != 80 ? ':'.$_SERVER['SERVER_PORT'] : ''). url_dir($_SERVER['REQUEST_URI']);
|
||||
return $_mttinfo['url'];
|
||||
case 'mtt_url':
|
||||
$_mttinfo['mtt_url'] = Config::get('mtt_url');
|
||||
if($_mttinfo['mtt_url'] == '') $_mttinfo['mtt_url'] = url_dir($_SERVER['REQUEST_URI']);
|
||||
return $_mttinfo['mtt_url'];
|
||||
case 'title':
|
||||
$_mttinfo['title'] = (Config::get('title') != '') ? htmlarray(Config::get('title')) : $lang->get('My Tiny Todolist');
|
||||
return $_mttinfo['title'];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
/*
|
||||
This file is part of myTinyTodo.
|
||||
(C) Copyright 2009 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
(C) Copyright 2009-2010 Max Pozdeev <maxpozdeev@gmail.com>
|
||||
Licensed under the GNU GPL v3 license. See file COPYRIGHT for details.
|
||||
*/
|
||||
|
||||
|
|
@ -46,18 +46,6 @@ function _c($key)
|
|||
return Config::get($key);
|
||||
}
|
||||
|
||||
function _e($s)
|
||||
{
|
||||
global $lang;
|
||||
echo $lang->get($s);
|
||||
}
|
||||
|
||||
function __($s)
|
||||
{
|
||||
global $lang;
|
||||
return $lang->get($s);
|
||||
}
|
||||
|
||||
function getLangs()
|
||||
{
|
||||
if (!$h = opendir(MTTPATH. 'lang')) return false;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ $().ready(function(){
|
|||
if(is_logged()) echo "\tflag.isLogged = true;\n";
|
||||
}
|
||||
if(Config::get('autotag')) echo "\tflag.autoTag = true;\n";
|
||||
if(isset($_GET['list'])) echo "\tmytinytodo.setOptions({openList:". (int)$_GET['list']. "});\n";
|
||||
echo "\tloadLists(1, 1);\n";
|
||||
?>
|
||||
$("#duedate").datepicker({dateFormat: '<?php echo datepickerformat(); ?>', firstDay: <?php echo Config::get('firstdayofweek'); ?>,
|
||||
|
|
|
|||
Loading…
Reference in a new issue