2019-12-01 22:27:00 +03:00
|
|
|
function supported_formats(printer)
|
|
|
|
{
|
|
|
|
var formats = printer.attrs["document-format-supported"].value;
|
2020-02-16 16:01:19 +03:00
|
|
|
var mimetypes = [];
|
2019-12-01 22:27:00 +03:00
|
|
|
var supported = [];
|
|
|
|
if(has(formats, "application/pdf"))
|
|
|
|
{
|
2020-02-16 16:01:19 +03:00
|
|
|
mimetypes.push("application/pdf");
|
2019-12-01 22:27:00 +03:00
|
|
|
supported.push("PDF");
|
|
|
|
}
|
2020-02-17 22:06:39 +03:00
|
|
|
if(has(formats, "application/postscript"))
|
|
|
|
{
|
|
|
|
mimetypes.push("application/postscript");
|
|
|
|
supported.push("Postscript");
|
|
|
|
}
|
2019-12-01 22:27:00 +03:00
|
|
|
if(has(formats, "image/jpeg"))
|
|
|
|
{
|
2020-02-16 16:01:19 +03:00
|
|
|
mimetypes.push("image/jpeg");
|
2019-12-01 22:27:00 +03:00
|
|
|
supported.push("JPEG");
|
|
|
|
}
|
|
|
|
|
2020-02-16 16:01:19 +03:00
|
|
|
//var info = "MFG:Hewlett-Packard;CMD:PJL,BIDI-ECP,PJL,POSTSCRIPT,PDF,PCLXL,PCL;MDL:HP LaserJet P3010 Series;CLS:PRINTER;DES:Hewlett-Packard ".split(";");
|
|
|
|
var maybe = []
|
2020-02-16 16:15:48 +03:00
|
|
|
var info = printer.attrs["printer-info"] ? printer.attrs["printer-info"].value.split(";") : [];
|
|
|
|
|
2020-02-16 16:01:19 +03:00
|
|
|
for(var i in info)
|
|
|
|
{
|
|
|
|
if(info[i].split(":")[0] == "CMD")
|
|
|
|
{
|
2020-02-16 16:15:48 +03:00
|
|
|
if(!has(supported, "PDF") && has(info[i].split(":")[1].split(","), "PDF"))
|
2020-02-16 16:01:19 +03:00
|
|
|
{
|
|
|
|
mimetypes.push("application/pdf");
|
|
|
|
maybe.push("PDF");
|
|
|
|
}
|
2020-02-17 22:06:39 +03:00
|
|
|
if(!has(supported, "Postscript") && has(info[i].split(":")[1].split(","), "POSTSCRIPT"))
|
|
|
|
{
|
|
|
|
mimetypes.push("application/postscript");
|
|
|
|
maybe.push("Postscript");
|
|
|
|
}
|
2020-02-16 16:01:19 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {supported: supported.join(" "), maybe: maybe.join(" "), mimetypes: mimetypes};
|
2019-12-01 22:27:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function has(arrayish, what)
|
|
|
|
{
|
|
|
|
for(var i in arrayish)
|
|
|
|
{
|
|
|
|
if(arrayish[i] == what)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2020-01-03 15:37:51 +03:00
|
|
|
|
|
|
|
function ippName(name, value)
|
|
|
|
{
|
|
|
|
switch(name) {
|
|
|
|
case "job-state":
|
|
|
|
switch(value) {
|
|
|
|
case 3:
|
|
|
|
return qsTr("pending");
|
|
|
|
case 4:
|
|
|
|
return qsTr("pending-held");
|
|
|
|
case 5:
|
|
|
|
return qsTr("processing");
|
|
|
|
case 6:
|
|
|
|
return qsTr("processing-stopped");
|
|
|
|
case 7:
|
|
|
|
return qsTr("canceled");
|
|
|
|
case 8:
|
|
|
|
return qsTr("aborted");
|
|
|
|
case 9:
|
|
|
|
return qsTr("completed");
|
|
|
|
default:
|
|
|
|
return qsTr("unknown state ")+value
|
|
|
|
}
|
|
|
|
case "print-quality":
|
|
|
|
switch(value) {
|
|
|
|
case 3:
|
|
|
|
return qsTr("draft");
|
|
|
|
case 4:
|
|
|
|
return qsTr("normal");
|
|
|
|
case 5:
|
|
|
|
return qsTr("high");
|
|
|
|
default:
|
|
|
|
return qsTr("unknown quality ")+value
|
|
|
|
}
|
|
|
|
case "orientation-requested":
|
|
|
|
switch(value) {
|
|
|
|
case 3:
|
|
|
|
return qsTr("portrait");
|
|
|
|
case 4:
|
|
|
|
return qsTr("landscape");
|
|
|
|
case 5:
|
|
|
|
return qsTr("reverse landscape");
|
|
|
|
case 6:
|
|
|
|
return qsTr("reverse portrait");
|
|
|
|
default:
|
|
|
|
return qsTr("unknown orientation ")+value
|
|
|
|
}
|
|
|
|
case "printer-resolution":
|
|
|
|
var units = "";
|
|
|
|
if(value.units==3) {
|
|
|
|
units=qsTr("dpi");
|
|
|
|
} else if (units==4){
|
|
|
|
units=qsTr("dots/cm")
|
|
|
|
}
|
|
|
|
return ""+value.x+"x"+value.y+units;
|
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
2020-01-05 15:24:25 +03:00
|
|
|
|
|
|
|
function endsWith(ending, string)
|
|
|
|
{
|
|
|
|
return string.lastIndexOf(ending) == (string.length - ending.length);
|
|
|
|
}
|