Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/kjvdictionary_store/modules/googleAddress/ |
Upload File : |
<?php
namespace modules\googleAddress;
class main extends \moduleMain {
use \modules\input\traits {
\modules\input\traits::__construct as __ConstructInput;
}
use \modules\database\traits {
\modules\database\traits::__construct as __ConstructDatabase;
}
use \modules\output\traits {
\modules\output\traits::__construct as __ConstructOutput;
}
private $active = FALSE;
public function __construct() {
parent::__construct(__DIR__);
$this->__ConstructInput();
$this->__ConstructDatabase();
$this->__ConstructOutput();
}
public function Activate() {
hook_add('component.add', [$this, '__component']);
hook_add('html.prepare', [$this, '__head']);
}
// intercept password fields
public function __component(&$status, $requested) {
if ($requested == 'address' && !empty($this->settings['api_key'])) {
$this->active = TRUE;
}
}
public function __head(&$theme) {
if ($this->active) {
$key = $this->settings['api_key'];
$id = $this->includeFile("https://maps.googleapis.com/maps/api/js?key={$key}&libraries=places");
$base = $this->StaticUriModule(__DIR__);
$this->includeFile("$base/address.js");
// include css
}
}
}
/*
// This sample uses the Places Autocomplete widget to:
// 1. Help the user select a place
// 2. Retrieve the address components associated with that place
// 3. Populate the form fields with those address components.
// This sample requires the Places library, Maps JavaScript API.
// Include the libraries=places parameter when you first load the API.
// For example: <script
// src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">
let autocomplete;
let address1Field;
let address2Field;
let postalField;
function initAutocomplete() {
address1Field = document.querySelector("#ship-address");
address2Field = document.querySelector("#address2");
postalField = document.querySelector("#postcode");
// Create the autocomplete object, restricting the search predictions to
// addresses in the US and Canada.
autocomplete = new google.maps.places.Autocomplete(address1Field, {
componentRestrictions: { country: ["us", "ca"] },
fields: ["address_components", "geometry"],
types: ["address"],
});
address1Field.focus();
// When the user selects an address from the drop-down, populate the
// address fields in the form.
autocomplete.addListener("place_changed", fillInAddress);
}
function fillInAddress() {
// Get the place details from the autocomplete object.
const place = autocomplete.getPlace();
let address1 = "";
let postcode = "";
// Get each component of the address from the place details,
// and then fill-in the corresponding field on the form.
// place.address_components are google.maps.GeocoderAddressComponent objects
// which are documented at http://goo.gle/3l5i5Mr
for (const component of place.address_components) {
// @ts-ignore remove once typings fixed
const componentType = component.types[0];
switch (componentType) {
case "street_number": {
address1 = `${component.long_name} ${address1}`;
break;
}
case "route": {
address1 += component.short_name;
break;
}
case "postal_code": {
postcode = `${component.long_name}${postcode}`;
break;
}
case "postal_code_suffix": {
postcode = `${postcode}-${component.long_name}`;
break;
}
case "locality":
document.querySelector("#locality").value = component.long_name;
break;
case "administrative_area_level_1": {
document.querySelector("#state").value = component.short_name;
break;
}
case "country":
document.querySelector("#country").value = component.long_name;
break;
}
}
address1Field.value = address1;
postalField.value = postcode;
// After filling the form with address components from the Autocomplete
// prediction, set cursor focus on the second address line to encourage
// entry of subpremise information such as apartment, unit, or floor number.
address2Field.focus();
}
window.initAutocomplete = initAutocomplete;
<!DOCTYPE html>
<html>
<head>
<title>Address Selection</title>
<style>
body {
margin: 0;
}
.sb-title {
position: relative;
top: -12px;
font-family: Roboto, sans-serif;
font-weight: 500;
}
.sb-title-icon {
position: relative;
top: -5px;
}
gmpx-split-layout {
height: 500px;
width: 600px;
}
gmpx-split-layout:not(:defined) {
visibility: hidden;
}
.panel {
background: white;
box-sizing: border-box;
height: 100%;
width: 100%;
padding: 20px;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.half-input-container {
display: flex;
justify-content: space-between;
}
.half-input {
max-width: 120px;
}
h2 {
margin: 0;
font-family: Roboto, sans-serif;
}
input {
height: 30px;
}
input {
border: 0;
border-bottom: 1px solid black;
font-size: 14px;
font-family: Roboto, sans-serif;
font-style: normal;
font-weight: normal;
}
input:focus::placeholder {
color: white;
}
</style>
<script type="module">
"use strict";
// This loads helper components from the Extended Component Library,
// https://github.com/googlemaps/extended-component-library.
// Please note unpkg.com is unaffiliated with Google Maps Platform.
import {APILoader} from 'https://unpkg.com/@googlemaps/extended-component-library@0.6';
const SHORT_NAME_ADDRESS_COMPONENT_TYPES =
new Set(['street_number', 'administrative_area_level_1', 'postal_code']);
const ADDRESS_COMPONENT_TYPES_IN_FORM = [
'location',
'locality',
'administrative_area_level_1',
'postal_code',
'country',
];
function getFormInputElement(componentType) {
return document.getElementById(`${componentType}-input`);
}
function fillInAddress(place) {
function getComponentName(componentType) {
for (const component of place.address_components || []) {
if (component.types[0] === componentType) {
return SHORT_NAME_ADDRESS_COMPONENT_TYPES.has(componentType) ?
component.short_name :
component.long_name;
}
}
return '';
}
function getComponentText(componentType) {
return (componentType === 'location') ?
`${getComponentName('street_number')} ${getComponentName('route')}` :
getComponentName(componentType);
}
for (const componentType of ADDRESS_COMPONENT_TYPES_IN_FORM) {
getFormInputElement(componentType).value = getComponentText(componentType);
}
}
function renderAddress(place) {
const mapEl = document.querySelector('gmp-map');
const markerEl = document.querySelector('gmp-advanced-marker');
if (place.geometry && place.geometry.location) {
mapEl.center = place.geometry.location;
markerEl.position = place.geometry.location;
} else {
markerEl.position = null;
}
}
async function initMap() {
const {Autocomplete} = await APILoader.importLibrary('places');
const autocomplete = new Autocomplete(getFormInputElement('location'), {
fields: ['address_components', 'geometry', 'name'],
types: ['address'],
});
autocomplete.addListener('place_changed', () => {
const place = autocomplete.getPlace();
if (!place.geometry) {
// User entered the name of a Place that was not suggested and
// pressed the Enter key, or the Place Details request failed.
window.alert(`No details available for input: '${place.name}'`);
return;
}
renderAddress(place);
fillInAddress(place);
});
}
initMap();
</script>
</head>
<body>
<gmpx-api-loader key="YOUR_API_KEY_HERE" solution-channel="GMP_QB_addressselection_v3_cABC">
</gmpx-api-loader>
<gmpx-split-layout row-layout-min-width="600">
<div class="panel" slot="fixed">
<div>
<img class="sb-title-icon" src="https://fonts.gstatic.com/s/i/googlematerialicons/location_pin/v5/24px.svg" alt="">
<span class="sb-title">Address Selection</span>
</div>
<input type="text" placeholder="Address" id="location-input"/>
<input type="text" placeholder="Apt, Suite, etc (optional)"/>
<input type="text" placeholder="City" id="locality-input"/>
<div class="half-input-container">
<input type="text" class="half-input" placeholder="State/Province" id="administrative_area_level_1-input"/>
<input type="text" class="half-input" placeholder="Zip/Postal code" id="postal_code-input"/>
</div>
<input type="text" placeholder="Country" id="country-input"/>
<gmpx-icon-button variant="filled">Checkout</gmpx-icon-button>
</div>
<gmp-map slot="main">
<gmp-advanced-marker></gmp-advanced-marker>
</gmp-map>
</gmpx-split-layout>
</body>
</html>
*/