diff --git a/css/main/layouts/mobile.css b/css/main/layouts/mobile.css index eb822eb..8ae3a9b 100644 --- a/css/main/layouts/mobile.css +++ b/css/main/layouts/mobile.css @@ -81,15 +81,24 @@ align-content: center;} .webrings .auto-scroll { + height: 65%; + width: fit-content; flex-direction: row; animation-name: scroll-webring-mobile;} .webrings .scroll_one, .webrings .scroll_two { + gap: 2em; flex-direction: row;} + .webrings .scroll_one > div , .webrings .scroll_two > div { + flex-shrink: 0; + height: 100%; + width: fit-content; + } + .webrings .auto-scroll > * > div img { - height: 60px; - width: auto;} + height: 100%; + width: auto;} .scroll_below-clip-box { position: absolute; @@ -127,6 +136,10 @@ from {transform: translateX(calc(-50%));} to {transform: translateX(0%);}} + .webrings .auto-scroll { + animation-duration: 25s; + } + /* Vertical scroll text */ .verticalscroll .auto-scroll { animation-name: scroll-vertical; diff --git a/img/webrings/transfem_cloud_button.png b/img/webrings/transfem_cloud_button.png new file mode 100644 index 0000000..caf2d42 Binary files /dev/null and b/img/webrings/transfem_cloud_button.png differ diff --git a/img/webrings/transfem_cloud_left_arrow.png b/img/webrings/transfem_cloud_left_arrow.png new file mode 100644 index 0000000..77da797 Binary files /dev/null and b/img/webrings/transfem_cloud_left_arrow.png differ diff --git a/img/webrings/transfem_cloud_right_arrow.png b/img/webrings/transfem_cloud_right_arrow.png new file mode 100644 index 0000000..edbb606 Binary files /dev/null and b/img/webrings/transfem_cloud_right_arrow.png differ diff --git a/img/webrings/transfem_enby_button.png b/img/webrings/transfem_enby_button.png new file mode 100644 index 0000000..b4aa6df Binary files /dev/null and b/img/webrings/transfem_enby_button.png differ diff --git a/img/webrings/transfem_enby_left_arrow.png b/img/webrings/transfem_enby_left_arrow.png new file mode 100644 index 0000000..0fa3a45 Binary files /dev/null and b/img/webrings/transfem_enby_left_arrow.png differ diff --git a/img/webrings/transfem_enby_right_arrow.png b/img/webrings/transfem_enby_right_arrow.png new file mode 100644 index 0000000..782fa16 Binary files /dev/null and b/img/webrings/transfem_enby_right_arrow.png differ diff --git a/img/webrings/transfem_trans_button.png b/img/webrings/transfem_trans_button.png new file mode 100644 index 0000000..cc38b3b Binary files /dev/null and b/img/webrings/transfem_trans_button.png differ diff --git a/img/webrings/transfem_trans_left_arrow.png b/img/webrings/transfem_trans_left_arrow.png new file mode 100644 index 0000000..6aa6bf1 Binary files /dev/null and b/img/webrings/transfem_trans_left_arrow.png differ diff --git a/img/webrings/transfem_trans_right_arrow.png b/img/webrings/transfem_trans_right_arrow.png new file mode 100644 index 0000000..cd06925 Binary files /dev/null and b/img/webrings/transfem_trans_right_arrow.png differ diff --git a/includes/common_webrings.inc.php b/includes/common_webrings.inc.php new file mode 100644 index 0000000..b8ea5cc --- /dev/null +++ b/includes/common_webrings.inc.php @@ -0,0 +1,40 @@ + 1, - "sources" => - [["url" => "https://fem.nz/ring/transfemring.js", - "source" => "internet"], - ["url" => "includes/transfemring.js", - "source" => "local"]] - ]; - -$VALID_WIDGET_TYPES = ["transgender", "nonbinary"]; - -$widget_type = $VALID_WIDGET_TYPES[1]; -$id = 8; - - -/* Implement fallback if scraping doesn't work */ - -function scrapeSitesFromSource(array $source) { - - function getSiteArray(array $source) { - function getFile(array $source){ - - $selected_source = $source["sources"][$source["selected_source"]]; - - if ($selected_source["source"] === "local") { - $file = file_get_contents($selected_source["url"]); - } else { - $curl = curl_init($selected_source["url"]); - curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); - - $file = curl_exec($curl); - if ($file === false) { - echo "Error: " . curl_error($curl); - exit; - } - - curl_close($curl); - } - return $file; - } - - function extractSites(string $script) { - $start_pos = strpos($script,"sites: [") + 8; // needle has 9 characters - $end_pos = strpos($script, "]", $start_pos); - - $sites = substr($script, $start_pos, $end_pos - $start_pos); - - return $sites; - } - - return extractSites(getFile($source)); - } - - function primarySplit(string $array) { - $i = 0; - while (strlen($array) !== 0) { - // Strip coma if found - if (str_starts_with($array,',')) { - $array = substr($array,1); - } - - // Get substring position and length - $start_pos = 1; - $end_pos = strpos($array,"}",1); - $item_len = $end_pos - $start_pos; - - // Save website into array, and strip array - $return_array[$i] = substr($array,$start_pos,$item_len); - $array = substr($array,$item_len+2); // +2 from { and } - - $i++; - } - return $return_array; - } - - function secondarySplit(string $sub_array) { - while (strlen($sub_array) !== 0){ - if (str_starts_with($sub_array,',')) { - $sub_array = substr($sub_array,1); - } - - $key_start_pos = 1; - $key_end_pos = strpos($sub_array,"\"",1); - $key_len = $key_end_pos - $key_start_pos; - $key = substr($sub_array,$key_start_pos,$key_len); - - $value_start_pos = $key_len + 3; // +3 from " , " and : - // Check if key is quoted - if (strpos($sub_array,"\"",$value_start_pos) != $value_start_pos) { - $keyhasQuotes = FALSE; - $value_end_pos = strpos($sub_array,","); - } else { - $value_start_pos++; // +1 from " - $value_end_pos = strpos($sub_array,"\"",$value_start_pos); - $keyhasQuotes = TRUE; - } - $value_len = $value_end_pos - $value_start_pos; - $value = substr($sub_array,$value_start_pos,$value_len); - - $return_sub_array[$key] = $value; - - $sub_sub_array_len = $key_len + $value_len + 3; // +3 from " , " and : - if ($keyhasQuotes) { - $sub_sub_array_len = $sub_sub_array_len + 2; // +2 from " and " - } - - $sub_array = substr($sub_array,$sub_sub_array_len); - } - return $return_sub_array; - } - - $websites = primarySplit(getSiteArray($source)); - - for ($i = 0; $i < sizeof($websites); $i++) { - $return_websites[$i] = secondarySplit($websites[$i]); - } - - return $return_websites; - -} - -$transfermring_sites = scrapeSitesFromSource($JS_SCRIPT_URL); - - -$root = "https://fem.nz"; - -// Add checks if id is at the start - -for ($i = 0; $i < count($transfermring_sites); $i++){ - if ($transfermring_sites[$i]["id"] == $id){ - $prev = $transfermring_sites[($i-1)]["site_link"]; - $current = $transfermring_sites[($i)]["site_link"]; - $next = $transfermring_sites[($i+1)]["site_link"]; - } -} - -$prev = 'https://' . $prev; -$current = 'https://' . $current; -$next = 'https://' . $next; - -$file = [ +// File sources, images & scripts +$TRANSFEMRING_FILES = [ "nonbinary" => [ "arrow_path" => "../../../img/webrings/transfem_enby_arrow.png", "banner_path" => "../../../img/webrings/transfem_enby_banner.png" @@ -153,3 +13,100 @@ $file = [ "banner_path" => "../../../img/webrings/transfem_trans_banner.png" ] ]; + +$TRANSFEMRING_SCRIPT_SOURCE = [ + "selected_source" => 1, + "sources" => + [["url" => "https://fem.nz/ring/transfemring.js", + "source" => "internet"], + ["url" => "/transfemwebring.js", + "source" => "local"]] + ]; + +// Specific variables for script +$TRANSFEMRING_ROOT = "https://fem.nz"; +$TRANSFEMRING_VALID_WIDGET_TYPES = ["transgender", "nonbinary"]; + +// Personal identifiers/choices +$TRANSFEMRING_WIDGET_TYPE = $TRANSFEMRING_VALID_WIDGET_TYPES[1]; +$TRANSFEMRING_ID = 8; + +// Functions +function primarySplit(string $array) { + $i = 0; + while (strlen($array) !== 0) { + // Strip coma if found + if (str_starts_with($array,',')) { + $array = substr($array,1); + } + + // Get substring position and length + $start_pos = 1; + $end_pos = strpos($array,"}",1); + $item_len = $end_pos - $start_pos; + + // Save website into array, and strip array + $return_array[$i] = substr($array,$start_pos,$item_len); + $array = substr($array,$item_len+2); // +2 from { and } + + $i++; + } + return $return_array; +} + +function secondarySplit(string $sub_array) { + while (strlen($sub_array) !== 0){ + if (str_starts_with($sub_array,',')) { + $sub_array = substr($sub_array,1); + } + + $key_start_pos = 1; + $key_end_pos = strpos($sub_array,"\"",1); + $key_len = $key_end_pos - $key_start_pos; + $key = substr($sub_array,$key_start_pos,$key_len); + + $value_start_pos = $key_len + 3; // +3 from " , " and : + // Check if key is quoted + if (strpos($sub_array,"\"",$value_start_pos) != $value_start_pos) { + $keyhasQuotes = FALSE; + $value_end_pos = strpos($sub_array,","); + } else { + $value_start_pos++; // +1 from " + $value_end_pos = strpos($sub_array,"\"",$value_start_pos); + $keyhasQuotes = TRUE; + } + $value_len = $value_end_pos - $value_start_pos; + $value = substr($sub_array,$value_start_pos,$value_len); + + $return_sub_array[$key] = $value; + + $sub_sub_array_len = $key_len + $value_len + 3; // +3 from " , " and : + if ($keyhasQuotes) { + $sub_sub_array_len = $sub_sub_array_len + 2; // +2 from " and " + } + + $sub_array = substr($sub_array,$sub_sub_array_len); + } + return $return_sub_array; +} + +$transfemring_sites = scrapeWebsiteSites($TRANSFEMRING_SCRIPT_SOURCE,'sites: [',']'); +$transfemring_sites = primarySplit($transfemring_sites); +for ($i = 0; $i < sizeof($transfemring_sites); $i++) { + $depured_transfemring_sites[$i] = secondarySplit($transfemring_sites[$i]); +} +$transfemring_sites = $depured_transfemring_sites; + +for ($i = 1; $i < count($transfemring_sites); $i++){ + if ($transfemring_sites[$i]['id'] == $TRANSFEMRING_ID) { + + $transfem_prev = 'https://' . $transfemring_sites[($i-1)]["site_link"]; + $transfem_current = 'https://' . $transfemring_sites[($i)]["site_link"]; + $transfem_next = 'https://' . $transfemring_sites[($i+1)]["site_link"]; + $found = TRUE; + } +} + +if (!isset($found)) { + echo ("ERROR ID NOT FOUND"); +} \ No newline at end of file diff --git a/includes/transfemwebring_view.inc.php b/includes/transfemwebring_view.inc.php index 6b57112..9a3fde2 100644 --- a/includes/transfemwebring_view.inc.php +++ b/includes/transfemwebring_view.inc.php @@ -2,18 +2,18 @@ declare(strict_types=1); -function render(){ - global $prev, $root, $next, $file, $widget_type; +function FEMRINGrender(){ + global $TRANSFEMRING_ROOT, $TRANSFEMRING_FILES, $TRANSFEMRING_WIDGET_TYPE, $transfem_prev, $transfem_next; ?> -
+
+
+