diff options
Diffstat (limited to 'website/static')
-rw-r--r-- | website/static/website/js/cloud.js | 63 | ||||
-rw-r--r-- | website/static/website/js/cookiealert.js | 53 | ||||
-rw-r--r-- | website/static/website/templates/index.html | 21 |
3 files changed, 117 insertions, 20 deletions
diff --git a/website/static/website/js/cloud.js b/website/static/website/js/cloud.js index 01153cd..de5d9f3 100644 --- a/website/static/website/js/cloud.js +++ b/website/static/website/js/cloud.js @@ -136,6 +136,7 @@ $(document.body).ready(function() { $("#diff-wrapper").hide(); $("#databox-wrapper").hide(); if ($("#main_categories").val() == 0) { + $('#main_categories').prop('selectedIndex',0); $("#category-wrapper").hide(); $("#books-wrapper").hide(); $("#chapters-wrapper").hide(); @@ -145,6 +146,35 @@ $(document.body).ready(function() { $("#diff-wrapper").hide(); $("#contributor").hide(); $("#databox-wrapper").hide(); + }else{ + $.ajax({ + url: 'get_subcategories/', + dataType: 'JSON', + type: 'GET', + data: { + maincat_id: $("#main_categories").val(), + }, + success: function(data) { + ajax_loader("clear"); + $("#categories").html( + ''); + $("#categories").html( + ' <option value="">Select Subcategory</option>' + ); + var j = 1; + for (var i = 0; i < + data.length; i++) { + $('#categories').append( + '<option value="' + + data[i].subcategory_id + + '">' + j + ' - ' + + data[i].subcategory + + '</option>' + ); + j++; + } + } + }); } if ($("#categories").val() == 0) { $("#books-wrapper").hide(); @@ -335,8 +365,6 @@ $(document.body).ready(function() { var book_id = $('#books').find(":selected").val(); ajax_loader(this); $("#chapters-wrapper").show(); - console.log(book_id); - if (book_id != 0) { $("#download-book").show(); $("#contributor").show(); @@ -404,7 +432,6 @@ $(document.body).ready(function() { var chapter_id = $('#chapters').find( ":selected").val(); $("#examples-wrapper").show(); - console.log(chapter_id); if (chapter_id != 0) { $("#examples-wrapper").show(); $("#download-chapter").show(); @@ -474,7 +501,6 @@ $(document.body).ready(function() { $("#databox-wrapper").hide(); editor.setValue(""); result.setValue(""); - console.log(example_id); ajax_loader('#revisions'); $.ajax({ url: 'get_revisions/', @@ -797,7 +823,6 @@ $(document.body).ready(function() { issue_id = $("#id_issue").val(); id_description_wrapper = $.trim($("#id_description").val()); id_email = $.trim($("#id_email").val()); - console.log(id_description_wrapper.length); if (issue_id == 0 || id_description_wrapper.length == 0 || id_email.length == 0) { if (issue_id == 0) { $('#id_issue').css({ @@ -838,7 +863,6 @@ $(document.body).ready(function() { email: id_email, }, success: function(data) { - console.log(data); alert(data); ajax_loader("clear"); $("#bug_form_wrapper").modal('toggle'); @@ -981,7 +1005,6 @@ $(document.body).ready(function() { search_string: search_string, }, success: function(data) { - console.log(data); $("#popular").html('<h2>Popular</h2><hr>'); for (var i = 0; i < data.length; i++) { $("#popular").append( @@ -999,7 +1022,6 @@ $(document.body).ready(function() { search_string: search_string, }, success: function(data) { - console.log(data); $("#recent").html('<h2>Recent</h2><hr>'); for (var i = 0; i < data.length; i++) { $("#recent").append( @@ -1030,12 +1052,20 @@ $(document.body).ready(function() { }); $(document).on("click", "#reset", function() { - if(confirm("Are you sure you want to reset? Reset will clear of your data/uploaded file.")){ - document.location.reload(true); - } - else{ - return false; - } + $.ajax({ + url : "reset/", + dataType: 'JSON', + type: 'GET', + data:{ reset: '1' }, + + success : function (data) { + document.location.reload(true); + }, + beforeSend:function(){ + return confirm("Are you sure you want to reset? Reset will clear of your data/uploaded file."); + }, + }); + }); }); //document.readOnly() @@ -1048,10 +1078,11 @@ function doSubmit(){ var file = fileSelect.files[0] formData.set("file", file , file.name); var user_id = document.getElementById("user_id"); - formData.set("user_id", user_id.value) - // Http Request + formData.set("user_id", user_id.value); + formData.set("X-Api-Key", key); var request = new XMLHttpRequest(); + request.open('POST', api_url_upload); request.send(formData); return (fileSelect.files[0].name); diff --git a/website/static/website/js/cookiealert.js b/website/static/website/js/cookiealert.js new file mode 100644 index 0000000..cbd5745 --- /dev/null +++ b/website/static/website/js/cookiealert.js @@ -0,0 +1,53 @@ +/*
+ * Bootstrap Cookie Alert by Wruczek
+ * https://github.com/Wruczek/Bootstrap-Cookie-Alert
+ * Released under MIT license
+ */
+(function () {
+ "use strict";
+
+ var cookieAlert = document.querySelector(".cookiealert");
+ var acceptCookies = document.querySelector(".acceptcookies");
+
+ if (!cookieAlert) {
+ return;
+ }
+
+ cookieAlert.offsetHeight; // Force browser to trigger reflow (https://stackoverflow.com/a/39451131)
+
+ // Show the alert if we cant find the "acceptCookies" cookie
+ if (!getCookie("acceptCookies")) {
+ cookieAlert.classList.add("show");
+ }
+
+ // When clicking on the agree button, create a 1 year
+ // cookie to remember user's choice and close the banner
+ acceptCookies.addEventListener("click", function () {
+ setCookie("acceptCookies", true, 365);
+ cookieAlert.classList.remove("show");
+ });
+
+ // Cookie functions from w3schools
+ function setCookie(cname, cvalue, exdays) {
+ var d = new Date();
+ d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
+ var expires = "expires=" + d.toUTCString();
+ document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
+ }
+
+ function getCookie(cname) {
+ var name = cname + "=";
+ var decodedCookie = decodeURIComponent(document.cookie);
+ var ca = decodedCookie.split(';');
+ for (var i = 0; i < ca.length; i++) {
+ var c = ca[i];
+ while (c.charAt(0) === ' ') {
+ c = c.substring(1);
+ }
+ if (c.indexOf(name) === 0) {
+ return c.substring(name.length, c.length);
+ }
+ }
+ return "";
+ }
+})();
diff --git a/website/static/website/templates/index.html b/website/static/website/templates/index.html index fb0681f..585dafa 100644 --- a/website/static/website/templates/index.html +++ b/website/static/website/templates/index.html @@ -18,6 +18,7 @@ <meta name="keywords" content="R on cloud,R online execute,R online compiler,R computation,calcul scientifique,numerical computation,R computing online,R calculator"> <script> var api_url_upload = "{{ api_url_upload }}"; + var key = "{{ key }}"; </script> <script> if('{{ err_msg }}'){ @@ -27,6 +28,14 @@ </head> <body> + <!-- START Bootstrap-Alert --> + <div class="alert text-center cookiealert" role="alert" style="background:#0f2342; color: #ffffff;"> + The website is currently undergoing some developmental changes. If you encounter any glitches, write to us at <a href="mailto:contact-r@fossee.in">contact-r[at]fossee[dot]in</a>; we value your feedback and suggestions ! + <button type="button" class="close" data-dismiss="alert" aria-label="Close" > + <span aria-hidden="true">×</span> + </button> + </div> + <!-- END Bootstrap-Alert --> <nav class="navbar navbar-expand-md bg-dark navbar-dark"> <img class="navbar-brand" src="{% static 'website/images/home-logo.png' %}" alt="logo" style="height:40px;width:30px"> <a class="navbar-brand" href="#">R on cloud <sup><i>Beta</i></sup></a> @@ -85,11 +94,11 @@ <div class="container small"> <form class="col-12"> <div id="main-category-wrapper" class="form-row form-group"> - <label class="col-sm-2 col-form-label font-weight-bold">Main Category :</label> + <label class="col-sm-2 col-form-label font-weight-bold">{{ maincat_id }} Main Category :</label> <select id="main_categories" class="form-control-sm col-sm-10"> <option value="0">Select Main Category</option> - {% for category in catg %} {% if maincat_id == category.category_id %} - <option value="{{ category.category_id }}" selected>{{ forloop.counter }} - {{ category.maincategory }}</option> + {% for category in catg %} {% if maincat_id == category.category_id or maincat_id == 0 %} + <option value="{{ maincat_id }}" selected>{{ forloop.counter }} - {{ category.maincategory }}</option> {% else %} <option value="{{ category.category_id }}">{{ forloop.counter }} - {{ category.maincategory }}</option> {% endif %} {% endfor %} @@ -219,7 +228,7 @@ <input type="hidden" id="user_id" name="user_id" value="{{ user_id }}"> <a id="execute" class="btn btn-dark text-white"><span id="execute-inner">Execute</span></a> <!-- Trigger the modal with a button --> - <button id="uploaddataset" type="button" class="btn btn-dark text-white" data-toggle="modal" data-target="#uploaddatasetModal">Upload Dataset</button> + <!-- <button id="uploaddataset" type="button" class="btn btn-dark text-white" data-toggle="modal" data-target="#uploaddatasetModal">Upload Dataset</button> --> <button id="reset" type="button" class="btn btn-dark text-white" data-dismiss="modal">Reset</button> <!-- Modal --> @@ -232,6 +241,7 @@ <div class="modal-body"> <p>Upload your CSV dataset file</p> <form> + {% csrf_token %} <input type="file" id="fileSelect" accept="text/csv" /> <button id="fileuploadsubmit" type="button" >Upload</button> </form> @@ -617,6 +627,9 @@ <script src="{% static 'website/js/cloud.js' %}"></script> <script src="{% static 'website/js/jsdiff.js'%}"></script> {% csrf_token %} + +<!-- JS for alert --> + <script src="{% static 'website/js/cookiealert.js'%}"></script> </body> </html> |