this.removeSelection();
this.removeSelection();
this.selectAll();
this.selectAll();

CategoryManager.add('catch');

// Uncomment that if tou want to see the inside element //this._internalDeck.selectedIndex = 0;

coreKit.coreMessager.subscribe(this, "CATCH", 1);

var internalDbFormat = { document:[ ['sourceUrl', null], ['filename','Filename'], ['docSize', 'docSize' ], ['mediaUrl', 'MediaUrl'], ['lastModified','lastModified'] ] } var profileDir = ow.io.places.get("profile"); this.db = new widgets.BaseCatchController( 'docscatch_autosave.owm', profileDir, 'docscatch.owc', internalDbFormat ); this.loadFromSqliteFile(true);

for (var i = 0; i < this.selectedItems.length; ++i) coreKit.fileManager.fileUtils.open(this.selectedItems[i]);
try { var exportData = []; var childs = this.childNodes, child, item; for (var i = 0; i < childs.length; i++) { var child = childs[i]; var item = { sourceUrl: child.getAttribute('sourceUrl'), mediaUrl: child.getAttribute('mediaUrl'), docSize: parseInt(child.getAttribute('docSize')), filename: child.getAttribute('filename'), lastModified: parseInt(child.getAttribute('lastModified')), } exportData.push(item); } return exportData; } catch (e) { // alert('yzawn! Export failed.'); return null; }

var returnVal = 0; if (!autoload && this.childNodes.length > 0) {

var prompts = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] .getService(Components.interfaces.nsIPromptService); var aButtonFlags = (prompts.BUTTON_POS_0) * (prompts.BUTTON_TITLE_IS_STRING) + (prompts.BUTTON_POS_1) * (prompts.BUTTON_TITLE_IS_STRING) + (prompts.BUTTON_POS_2) * (prompts.BUTTON_TITLE_IS_STRING) + prompts.BUTTON_POS_1_DEFAULT; var returnValue = {value:false}; returnVal = prompts.confirmEx(window, coreKit.localeService.getString('catchOWCTitle', 'chrome://outwit-kernel/locale/widgets/catch/catch.properties'), coreKit.localeService.getString('catchOWCQuestion', 'chrome://outwit-kernel/locale/widgets/catch/catch.properties'), aButtonFlags, coreKit.localeService.getString('catchOWCButton2', 'chrome://outwit-kernel/locale/widgets/catch/catch.properties'), coreKit.localeService.getString('catchOWCButton1', 'chrome://outwit-kernel/locale/widgets/catch/catch.properties'), coreKit.localeService.getString('catchOWCButton3', 'chrome://outwit-kernel/locale/widgets/catch/catch.properties'), null, returnValue); }

switch( returnVal ){ case 1://Annuler return; break; case 2://Remplacer while (this.hasChildNodes()) this.lastChild.remove(); case 0://Ajouter

var rv = []; var dedup = {};

function callbackFunction( aHeaderObject, base, anId, aDataArray ){ try{ var aBean = { docSize:parseInt(aDataArray[aHeaderObject.docSize]), mediaUrl:aDataArray[aHeaderObject.mediaUrl], sourceUrl:aDataArray[aHeaderObject.sourceUrl], filename:aDataArray[aHeaderObject.filename], lastModified:parseInt(aDataArray[aHeaderObject.lastModified]), }

if( dedup[aBean.mediaUrl] ) return;

aBean.db_uid = anId; coreKit.coreMessager.observe('CATCH', 1, 1, '', aBean);

dedup[aBean.mediaUrl] = true; rv.push( aBean ); } catch(e){ dump('Failed to load something in the catch\n'); } }

try { this.db.loadFrom( autoload ? this.db._db : null, this, aFilePath, callbackFunction ); return rv; } catch(e){ dump('Failed to load the catch\n'); return null; }

break; }

var length = this.childNodes.length; var string = coreKit.localeService.getString('cleanAllItems', 'chrome://outwit-modules-docs/locale/mediacatch.properties');

if ( length > 0 && window.confirm(string) ) { while (this.hasChildNodes()) this.lastChild.remove(); }
try { //We can add only n items to the catch, but we want to be able to replace if (this.maxItem > 0 && this.childNodes.length == this.maxItem && forceMax != 'Over') { return null; }

// dedup for (var i = 0; i < this.childNodes.length; i++) if (this.childNodes[i].getAttribute("mediaUrl") == item.mediaUrl) return null;

var mediaItem = document.createElement('mediaitem');

mediaItem.uid = this.length + 1; mediaItem.setAttribute('allowevents', 'false');

mediaItem.setAttribute("docSize", item.docSize); mediaItem.setAttribute("filename", item.filename); mediaItem.setAttribute("sourceUrl", item.sourceUrl); mediaItem.setAttribute("lastModified", item.lastModified); mediaItem.setAttribute("mediaUrl", item.mediaUrl);

mediaItem.setAttribute("type", 'document');

return mediaItem; } catch (e) { dump("Create item failed on:" + e + '\n'); }
try { var item = this.createItem(data); if (item) { var fileExtension = data.filename.split('.').pop().toLowerCase(); data.src = "moz-icon://." + fileExtension + "?size=32"; try { var mime = coreKit.localeService.getString(fileExtension, 'chrome://outwit-modules-docs/locale/mimetypes.properties'); data.fileType = mime; } catch(e) { dump("CATCH error : Cannot find mime for '" + fileExtension.toLowerCase() + "'"); }

if(data.db_uid){ item.db_uid = data.db_uid; } else item.db_uid = this.db.insert(item);

this.appendItem(item);

if (!data.dontScroll) { this.ensureElementIsVisible(item); }

CategoryManager.getCategory('catch').add(data);

if( searchTreeCtrl.isCurrent('catch') ) gContainer.appendItem(data, true); if (optionsCtrl.autoSave) { // XXX compat fix, remove third and fourth parameter in next version gDownloadManager.download(outwitKit.URLHistoryService.getBeanFromString(data.mediaUrl, true), optionsCtrl.autoSaveFolder, "", function() {}); } } } catch(e) { dump("CATCH failed : " + e + "\n"); }
this.parentNode.open();
return document.getAnonymousElementByAttribute(this, "anonid","docIcon");

document.getAnonymousElementByAttribute(this, "anonid", "docSize");
return this.getAttribute('mediaUrl'); this.setAttribute('mediaUrl', val);

return parseInt(this.getAttribute('docSize')); var newVal = parseInt(val); if (newVal) { this.setAttribute('docSize', newVal); var convertedVal = coreKit.fileManager.fileUtils.convertSize(newVal); this.setAttribute('docSizeConverted', convertedVal); this.setAttribute('docSizeConvertedLabel', '(' + convertedVal + ')'); } else { this.setAttribute('docSize', 'N/A'); this.setAttribute('docSizeConverted', 'N/A'); this.setAttribute('docSizeConvertedLabel', '(' + 'N/A' + ')'); }

return parseInt(this.getAttribute('lastModified')); this.setAttribute('lastModified', val); this.setAttribute('lastModifiedConverted', (val ? ow.util.date.toLocaleString(new Date(parseInt(val))) : ''));

return this.getAttribute('filename'); this.setAttribute('filename', val); var ext = val.split(".").pop().toLowerCase(); this._docIcon.setAttribute("src", "moz-icon://." + ext + "?size=32");

this.mediaUrl = this.getAttribute("mediaUrl"); this.filename = this.getAttribute("filename"); this.sourceUrl = this.getAttribute("sourceUrl"); this.docSize = this.getAttribute("docSize"); this.lastModified = this.getAttribute("lastModified");
var allCategory = CategoryManager.getAll(); for( let i = 0 ; i < allCategory.length ; i++ ){ allCategory[i].unmark( this.mediaUrl ); } CategoryManager.getCategory('catch').remove(this.mediaUrl); return true;