summaryrefslogtreecommitdiff
path: root/public/app/views/welcome.php
diff options
context:
space:
mode:
Diffstat (limited to 'public/app/views/welcome.php')
-rw-r--r--public/app/views/welcome.php280
1 files changed, 0 insertions, 280 deletions
diff --git a/public/app/views/welcome.php b/public/app/views/welcome.php
deleted file mode 100644
index fd3f703..0000000
--- a/public/app/views/welcome.php
+++ /dev/null
@@ -1,280 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
- <meta charset="utf-8">
- <title>Welcome!</title>
-
- <!-- Latest compiled and minified CSS -->
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
-
- <!-- jQuery library -->
- <script src="https://cdn.jsdelivr.net/npm/jquery@3.6.4/dist/jquery.slim.min.js"></script>
-
- <!-- select2 -->
- <link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/css/select2.min.css" rel="stylesheet" />
- <script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-rc.0/dist/js/select2.min.js"></script>
-
- <style>
-label { font-size:12px; }
-.col, .col-1, .col-10, .col-11, .col-12, .col-2, .col-3, .col-4, .col-5, .col-6, .col-7, .col-8, .col-9 { padding-left: 0; }
-.form-group { margin-bottom: .667rem; }
-select { height: 31px; padding-left: 8px; padding-right: 24px; }
-select, input,
-select option { font-size: .87rem; }
- </style>
-
-</head>
-<body class='classroom'>
- <div class="container" style="max-width: 640px;">
- <div class="row">
-
-<?php
- $form = JsonToForm::make_a_form(REGISTRATION_FORM);
-?>
-<?=$form['html']?>
-
- </div>
- </div>
-
-
-
-<script>
-// NOW RUN EVERYTHING AFTER JQUERY (AND DOM ready)
-// -----------------------------------------------------------------------------
-////////////////////////////////////////////////////////////////////////////////
-
-// 00. FLAGS and NEEDED FUNCTIONS
-// ---------------------------------------------------------------------------
-//////////////////////////////////////////////////////////////////////////////
-
-var waitingResponse = false; // flag for an ajax request that was sent and still waiting response
-
-// pure JS ajax GET request
-// return data as JSON
-// no fancy things like UTF8; if needed use base64 ---------------------------
-function ajax_get(url, callback) {
- var xmlhttp = new XMLHttpRequest();
- xmlhttp.onreadystatechange = function() {
- if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
-
- try {
- var data = JSON.parse(xmlhttp.responseText);
- } catch(err) {
- console.log(err.message + ' in ' + xmlhttp.responseText);
- return;
- }
- callback(data);
- }
- };
-
- xmlhttp.open("GET", url, true);
- xmlhttp.send();
-}
-
-
-// 01. MENU MANAGEMENT
-// ---------------------------------------------------------------------------
-//////////////////////////////////////////////////////////////////////////////
-
-// menu management
-// ---------------------------------------------------------------------------
-$('.dropdown-item').on('click', function(e){
- e.preventDefault();
-
- if (!waitingResponse) {
- waitingResponse = true;
-
- var r = confirm('Δεν έχετε αποθηκεύσει το τρέχον αντικείμενο!\nΕίστε σίγουροι ότι θέλετε να εγκαταλείψετε τη σελίδα;');
- if (r == true) {
-
- // all data-goto have the format: 'method,uri_address'
- // uri_address is the url to call
- // method options:
- // * url : means goto url (redirect)
- // * ajax : means call url via ajax; if 'success = true' then goto '/' after that
- // -----------------------------------------------------------------------
- var opt = $(this).data('goto').split(','); // split data-goto
-
- if (opt[0] == 'url') { // if method = url
- window.location.href = opt[1];
- }
- else { // else, method = ajax
- ajax_get(opt[1], function(response) {
- if (response.success) {
- window.location.href = '/';
- }
- });
- }
-
- }
- else {
- // user did not confirmed the selection; do nothing
- }
-
- waitingResponse = false;
- }
-
-});
-
-// 02. USER INTERFACE
-// ---------------------------------------------------------------------------
-//////////////////////////////////////////////////////////////////////////////
-
-// tabs to accorderon --------------------------------------------------------
-//////////////////////////////////////////////////////////////////////////////
-
-// FUNCTION: Set tabsContainer height
-// acording to which tab is visible
-// and tab mode (tabs|acordeon)
-// ---------------------------------------------------------------------------
-function set_tabsContainer_height() {
- var ch_; // content height
- var tc_base; // tabs-container base height
- tc_base = ($(window).width() > 650) ? 100 : 400;
- if ($('#content1').is(':visible')) ch_ = $('#content1').height();
- if ($('#content2').is(':visible')) ch_ = $('#content2').height();
- if ($('#content3').is(':visible')) ch_ = $('#content3').height();
- if ($('#content4').is(':visible')) ch_ = $('#content4').height();
- if ($('#content5').is(':visible')) ch_ = $('#content5').height();
- if ($('#content6').is(':visible')) ch_ = $('#content6').height();
-
- $('#tabsContainer').height(ch_ + tc_base);
-
-}
-set_tabsContainer_height(); // init (run for 1st time)
-
-// on tab selection
-// calculate tabsContainer height
-$('input:radio[name="tabs"]').change( function(){
- set_tabsContainer_height()
-});
-
-// on window change
-// set tabsContainer height
-$( window ).resize(function() {
- set_tabsContainer_height();
-});
-
-
-
-// 03. FORM-CONTROLS
-// ---------------------------------------------------------------------------
-//////////////////////////////////////////////////////////////////////////////
-
-// Select2 controls
-//////////////////////////////////////////////////////////////////////////////
-
-// FUNCTION: Get selected value(s) of Select2 control
-// pass arg: source-element
-// return: value(s) comma-separated
-// ---------------------------------------------------------------------------
-function getValues(srcElm) {
- var res;
- var obj = srcElm.select2('data'); // get delected data array
-
- if (obj.length === 0) return ''; // if empty list then nothig is selected
- else {
- var i = 0;
- obj.forEach(function(elm){ // loop through object elements array
-
- if (i) res += ',' + elm.id; // if not first item, prepend ',' befor value(id)
- else res = elm.id; // else set (first) checked value
-
- i++;
- });
- }
- return res;
-}
-
-// patch select2-multiple widths
-// ---------------------------------------------------------------------------
-$('.select-field').select2({ width: '100%' });
-
-// init select2 fields
-// (embed from php)
-// ---------------------------------------------------------------------------
-<?=$form['init_js']?>
-
-<?=$form['values_js']?>
-
-
-// 04. FORM-LOGIC
-// ---------------------------------------------------------------------------
-//////////////////////////////////////////////////////////////////////////////
-
-// FUNCTION: Report empty fields
-// ---------------------------------------------------------------------------
-function reportEmpty() {
- var empty = '';
- var needit = [];
- var values = {};
-
- // embed if-conditions from php
- <?=$form['values_js']?>
-
- $("#empty-fields").html(empty); // render empty fields
-
- // console.log(JSON.stringify(values));
-
- return { need : needit, data: values }; // return all fields
-}
-reportEmpty();
-
-$('form').on('keyup change paste', 'input, select, textarea', function(){
- console.log('Form changed!');
- reportEmpty();
-});
-
-// validation?
-// check: https://www.sitepoint.com/instant-validation/
-
-
-$('#post-form').on('submit', function(e){
- e.preventDefault();
- if (!waitingResponse) {
- waitingResponse = true;
- var resp = reportEmpty();
-
- if (resp.need.length > 0) alert("Tα πεδία:\n\n" + resp.need.join(',\n') + "\n\nείναι υποχρεωτικά!");
- else {
- // alert('sending: '+JSON.stringify(resp.data));
- var postUrl = "/ajax.php?do=additem"; // url to post form
- var data2send = resp.data; // parse data to send
-
- $.ajax({
- type: 'POST',
- url: postUrl, // make sure you respect the same origin policy with this url
- data: data2send,
- dataType: "text",
-
- success: function(data) { // server replies
- var json = $.parseJSON(data);
- if (json.success == true) { // good! post accepted
- // alert(json.id)
- window.location.href = '/ui-show-item.php?id='+ json.id;
- }
- else {
- alert("Post not accepted.\nPlease check the data you submit.");
- // $('#oc-company-form')[0].reset();
- }
- },
-
- error: function() {
- alert('Some ajax error! :(');
- }
- });
- }
-
- waitingResponse = false;
- }
-
-});
-
-</script>
-
-
-
- </body>
-</html>
-
-