<?php
// Headers
header('Access-Control-Allow-Origin: http://localhost:3000');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');
header('Access-Control-Allow-Headers: *');
header('Content-Type: application/json');
// Connect to db
$connect = mysqli_connect('localhost', 'root', 'root', 'f-mania');
// If connect error
if (!$connect) {
echo mysqli_connect_error();
die();
}
// Split url into array
$params = explode('/', $_GET['url']);
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
if ($params[0] == 'account') {
// ...
}
} elseif ($_SERVER['REQUEST_METHOD'] == 'POST') {
if ($params[0] == 'account') {
if ($params[1] == 'login') {
// ...
} elseif ($params[1] == 'recover') {
// ...
} elseif ($params[1] == 'reset') {
// ...
} elseif ($params[1] == 'register') {
// ...
}
}
} elseif ($_SERVER['REQUEST_METHOD'] == 'PUT') {
// ...
} elseif ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
// ...
}
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-F
RewriteRule ^(.+)$ index.php?url=$1 [L,QSA]
// App.vue
import Menu from './components/Menu'
export default {
name: 'Artefact',
components: {
Menu
},
methods: {
getPost() {
fetch('db.json')
.then(res => res.json())
.then(users=> {
document.title = `user ${users.id}`;
.......
})
}
},
created() {
this.getPost()
}
}
const content = document.querySelector('.editer'),
htmlTags = content.getElementsByTagName("*");
let navs = [],
lastIndexH2 = 0,
lastIndexH3 = 0;
const addItem = (obj, elem) => {
obj.push({
name: elem.innerText,
id: elem.id,
children: []
});
}
htmlTags.forEach((e, i) => {
if (e.localName == 'h2') {
e.id = `nav-${i}`
addItem(navs, e);
lastIndexH2 = i;
}
else if (e.localName == 'h3') {
e.id = `nav-${i}`
const resH2 = navs.find(item => item.id == `nav-${lastIndexH2}`);
if (resH2) {
addItem(resH2.children, e);
lastIndexH3 = i
}
}
else if (e.localName == 'h4') {
e.id = `nav-${i}`
navs.find(itemH2 => {
if (itemH2.id == `nav-${lastIndexH2}`) {
const resH3 = itemH2.children.find(elem => elem.id == `nav-${lastIndexH3}`);
resH3 ? addItem(resH3.children, e) : addItem(itemH2.children, e)
}
});
}
});
function drop(ev) {
ev.preventDefault();
var data = ev.dataTransfer.getData('text');
var elem = document.getElementById(data)
ev.target.appendChild(elem);
}
<div class="content" id="content">Ку-ку</div>
const tabs = document.querySelector('.content');