2 * Copyright 2007 Jesse Andrews, Manish Singh, Ian Fischer
4 * This file may be used under the terms of of the
5 * GNU General Public License Version 2 or later (the "GPL"),
6 * http://www.gnu.org/licenses/gpl.html
8 * Software distributed under the License is distributed on an "AS IS" basis,
9 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
10 * for the specific language governing rights and limitations under the
14 function Controller() {
15 var content = $('content');
18 this.load = function(ViewClass) {
19 content.innerHTML = '';
20 view = new ViewClass(content);
22 tboPrefs.setCharPref("extensions.taboo.view", ViewClass + '');
27 this.filter = function(str) {
28 if (this._filterStr == str) {
33 this._filterStr = str;
37 this.tabDelete = function(tab, el) {
38 el.style.display = "none";
39 self.displayUndelete(tab, el);
43 this.tabFinalDelete = function(tab, el) {
44 el.style.display = "none";
45 SVC.reallyDelete(tab.url);
48 this.tabUndelete = function(tab) {
49 var div = document.createElement('div');
50 div.style.textAlign = 'center';
51 div.style.marginLeft = 'auto';
52 div.style.marginRight = 'auto';
53 div.style.width = '400px';
55 var text = document.createElement('div');
56 text.style.background = '#ee2';
57 text.style.width = '400px';
58 text.innerHTML = 'This taboo has been undeleted. Click another view to see it.'
59 div.appendChild(text);
61 div.appendChild(document.createElement('br'));
63 setTimeout(function() { div.style.display = 'none'; }, 30000);
64 document.body.insertBefore(div, document.getElementById('content'));
65 SVC.undelete(tab.url);
68 this.displayUndelete = function(tab, el) {
69 var div = document.createElement('div');
70 div.style.textAlign = 'center';
71 div.style.marginLeft = 'auto';
72 div.style.marginRight = 'auto';
73 div.style.width = '250px';
75 var text = document.createElement('div');
76 text.style.background = '#ee2';
77 text.style.width = '250px';
78 div.appendChild(text);
80 var a = document.createElement('a');
81 a.innerHTML = 'Click here to undelete your taboo.';
83 a.onclick = function() {
84 el.style.display = '';
85 div.style.display = 'none';
86 SVC.undelete(tab.url);
90 div.appendChild(document.createElement('br'));
92 setTimeout(function() { div.style.display = 'none'; }, 30000);
93 document.body.insertBefore(div, document.getElementById('content'));
96 this.display = function(searchTxt) {
99 var enum = SVC.get(searchTxt, view.trash);
101 if (!view.trash && !view.info && !enum.hasMoreElements()) {
102 controller.load(DisplayInfo);
106 while (enum.hasMoreElements()) {
107 var tab = enum.getNext();
108 tab.QueryInterface(Components.interfaces.oyITabooInfo);
117 var controller = new Controller();
119 var view = tboPrefs.getCharPref("extensions.taboo.view");
120 if (view.match(/GridTrash|DisplayInfo/)) throw 'We don\'t reload trash';
121 var ViewClass = eval('(' + view + ')');
122 controller.load(ViewClass);
125 controller.load(Grid);