Skip to content

Commit

Permalink
I don't even
Browse files Browse the repository at this point in the history
  • Loading branch information
Jon Brede Skaug committed Oct 31, 2012
1 parent bbe312f commit 6c9f2ba
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 50 deletions.
2 changes: 1 addition & 1 deletion rest/configfiles/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//Extras
$footer_modules = array(
"js" => array(
'/static/js/min/script.js',
'/static/js/script.js',
'/static/js/form.js'
)
);
Expand Down
12 changes: 10 additions & 2 deletions rest/contentfiles/main.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
<br/>
<form name="prereg" action="" method="post">
<label for="name">Username:</label>
<input type="text" name="name" id="name" onChange="validateName()" onkeypress="validateName()" placeholder="USERNAME HERE" /><span ID="n" class="msg"></span>
<input type="text" name="name" id="name"
onChange="validateName()" onkeypress="validateCheckpoint()"
placeholder="USERNAME HERE"
/>
<span ID="n" class="msg"></span>
<label for="password">Password:</label>
<input type="password" name="password" id="pass" onChange="validateEmail()" onkeypress="validateEmail()" placeholder="WRITE IN PASSWORD" /><span ID="m" class="msg"></span>
<input type="password" name="password" id="pass"
onChange="validateEmail()" onkeypress="validateCheckpoint()"
placeholder="WRITE IN PASSWORD"
/>
<span ID="m" class="msg"></span>
<input type="submit" value="Send" id="sendbtn" class="sndactive" onClick="sendForm(); return false;">
</form>
<script type="text/javascript">
Expand Down
4 changes: 2 additions & 2 deletions static/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ ExpiresByType image/jpeg "access plus 2592000 seconds"
ExpiresByType image/png "access plus 2592000 seconds"
ExpiresByType image/x-icon "access plus 2592000 seconds"
ExpiresByType text/css "access plus 604801 seconds"
ExpiresByType text/javascript "access plus 604801 seconds"
ExpiresByType application/x-javascript "access plus 604801 seconds"
ExpiresByType text/javascript "access plus 10 seconds"
ExpiresByType application/x-javascript "access plus 10 seconds"

<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz)$">
Expand Down
64 changes: 37 additions & 27 deletions static/js/form.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
var acceptForm = false;
var formresponse;
var validation = new Array;
var togfadeN = true;
var togfadeM = true;
var Msgtxt = new Array;
var Msgname = new Array(['n'],['m']);
console.log(Msgname[1]);
console.log("initialized form ver. 0.0.4!");


function validateName (){
<<<<<<< Updated upstream
var x=document.forms["prereg"]["name"].value;
if (x==null || x=="" || x.length < 3 || hasWhiteSpace(x) == false) return false;
else return true;
Expand All @@ -24,35 +20,39 @@ function validateEmail(){
if (togfadeM === false && changed === true) {setTimeout(function(){fadeMsg("m",1)},TimeDelay);} else if (togfadeM === true) {fadeMsg("m",1)}
togfadeM = false;
validateCheckpoint();
=======
var x = document.forms["prereg"]["name"].value;
if (x==null || x=="" || x.length < 3) return false;
else return true;
>>>>>>> Stashed changes
}
//This function is needed
function validatePassword(){

return true;
}
function fadeMsg(id, num) {
var x = document.getElementById(id);
var valid = validation[num];
if (valid === false) x.className = "msg error"; else x.className = "msg success";
x.innerHTML = Msgtxt[num];
init(Msgname[num], 150, 1);
var x = document.getElementById(id);

if (valid === false) x.className = "msg error"; else x.className = "msg success";
x.innerHTML = Msgtxt[num];
fade(Msgname[num], 150, 1);
}
function validateCheckpoint (){
//Need to rewrite so functions return boolean, so there is no need for variables.
if (validation[0] === true && validation[1] === true) {
acceptForm = true;
console.log("All fields are valid!");
sndbtn.className = "sndactive";
var x = validateName();
var y = validatePassword();

if (x === true && y === true) {
console.log("All fields are valid!");
sndbtn.className = "sndactive";
return true;
} else {
acceptForm = false;
sndbtn.className = "sndgrey";
sndbtn.className = "sndgrey";
}
if (x === true) console.log("Name is valid!");
if (y === true) console.log("Password is valid!");
return false;
}
function sendForm() {
validateName();
validateEmail();
validateCheckpoint();
if (acceptForm === true) {
console.log("Sent!");
if (validateCheckpoint() === true) {
var data="Name="+document.forms["prereg"]["name"].value+"&Email="+document.forms["prereg"]["email"].value;
loadData("/secure/prereg.php","POST",data,function(){
if (xmlhttp.readyState==4 && xmlhttp.status==200){
Expand All @@ -63,4 +63,14 @@ if (acceptForm === true) {
});
} else { console.log("Can't send, some fields are invalid!"); }
return false;
}
//Validate email is not needed right now.
function validateEmail(){
var x=document.forms["prereg"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length){ return false; Msgtxt[1] = "Incorrect Email!"}
else { return true; Msgtxt[1] = "";}

validateCheckpoint();
}
40 changes: 24 additions & 16 deletions static/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Created by Ramen, in the long time ago.
//

console.log("initialized the script!");
console.log("initialized script ver. 0.0.2!");
// Variables
var TimeToFade = 100.0;
var TimeDelay = TimeToFade+25;
Expand All @@ -27,7 +27,7 @@ function loadData(url,format,data,cfunc){
xmlhttp.send(data); }
}
function loadPage(url,data){
init(idmaincontent, TimeToFade, 0);
fade(idmaincontent, TimeToFade, 0);
curl[0] = "/"+url;
curl[1] = url.capitalize()+" - Bitkraken";
if (data === 'static') { url = '/txt/'+url+'.txt'; data = ''; }
Expand All @@ -52,29 +52,34 @@ function loadJS(url) {
oHead.appendChild( oScript);
console.log("Loaded JS file: "+url);
}
function backPage() {
init(idmaincontent, TimeToFade, 1);
pageresponse = saveDocument;
setTimeout(addtoPage, TimeDelay)
}
function hasWhiteSpace(s) {
return s.indexOf(' ') >= 0;
}
function waitFade(itemtofade) {
init(itemtofade, TimeToFade, 1);
}
//function backPage() {
//fade(idmaincontent, TimeToFade, 1);
//pageresponse = saveDocument;
//setTimeout(addtoPage, TimeDelay)
//}
//function hasWhiteSpace(s) {
// return s.indexOf(' ') >= 0;
//}
//function waitFade(itemtofade) {
//fade(itemtofade, TimeToFade, 1);
//}
function addtoPage(){
document.getElementById("mainbody").innerHTML = pageresponse;
<<<<<<< Updated upstream
init(idmaincontent, TimeToFade, 1);
}
//
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
=======
fade(idmaincontent, TimeToFade, 1);
>>>>>>> Stashed changes
}

window.onpopstate = function(e){
if(e.state){
fade('mainbody');
console.log("Detected popstate "+e.state);
if(e.state != null){
fade(idmaincontent, TimeToFade, 0);
pageresponse = e.state.txt;
document.title = e.state.pageTitle;
setTimeout(addtoPage, TimeDelay)
Expand All @@ -87,6 +92,9 @@ var animateFade = function(elmOrElmId, duration, state) {
this.setOptions(elmOrElmId, duration, state);
};

String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
//prototype its helper functions
animateFade.prototype = {

Expand Down Expand Up @@ -146,7 +154,7 @@ animateFade.prototype = {
};

//initialize function
var init = function(elmsOrElmIdArr, duration, state) {
var fade = function(elmsOrElmIdArr, duration, state) {
for (var i = 0, l = elmsOrElmIdArr.length; i < l; i++) {
//use "new" keyword to create separate instances
new animateFade(elmsOrElmIdArr[i], duration, state);
Expand Down
20 changes: 20 additions & 0 deletions txt/.htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript

# Set Expires headers
ExpiresActive On
ExpiresDefault "access plus 10 seconds"

<IfModule mod_headers.c>
<FilesMatch "\.(js|css|xml|gz)$">
Header append Vary Accept-Encoding
</FilesMatch>
</IfModule>
12 changes: 10 additions & 2 deletions txt/main.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
<br/>
<form name="prereg" action="" method="post">
<label for="name">Username:</label>
<input type="text" name="name" id="name" onChange="validateName()" onkeypress="validateName()" placeholder="USERNAME HERE" /><span ID="n" class="msg"></span>
<input type="text" name="name" id="name"
onChange="validateName()" onkeypress="validateCheckpoint()"
placeholder="USERNAME HERE"
/>
<span ID="n" class="msg"></span>
<label for="password">Password:</label>
<input type="password" name="password" id="pass" onChange="validateEmail()" onkeypress="validateEmail()" placeholder="WRITE IN PASSWORD" /><span ID="m" class="msg"></span>
<input type="password" name="password" id="pass"
onChange="validateEmail()" onkeypress="validateCheckpoint()"
placeholder="WRITE IN PASSWORD"
/>
<span ID="m" class="msg"></span>
<input type="submit" value="Send" id="sendbtn" class="sndactive" onClick="sendForm(); return false;">
</form>
<script type="text/javascript">
Expand Down

0 comments on commit 6c9f2ba

Please sign in to comment.