-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOne Author.js
99 lines (94 loc) · 2.53 KB
/
One Author.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
function oneAuthorCite(options) {
// options:
// first: first name,
// initial: initial,
// last: last name,
// title: the title,
// year: year of publication,
// company: company name,
// city: publishing city,
// state: publishing state
// Example of use:
// var html = oneAuthorCite({
// first: 'Jordan',
// last: 'Upiter',
// title: 'Jordan and the Moon',
// year: 1994,
// company: Jupiter Inc,
// city: Toronto,
// state: Ontario
// });
if (options.first != ""){
if (options.last != ""){
options.first = options.first.substring(0,1).toUpperCase() + ". ";
}
}
if (options.initial != ""){
options.initial = options.initial.substring(0,1).toUpperCase() + ". ";
}
if (options.last != ""){
options.last = options.last.charAt(0).toUpperCase() +
options.last.substring(1).toLowerCase();
if (options.first == ""){
options.last += ", ";
}
else {
options.last += ". ";
}
}
var name = options.last + options.first + options.initial;
if (name == ""){
if (options.company != ""){
name = options.company;
}
else{
name = options.title;
}
}
if (options.year != ""){
options.year = "(" + options.year + "). ";
}
else {
options.year = "(n.d). ";
}
if (options.title != ""){
options.title += ". "
}
if (options.city != "" ){
if (options.state != ""){
options.city += ", ";
}
else{
options.city +=": ";
}
}
if (options.state != ""){
options.state += ": ";
}
if (options.company != ""){
options.company += ".";
}
return name + options.year + options.title.italics() + options.city + options.state + options.company;
}
function createReference(){
var reference = oneAuthorCite({
first: O('firstName').value,
initial: O('initial').value,
last: O('lastName').value,
title: O('title').value,
year: O('pubYear').value,
company: O('pubComp').value,
city: O('pubCity').value,
state: O('pubState').value
});
var li = document.createElement("li");
li.innerHTML = reference;
var ul = O("referenceList");
ul.appendChild(li);
}
function O(obj){
return document.getElementById(obj);
}
function S(obj){
return O(obj).style;
}