mirror of
https://gitlab.com/CodeSolutionsProject/CodeShare.git
synced 2026-12-06 01:38:25 +01:00
#15 finished
This commit is contained in:
1 parent
40e0291517
commit
7cb682c146
7 files changed
+53
-17
No files matched your search
@@ -54,6 +54,10 @@ p{
|
||||
background-color: #b2dbfb !important
|
||||
}
|
||||
|
||||
.loginMessage {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.codebox{
|
||||
margin-top: 2em;
|
||||
margin-bottom: 2em;
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<script src="{{ app.frontjs }}/highlight.pack.js"></script>
|
||||
<script src="{{ app.frontjs }}/jquery-3.2.1.min.js"></script>
|
||||
<script src="{{ app.frontjs }}/jquery.form.min.js"></script>
|
||||
<script src="{{ app.frontjs }}/bootstrap.min.js"></script>
|
||||
<script src='https://www.google.com/recaptcha/api.js'></script>
|
||||
<script src="{{ app.frontjs }}/functions.js"></script>
|
||||
|
||||
@@ -8,20 +8,15 @@
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-sm-12">
|
||||
{% if page.state == 'BAD_CREDENTIAL' %}
|
||||
<p class="text-danger">Bad credentials</p>
|
||||
{% elseif page.state == 'POST_ERROR' %}
|
||||
<p class="text-danger">Error during sign-up, check your data</p>
|
||||
{% elseif page.state == 'MAIL_IN_USE' %}
|
||||
<p class="text-danger">The e-mail is currently in use</p>
|
||||
{% elseif page.state == 'NICK_IN_USE' %}
|
||||
<p class="text-danger">The nickname is currently in use</p>
|
||||
{% endif %}
|
||||
<p class="text-danger loginMessage" id="BAD_CREDENTIAL">Bad credentials</p>
|
||||
<p class="text-danger loginMessage" id="POST_ERROR">Error during sign-up, check your data</p>
|
||||
<p class="text-danger loginMessage" id="MAIL_IN_USE">The e-mail is currently in use</p>
|
||||
<p class="text-danger loginMessage" id="NICK_IN_USE">The nickname is currently in use</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="login">
|
||||
<form class="form-horizontal" method="post">
|
||||
<form class="form-horizontal" method="post" id="loginForm">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="email">Email:</label>
|
||||
<div class="col-sm-10">
|
||||
@@ -45,7 +40,7 @@
|
||||
</form>
|
||||
</div>
|
||||
<div id="register" style="display:none;">
|
||||
<form class="form-horizontal" method="post">
|
||||
<form class="form-horizontal" method="post" id="regForm">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-sm-2" for="emailre">Email:</label>
|
||||
<div class="col-sm-10">
|
||||
@@ -98,6 +93,28 @@
|
||||
{% block js %}
|
||||
<script>
|
||||
|
||||
doneFun = function(data){
|
||||
console.log(data);
|
||||
if (data == 'redirect'){
|
||||
window.location.href = '{{path('home')}}';
|
||||
}
|
||||
var todos = $(".text-danger").each(function (){
|
||||
$(this).css("display","none");
|
||||
});
|
||||
$("#"+data).css('display',"block");
|
||||
}
|
||||
|
||||
$(document).ready(function() {
|
||||
var options = {success: doneFun,
|
||||
url: '{{ path("login")}}',
|
||||
beforeSubmit: function(arr, $form, options){
|
||||
console.log(arr);
|
||||
}} ;
|
||||
$("#regForm").ajaxForm(options);
|
||||
|
||||
$("#loginForm").ajaxForm(options);
|
||||
});
|
||||
|
||||
function checkPassword() {
|
||||
if ($('#pwdre').val() != $("#pwdre-re").val()) {
|
||||
$("#pwdre-re")[0].setCustomValidity('Password do not match');
|
||||
|
||||
Vendored
+11
@@ -0,0 +1,11 @@
|
||||
/*!
|
||||
* jQuery Form Plugin
|
||||
* version: 3.51.0-2014.06.20
|
||||
* Requires jQuery v1.5 or later
|
||||
* Copyright (c) 2014 M. Alsup
|
||||
* Examples and documentation at: http://malsup.com/jquery/form/
|
||||
* Project repository: https://github.com/malsup/form
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
* https://github.com/malsup/form#copyright-and-license
|
||||
*/
|
||||
!function(e){"use strict";"function"==typeof define&&define.amd?define(["jquery"],e):e("undefined"!=typeof jQuery?jQuery:window.Zepto)}(function(e){"use strict";function t(t){var r=t.data;t.isDefaultPrevented()||(t.preventDefault(),e(t.target).ajaxSubmit(r))}function r(t){var r=t.target,a=e(r);if(!a.is("[type=submit],[type=image]")){var n=a.closest("[type=submit]");if(0===n.length)return;r=n[0]}var i=this;if(i.clk=r,"image"==r.type)if(void 0!==t.offsetX)i.clk_x=t.offsetX,i.clk_y=t.offsetY;else if("function"==typeof e.fn.offset){var o=a.offset();i.clk_x=t.pageX-o.left,i.clk_y=t.pageY-o.top}else i.clk_x=t.pageX-r.offsetLeft,i.clk_y=t.pageY-r.offsetTop;setTimeout(function(){i.clk=i.clk_x=i.clk_y=null},100)}function a(){if(e.fn.ajaxSubmit.debug){var t="[jquery.form] "+Array.prototype.join.call(arguments,"");window.console&&window.console.log?window.console.log(t):window.opera&&window.opera.postError&&window.opera.postError(t)}}var n={};n.fileapi=void 0!==e("<input type='file'/>").get(0).files,n.formdata=void 0!==window.FormData;var i=!!e.fn.prop;e.fn.attr2=function(){if(!i)return this.attr.apply(this,arguments);var e=this.prop.apply(this,arguments);return e&&e.jquery||"string"==typeof e?e:this.attr.apply(this,arguments)},e.fn.ajaxSubmit=function(t){function r(r){var a,n,i=e.param(r,t.traditional).split("&"),o=i.length,s=[];for(a=0;o>a;a++)i[a]=i[a].replace(/\+/g," "),n=i[a].split("="),s.push([decodeURIComponent(n[0]),decodeURIComponent(n[1])]);return s}function o(a){for(var n=new FormData,i=0;i<a.length;i++)n.append(a[i].name,a[i].value);if(t.extraData){var o=r(t.extraData);for(i=0;i<o.length;i++)o[i]&&n.append(o[i][0],o[i][1])}t.data=null;var s=e.extend(!0,{},e.ajaxSettings,t,{contentType:!1,processData:!1,cache:!1,type:u||"POST"});t.uploadProgress&&(s.xhr=function(){var r=e.ajaxSettings.xhr();return r.upload&&r.upload.addEventListener("progress",function(e){var r=0,a=e.loaded||e.position,n=e.total;e.lengthComputable&&(r=Math.ceil(a/n*100)),t.uploadProgress(e,a,n,r)},!1),r}),s.data=null;var c=s.beforeSend;return s.beforeSend=function(e,r){r.data=t.formData?t.formData:n,c&&c.call(this,e,r)},e.ajax(s)}function s(r){function n(e){var t=null;try{e.contentWindow&&(t=e.contentWindow.document)}catch(r){a("cannot get iframe.contentWindow document: "+r)}if(t)return t;try{t=e.contentDocument?e.contentDocument:e.document}catch(r){a("cannot get iframe.contentDocument: "+r),t=e.document}return t}function o(){function t(){try{var e=n(g).readyState;a("state = "+e),e&&"uninitialized"==e.toLowerCase()&&setTimeout(t,50)}catch(r){a("Server abort: ",r," (",r.name,")"),s(k),j&&clearTimeout(j),j=void 0}}var r=f.attr2("target"),i=f.attr2("action"),o="multipart/form-data",c=f.attr("enctype")||f.attr("encoding")||o;w.setAttribute("target",p),(!u||/post/i.test(u))&&w.setAttribute("method","POST"),i!=m.url&&w.setAttribute("action",m.url),m.skipEncodingOverride||u&&!/post/i.test(u)||f.attr({encoding:"multipart/form-data",enctype:"multipart/form-data"}),m.timeout&&(j=setTimeout(function(){T=!0,s(D)},m.timeout));var l=[];try{if(m.extraData)for(var d in m.extraData)m.extraData.hasOwnProperty(d)&&l.push(e.isPlainObject(m.extraData[d])&&m.extraData[d].hasOwnProperty("name")&&m.extraData[d].hasOwnProperty("value")?e('<input type="hidden" name="'+m.extraData[d].name+'">').val(m.extraData[d].value).appendTo(w)[0]:e('<input type="hidden" name="'+d+'">').val(m.extraData[d]).appendTo(w)[0]);m.iframeTarget||v.appendTo("body"),g.attachEvent?g.attachEvent("onload",s):g.addEventListener("load",s,!1),setTimeout(t,15);try{w.submit()}catch(h){var x=document.createElement("form").submit;x.apply(w)}}finally{w.setAttribute("action",i),w.setAttribute("enctype",c),r?w.setAttribute("target",r):f.removeAttr("target"),e(l).remove()}}function s(t){if(!x.aborted&&!F){if(M=n(g),M||(a("cannot access response document"),t=k),t===D&&x)return x.abort("timeout"),void S.reject(x,"timeout");if(t==k&&x)return x.abort("server abort"),void S.reject(x,"error","server abort");if(M&&M.location.href!=m.iframeSrc||T){g.detachEvent?g.detachEvent("onload",s):g.removeEventListener("load",s,!1);var r,i="success";try{if(T)throw"timeout";var o="xml"==m.dataType||M.XMLDocument||e.isXMLDoc(M);if(a("isXml="+o),!o&&window.opera&&(null===M.body||!M.body.innerHTML)&&--O)return a("requeing onLoad callback, DOM not available"),void setTimeout(s,250);var u=M.body?M.body:M.documentElement;x.responseText=u?u.innerHTML:null,x.responseXML=M.XMLDocument?M.XMLDocument:M,o&&(m.dataType="xml"),x.getResponseHeader=function(e){var t={"content-type":m.dataType};return t[e.toLowerCase()]},u&&(x.status=Number(u.getAttribute("status"))||x.status,x.statusText=u.getAttribute("statusText")||x.statusText);var c=(m.dataType||"").toLowerCase(),l=/(json|script|text)/.test(c);if(l||m.textarea){var f=M.getElementsByTagName("textarea")[0];if(f)x.responseText=f.value,x.status=Number(f.getAttribute("status"))||x.status,x.statusText=f.getAttribute("statusText")||x.statusText;else if(l){var p=M.getElementsByTagName("pre")Line truncated
|
||||
Reference in new issue
Block a user