comparison awesome_js/robert.js @ 44:1045db9799e3 laserkard

[svn r45] Greatly Enhanced Responsiveness of the website.
author rlm
date Thu, 28 Jan 2010 04:10:44 -0500
parents 329638a361cc
children 26c2b3ad21c7
comparison
equal deleted inserted replaced
43:329638a361cc 44:1045db9799e3
1
2
3 1
4 function defaults() 2 function defaults()
5 { 3 {
6 alias = "Robert Mac"; 4 alias = "Robert Mac";
7 email = "rlm@mit.edu"; 5 email = "rlm@mit.edu";
11 website = ""; 9 website = "";
12 lineArt = ""; 10 lineArt = "";
13 } 11 }
14 12
15 13
16 function drawElement(obj) 14
15 function stabForm(ID)
17 { 16 {
17 var JSONtext = document.getElementById('formValues').innerHTML;
18 var hash = new Object();
19 hash = eval('(' + JSONtext + ')');
20
21 propertyValue = document.getElementById(ID).value;
22 propertyName = ID;
23 propertyValue = escape(propertyValue);
24
25 eval("hash."+propertyName+"='"+propertyValue+"'");
18 26
27 var JSONtext = document.getElementById('formValues').innerHTML = JSON.stringify(hash);
28 }
29
30
31
32 function getPosition(style, field)
33 {
34
35 var cardType = eval ("laserkard." + style);
36
37
38 if ( eval("typeof cardType." + field + " != 'undefined'")) //shouldn't ever really matter
39 {
40 values = eval("cardType." + field);
41
42 if (typeof values.posx != 'undefined'){posx = values.posx;}
43 if (typeof values.posy != 'undefined'){posy = values.posy;}
44 if (typeof values.center != 'undefined'){center = values.center;}
45 if (typeof values.font != 'undefined'){font = values.font;}
46 if (typeof values.weirdFlip != 'undefined'){weirdFlip = values.weirdFlip;}
47 }
48
49
50 }
51
52
53
54
55 function smallRedraw(style,field)
56 {
57
58 var JSONtext = document.getElementById('formValues').innerHTML;
59 var hash = new Object();
60 hash = eval('(' + JSONtext + ')');
61
62 var content = eval("hash."+field);
63
64 content = unescape(content);
65
66 posx = 10;
67 posy = 10;
68 center = 0;
69 font = 10;
70 face = 700;
71 weirdFlip = 0;
72
73 getPosition(style, field);
74
75 target = "d_" + field;
76
77
78 var whatev = eval("typeof " + target + " != 'undefined'")
79
80 if (whatev){eval ("{" + target + ".remove();}");}
81
82 eval ( target + " = raphe.print(posx, posy, content , raphe.getFont('HelveticaNeue', face), font);" );
83
84
85 eval ( target +".attr('stroke', '#6a6a6a');");
86 eval ( target +".attr('fill', 'none');");
87
88
89 if (center == 1)
90 {
91 eval ("var c = " + target+".getBBox().width; " + target + ".translate((485 - c)/2,0);");
92 }
93
94
95 if (weirdFlip == 1)
96 {
97 eval("var c = "+target+".getBBox().width;");
98 eval(target+ ".translate((317 - c)/2,0);");
99 eval(target+".translate(0, -490);");
100 eval(target+".rotate(90,0,0);");
101 }
102
103
104
105
106
107 }
108
109 function clearAll()
110 {
111 if(typeof d_Name != 'undefined' ){d_Name.remove();}
112 if(typeof d_Company != 'undefined' ){d_Company.remove();}
113 if(typeof d_Email != 'undefined' ){d_Email.remove();}
114 if(typeof d_Occupation != 'undefined' ){d_Occupation.remove();}
115 if(typeof d_Phone != 'undefined' ){d_Phone.remove();}
116 if(typeof d_Website != 'undefined' ){d_Website.remove();}
117
118 if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();}
19 } 119 }
20 120
21 function redraw(style) 121 function redraw(style)
22 { 122 {
23 123
24 124
25 var JSONtext = document.getElementById('formValues').innerHTML;
26 var hash = new Object();
27 hash = eval('(' + JSONtext + ')');
28 125
29 if(hash.Name){alias = hash.Name;}
30 if(hash.Email){email = hash.Email;}
31 if(hash.Occupation){occupation = hash.Occupation;}
32 if(hash.Company){company = hash.Company;}
33 if(hash.Phone){phone = hash.Phone;}
34 if(hash.website){website = Website;}
35 126
36 if (style == "bold") 127 if (style == "bold")
37 { 128 {
38 129
39 130 clearAll();
40 131 smallRedraw("bold","Name");
41 if(typeof d_alias != 'undefined' ){d_alias.remove();} 132 smallRedraw("bold","Email");
42 if(typeof d_email != 'undefined' ){d_email.remove();}
43 if(typeof d_occupation != 'undefined' ){d_occupation.remove();}
44 if(typeof d_company != 'undefined' ){d_company.remove();}
45 if(typeof d_phone != 'undefined' ){d_phone.remove();}
46 if(typeof d_website != 'undefined' ){d_website.remove();}
47 if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();}
48
49
50
51
52 d_alias = raphe.print(10, 160, alias, raphe.getFont('HelveticaNeue', 700), 60);
53 d_alias.attr('stroke', '#6a6a6a');
54 d_alias.attr('fill', 'none')
55 var c = d_alias.getBBox().width;
56 d_alias.translate((485 - c)/2,0);
57
58
59
60
61 d_email = raphe.print(280, 270, email, raphe.getFont("HelveticaNeue", 700), 25);
62 d_email.attr('stroke', '#6a6a6a');
63 d_email.attr('fill', 'TRANSPARENT');
64
65 133
66 134
67 135
68 } 136 }
69 137
70 138
71 if (style == "arrow") 139 if (style == "arrow")
72 { 140 {
73 141
74 if(typeof d_alias != 'undefined' ){d_alias.remove();} 142 clearAll();
75 if(typeof d_email != 'undefined' ){d_email.remove();}
76 if(typeof d_occupation != 'undefined' ){d_occupation.remove();}
77 if(typeof d_company != 'undefined' ){d_company.remove();}
78 if(typeof d_phone != 'undefined' ){d_phone.remove();}
79 if(typeof d_website != 'undefined' ){d_website.remove();}
80 if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();}
81 143
144 smallRedraw("arrow","Name");
145 smallRedraw("arrow","Email");
146 smallRedraw("arrow","Occupation");
147 smallRedraw("arrow","Company");
82 148
83
84 d_alias = raphe.print(40, 110, alias, raphe.getFont('HelveticaNeue', 700), 55);
85 d_alias.attr('stroke', '#6a6a6a');
86 d_alias.attr('fill', 'none')
87
88 d_company = raphe.print(40, 155, company, raphe.getFont("HelveticaNeue", 700), 27);
89 d_company.attr('stroke', '#6a6a6a');
90 d_company.attr('fill', 'TRANSPARENT');
91
92 d_occupation = raphe.print(40, 190, occupation, raphe.getFont("HelveticaNeue", 700), 27);
93 d_occupation.attr('stroke', '#6a6a6a');
94 d_occupation.attr('fill', 'TRANSPARENT');
95
96 d_email = raphe.print(280, 270, email, raphe.getFont("HelveticaNeue", 700), 25);
97 d_email.attr('stroke', '#6a6a6a');
98 d_email.attr('fill', 'TRANSPARENT');
99 149
100 d_lineArt = raphe.path("M 2 272 L 258 272"); 150 d_lineArt = raphe.path("M 2 272 L 258 272");
101 d_lineArt.attr('stroke', '#6a6a6a'); 151 d_lineArt.attr('stroke', '#6a6a6a');
102 152
103 } 153 }
104 154
105 155
106 if (style == "classic") 156 if (style == "classic")
107 { 157 {
108
109 if(typeof d_alias != 'undefined' ){d_alias.remove();}
110 if(typeof d_email != 'undefined' ){d_email.remove();}
111 if(typeof d_occupation != 'undefined' ){d_occupation.remove();}
112 if(typeof d_company != 'undefined' ){d_company.remove();}
113 if(typeof d_phone != 'undefined' ){d_phone.remove();}
114 if(typeof d_website != 'undefined' ){d_website.remove();}
115 if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();}
116 158
159 clearAll();
117 160
118 d_email = raphe.print(0, 42, email, raphe.getFont("HelveticaNeue", 700), 29); 161 smallRedraw("classic","Name");
119 d_email.attr('stroke', '#6a6a6a'); 162 smallRedraw("classic","Email");
120 d_email.attr('fill', 'TRANSPARENT'); 163 smallRedraw("classic","Occupation");
121 var c = d_email.getBBox().width; 164 smallRedraw("classic","Company");
122 d_email.translate((510 - c)/2,0); 165 smallRedraw("classic","Phone");
123 166 smallRedraw("classic","Website");
124
125
126 d_phone = raphe.print(0, 75, phone, raphe.getFont("HelveticaNeue", 700), 27);
127 d_phone.attr('stroke', '#6a6a6a');
128 d_phone.attr('fill', 'TRANSPARENT');
129 var c = d_phone.getBBox().width;
130 d_phone.translate((510 - c)/2,0);
131
132
133 d_alias = raphe.print(0, 164, alias, raphe.getFont('HelveticaNeue', 800), 47);
134 d_alias.attr('stroke', '#6a6a6a');
135 d_alias.attr('fill', 'none')
136 var c = d_alias.getBBox().width;
137 d_alias.translate((510 - c)/2,0);
138
139
140 d_company = raphe.print(0, 247, company, raphe.getFont("HelveticaNeue", 700), 27);
141 d_company.attr('stroke', '#6a6a6a');
142 d_company.attr('fill', 'TRANSPARENT');
143 var c = d_company.getBBox().width;
144 d_company.translate((510 - c)/2,0);
145
146
147
148 d_occupation = raphe.print(0, 278, occupation, raphe.getFont("HelveticaNeue", 700), 27);
149 d_occupation.attr('stroke', '#6a6a6a');
150 d_occupation.attr('fill', 'TRANSPARENT');
151 var c = d_occupation.getBBox().width;
152 d_occupation.translate((510 - c)/2,0);
153
154
155 d_website = raphe.print(0, 0, website, raphe.getFont("HelveticaNeue", 700), 21);
156 d_website.attr('stroke', '#6a6a6a');
157 d_website.attr('fill', 'TRANSPARENT');
158
159 var c = d_website.getBBox().width;
160 d_website.translate((317 - c)/2,0);
161
162 d_website.translate(0, -490);
163 d_website.rotate(90,0,0);
164 } 167 }
165 168
166 169
167 if (style == "direct") 170 if (style == "direct")
168 { 171 {
169 172
170 if(typeof d_alias != 'undefined' ){d_alias.remove();} 173 clearAll();
171 if(typeof d_email != 'undefined' ){d_email.remove();}
172 if(typeof d_occupation != 'undefined' ){d_occupation.remove();}
173 if(typeof d_company != 'undefined' ){d_company.remove();}
174 if(typeof d_phone != 'undefined' ){d_phone.remove();}
175 if(typeof d_website != 'undefined' ){d_website.remove();}
176 if(typeof d_lineArt != 'undefined' ){d_lineArt.remove();}
177 174
178 175 smallRedraw("direct","Name");
179 176 smallRedraw("direct","Email");
180 177 smallRedraw("direct","Occupation");
181 d_alias = raphe.print(37, 70, alias, raphe.getFont('HelveticaNeue', 700), 55); 178 smallRedraw("direct","Company");
182 d_alias.attr('stroke', '#6a6a6a'); 179 smallRedraw("direct","Phone");
183 d_alias.attr('fill', 'none') 180 smallRedraw("direct","Website");
184
185
186
187 d_occupation = raphe.print(37, 120, occupation, raphe.getFont("HelveticaNeue", 700), 27);
188 d_occupation.attr('stroke', '#6a6a6a');
189 d_occupation.attr('fill', 'TRANSPARENT');
190
191
192
193 d_company = raphe.print(37, 178, company, raphe.getFont("HelveticaNeue", 700), 27);
194 d_company.attr('stroke', '#6a6a6a');
195 d_company.attr('fill', 'TRANSPARENT');
196
197
198
199 d_phone = raphe.print(37, 210, phone, raphe.getFont("HelveticaNeue", 700), 27);
200 d_phone.attr('stroke', '#6a6a6a');
201 d_phone.attr('fill', 'TRANSPARENT');
202
203
204
205 d_email = raphe.print(37, 240, email, raphe.getFont("HelveticaNeue", 700), 27);
206 d_email.attr('stroke', '#6a6a6a');
207 d_email.attr('fill', 'TRANSPARENT');
208
209
210
211
212 d_website = raphe.print(37, 270, website, raphe.getFont("HelveticaNeue", 700), 27);
213 d_website.attr('stroke', '#6a6a6a');
214 d_website.attr('fill', 'TRANSPARENT');
215 181
216 d_lineArt = raphe.path("M 350 165 L 512 165 M 350 173 L 512 173 M 350 181 L 512 181 M 350 189 L 512 189 M 350 197 L 512 197 M 350 213 L 512 213 M 350 205 L 512 205 M 350 221 L 512 221"); 182 d_lineArt = raphe.path("M 350 165 L 512 165 M 350 173 L 512 173 M 350 181 L 512 181 M 350 189 L 512 189 M 350 197 L 512 197 M 350 213 L 512 213 M 350 205 L 512 205 M 350 221 L 512 221");
217 d_lineArt.attr('stroke', '#6a6a6a'); 183 d_lineArt.attr('stroke', '#6a6a6a');
218 184
219 185