📄 clientprintfunctions.js
字号:
// Client-side printing javascript functions
var printWin = null;
// Called when another task executes--updates list of tasks
function RefreshTaskResults(callbackFunctionString) {
// Must include a delay, otherwise causes repeated client callback loop
var sendString = "sendRefreshTaskResults(\"" + callbackFunctionString + "\")";
window.setTimeout(sendString, 200);
}
function sendRefreshTaskResults(callbackFunctionString){
var argument='EventArg=updateTaskResults';
var context=null;
eval(callbackFunctionString);
}
function PrintTaskSendRequest(button, callbackFunctionString, mapId) {
doHourglass();
var pre = getControlPrefix(button.id);
// get task results items checked
var cblPrefix = pre + "_cblResults";
var cbResult = null;
var printItems = "";
var listDone = false;
var i = 0;
while (!listDone) {
cbResult = document.getElementById(cblPrefix + "_" + i.toString());
if (cbResult != null) {
if (cbResult.checked) {
// add to list of checked results items
if (printItems.length > 0) printItems += ",";
printItems += i.toString();
}
i++;
}
else {
listDone = true;
}
}
// get map print options from form
var printTitle = "";
var printBox = document.getElementById(pre + "_ptitle");
if (printBox != null) {
// replace "&"
printTitle = printBox.value;
printTitle = printTitle.replace(/&/, "##amp##");
printTitle = printTitle;
//printTitle = escape(printTitle);
//printTitle = encode64(printTitle);
}
var printMap = document.getElementById(pre + "_printMap").checked;
if (!printMap)
mapId = "";
var widthList = document.getElementById(pre + "_width");
var resolutionList = document.getElementById(pre + "_resolution");
var printWidth = widthList.options[widthList.selectedIndex].value;
var printResolution = resolutionList.options[resolutionList.selectedIndex].value;
var scale = escape(document.getElementById(pre + "_scale").value);
var argument = "mapId="+mapId + "&title="+printTitle; //EventArg=getPrintPage&
argument += "&printResults="+printItems;
argument += "&width="+printWidth + "&resolution="+printResolution + "&scale="+scale;
//alert(argument);
var context=null;
executeTask(argument, callbackFunctionString);
//eval(callbackFunctionString);
// hide print dialog
//window.setTimeout("hideFloatingPanel('"+pre+"')", 1000);
}
// Called from server-generated function after print request
function PrintTaskDisplayPage(printContent) { //printImageUrl, mapHeight, taskResultsHtml) {
var windowOptions = "toolbar=yes,width=700,height=600,top=100,left=200,scrollbars=yes,resizable=yes";
if (!printWin || printWin.closed) {
printWin = window.open("", "printWindow", windowOptions);
}
if (printWin != null) {
// restore line breaks (encoded as xxrnxx at server)
var regexp = /xxrnxx/gi;
printContent = printContent.replace(regexp, "\n");
// "unescape" the content
printContent = decode(printContent);
printWin.document.write(printContent);
printWin.document.close();
printWin.focus();
}
else
alert("Cannot display print preview window. Check that popup blockers are disabled for this site.");
undoHourglass();
}
function getControlPrefix (fullControlId) {
var lastUnderscore = fullControlId.lastIndexOf("_");
return fullControlId.substring(0, lastUnderscore);
}
function doHourglass() {
document.body.style.cursor = 'wait';
}
function undoHourglass() {
document.body.style.cursor = 'auto';
}
var conversionMap = {
"amp" : "&",
"lt" : "<",
"gt" : ">",
"apos" : "'",
"quot" : '"'
}
function decode(entityString) {
return entityString.replace(/&(\w+);/g, function(m,g) {
return conversionMap[g]||m;
});
}
function encode64(input) {
input = escape(input);
var output = "";
var chr1, chr2, chr3 = "";
var enc1, enc2, enc3, enc4 = "";
var i = 0;
do {
chr1 = input.charCodeAt(i++);
chr2 = input.charCodeAt(i++);
chr3 = input.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if (isNaN(chr2)) {
enc3 = enc4 = 64;
} else if (isNaN(chr3)) {
enc4 = 64;
}
output = output +
keyStr.charAt(enc1) +
keyStr.charAt(enc2) +
keyStr.charAt(enc3) +
keyStr.charAt(enc4);
chr1 = chr2 = chr3 = "";
enc1 = enc2 = enc3 = enc4 = "";
} while (i < input.length);
return output;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -