diff --git a/src/ajax.js b/src/ajax.js index 49ae987..683c503 100644 --- a/src/ajax.js +++ b/src/ajax.js @@ -1,3 +1,9 @@ +/* + This file is part of myTinyTodo. + (C) Copyright 2009-2010 Max Pozdeev + 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 += '
  • '+ - ''+item.name+''+ + ti += '
  • '+ + ''+item.name+''+ '
  • '; }); 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('
  • '+ - ''+item.name+''+ + ''+item.name+''+ '
  • '); 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]; + } +} diff --git a/src/feed.php b/src/feed.php index cf63dcf..53f907b 100644 --- a/src/feed.php +++ b/src/feed.php @@ -2,7 +2,7 @@ /* This file is part of myTinyTodo. - (C) Copyright 2009 Max Pozdeev + (C) Copyright 2009-2010 Max Pozdeev 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 = "\n\n\n". diff --git a/src/index.php b/src/index.php index 22f13a7..5cdcc72 100644 --- a/src/index.php +++ b/src/index.php @@ -1,7 +1,7 @@ + (C) Copyright 2009-2010 Max Pozdeev 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']; - } -} - ?> \ No newline at end of file diff --git a/src/init.php b/src/init.php index 9145e62..0a7351a 100644 --- a/src/init.php +++ b/src/init.php @@ -1,4 +1,9 @@ + 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']; + } +} + ?> \ No newline at end of file diff --git a/src/settings.php b/src/settings.php index bc0a135..a904c2a 100644 --- a/src/settings.php +++ b/src/settings.php @@ -2,7 +2,7 @@ /* This file is part of myTinyTodo. - (C) Copyright 2009 Max Pozdeev + (C) Copyright 2009-2010 Max Pozdeev 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; diff --git a/src/themes/default/index.php b/src/themes/default/index.php index f7cbfa2..2ad84d6 100644 --- a/src/themes/default/index.php +++ b/src/themes/default/index.php @@ -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: '', firstDay: ,