Архив

Публикации с меткой ‘javascript’
try{
	var result=JSON.parse(r);
	//...
}
catch(e){
}
Categories: Javascript Tags:
20 февраля 2021 Нет комментариев
var region_id=$('select[name=city] option:selected').data('region');
var region_pay=[10,20,1,76,77,6,55,59,13];
if(region_pay.includes(region_id))){
}
Categories: Javascript Tags:
20 ноября 2020 Нет комментариев
new Date(new Date().getTime()+172800000)
Categories: Javascript Tags:
23 октября 2020 Нет комментариев

При ошибке Classic styles are no longer supported; see https://blog.mapbox.com/deprecating-studio-classic-styles-d8892ac38cb4 for more information
Заменить

L.tileLayer('https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}',{
	attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
	maxZoom:18,
	id:'mapbox.streets',
	accessToken:'YOUR_MAPBOX_ACCESS_TOKEN'
}).addTo(mymap);

на

L.tileLayer('https://api.mapbox.com/styles/v1/{id}/tiles/{z}/{x}/{y}?access_token={accessToken}',{
	attribution: '© <a href="https://www.mapbox.com/about/maps/">Mapbox</a> © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> <strong><a href="https://www.mapbox.com/map-feedback/" target="_blank" rel="noopener noreferrer">Improve this map</a></strong>',
	tileSize:512,
	maxZoom:18,
	zoomOffset:-1,
	id:'mapbox/streets-v11',
	accessToken:'YOUR_MAPBOX_ACCESS_TOKEN'
}).addTo(mymap);
Categories: Javascript Tags:
25 февраля 2020 Нет комментариев

Добавить muted=true, например:

v.muted=true;
v.play();
Categories: Javascript Tags:
24 января 2020 Нет комментариев
<input type="text" name="test" placeholder="Test" onkeyup="this.value=this.value.replace(/\s+/gi,'')"/>
Categories: Javascript Tags:
24 декабря 2019 Нет комментариев

Javascript:

$(document).ready(function(){
	var select_brand=$('select[name=brand]');
	var select_collection=$('select[name=collection]');
	select_brand.on('change',function(){
		$.ajax({
			url:"/?ajax_action=get_collections&brand="+select_brand.val(),
			dataType:"json",
			success:function(data){
				select_collection.find('option').not(':first').remove();
				$.each(data,function(index,item){
					select_collection.append('<option value="'+item.id+'">'+item.name+'</option>');
				});
				select_collection.trigger("chosen:updated");
			}
		});
	});
});

HTML:

<select name="brand" class="chosen">
	<option value="0">Выбрать</option>
	<?if(count($brands)>0){?>
		<?foreach($brands as $item){?>
			<option value="<?=$item['id']?>"<?if($item['id']==$change_catalog["brand"]){?> selected="selected"<?}?>><?=$item['name']?></option>
		<?}?>
	<?}?>
</select>
<select name="collection" class="chosen">
	<option value="0">Выбрать</option>
	<?if(count($collections)>0){?>
		<?foreach($collections as $item){?>
			<option value="<?=$item['id']?>"<?if($item['id']==$change_catalog["collection"]){?> selected="selected"<?}?>><?=$item['name']?></option>
		<?}?>
	<?}?>
</select>

PHP:

if($_GET['ajax_action']=='get_collections'&&$_GET['brand']>0){
	header("Content-Type: application/json");
	$result=get_from_base('`id`,`name`','collections',"`parent`='".$_GET['brand']."'",'pos');
	echo json_encode($result);
	exit();
}
$brands=get_from_base('`id`,`name`','brands',"1",'`parent`,`pos`');
if($_GET["change_id"]){
	$change_catalog=get_by_id($_GET["change_id"],'catalog');
	if($change_catalog['brand']){
		$collections=get_from_base('`id`,`name`','collections',"`parent`='".$change_catalog['brand']."'",'pos');
	}
}
Categories: Javascript, PHP Tags: ,