Fusion de code javascript

Fermé
jericoallods Messages postés 6 Date d'inscription lundi 17 novembre 2014 Statut Membre Dernière intervention 19 novembre 2014 - 17 nov. 2014 à 16:15
jericoallods Messages postés 6 Date d'inscription lundi 17 novembre 2014 Statut Membre Dernière intervention 19 novembre 2014 - 19 nov. 2014 à 10:17
Bonjour,

slt a tous est ce qu'on peut fusionné deux code javascript

A voir également:

6 réponses

Utilisateur anonyme
17 nov. 2014 à 17:52
Salut,
si tu parles de mettre le contenu de deux <script></script> dans un seul set de balises, oui, c'est tout à fait possible.
Le mieux reste encore de mettre tes codes javascript dans un fichier externe que tu appelleras dans ta page HTML.

<script src="CHEMIN_VERS_TON_FICHIER_JS" type="text/javascript"></script>
0
jericoallods Messages postés 6 Date d'inscription lundi 17 novembre 2014 Statut Membre Dernière intervention 19 novembre 2014
18 nov. 2014 à 10:31
le problème c'est que j'ai deux script un pour un slider et un autre pour faire l'appel a des données depuis datamanager de mapquest les données apporter de datamanager doivent être afficher sur le slider lorsque j'ai mis les deux code le slider affiche les données mais sans annimation c'est a dire le slider s'affiche l'une a coté de l'autre
0
jericoallods Messages postés 6 Date d'inscription lundi 17 novembre 2014 Statut Membre Dernière intervention 19 novembre 2014
18 nov. 2014 à 10:32
voici le code du slider

jQuery(document).ready(function ($) {

$('#checkbox').change(function(){
setInterval(function () {
moveRight();
}, 3000);
});

var slideCount = $('#slider ul li').length;
var slideWidth = $('#slider ul li').width();
var slideHeight = $('#slider ul li').height();
var sliderUlWidth = slideCount * slideWidth;

$('#slider').css({ width: slideWidth, height: slideHeight });

$('#slider ul').css({ width: sliderUlWidth, marginLeft: - slideWidth });

$('#slider ul li:last-child').prependTo('#slider ul');

function moveLeft() {
$('#slider ul').animate({
left: + slideWidth
}, 200, function () {
$('#slider ul li:last-child').prependTo('#slider ul');
$('#slider ul').css('left', '');
});
};

function moveRight() {
$('#slider ul').animate({
left: - slideWidth
}, 200, function () {
$('#slider ul li:first-child').appendTo('#slider ul');
$('#slider ul').css('left', '');
});
};

$('a.control_prev').click(function () {
moveLeft();
});

$('a.control_next').click(function () {
moveRight();
});

});
0
jericoallods Messages postés 6 Date d'inscription lundi 17 novembre 2014 Statut Membre Dernière intervention 19 novembre 2014
18 nov. 2014 à 10:35
voici le code de mapquest


var key = "Fmjtd%7Cluurnu0tn9%2Cbg%3Do5-9w8n90";

/*An example using jQuery's $(document).ready function to wait until the DOM is fully loaded and
$.ajax function to make an asynchronous HTTP (Ajax) request to the Search API Web Service.*/

$(document).ready(function() {

/*Radius Search Using Your Own Custom Data Table*/
$.ajax({
url: 'http://www.mapquestapi.com/search/v2/radius',
dataType: 'jsonp',
crossDomain: true,
data: {
key: decodeURIComponent(key),
origin: '36.793626,10.277790', /*origin of the radius search*/
radius: 1, /*radius of search in kilometre*/
hostedData: 'mqap.145112_hanglocationstest|' /*the hosted data table you want to search along with query to narrow the results*/
},
success: function(data, textStatus, jqXHR) {
var pois = new MQA.ShapeCollection();
var html = '<div id="slider"><a href="#" class="control_next">>></a><a href="#" class="control_prev"><</a><ul>'; /* 200<thead><tr><th>Announcer_ID</th><th>Name</th><th>ADDRESS</th><th>Discription</th><th>DISTANCE (k)</th></tr>*/

/*Add POI markers and populate the search result table*/
for (i=1;i<data.searchResults.length;i++) {
var location = new MQA.Poi({lat:data.searchResults[i].shapePoints[0],lng:data.searchResults[i].shapePoints[1]});

/*Change default POI icons to numbered icons*/
var numberedPoi = new MQA.Icon('http://www.mapquestapi.com/staticmap/geticon?uri=poi-' + (i+1) + '.png',20,29);
location.setIcon(numberedPoi);

/*Populate the content within the InfoWindows*/
location.setRolloverContent('<div style="width:200px; font:bold 14px Helvetica, Arial, sans-serif;">' + data.searchResults[i].fields.title_annonce + '</div>');
location.setInfoContentHTML('<div style="width:200px; font:bold 14px Helvetica, Arial, sans-serif;">' + data.searchResults[i].fields.title_annonce + '</div>' + data.searchResults[i].fields.title_place + '<br />' + data.searchResults[i].fields.desc_id + ', CO ');

pois.add(location);
/*<td>' + data.searchResults[i].resultNumber + '</td>*/

html += '<li><tr><td align="center">' + data.searchResults[i].fields.title_annonce + '</td></tr><tr><td align="center">' + data.searchResults[i].fields.desc_id + '</td></tr><tr><td align="center">' + data.searchResults[i].fields.title_place + '</td></tr><tr><td align="center"><b> A </b>'+ data.searchResults[i].distance + '<b> K</b></td></tr></li>';
}

html += '</ul></div>';

document.getElementById('searchResults').innerHTML = html;

/*Create an object for options*/
var options={
elt:document.getElementById('map'),
collection:pois
};
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
jericoallods Messages postés 6 Date d'inscription lundi 17 novembre 2014 Statut Membre Dernière intervention 19 novembre 2014
18 nov. 2014 à 10:39
j'ai pas pu mettre la suite du code mais tous le code nécessaire est la je veut afficher les annonce apporter dpuis data manager sur le slider en fonction du nombre de données le nombre de slide augmente
0
jericoallods Messages postés 6 Date d'inscription lundi 17 novembre 2014 Statut Membre Dernière intervention 19 novembre 2014
19 nov. 2014 à 10:17
Personne peut m'aidez ?
0