work
This commit is contained in:
parent
22e8271b48
commit
73070acdc9
|
@ -0,0 +1 @@
|
|||
Subproject commit 22e8271b48453c13712a6b32f7598f342a8a3332
|
|
@ -0,0 +1,154 @@
|
|||
-- phpMyAdmin SQL Dump
|
||||
-- version 4.7.6
|
||||
-- https://www.phpmyadmin.net/
|
||||
--
|
||||
-- Hôte : localhost
|
||||
-- Généré le : sam. 22 déc. 2018 à 19:41
|
||||
-- Version du serveur : 10.1.37-MariaDB-0+deb9u1
|
||||
-- Version de PHP : 7.0.33-0+deb9u1
|
||||
|
||||
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
|
||||
SET AUTOCOMMIT = 0;
|
||||
START TRANSACTION;
|
||||
SET time_zone = "+00:00";
|
||||
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
||||
/*!40101 SET NAMES utf8mb4 */;
|
||||
|
||||
--
|
||||
-- Base de données : `TVJeanray`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `communication`
|
||||
--
|
||||
|
||||
CREATE TABLE `communication` (
|
||||
`ID_Com` int(11) NOT NULL,
|
||||
`Texte` varchar(200) DEFAULT NULL,
|
||||
`Titre_Com` varchar(50) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `com_active`
|
||||
--
|
||||
|
||||
CREATE TABLE `com_active` (
|
||||
`ID_Com_Actif` int(11) NOT NULL,
|
||||
`ID_Com` int(11) NOT NULL,
|
||||
`ID_Zone` int(11) NOT NULL,
|
||||
`Actif` tinyint(1) NOT NULL,
|
||||
`Type` tinyint(4) NOT NULL DEFAULT '1',
|
||||
`Date_debut` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`Date_fin` date NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `user`
|
||||
--
|
||||
|
||||
CREATE TABLE `user` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` varchar(255) NOT NULL,
|
||||
`pw` varchar(255) NOT NULL,
|
||||
`actif` tinyint(1) NOT NULL DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Structure de la table `zone`
|
||||
--
|
||||
|
||||
CREATE TABLE `zone` (
|
||||
`ID_Zone` int(11) NOT NULL,
|
||||
`Active` tinyint(1) NOT NULL,
|
||||
`Nom` varchar(200) NOT NULL,
|
||||
`Nord` double NOT NULL,
|
||||
`Sud` double NOT NULL,
|
||||
`Ouest` double NOT NULL,
|
||||
`Est` double NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Index pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- Index pour la table `communication`
|
||||
--
|
||||
ALTER TABLE `communication`
|
||||
ADD PRIMARY KEY (`ID_Com`);
|
||||
|
||||
--
|
||||
-- Index pour la table `com_active`
|
||||
--
|
||||
ALTER TABLE `com_active`
|
||||
ADD PRIMARY KEY (`ID_Com_Actif`),
|
||||
ADD KEY `ID_Zone` (`ID_Zone`),
|
||||
ADD KEY `ID_Com` (`ID_Com`);
|
||||
|
||||
--
|
||||
-- Index pour la table `user`
|
||||
--
|
||||
ALTER TABLE `user`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Index pour la table `zone`
|
||||
--
|
||||
ALTER TABLE `zone`
|
||||
ADD PRIMARY KEY (`ID_Zone`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `communication`
|
||||
--
|
||||
ALTER TABLE `communication`
|
||||
MODIFY `ID_Com` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `com_active`
|
||||
--
|
||||
ALTER TABLE `com_active`
|
||||
MODIFY `ID_Com_Actif` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=6;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `user`
|
||||
--
|
||||
ALTER TABLE `user`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT pour la table `zone`
|
||||
--
|
||||
ALTER TABLE `zone`
|
||||
MODIFY `ID_Zone` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=24;
|
||||
|
||||
--
|
||||
-- Contraintes pour les tables déchargées
|
||||
--
|
||||
|
||||
--
|
||||
-- Contraintes pour la table `com_active`
|
||||
--
|
||||
ALTER TABLE `com_active`
|
||||
ADD CONSTRAINT `fk_com` FOREIGN KEY (`ID_Com`) REFERENCES `communication` (`ID_Com`),
|
||||
ADD CONSTRAINT `fk_zone` FOREIGN KEY (`ID_Zone`) REFERENCES `zone` (`ID_Zone`);
|
||||
COMMIT;
|
||||
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
|
@ -0,0 +1,23 @@
|
|||
exports.choixZone = function(zones){
|
||||
var zone = zones[0];
|
||||
var aireMin = (zones[0].Nord-zones[0].Sud)*(zones[0].Est-zones[0].Ouest)
|
||||
for(var i = 1;i<zones.length;i++)
|
||||
{
|
||||
var aire = (zones[i].Nord-zones[i].Sud)*(zones[i].Est-zones[i].Ouest)
|
||||
if(aire<aireMin){
|
||||
zone = zones[i];
|
||||
aireMin = aire;
|
||||
}
|
||||
}
|
||||
return zone;
|
||||
}
|
||||
|
||||
exports.listPubDansZone = function(zone, callback){
|
||||
var con = require('./bdd.js')
|
||||
con.query("SELECT * FROM com_active INNER JOIN zone ON com_active.ID_Zone = zone.ID_Zone INNER JOIN communication ON com_active.ID_Com = communication.ID_Com WHERE zone.ID_Zone = ? ", [zone], function(err, result){
|
||||
var data = JSON.stringify(result);
|
||||
console.log("BLA "+data+ "_____RESULT_____"+result+"___"+[zone]);
|
||||
data = JSON.parse(data);
|
||||
callback(err, data)
|
||||
});
|
||||
}
|
47
fonction.js
47
fonction.js
|
@ -1,24 +1,23 @@
|
|||
exports.choixZone = function(zones){
|
||||
var zone = zones[0];
|
||||
var aireMin = (zones[0].Nord-zones[0].Sud)*(zones[0].Est-zones[0].Ouest)
|
||||
for(var i = 1;i<zones.length;i++)
|
||||
{
|
||||
var aire = (zones[i].Nord-zones[i].Sud)*(zones[i].Est-zones[i].Ouest)
|
||||
if(aire<aireMin){
|
||||
zone = zones[i];
|
||||
aireMin = aire;
|
||||
}
|
||||
}
|
||||
return zone;
|
||||
}
|
||||
|
||||
exports.listPubDansZone = function(zone, callback){
|
||||
var con = require('./bdd.js')
|
||||
con.query("SELECT * FROM com_active INNER JOIN zone ON com_active.ID_Zone = zone.ID_Zone INNER JOIN communication ON com_active.ID_Com = communication.ID_Com WHERE zone.ID_Zone = ? ", [zone], function(err, result){
|
||||
var data = JSON.stringify(result);
|
||||
console.log(data);
|
||||
data = JSON.parse(data);
|
||||
callback(err, data)
|
||||
});
|
||||
}
|
||||
|
||||
exports.choixZone = function(zones){
|
||||
var zone = zones[0];
|
||||
var aireMin = (zones[0].Nord-zones[0].Sud)*(zones[0].Est-zones[0].Ouest)
|
||||
for(var i = 1;i<zones.length;i++)
|
||||
{
|
||||
var aire = (zones[i].Nord-zones[i].Sud)*(zones[i].Est-zones[i].Ouest)
|
||||
if(aire<aireMin){
|
||||
zone = zones[i];
|
||||
aireMin = aire;
|
||||
}
|
||||
}
|
||||
return zone;
|
||||
}
|
||||
|
||||
exports.listPubDansZone = function(zone, callback){
|
||||
var con = require('./bdd.js')
|
||||
con.query("SELECT * FROM com_active INNER JOIN zone ON com_active.ID_Zone = zone.ID_Zone INNER JOIN communication ON com_active.ID_Com = communication.ID_Com WHERE zone.ID_Zone = ? ", [zone], function(err, result){
|
||||
var data = JSON.stringify(result);
|
||||
console.log("BLA "+data+ "_____RESULT_____"+result+"___"+[zone]);
|
||||
data = JSON.parse(data);
|
||||
callback(err, data)
|
||||
});
|
||||
}
|
||||
|
|
2
index.js
2
index.js
|
@ -51,7 +51,7 @@ app.get('/', function(req, res){
|
|||
var data = JSON.stringify(result);
|
||||
data = JSON.parse(data);
|
||||
var zone = fonctionMaison.choixZone(data[0]);
|
||||
fonctionMaison.listPubDansZone(zone,function(err, pub){
|
||||
fonctionMaison.listPubDansZone(zone.ID_Zone,function(err, pub){
|
||||
if (err) throw err;
|
||||
res.render('TV', {zone:zone.ID_Zone,pub:pub})
|
||||
});
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
var CommunicationJSON = JSON.parse(msg);
|
||||
console.debug(CommunicationJSON)
|
||||
CommunicationJSON.ListeCom.forEach(function(Communication){
|
||||
console.debug(Communication)
|
||||
switch (Communication.level) {
|
||||
case "1":
|
||||
$("#lvl1").append('<li class="caption center-align" data-idPub="'+Communication.IDPub+'\">'+Communication.html+'</li>')
|
||||
|
@ -36,6 +37,7 @@
|
|||
default:
|
||||
|
||||
}
|
||||
$('.slider').slider({indicators: false})
|
||||
})
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue