Subversion Repositories SmartDukaan

Rev

Rev 36644 | Rev 36651 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 36644 Rev 36650
Line 1628... Line 1628...
1628
		if (homeMarker) b.extend(homeMarker.getPosition());
1628
		if (homeMarker) b.extend(homeMarker.getPosition());
1629
		for (var k in markers) b.extend(markers[k].getPosition());
1629
		for (var k in markers) b.extend(markers[k].getPosition());
1630
		map.fitBounds(b);
1630
		map.fitBounds(b);
1631
	}
1631
	}
1632
}
1632
}
-
 
1633
 
-
 
1634
// ============ AUTO-LOAD FROM URL PARAMS ============
-
 
1635
// When opened with ?autoUserId=X[&autoUserName=Y], skip the user-picker
-
 
1636
// dropdowns and load that user's beats directly (and jump to Calendar tab).
-
 
1637
$(function () {
-
 
1638
	// Use a manual parser so we don't depend on URLSearchParams
-
 
1639
	function getParam(name) {
-
 
1640
		var q = window.location.search.substring(1);
-
 
1641
		var pairs = q.split('&');
-
 
1642
		for (var i = 0; i < pairs.length; i++) {
-
 
1643
			var kv = pairs[i].split('=');
-
 
1644
			if (decodeURIComponent(kv[0]) === name) {
-
 
1645
				return kv.length > 1 ? decodeURIComponent(kv[1].replace(/\+/g, ' ')) : '';
-
 
1646
			}
-
 
1647
		}
-
 
1648
		return null;
-
 
1649
	}
-
 
1650
 
-
 
1651
	var autoUid = getParam('autoUserId');
-
 
1652
	console.log('[BEAT-AUTO] autoUserId =', autoUid);
-
 
1653
	if (!autoUid) return;
-
 
1654
 
-
 
1655
	var autoName = getParam('autoUserName');
-
 
1656
	state.authUserId = parseInt(autoUid);
-
 
1657
	state.categoryId = parseInt($('#bp-category').val()) || 4;
-
 
1658
	state.mode = 'list';
-
 
1659
	$('#bp-user-label').text(autoName || ('User #' + autoUid));
-
 
1660
 
-
 
1661
	$.ajax({
-
 
1662
		url: context + '/beatPlan/getBaseLocation', type: 'GET', dataType: 'json',
-
 
1663
		data: {authUserId: autoUid},
-
 
1664
		success: function (r) {
-
 
1665
			console.log('[BEAT-AUTO] getBaseLocation ok');
-
 
1666
			var data = r.response || r;
-
 
1667
			if (data.locationName) {
-
 
1668
				state.homeLat = parseFloat(data.latitude);
-
 
1669
				state.homeLng = parseFloat(data.longitude);
-
 
1670
				state.homeName = data.locationName;
-
 
1671
			}
-
 
1672
			showBeatList();
-
 
1673
			// Jump straight to the Calendar tab (that's what the user came here for)
-
 
1674
			setTimeout(function () {
-
 
1675
				$('.panel-tab[data-tab="calendar"]').click();
-
 
1676
			}, 100);
-
 
1677
		},
-
 
1678
		error: function (xhr) {
-
 
1679
			console.error('[BEAT-AUTO] getBaseLocation failed:', xhr.status, xhr.responseText);
-
 
1680
		}
-
 
1681
	});
-
 
1682
});