-
-
Notifications
You must be signed in to change notification settings - Fork 37
/
Copy pathrules.js
505 lines (442 loc) · 14.7 KB
/
rules.js
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
/*
Termination of Transfer - tool to help in returning authors rights.
Copyright (C) 2016 Creative Commons Corporation.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
var Rules = {};
Rules.simpleYesNoRule = function (variable_id, yesValue, noValue) {
return function () {
var result = undefined;
if (Values[variable_id] == 'yes') {
result = yesValue;
} else {
result = noValue;
}
return result;
};
};
Rules.jumpToFinish = 'finish';
Rules.conclusion = function (conclusion) {
Values.conclusion = conclusion;
return Rules.jumpToFinish;
};
Rules.conclusionPDF = function (conclusion) {
Rules.conclusion(conclusion);
Values.conclusion_generate_pdf = true;
return Rules.jumpToFinish;
};
Rules.addFlag = function(flag) {
Values.flags.push(flag);
};
////////////////////////////////////////////////////////////////////////////////
// Calculated/inferred properties
////////////////////////////////////////////////////////////////////////////////
Rules.is203 = function () {
return (Values.conclusion == "A.iii");
};
Rules.is304 = function () {
return (['A.i', 'A.ii', 'A.i-ii'].indexOf(Values.conclusion) > -1);
};
Rules.hasPublicDomainFlags = function () {
var result = false;
for (var i = 0; i < Values.flags.length; i++) {
if (Values.flags[i][0] == 'B') {
result = true;
}
}
return result;
};
Rules.beforeEndOfNoticeWindow = function () {
return ((Values.notice_end != undefined)
&& (Values.notice_end >= Values.current_year))
|| ((Values.d_notice_end != undefined)
&& (Values.d_notice_end >= Values.current_year))
|| ((Values.p_notice_end != undefined)
&& (Values.p_notice_end >= Values.current_year));
};
////////////////////////////////////////////////////////////////////////////////
// Section N Analyses
////////////////////////////////////////////////////////////////////////////////
Rules.section304Analysis = function () {
// Note that this is part of the logic from the section 203 analysis
var result = 's1q1f';
if (Values.k_year < 1978) {
result = 's2q2a';
Rules.addFlag('F.i');
if ((Values.pub_year > 1977) && (Values.reg_year > 1977)) {
result = Rules.conclusion('B.vii');
} else {
// Under the 1909 Act, copyright term begins at the earlier of
// the registration date and the publication date.
// If the work is both registered and published use the minimum of them.
if ((Values.reg_year != undefined)
&& (Values.pub_year != undefined)) {
Values.cright_year = Math.min(Values.pub_year,
Values.reg_year);
}
// Otherwise use whichever value is set. One *will* be set here, see top.
else {
Values.cright_year = Values.reg_year || Values.pub_year;
}
Values.cright_year = Math.min(Values.cright_year, 1978);
Values.term_begin = Values.cright_year + 56;
Values.term_begin = Math.max(Values.term_begin, 1978);
Values.term_end = Values.term_begin + 5;
Values.notice_begin = Values.term_begin - 10;
Values.notice_end = Values.term_end - 2;
// If the we're presently before the 304(c) window, then we don't have to worry about 304(d)
if (Values.notice_begin > Values.current_year) {
Rules.addFlag('A.i.a');
// Following Copyright Office guidance, works copyrighted before 1940 may also be eligible for termination under 304d
} else if (Values.cright_year < 1940) {
Rules.addFlag('F.ii');
Values.d_term_begin = Values.term_begin + 19;
Values.d_term_end = Values.d_term_begin + 5;
Values.d_notice_begin = Values.d_term_begin - 10;
Values.d_notice_end = Values.d_term_end - 2;
if (Values.cright_year > 1936) {
Rules.addFlag('G.i');
}
if (Values.cright_year == 1939) {
Rules.addFlag('G.ii.a');
}
if (Values.d_notice_begin > Values.current_year) {
// time traveler flag -- applies where the present day is between
// the 304(c) and 304(d) notice windows
Rules.addFlag('A.iii.a');
} else if (Values.d_notice_end < Values.current_year) {
Rules.addFlag('A.ii.a');
}
} else if (Values.notice_end < Values.current_year) {
Rules.addFlag('A.ii.a');
} else {
// Here for clarity / to reflect decision tree structure
// But note that we set it as the result above.
result = 's2q2a';
}
}
if ((Values.d_term_begin != undefined)
&& (Values.term_begin != undefined)) {
Rules.addFlag('E.i');
}
}
return result;
};
Rules.section203Analysis = function () {
var result = 's2q2a';
if (typeof Values.grant_pub_year !== 'undefined') {
Rules.addFlag('F.iv');
}
Values.triggering_pub_year = Values.grant_pub_year || Values.pub_year;
if (Values.k_year > 1977) {
Rules.addFlag('F.iii');
if (Values.pub_right == 'yes' ) {
if (Values.triggering_pub_year != undefined) {
Values.term_begin = Math.min(Values.triggering_pub_year + 35 ,
Values.k_year + 40);
} else {
Values.term_begin = Values.k_year + 40;
}
} else if ((Values.triggering_pub_year != Values.k_year)
|| (Values.pub_right == 'no')) {
Values.term_begin = Values.k_year + 35;
}
if (Values.term_begin != undefined) {
Values.term_end = Values.term_begin + 5;
Values.notice_begin = Values.term_begin - 10;
Values.notice_end = Values.term_end - 2;
if (Values.notice_begin > Values.current_year) {
Rules.addFlag('A.i.a');
} else if (Values.notice_end < Values.current_year) {
Rules.addFlag('A.ii.a');
}
}
if (Values.pub_right == 'maybe') {
Values.p_term_begin = Values.k_year + 40;
if (Values.triggering_pub_year != undefined) {
Values.p_term_begin = Math.min(Values.triggering_pub_year + 35,
Values.p_term_begin);
}
Values.p_term_end = Values.p_term_begin + 5;
Values.p_notice_begin = Values.p_term_begin - 10;
Values.p_notice_end = Values.p_term_end - 2;
if (Values.p_notice_begin > Values.current_year) {
Rules.addFlag('A.i.a');
} else if (Values.p_notice_end < Values.current_year) {
Rules.addFlag('A.ii.a');
}
}
}
if ((Values.p_term_begin != undefined)
&& (Values.term_begin != undefined)) {
Rules.addFlag('E.ii');
}
return result;
};
////////////////////////////////////////////////////////////////////////////////
// Section 1
////////////////////////////////////////////////////////////////////////////////
// When was the work created?
Rules.s1q1a = 's1q1b';
// Has the work been published?
Rules.s1q1b = Rules.simpleYesNoRule('work_published',
's1q1bi',
's1q1c');
// When was the work first published?
Rules.s1q1bi = 's1q1bii';
// When was the work first published under the grant?
// Note that the condition is based on s1q1b, we are inserting this question
// after 'When was the work first published?' and *then* going on to the
// questions about registration/notices or not.
Rules.s1q1bii = function () {
var result = undefined;
if (Values.pub_year < 1923) {
result = Rules.conclusion('B.viii');
} else if (Values.pub_year < 1990)
result = 's1q1bi2';
else {
result = 's1q1d';
}
return result;
};
// Works from 1989 and earlier usually display a copyright notice...
Rules.s1q1bi2 = function () {
var result = undefined;
if (Values.copyright_notice == 'yes') {
result = 's1q1c';
} else if (Values.copyright_notice == 'no') {
// The same
result = 's1q1c';
if (Values.pub_year < 1989) {
Rules.addFlag('B.i');
} else {
Rules.addFlag('B.ii');
}
} else /* maybe */ {
result = 's1q1c';
Rules.addFlag('B.iii');
}
return result;
};
// Has the work been registered with the United State Copyright Office?
Rules.s1q1c = function () {
var result = undefined;
if (Values.work_registered == 'yes') {
result = 's1q1ci';
} else if (Values.work_registered == 'no') {
result = 's1q1d';
} else /* don't know */ {
// If someone doesn't know, continue without asking for registration number
result = 's1q1d';
}
return result;
};
// When was the work registered with the United States Copyright Office?
Rules.s1q1ci = function () {
var result = undefined;
if (Values.reg_year < 1923) {
result = Rules.conclusion('B.viii');
} else {
result = 's1q1d';
}
return result;
};
// For s1q1d,
// What is the date of the agreement or transfer? ...
Rules.s1q1d = function () {
var result = undefined;
if (Values.user_inputted_k_year != Values.k_year) {
Rules.addFlag('H.i');
}
if ((Values.k_year < 1978)
&& ((Values.pub_year == undefined)
&& (Values.reg_year == undefined))) {
result = Rules.conclusion('B.vii');
} else {
// Intercept the result so we can add encouragement if things look good
result = Rules.section304Analysis();
if ((result != Rules.jumpToFinish)
&& Rules.beforeEndOfNoticeWindow()
&& (! Rules.hasPublicDomainFlags())) {
Notifications.setEncouragement("Both notice window and copyright status look good, let's get some more details!");
}
}
return result;
};
// Did the agreement or transfer include the right of publication?
Rules.s1q1f = function () {
// Intercept the result so we can add encouragement if things look good
var result = Rules.section203Analysis();
if ((result != Rules.jumpToFinish)
&& Rules.beforeEndOfNoticeWindow()
&& (! Rules.hasPublicDomainFlags())) {
Notifications.setEncouragement("Both notice window and copyright status look good, let's get some more details!");
}
return result;
};
Rules.section203Analysis;
////////////////////////////////////////////////////////////////////////////////
// Section 2
////////////////////////////////////////////////////////////////////////////////
// Is the agreement or transfer you want to terminate part of a last will...
Rules.s2q2a = function () {
var result = undefined;
if (Values.last_will == 'yes') {
result = Rules.conclusion('B.iv');
} else {
if ((Values.creation_year > 1977)
|| (((Values.pub_year == undefined) || (Values.pub_year > 1977))
&& ((Values.reg_year == undefined) || (Values.reg_year > 1977)))) {
result = 's2q2bi';
} else {
result = 's2q2c';
}
}
return result;
};
// Are any of the authors still alive?
// It's i) because the conditional logic that starts b is included in a
Rules.s2q2bi = function () {
var result = undefined;
if (Values.any_authors_alive == 'yes') {
result = 's2q2c'
} else {
result = 's2q2bi2';
}
return result;
};
// What is the year the last surviving author died?
Rules.s2q2bi2 = function () {
var result = undefined;
// creation_year is always set, pub_year may not be, death will be here
if (Values.creation_year > 1977) {
Values.pd = Values.death + 71;
} else if ((Values.pub_year != undefined)
&& (Values.pub_year < 2003)) {
Values.pd = Math.max((Values.death + 71), 2048);
} else {
Values.pd = Math.max((Values.death + 71), 2003);
}
// pd *will* have been set in the if/else block
if (Values.current_year > Values.pd) {
result = Rules.conclusion('B.viii');
} else {
result = 's2q2c';
}
return result;
};
// Was the work created within the scope of the author’s employment?
Rules.s2q2c = function () {
var result = undefined;
if (Values.within_scope_of_employment == 'yes') {
if (Values.creation_year > 1977) {
result = 's2q2ci';
} else {
result = Rules.conclusion('B.i');
}
} else {
result = 's2q2d';
}
return result
};
// Was there an express agreement between you...
Rules.s2q2ci = function () {
var result = undefined;
if (Values.express_agreement == 'yes') {
result = 's2q2d';
} else {
result = Rules.conclusion('B.i');
}
return result;
};
// Was the work created in response to a special order or commission?
Rules.s2q2d = function () {
var result = undefined;
if (Values.special_order == 'yes') {
if (Values.creation_year < 1978) {
Rules.addFlag('D.i');
result = 's2q2e';
} else {
result = 's2q2di';
}
} else {
result = 's2q2e';
}
return result
};
// Was there a signed written agreement regarding the special order...
Rules.s2q2di = function () {
var result = undefined;
if (Values.signed_written_agreement == 'yes') {
if (Values.creation_year < 1978) {
result = Rules.conclusion('B.iii');
} else {
result = 's2q2dia';
}
} else {
result = 's2q2e';
}
return result
};
// Was the work created for use as one of the following? ...
Rules.s2q2dia = function () {
var result = undefined;
if (Values.created_as_part_of_motion_picture == 'yes') {
result = Rules.conclusion('C.ii');
} else if (Values.created_as_part_of_motion_picture == 'no') {
result = 's2q2e';
} else /* don't know */ {
Rules.addFlag('D.ii');
result = 's2q2e';
}
return result;
};
// Has the original transfer since been renegotiated or altered?
Rules.s2q2e = function () {
var result = 's2q2f';
if (Values.renego == 'yes') {
Rules.addFlag('C.i');
} else if (Values.renego == 'no') {
// Continue
} else /* don't know */ {
Rules.addFlag('C.ii');
}
return result;
};
// Did one or more of the authors or artists enter into the agreement...
Rules.s2q2f = function () {
var result = undefined;
if (Values.authors_entered_agreement == 'yes') {
if (Values.k_year < 1978) {
result = Rules.conclusionPDF('A.i-ii');
} else /*if (k_year > 1977)*/ {
result = Rules.conclusionPDF('A.iii');
}
} else {
if (Values.k_year < 1978) {
result = 's2q2fii';
} else /*if (Values.k_year > 1977)*/ {
result = Rules.conclusion('B.vi');
}
}
return result;
};
// Was the agreement or transfer made by a member of...
Rules.s2q2fii = function () {
var result = undefined;
if (Values.agreement_by_family_or_executor) {
result = Rules.conclusionPDF('A.i-ii');
} else {
result = Rules.conclusion('B.v');
}
return result
};