move /ps.html to /ps/index.html
[ucas-personal-statement-counter.git] / index.html
1 <!DOCTYPE html>
2 <html>
3 <!--
4 UCAS Personal Statement Word Counter
5 Copyright (c) 2014 Adrian Iain Lam
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 A copy of the GNU General Public License can be found at
18 <http://www.gnu.org/licenses/gpl.html>.
19
20 Contact: <ail30@cam.ac.uk>
21 -->
22 <head>
23 <title>UCAS Personal Statement Line &amp; Character Counter</title>
24 <meta charset="utf-8" />
25 <meta name="description" content="Confused by UCAS's way of counting lines and characters? Click here for a detailed analysis." />
26 <meta name="keywords" content="UCAS,line,word,character,count,counter,number,personal,statement" />
27 <meta name="author" content="Adrian Iain Lam" />
28 <meta property="og:description" content="Confused by UCAS's way of counting lines and characters? Click here for a detailed analysis." />
29 <meta name="twitter:description" content="Confused by UCAS's way of counting lines and characters? Click here for a detailed analysis." />
30 <script>
31 $ = document.getElementById.bind(document);
32 function printStats(lines, numLines, numChars, parasWithExtraSpace, parasLines) {
33 $("results").innerHTML="";
34 for(var i=0; i<numLines; i++) {
35 $("results").innerHTML+=(i<9?"0"+(i+1):(i+1))+" "+lines[i]+"<br />";
36 if(parasLines.indexOf(i+1)>=0 && $("chk2").checked) $("results").innerHTML+="<br />";
37 }
38
39 $("statLines").innerHTML="Lines: "+numLines+"/47";
40 $("statLines").style.color=numLines>47?"red":"initial";
41 $("statChars").innerHTML="Characters: "+numChars+"/4000";
42 $("statChars").style.color=numChars>4000?"red":"initial";
43
44 if(parasWithExtraSpace.length>0) {
45 $("statWarn").innerHTML="Warning: Extra space(s) found at end of paragraph(s) "+parasWithExtraSpace.join(", ");
46 $("statWarn").style.visibility="visible";
47 $("statWarn").style.color="red";
48 } else {
49 $("statWarn").innerHTML="Warning: Extra space(s) found at end of paragraph(s) ";
50 $("statWarn").style.visibility="hidden";
51 }
52 }
53
54 function analyse() {
55 var text=$("txt1").value;
56 var parasWithExtraSpace=[];
57 var parasLines=[];
58 var paras=text.split('\n');
59 var lines=[];
60 var line=""
61 if(text=="") {
62 printStats(lines, 0, 0, parasWithExtraSpace, parasLines);
63 return;
64 }
65 for(var i=0; i<paras.length; i++) {
66 if(paras[i][paras[i].length-1]==' ') parasWithExtraSpace.push(i+1);
67 do {
68 if(paras[i][0]==' ') paras[i]=paras[i].substring(1); //remove preceding space
69 line=paras[i].substring(0, paras[i].length>94?94:paras[i].length); //extract line of 94 chars or fewer
70 var lastidx=line.lastIndexOf(' ');
71 if(lastidx>=0) { //if there is a space in line
72 if(line.length<94) lastidx=line.length; //if it can contain whole line
73 } else lastidx=line.length;
74 if(paras[i][94]==' ') lastidx=94; //if extracted right before a space
75 paras[i] = line.substring(lastidx+1)+paras[i].substring(94); //remove extracted string (up to lastidx) from paras
76 line=line.substring(0, lastidx);
77 lines.push(line);
78 } while(paras[i]!="");
79 parasLines.push(lines.length); //lines where paragraphs end
80 }
81 printStats(lines, lines.length, text.length+paras.length-1, parasWithExtraSpace, parasLines);
82 }
83
84 function autocheck() {
85 if($("chk1").checked) {
86 $("txt1").addEventListener("input", analyse);
87 $("btn1").style.visibility='hidden';
88 analyse();
89 } else {
90 $("txt1").removeEventListener("input", analyse);
91 $("btn1").style.visibility='visible';
92 }
93 }
94 </script>
95
96 <style>
97 #txt1 {
98 font-family: "Liberation Serif", "Times New Roman", serif;
99 width: 100%;
100 padding-left: 1em;
101 padding-right: 1em;
102 height: 15em;
103 box-sizing: border-box;
104 }
105 .topPadding {
106 padding-top: 12pt;
107 }
108 #resultsContainer {
109 font-family: monospace;
110 float: right;
111 min-width: 100ch;
112 border-left-style: solid;
113 border-left-width: 1px;
114 border-left-color: black;
115 box-sizing: border-box;
116 white-space: nowrap;
117 }
118 #statContainer {
119 overflow: auto;
120 padding-right: 8pt;
121 }
122 .note {
123 font-size: 8pt;
124 }
125 .hidden {
126 visibility: hidden;
127 }
128 </style>
129 <!-- Google Analytics -->
130 <script>
131 (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
132 (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
133 m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
134 })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
135 ga('create', 'UA-54745078-1', 'auto');
136 ga('send', 'pageview');
137 </script>
138 <!-- / Google Analytics -->
139 <!-- Project Wonderful Ad Box Loader -->
140 <script type="text/javascript">
141 (function(){function pw_load(){
142 if(arguments.callee.z)return;else arguments.callee.z=true;
143 var d=document;var s=d.createElement('script');
144 var x=d.getElementsByTagName('script')[0];
145 s.type='text/javascript';s.async=true;
146 s.src='//www.projectwonderful.com/pwa.js';
147 x.parentNode.insertBefore(s,x);}
148 if (window.attachEvent){
149 window.attachEvent('DOMContentLoaded',pw_load);
150 window.attachEvent('onload',pw_load);}
151 else{
152 window.addEventListener('DOMContentLoaded',pw_load,false);
153 window.addEventListener('load',pw_load,false);}})();
154 </script>
155 <!-- / Project Wonderful Ad Box Loader -->
156 </head>
157 <body onload="autocheck()">
158 <h3>UCAS Personal Statement Line &amp; Character Counter</h3>
159 <div id="txtContainer">
160 Paste your personal statement here!<br />
161 <textarea id="txt1"></textarea>
162 </div>
163
164 <div id="outputContainer" class="topPadding">
165 <div id="resultsContainer">
166 <div id="results"></div>
167 <!-- Empty div will not have space reserved -->
168 <div id="workaround" class="hidden">.</div>
169 </div>
170
171 <div id="statContainer">
172 <input id="chk1" type="checkbox" onclick="autocheck()" checked>Automatic analysis <span class="note">(Not recommended for slow computers)</span>
173 <button id="btn1" class="hidden" onclick="analyse()">Analyse</button><br />
174 <input id="chk2" type="checkbox" onclick="analyse()" checked>Separate paragraphs<br /><span class="note">(For readability purpose only. Will NOT be present in the UCAS submission)</span>
175 <div id="stats" class="topPadding">
176 <div id="statLines">Lines: 0/47</div>
177 <div id="statChars">Characters: 0/4000</div>
178 <div id="statWarn" class="hidden">Warning: Extra space(s) found at end of paragraph(s)</div>
179 </div>
180 <p>Found a bug? Please report to &lt;00alam@brightoncollege.net&gt;.</p>
181 <p class="note">Copyright (c) 2014 Adrian Iain Lam<br />This program is free software, and you are welcome to redistribute it under the terms of the GNU GPL. This program comes with ABSOLUTELY NO WARRANTY. View the source for details.</p>
182 <p class="note">This site is not affiliated with, endorsed by, approved by, or related to UCAS.</p>
183 <p class="note">Unlike <a href="http://maccery.com/ps/" target="_blank">the counter by Maccery</a>, no personal statements are sent to the hosting server. All codes are executed on the client-side.</p>
184 <p>Advertisements:</p>
185 <!-- Anonymous Ads -->
186 <iframe data-aa='40362' src='//ad.a-ads.com/40362?size=300x250' style='width:300px; height:250px; border:0px; padding:0;overflow:hidden' seamless></iframe>
187 <!-- / Anonymous Ads -->
188 <!-- Wanted to use Google AdSense but I need to be 18... -->
189 </div>
190 </div>
191 </body>
192 </html>