Skip to content
This repository has been archived by the owner on Jan 28, 2019. It is now read-only.

Commit

Permalink
Allow to reprint protocols, closes #36
Browse files Browse the repository at this point in the history
  • Loading branch information
stesie committed Jan 18, 2015
1 parent 31a0c19 commit 8c93567
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 25 deletions.
50 changes: 25 additions & 25 deletions chrome/content/js/geierlein.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,30 +58,6 @@
return false;
}

/**
* Show the modal protocol dialog and display the provided protocol.
*
* The provided document is run through XSL processor before being
* displayed.
*
* @param res The XML result document as a string.
* @return void
*/
function showProtocol(res) {
var xslUrl = location.href.replace(/[^\/]+$/, '') + 'xsl/ustva.xsl';
$.ajax({
url: xslUrl,
isLocal: xslUrl.substr(0, 7) === 'chrome:',
success: function(xslDom) {
var xmlDom = jsxml.fromString(res, false);
var xslResult = jsxml.transReady(xmlDom, xslDom);
$('body').trigger('show-protocol', res);
$('#protocol-frame')[0].src = 'data:text/html;charset=UTF-8,' + encodeURIComponent(xslResult);
$('#protocol').modal();
}
});
}

function updateModelHandler(el, model) {
var kz = el.id.toLowerCase();
var $cg = $(el).parents('.control-group');
Expand Down Expand Up @@ -161,6 +137,30 @@
*/


/**
* Show the modal protocol dialog and display the provided protocol.
*
* The provided document is run through XSL processor before being
* displayed.
*
* @param res The XML result document as a string.
* @return void
*/
geierlein.showProtocol = function(res) {
var xslUrl = location.href.replace(/[^\/]+$/, '') + 'xsl/ustva.xsl';
$.ajax({
url: xslUrl,
isLocal: xslUrl.substr(0, 7) === 'chrome:',
success: function(xslDom) {
var xmlDom = jsxml.fromString(res, false);
var xslResult = jsxml.transReady(xmlDom, xslDom);
$('body').trigger('show-protocol', res);
$('#protocol-frame')[0].src = 'data:text/html;charset=UTF-8,' + encodeURIComponent(xslResult);
$('#protocol').modal();
}
});
};

/**
* Prepare submission of tax declaration, display signature control dialog
*
Expand Down Expand Up @@ -208,7 +208,7 @@

var status = res.match(/<Code>(.*?)<\/Code>\s*<Text>(.*?)<\/Text>/);
if(+status[1] === 0) {
showProtocol(res);
geierlein.showProtocol(res);
} else {
alert('Die Datenübertragung wurde vom Server abgebrochen:\n' +
status[2] + '\nFehlercode: ' + status[1]);
Expand Down
29 changes: 29 additions & 0 deletions chrome/content/js/xulapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,35 @@ var xulapp = (function() {
cW.geierlein.showUStSvzA();
},

reprintProto: function() {
var nsIFilePicker = I.nsIFilePicker;
var fp = C["@mozilla.org/filepicker;1"].createInstance(nsIFilePicker);

fp.init(window, 'Protokoll nachdrucken', nsIFilePicker.modeOpen);
fp.appendFilters(nsIFilePicker.filterText | nsIFilePicker.filterAll);

var res = fp.show();
if (res !== nsIFilePicker.returnOK) {
return;
}

var channel = NetUtil.newChannel(fp.file);
channel.contentType = 'text/xml';
channel.contentCharset = 'UTF-8';

NetUtil.asyncFetch(channel, function(inStream, status) {
if(!Components.isSuccessCode(status)) {
alert('Beim Lesen der Datei ist ein Fehler aufgetreten!');
return;
}

var data = NetUtil.readInputStreamToString(inStream,
inStream.available(), { charset: 'UTF-8' });

cW.geierlein.showProtocol(data);
});
},

shutdownQuery: function() {
return !modalAskSaveChanges();
},
Expand Down
1 change: 1 addition & 0 deletions chrome/content/main.xul
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<menu label="Werkzeuge">
<menupopup>
<menuitem label="Dauerfristverlängerung ..." accesskey="d" oncommand="xulapp.showUStSvzA();"/>
<menuitem label="Protokoll nachdrucken ..." accesskey="p" oncommand="xulapp.reprintProto();"/>
<menuseparator class="hideDevel"/>
<menuitem class="hideDevel" label="Extension Manager" oncommand="window.open('chrome://mozapps/content/extensions/extensions.xul?type=extensions', '', 'chrome');"/>
<menuitem class="hideDevel" label="DOM Inspector" oncommand="window.open('chrome://inspector/content/inspector.xul', '', 'chrome');"/>
Expand Down

0 comments on commit 8c93567

Please sign in to comment.