Example for API

This commit is contained in:
Mathieu Sanchez 2018-12-13 10:55:35 +09:00
parent cf4ad2b1cc
commit cce4b1f186
3 changed files with 23 additions and 6 deletions

View File

@ -5,19 +5,23 @@ namespace WebProjectFitness\API;
class APIUser extends API { class APIUser extends API {
private $declaredFunctions = [ private $declaredFunctions = [
'insert' => [ 'create' => [
'method' => 'POST', 'method' => 'POST',
'params' => [ 'params' => [
'name' => [ 'id' => [
'required' => true, 'required' => true,
'type' => 'string' 'type' => 'string'
] ]
] ]
], ]
]; ];
public function __construct() { public function __construct() {
parent::__construct( $this->declaredFunctions ); parent::__construct( $this->declaredFunctions );
} }
public function create( $data ) {
$this->returnJson( [ 'body' => 'truc', 'id' => $data[ 'id' ] ] );
}
} }

View File

@ -26,4 +26,9 @@
height: 10px; height: 10px;
border-radius: 50%; border-radius: 50%;
cursor: pointer; cursor: pointer;
display: none;
}
#point-container.start .point {
display: inherit;
} }

View File

@ -23,8 +23,9 @@ let pointConfig = [
let Point = ( function () { let Point = ( function () {
let Point = function ( conf ) { let Point = function ( conf, callback ) {
this.config = conf; this.config = conf;
this.callback = callback;
this.addSpecificCSS(); this.addSpecificCSS();
this.adHtml(); this.adHtml();
}; };
@ -36,7 +37,6 @@ let Point = ( function () {
let css = `<style id="point-css">`; let css = `<style id="point-css">`;
for ( let conf of this.config ) { for ( let conf of this.config ) {
console.log( conf );
css += ` css += `
.${ conf.title }-css { .${ conf.title }-css {
animation: ${ conf.title }-animation 1s linear 0s infinite normal none running; animation: ${ conf.title }-animation 1s linear 0s infinite normal none running;
@ -82,10 +82,13 @@ let Point = ( function () {
html += `<div class="blue darken-3 point ${ conf.title }-css ${ conf.noAnim ? "stop" : "" }"></div>`; html += `<div class="blue darken-3 point ${ conf.title }-css ${ conf.noAnim ? "stop" : "" }"></div>`;
} }
container.append( html.replace( / |\n/g, "" ) ); container.append( html.replace( / |\n/g, "" ) );
this.callback( this );
}; };
proto.start = function () { proto.start = function () {
let container = $( "#point-container" );
container.addClass( "start" );
}; };
return Point; return Point;
@ -95,6 +98,11 @@ $( document ).ready( () => {
$( ".dropdown-trigger" ).dropdown(); $( ".dropdown-trigger" ).dropdown();
// let point = new Point( pointConfig ); let point;
new Point( pointConfig, ( p ) => {
point = p;
point.start();
} );
} ); } );