-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSotM_12-Free_Printing_Keywords.js
More file actions
75 lines (68 loc) · 1.84 KB
/
Copy pathSotM_12-Free_Printing_Keywords.js
File metadata and controls
75 lines (68 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
* Keyword(s) = Free Printing
*
* Read more at https://www.selectec.com/papercut-print-script-month-12-keywords-free-printing/
*/
function printJobHook( inputs, actions ) {
// Comment to apply to job
var JOB_COMMENT = "Free Print Job Roald Dahl 100th Anniversary";
// Array of Book Names
var BOOK_NAMES = [
"The Gremlins",
"Over To You",
"Some Time Never",
"Someone Like You",
"Kiss Kiss",
"James and the Giant Peach",
"Charlie and the Chocolate Factory",
"The Magic Finger",
"Fantastic Mr Fox",
"Charlie and the Great Glass Elevator",
"Danny, the Champion of the World",
"The Wonderful Story of Henry Sugar and Six More",
"The Enormous Crocodile",
"My Uncle Oswald",
"The Twits",
"George's Marvellous Medicine",
"Revolting Rhymes",
"The BFG",
"Dirty Beasts",
"The Witches",
"Roald Dahl’s Book of Ghost Stories",
"Boy: Tales of Childhood",
"The Giraffe and the Pelly and Me",
"Two Fables",
"Going Solo",
"Matilda",
"Rhyme Stew",
"Ah, Sweet Mystery of Life",
"Esio Trot",
"The Vicar of Nibbleswicke",
"The Minpins",
"Roald Dahl's Guide to Railway Safety",
"My Year"
];
if (!inputs.job.isAnalysisComplete) {
// No job details yet so return.
return;
}
// If jobname matches any of the book names
if (matchesAny(inputs.job.documentName.toLowerCase(), BOOK_NAMES)) {
// Add comment to job
actions.job.addComment(JOB_COMMENT);
// Set the cost to 0
actions.job.setCost(0);
}
}
// Function borrowed from PaperCut Recipe (Confirm printing emails in color (from Outlook))
function matchesAny(str, matchStrs, actions) {
if (str == null || matchStrs == null) {
return false;
}
for (var i in matchStrs) {
if (str.match(matchStrs[i]).toLowerCase()) {
return true;
}
}
return false;
}