Skip to content

Commit

Permalink
Placido-Shop v-2.1.5
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed Dec 5, 2022
1 parent d82ec8a commit 061a653
Show file tree
Hide file tree
Showing 46 changed files with 3,332 additions and 4,070 deletions.
6 changes: 0 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +0,0 @@

# not update readme files
/README.md
/READ_ME.txt
/LICENSE.txt
/security.txt
7 changes: 5 additions & 2 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
RewriteEngine on

# redirect www. to non-www.
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Expand All @@ -25,8 +30,6 @@ Header set Access-Control-Allow-Credentials "true"

Header set Access-Control-Allow-Private-Network "true"

Header set Server "Placido-Shop"

## age : 31536000 seconds / 365 days
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"

Expand Down
7 changes: 5 additions & 2 deletions ADMIN/.htaccess
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
RewriteEngine on

# redirect www. to non-www.
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

RewriteCond %{HTTPS} !=on
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Expand All @@ -9,8 +14,6 @@ Header set Access-Control-Allow-Credentials "true"

Header set Access-Control-Allow-Private-Network "true"

Header set Server "Placido-Shop"

# age : 31536000 seconds / 365 days
Header set Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"

Expand Down
11 changes: 10 additions & 1 deletion ADMIN/CSS/api.css
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ html, body {
#main {
color: #e6e6e6;
width: 100%;
overflow-x: hidden;
}
#main h5 {
color: #e6e6e6;
Expand Down Expand Up @@ -686,11 +687,18 @@ hr {
.title_set:hover {
text-decoration: underline;
}
#stripe_keys input {
#stripe_keys input, #token_placido input {
width: 300px;
max-width: 85%;
}
width: 300px;
max-width: 85%;
}
/* API settings */
#form_api_settings label {
display: inline-block;
margin: 0 0 6px;
}
#form_api_settings input:not([type="range"]),
#form_api_settings select,
#form_api_settings textarea,
Expand All @@ -716,6 +724,7 @@ select#LANG_LOCALE option:disabled {
background: #616161;
color: #fbdfda;
}

/* INPUTS STATIC PAGES */
#static_pages input {
font-size: 20px;
Expand Down
19 changes: 9 additions & 10 deletions ADMIN/JS/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@
*
*/


// List resources loaded
// var entries = performance.getEntriesByType('resource');
// entries.map(function(entry) {
// console.log('Type: '+entry.initiatorType+' File: '+ entry.name);
// });
const DEV_MODE = false;

// start jQuery
$(function(){



/* LOGIN BY PRESS ENTER KEY */
$(document).one('keydown', function(e){
$(document).on('keydown', function(e){

if( e.key == 'Enter' ){

Expand Down Expand Up @@ -85,11 +80,15 @@ $.extend({
// off press enter
$(document).off('keydown');

$.o = data.response;

// PASS DATAS API TO $.o OBJECT enter -> $.o <- in a console to see object
$.o = data.response;
if( DEV_MODE ){

// SHOW OBJECT API
console.log($.o);
}

// SHOW OBJECT API
console.log($.o);

// LOAD JS BACKEND BASE TEMPLATE
$.Mustache.load('templates/new_sales.html',
Expand Down
217 changes: 214 additions & 3 deletions ADMIN/JS/settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* PlACIDO-SHOP FRAMEWORK - BACK OFFICE
* Copyright © Raphaël Castello , 2021-2022
* Copyright © Raphaël Castello , 2022
* Organisation: SNS - Web et Informatique
* Web site: https://sns.pm
* @link: [email protected]
Expand All @@ -10,13 +10,17 @@
* $.deploy_settings_item();
* $.change_admin_pass();
* $.clear_set_admin_pass();
* $.record_token_placido();
* $.set_stripe_keys( context );
* $.select_pay_mode( mode );
* $.update_by_money();
* $.compress_ressources();
* $.use_compressed_ressources( use );
* $.display_products( display );
* $.record_api_settings();
* $.update_mailbox( command );
* $.confirm_switch_prod_mode();
* $.switch_to_prod_mode();
*
*/

Expand Down Expand Up @@ -156,6 +160,72 @@ $.extend({



/**
* $.record_token_placido();
*
* @return {json} success/error
*/
record_token_placido : function(){


// disable btn
$('#btn_token_placido')
.removeAttr('onclick')
.append(`<span class="spinner">
&nbsp;<i class="fas fa-circle-notch fa-spin fa-fw"></i></span>`);

// set a FormData
var formData = new FormData();

// append command
formData.append( 'set', 'record_token_placido' );

// append token user
formData.append( 'token', $.o.user.token );

// append token Placido
formData.append( 'token_placido', $('#token_placido_input').val() );

// post datas - false on form - unbug event listener button
$.sender(false, 'POST', 'index.php', formData, 'json',
function(data){

// succes
if( data.success ){

// assign value to token - same as server
$.o.user.token_Placido = $('#token_placido_input').val();

// state
$('#token_placido_state').empty()
.mustache('token_placido_state', $.o );

$.show_alert('success', data.success, false);
}

// error
if( data.error ){

$.show_alert('warning', data.error, false);
}

// enable click btn
$('#btn_token_placido')
.attr('onclick', '$.record_token_placido();');

// remove spinner
$('.spinner').remove();

});
// end $.sender

},
/**
* $.record_token_placido();
*/



/**
* $.set_stripe_keys( context );
*
Expand Down Expand Up @@ -440,6 +510,49 @@ $.extend({



/**
* $.display_products( display, event );
*
* @param {string} display 'inline' / 'mozaic'
* @param {event} event
* @return {void} choose how to display products in view
*/
display_products : function( display, event ){

if( display != 'inline' && display != 'mozaic' ){
return;
}

// both
$('label[for="display_mozaic"],label[for="display_inline"]')
.removeClass('gree').addClass('blue');

$('input#display_inline, input#display_mozaic')
.removeAttr('checked');

// display on line
if( display == 'inline' ){

// $('input#display_inline').attr('checked', true).prop('checked', true);

$('label[for="display_inline"]')
.removeClass('blue').addClass('gree');
}
else{

// $('input#display_mozaic').attr('checked', true).prop('checked', true);

$('label[for="display_mozaic"]')
.removeClass('blue').addClass('gree');
}

},
/**
* $.display_products( display, event );
*/



/**
* $.record_api_settings();
*
Expand Down Expand Up @@ -481,19 +594,33 @@ $.extend({
formData.append('img[]', $.obj.files[0]);
}

// test entries :
// for (var variable of formData.entries() ) {
//
// console.log( variable );
// }
// return;

// post datas - false on form - unbug event listener button
$.sender(false, 'POST', 'index.php', formData, 'json',
function(data){

// succes
// success
if( data.success ){

$.show_alert('success', data.success, false);

// re-init datas object
$.o.api_settings = data.api_settings;

// $('#add_sn_img').attr('onclick', '$.add_img_prod();');
// render displaying type of products view on settings
// 'inline'
$.o.template.display_inline =
( $.o.api_settings.DISPLAY_PRODUCTS == 'inline' ) ? true : false;
// 'mozaic'
$.o.template.display_mozaic =
( $.o.api_settings.DISPLAY_PRODUCTS == 'mozaic' ) ? true : false;

}

// error
Expand Down Expand Up @@ -591,6 +718,90 @@ $.extend({



/**
* $.confirm_switch_prod_mode();
*
* @return {html} ask to confirm
* to switch to production mode
*/
confirm_switch_prod_mode : function(){


var html =
`<p>`+$.o.tr.confirm_switch_prod_mode+`</p>
<button class="btn deep-orange card round left"
onclick="$.switch_to_prod_mode();" role="button">
<i class="fa-sign-in-alt fas"></i>&nbsp; `+$.o.tr['confirm']+`</button>
<button class="btn dark-gray card round right"
onclick="$.show_alert(false);" role="button">
<i class="fa-ban fas"></i>&nbsp; `+$.o.tr['abort']+`</button>`;

$.show_alert('info', html, true);

},
/**
* $.confirm_switch_prod_mode();
*/



/**
* $.switch_to_prod_mode();
*
* @return {type} description
*/
switch_to_prod_mode : function(){


// disable btn
$('#btn_prod_mode')
.removeAttr('onclick')
.append(`<span class="spinner">
&nbsp;<i class="fas fa-circle-notch fa-spin fa-fw"></i></span>`);

// set a FormData
var formData = new FormData();

// append command
formData.append( 'set', 'switch_production_mode' );

// append token user
formData.append( 'token', $.o.user.token );

// post datas - false on form - unbug event listener button
$.sender(false, 'POST', 'index.php', formData, 'json',
function(data){

// succes
if( data.success ){

$.show_alert('success', data.success, false);
}

// error
if( data.error ){

$.show_alert('warning', data.error, false);
}

// enable click btn
$('#btn_prod_mode')
.attr('onclick', '$.switch_to_prod_mode();');

// remove spinner
$('.spinner').remove();

});
// end $.sender

},
/**
* $.switch_to_prod_mode();
*/




});
// END EXTEND

Expand Down
Loading

0 comments on commit 061a653

Please sign in to comment.