Commit d95f3360 authored by Antonin Delpeuch's avatar Antonin Delpeuch
Browse files

Started detecting moderation messages

parent b9efdd5b
all:
runtb.sh
content moderation chrome/content/
overlay chrome://messenger/content/messenger.xul chrome://moderation/content/mylabel.xul
overlay chrome://messenger/content/messenger.xul chrome://moderation/content/mod-buttons.xul
locale moderation fr-FR chrome/locale/fr-FR
<?xml version="1.0"?>
<overlay id="sample"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/javascript" src="chrome://moderation/content/toolbar-events.js" />
<toolbar id="header-view-toolbar">
<toolbarbutton id="hdrModAcceptButton" label="Accepter" oncommand="ToolbarEvents.onAccept(event);" />
</toolbar>
<toolbar id="header-view-toolbar">
<toolbarbutton id="hdrModRejectButton" label="Rejeter" oncommand="ToolbarEvents.onReject(event);" />
</toolbar>
</overlay>
<?xml version="1.0"?>
<overlay id="sample"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<!-- <script type="application/javascript" src="chrome://moderation/content/overlay.js" /> -->
<statusbar id="status-bar">
<statusbarpanel id="my-panel" label="Date" />
</statusbar>
</overlay>
var ToolbarEvents = {
onLoad: function() {
// init code
var messagepane = document.getElementById("messagepane");
if(messagepane)
messagepane.addEventListener("load", ToolbarEvents.updateButtons, true);
window.addEventListener("activate", ToolbarEvents.updateButtons, true);
LOG("init done");
this.initialized = true;
},
mylog:function(msg)
{
Components.utils.reportError(msg);
},
updateButtons: function() {
if(!gFolderDisplay)
return;
LOG("test passed");
var msg = gFolderDisplay.selectedMessage;
if(!msg)
return;
var acceptButton = document.getElementById("hdrModAcceptButton");
var rejectButton = document.getElementById("hdrModRejectButton");
if(!acceptButton && !rejectButton)
return;
var subject = msg.mime2DecodedSubject;
ToolbarEvents.mylog("subject is "+subject);
var re = /moderate ([0-9A-F]{8}) \(([a-z0-9]*)\)/g;
matches = re.exec(subject);
if(matches[1])
acceptButton.label= matches[1];
if(matches[2])
rejectButton.label = matches[2];
},
onAccept: function() {
LOG("onAccept called");
window.open("chrome://moderation/content/hello.xul", "", "chrome");
},
onReject: function() {
LOG("onReject called");
window.open("chrome://moderation/content/hello.xul", "", "chrome");
},
LOG:function(msg) {
var consoleService = Components.classes["@mozilla.org/consoleservice;1"].getService(Components.interfaces.nsIConsoleService);
var str=msg;
if(typeof msg == 'object'){
var objToString=function(obj, depth){
if(obj+'' == '[object Object]' ||(typeof(obj)=='object'&&(obj instanceof Array))){
var str=obj+" {";
for(var key in obj){
if(obj.hasOwnProperty(key)){
str+="\n";
for(var i =0; i < depth; i++)
str+="\t";
str+=" ["+key+"]=["+objToString(obj[key], depth+1)+"]";
}
}
return str+"}";
}
return obj;
};
str=" "+objToString(msg,0);
}
consoleService.logStringMessage(str);
}
};
window.addEventListener("load", function(e) { ToolbarEvents.onLoad(e); }, false);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment