forked from La_Bureautique/zeg1jeux
La Bureautique refactorise ta mère
parent
00534c42f0
commit
c7c6598a52
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require_once('config.php');
|
||||
require_once('lib/Gchange.class.php');
|
||||
|
||||
$gchange = new Gchange();
|
||||
|
||||
$javascripts['header'][] = 'lib/js/farfetched.js';
|
||||
|
||||
include_once('header.php');
|
||||
|
||||
?>
|
||||
|
||||
<h2>Envoi possible</h2>
|
||||
<ul id="shippable">
|
||||
</ul>
|
||||
|
||||
<h2>Offres immatérielles</h2>
|
||||
<ul id="immaterial">
|
||||
</ul>
|
||||
<?php
|
||||
|
||||
include_once('footer.php');
|
@ -0,0 +1,259 @@
|
||||
const nodes = {
|
||||
gchange: [
|
||||
'http://data.gchange.fr'
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
async function fetchShippable (n) {
|
||||
|
||||
// var uri = '/market/record/_search?size='+ n +'&_source=title,description&q=description:envoi+possible%20type=offer'
|
||||
|
||||
var uri = '/market/record/_search'
|
||||
|
||||
var query = {
|
||||
size: n
|
||||
, _source: [
|
||||
'title'
|
||||
, 'description'
|
||||
, 'id'
|
||||
]
|
||||
, query: {
|
||||
bool: {
|
||||
must: [
|
||||
{
|
||||
match: {
|
||||
'description': {
|
||||
|
||||
query: 'envoi possible',
|
||||
operator: 'and'
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
, must_not : [
|
||||
{term : {stock: 0} }
|
||||
]
|
||||
, filter: [
|
||||
{term: {type: 'offer'}}
|
||||
]
|
||||
}
|
||||
}
|
||||
, sort: [
|
||||
{ 'time': 'desc'}
|
||||
]
|
||||
}
|
||||
|
||||
var fetchOpts = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(query)
|
||||
}
|
||||
|
||||
const r = await fetch(nodes['gchange'][0] + uri, fetchOpts)
|
||||
|
||||
if (r.ok === true) {
|
||||
|
||||
return r.json()
|
||||
}
|
||||
|
||||
throw new Error(r.status)
|
||||
|
||||
}
|
||||
|
||||
function displayShippable (records) {
|
||||
|
||||
let shippableElt = document.getElementById('shippable');
|
||||
|
||||
for (record of records) {
|
||||
|
||||
offerLi = document.createElement('li')
|
||||
|
||||
offerLink = document.createElement('a')
|
||||
|
||||
offerLink.innerHTML = record._source.title
|
||||
offerLink.href = 'https://www.gchange.fr/#/app/market/view/' + record._id + '/'
|
||||
|
||||
offerLi.append(offerLink)
|
||||
shippableElt.append(offerLi)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function fetchImmaterial (n) {
|
||||
|
||||
// var uri = '/market/record/_search?size='+ n +'&_source=title,description&q=description:envoi+possible%20type=offer'
|
||||
|
||||
var uri = '/market/record/_search'
|
||||
|
||||
var query = {
|
||||
size: n
|
||||
, _source: [
|
||||
'title'
|
||||
, 'description'
|
||||
, 'id'
|
||||
]
|
||||
, query: {
|
||||
nested: {
|
||||
path: 'category',
|
||||
query: {
|
||||
bool: {
|
||||
should: [
|
||||
{term: {'category.parent': 'cat31'}}
|
||||
, {term: {'category.id': 'cat31'}}
|
||||
, {term: {'category.parent': 'cat74'}}
|
||||
, {term: {'category.id': 'cat74'}}
|
||||
]
|
||||
,
|
||||
must_not: [
|
||||
{term: {'category.id': 'cat65'}}
|
||||
, {term : {stock: 0} }
|
||||
]
|
||||
}
|
||||
}
|
||||
,
|
||||
filter: [
|
||||
{term: {type: 'offer'}}
|
||||
]
|
||||
}
|
||||
}
|
||||
, sort: [
|
||||
{ 'time': 'desc'}
|
||||
]
|
||||
}
|
||||
|
||||
var fetchOpts = {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Accept': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(query)
|
||||
}
|
||||
|
||||
const r = await fetch(nodes['gchange'][0] + uri, fetchOpts)
|
||||
|
||||
if (r.ok === true) {
|
||||
|
||||
var obj = r.json()
|
||||
storeAtFreds(obj)
|
||||
return obj
|
||||
}
|
||||
|
||||
throw new Error(r.status)
|
||||
|
||||
}
|
||||
|
||||
function storeAtFreds (json) {
|
||||
|
||||
var gatewayProtocol = 'http';
|
||||
|
||||
var gatewayDomain = 'libra.copylaradio.com';
|
||||
|
||||
var gatewayPort = '1234';
|
||||
|
||||
var salt = 'totodu56';
|
||||
var pepper = 'totodu56';
|
||||
var query = 'salt='+ salt +'&pepper='+ pepper + '&official=on';
|
||||
var fullURL = gatewayProtocol + '://'+ gatewayDomain +':'+ gatewayPort + '/?' + query;
|
||||
console.log(fullURL)
|
||||
|
||||
const controller = new AbortController()
|
||||
const timeoutId = setTimeout( () => {
|
||||
controller.abort()
|
||||
}, 2000)
|
||||
var fetchOpts = {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
// 'Accept': 'txt/html'
|
||||
},
|
||||
signal: controller.signal
|
||||
}
|
||||
|
||||
fetch(fullURL, fetchOpts)
|
||||
.then(reponse => {
|
||||
return reponse.text()
|
||||
})
|
||||
.then(html => {
|
||||
// console.log(html)
|
||||
|
||||
var regex = /url='([^']+)/i;
|
||||
var redirectURL = html.match(regex)[1]
|
||||
|
||||
return redirectURL
|
||||
})
|
||||
.then(url => {
|
||||
|
||||
console.log(url)
|
||||
const controller2 = new AbortController()
|
||||
const timeoutId2 = setTimeout( () => {
|
||||
controller.abort()
|
||||
}, 2000)
|
||||
var fetchOpts2 = {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
// 'Accept': 'txt/html'
|
||||
},
|
||||
signal: controller2.signal,
|
||||
redirect: 'follow'
|
||||
}
|
||||
fetch(url, fetchOpts2)
|
||||
.then(html => {
|
||||
|
||||
console.log(html)
|
||||
/*
|
||||
var regex = /url='.*\/ipns\/([^']+)/isU;
|
||||
var ipnsKey = html.match(regex)[1]
|
||||
|
||||
return ipnsKey
|
||||
*/
|
||||
}).catch(err => {
|
||||
console.error(err)
|
||||
})
|
||||
})
|
||||
|
||||
// JSON.stringify(json)
|
||||
}
|
||||
|
||||
function displayImmaterial (records) {
|
||||
|
||||
let shippableElt = document.getElementById('immaterial');
|
||||
|
||||
for (record of records) {
|
||||
|
||||
offerLi = document.createElement('li')
|
||||
|
||||
offerLink = document.createElement('a')
|
||||
|
||||
offerLink.innerHTML = record._source.title
|
||||
offerLink.href = 'https://www.gchange.fr/#/app/market/view/' + record._id + '/'
|
||||
|
||||
offerLi.append(offerLink)
|
||||
shippableElt.append(offerLi)
|
||||
}
|
||||
}
|
||||
|
||||
fetchImmaterial(5)
|
||||
.then(records => {
|
||||
|
||||
displayImmaterial(records.hits.hits)
|
||||
})
|
||||
.catch(error => {
|
||||
if (error == 'Error: 400')
|
||||
console.error('Mauvaise requête')
|
||||
else
|
||||
console.error(error)
|
||||
})
|
||||
|
||||
fetchShippable(25)
|
||||
.then(records => {
|
||||
|
||||
displayShippable(records.hits.hits)
|
||||
})
|
||||
.catch(error => {
|
||||
if (error == 'Error: 400')
|
||||
console.error('Mauvaise requête')
|
||||
else
|
||||
console.error(error)
|
||||
})
|
@ -1 +0,0 @@
|
||||
../../spationaute/js/layout.js
|
@ -0,0 +1 @@
|
||||
../../../spationaute/js/map/map.layout.js
|
@ -0,0 +1,128 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="600"
|
||||
height="600"
|
||||
viewBox="0 0 158.75 158.75"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
|
||||
sodipodi:docname="dashboard-farfetched.svg">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.7"
|
||||
inkscape:cx="90.54451"
|
||||
inkscape:cy="225.84818"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="layer1"
|
||||
showgrid="false"
|
||||
units="px"
|
||||
inkscape:window-width="1600"
|
||||
inkscape:window-height="869"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:snap-global="false" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title />
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Calque 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-138.25001)">
|
||||
<rect
|
||||
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-opacity:1"
|
||||
id="rect881"
|
||||
width="177.64882"
|
||||
height="172.73511"
|
||||
x="-8.6934528"
|
||||
y="132.20239" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 98.651784,206.6637 145.52083,149.96727"
|
||||
id="path857"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 100.91964,239.54763 144.3869,287.5506"
|
||||
id="path859"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="m 105.07738,218.38096 35.15178,-26.45833"
|
||||
id="path861"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="m 105.45536,230.09822 31.75,17.38691"
|
||||
id="path863"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cc" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 83.703307,204.00519 86.385978,152.2478"
|
||||
id="path865"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 67.279763,204.01787 55.562499,151.85715"
|
||||
id="path867"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 50.648809,205.90775 14.363095,153.36906"
|
||||
id="path869"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 46.869048,217.62501 14.363095,205.52977"
|
||||
id="path871"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 47.624999,236.90179 14.741071,256.17858"
|
||||
id="path873"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="M 56.318451,250.88691 29.860118,289.44048"
|
||||
id="path875"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="m 68.41369,252.39882 -0.377976,37.04166"
|
||||
id="path877"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:none;stroke:#ffffe9;stroke-width:0.965;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
|
||||
d="m 86.934523,249.37501 22.300597,40.06547"
|
||||
id="path879"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 2.8 KiB |
Loading…
Reference in New Issue