| 1 | <?php |
|---|
| 2 | ############################################################################### |
|---|
| 3 | # Gregarius - A PHP based RSS aggregator. |
|---|
| 4 | # Copyright (C) 2003 - 2006 Marco Bonetti |
|---|
| 5 | # |
|---|
| 6 | ############################################################################### |
|---|
| 7 | # This program is free software and open source software; you can redistribute |
|---|
| 8 | # it and/or modify it under the terms of the GNU General Public License as |
|---|
| 9 | # published by the Free Software Foundation; either version 2 of the License, |
|---|
| 10 | # or (at your option) any later version. |
|---|
| 11 | # |
|---|
| 12 | # This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 13 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|---|
| 14 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
|---|
| 15 | # more details. |
|---|
| 16 | # |
|---|
| 17 | # You should have received a copy of the GNU General Public License along |
|---|
| 18 | # with this program; if not, write to the Free Software Foundation, Inc., |
|---|
| 19 | # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA or visit |
|---|
| 20 | # http://www.gnu.org/licenses/gpl.html |
|---|
| 21 | # |
|---|
| 22 | ############################################################################### |
|---|
| 23 | # E-mail: mbonetti at gmail dot com |
|---|
| 24 | # Web page: http://gregarius.net/ |
|---|
| 25 | # |
|---|
| 26 | ############################################################################### |
|---|
| 27 | |
|---|
| 28 | /// Name: Doubleclick to Read |
|---|
| 29 | /// Author: Marco Bonetti |
|---|
| 30 | /// Description: Marks an item as read when you doubleclick its whitespace |
|---|
| 31 | /// Version: 1.91 |
|---|
| 32 | |
|---|
| 33 | /** |
|---|
| 34 | * Changelog: |
|---|
| 35 | * |
|---|
| 36 | * 1.5 Updated description |
|---|
| 37 | * 1.6 Fixed a bug that would cause a Javascript error when user is not logged in |
|---|
| 38 | * 1.7 Moved the EtagHandler to make the javascript load faster. -- Sameer |
|---|
| 39 | * 1.8 Switched to the rss_bootstrap caching method |
|---|
| 40 | * 1.9 Set the cache-validity to 0 to cause a reload when loggin in and out -- Sameer |
|---|
| 41 | * 1.91 Stupid PHP short tags -- Marco |
|---|
| 42 | */ |
|---|
| 43 | |
|---|
| 44 | function __dblclicktoread_js_register($js) { |
|---|
| 45 | $js[] = getPath(). RSS_PLUGINS_DIR . "/dblclicktoread.php?dcljs"; |
|---|
| 46 | return $js; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | function __dblclickToRead_init_js($dummy) { |
|---|
| 50 | if (!hidePrivate()) { |
|---|
| 51 | echo "\n<script type=\"text/javascript\">\n" |
|---|
| 52 | ."<!--\n" |
|---|
| 53 | ."__dbclickToRead_jsInit();\n" |
|---|
| 54 | ."-->\n" |
|---|
| 55 | ."</script>\n"; |
|---|
| 56 | } |
|---|
| 57 | return $dummy; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | if (isset($_REQUEST['dcljs'])) { |
|---|
| 61 | require_once('../core.php'); |
|---|
| 62 | rss_bootstrap(false,'$Revision$',0); |
|---|
| 63 | require_once('../init.php'); |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | if (hidePrivate()) { |
|---|
| 67 | return ""; |
|---|
| 68 | } |
|---|
| 69 | |
|---|
| 70 | ?> |
|---|
| 71 | |
|---|
| 72 | var isIE=document.all?true:false; |
|---|
| 73 | //alert(isIE); |
|---|
| 74 | function __dblclickToRead_js_getId(o) { |
|---|
| 75 | if (html = o.innerHTML) { |
|---|
| 76 | if (r1 = new RegExp(".*es.([0-9]+),([0-9]+).*,([0-9]+).*","gm").exec(html)) { |
|---|
| 77 | if (!isIE) { |
|---|
| 78 | c = unreadCnt(-1,r1[3]); |
|---|
| 79 | } else { |
|---|
| 80 | c = 1; |
|---|
| 81 | } |
|---|
| 82 | id=r1[1]; |
|---|
| 83 | s =r1[2] & <?php echo SET_MODE_READ_STATE ?>; |
|---|
| 84 | if ((sel = document.getElementById('<?php echo SHOW_WHAT ?>')) && |
|---|
| 85 | sel.options[sel.selectedIndex].value == <?php echo SHOW_UNREAD_ONLY ?>) { |
|---|
| 86 | setItemHide(id, (c == 0)); |
|---|
| 87 | } else{ |
|---|
| 88 | setItemClass(id, 'item even'); |
|---|
| 89 | if (document.all) { |
|---|
| 90 | o.ondblclick = function() {return false;} |
|---|
| 91 | } else { |
|---|
| 92 | o.setAttribute("ondblclick","return false;"); |
|---|
| 93 | } |
|---|
| 94 | } |
|---|
| 95 | |
|---|
| 96 | setState(id,s); |
|---|
| 97 | // legacy code for compatibility with old themes - 2006-06-12 |
|---|
| 98 | }else if (r1 = new RegExp(".*es.([0-9]+),([0-9]+).*","gm").exec(html)) { |
|---|
| 99 | if (!isIE) { |
|---|
| 100 | c = unreadCnt(-1); |
|---|
| 101 | } else { |
|---|
| 102 | c = 1; |
|---|
| 103 | } |
|---|
| 104 | id=r1[1]; |
|---|
| 105 | s =r1[2] & <?php echo SET_MODE_READ_STATE ?>; |
|---|
| 106 | if ((sel = document.getElementById('<?php echo SHOW_WHAT ?>')) && |
|---|
| 107 | sel.options[sel.selectedIndex].value == <?php echo SHOW_UNREAD_ONLY ?>) { |
|---|
| 108 | setItemHide(id, (c == 0)); |
|---|
| 109 | } else{ |
|---|
| 110 | setItemClass(id, 'item even'); |
|---|
| 111 | if (document.all) { |
|---|
| 112 | o.ondblclick = function() {return false;} |
|---|
| 113 | } else { |
|---|
| 114 | o.setAttribute("ondblclick","return false;"); |
|---|
| 115 | } |
|---|
| 116 | } |
|---|
| 117 | |
|---|
| 118 | setState(id,s); |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | } |
|---|
| 122 | } |
|---|
| 123 | function __dbclickToRead_jsInit() { |
|---|
| 124 | var isIE=document.all?true:false; |
|---|
| 125 | var items = document.getElementsByTagName('li'); |
|---|
| 126 | for (var i=0; i<items.length; i++) { |
|---|
| 127 | var item = items[i]; |
|---|
| 128 | if (item.className == "item unread") { |
|---|
| 129 | if (isIE) { |
|---|
| 130 | item.ondblclick = function() { __dblclickToRead_js_getId(this); return false;} |
|---|
| 131 | } else { |
|---|
| 132 | item.setAttribute("ondblclick","__dblclickToRead_js_getId(this); return false;"); |
|---|
| 133 | } |
|---|
| 134 | } |
|---|
| 135 | } |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | <?php |
|---|
| 139 | flush(); |
|---|
| 140 | exit(); |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | rss_set_hook('rss.plugins.javascript','__dblclicktoread_js_register'); |
|---|
| 144 | rss_set_hook('rss.plugins.bodyend','__dblclickToRead_init_js'); |
|---|
| 145 | ?> |
|---|