<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>UX Archives - rweber.net</title>
	<atom:link href="https://www.rweber.net/tag/ux/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.rweber.net/tag/ux/</link>
	<description>trying to be a mile wide AND a mile deep</description>
	<lastBuildDate>Sun, 01 Jul 2018 11:22:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
<site xmlns="com-wordpress:feed-additions:1">37896774</site>	<item>
		<title>Bookmarkable Ajax-Driven Pages</title>
		<link>https://www.rweber.net/javascript/bookmarkable-ajax-driven-pages/</link>
					<comments>https://www.rweber.net/javascript/bookmarkable-ajax-driven-pages/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 09 Jul 2018 12:00:56 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[UX]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=40496</guid>

					<description><![CDATA[<div><img width="212" height="300" src="https://www.rweber.net/wp-content/uploads/2018/07/Kate-Greenaway-illustrations-212x300.jpg" class="attachment-medium size-medium wp-post-image" alt="Kate Greenaway illustrations as bookmarks via Emmie_Norfolk on Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" fetchpriority="high" srcset="https://www.rweber.net/wp-content/uploads/2018/07/Kate-Greenaway-illustrations-212x300.jpg 212w, https://www.rweber.net/wp-content/uploads/2018/07/Kate-Greenaway-illustrations-106x150.jpg 106w, https://www.rweber.net/wp-content/uploads/2018/07/Kate-Greenaway-illustrations.jpg 452w" sizes="(max-width: 212px) 100vw, 212px" /></div>
<p>Generic get/set functions for query string parameters that keep default values out of the URL and respect the existence of extra parameters.</p>
<p>The post <a href="https://www.rweber.net/javascript/bookmarkable-ajax-driven-pages/">Bookmarkable Ajax-Driven Pages</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="212" height="300" src="https://www.rweber.net/wp-content/uploads/2018/07/Kate-Greenaway-illustrations-212x300.jpg" class="attachment-medium size-medium wp-post-image" alt="Kate Greenaway illustrations as bookmarks via Emmie_Norfolk on Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" srcset="https://www.rweber.net/wp-content/uploads/2018/07/Kate-Greenaway-illustrations-212x300.jpg 212w, https://www.rweber.net/wp-content/uploads/2018/07/Kate-Greenaway-illustrations-106x150.jpg 106w, https://www.rweber.net/wp-content/uploads/2018/07/Kate-Greenaway-illustrations.jpg 452w" sizes="(max-width: 212px) 100vw, 212px" /></div><p>If someone might reasonably expect to bookmark or link others to content, I like that to be possible. With ajax-updated pages it doesn&#8217;t come for free, though. The newest addition to the <a href="https://github.com/ReveWeber/utilities">Utilities repository</a> is a little bit of get/set code for query strings to support bookmarkability.</p>
<p>The code consists of two functions, <code>parseQuery</code> and <code>updateQuery</code>. They should live inside a scope (perhaps a <a href="http://markdalgleish.com/2011/03/self-executing-anonymous-functions/">self-executing anonymous function</a>) with variables holding the default and current values of the parameters that determine the content of the page.</p>
<pre>
var default1 = "default1";
var param1;
</pre>
<p>Parsing queries is straightforward and can be done in multiple ways. This version uses a regular expression to grab everything between the parameter name with equals sign, and the next ampersand if any, provided that&#8217;s at least one character long.</p>
<pre>
function parseQuery() {
  var queryString = window.location.search.substr(1);
  // set all parameters to their default values
  param1 = default1;
  if (queryString.length > 0) {
    // if there's a query string, check for each param within it
    var val1 = queryString.match(/.*param1=([^&]+).*/i);
    if (val1) {
        param1 = val1[1];
    }
  }
}
</pre>
<p>To handle multiple parameters you&#8217;d repeat the blocks right after the comments: set all variables to the default, and then do a match and a length check for each of them within the single &#8220;if there&#8217;s a query string&#8221; check.</p>
<p>You can also split the query string into an array, but it&#8217;s a little more difficult to deal with exceptional cases like parameter names that lack values.</p>
<p>Updating the query is more complicated. I wanted my query string to consist of parameters with non-default values only, plus any parameters that don&#8217;t belong to this code. My original version simply rewrote the whole query string to consist exactly of all the parameters &#8211; default or not &#8211; and would not permit other parameters to persist, such as those that you might use to track (or deactivate) A/B tests. The reason to keep default parameters out of the query string was that one of those had a default value dependent on the date; if you bookmarked the &#8220;now&#8221; version of the page I wanted it to still be &#8220;now&#8221; when you came back a month later.</p>
<p>The answer was once again regular expressions (when is it not?).</p>
<pre>
function updateQuery() {
  var newUrl = window.location.href;
  // clean out valueless parameters to simplify ensuing matching
  newUrl = newUrl.replace(/(.*[?&])param1(&(.*))?$/, "$1$3");
  if (param1 !== default1) {
    if (newUrl.match(/[?&]param1=/)) {
      newUrl = newUrl.replace(/(.*[?&]param1=)[^&]*(.*)/, 
      '$1' + param1 + '$2');
    } else if (newUrl.indexOf('?') > 0) {
      newUrl = newUrl + '&amp;param1=' + param1;
    } else {
      newUrl = newUrl + '?param1=' + param1;
    }
  } else {
    newUrl = newUrl.replace(/(.*[?&])param1=[^&]*&?(.*)/, '$1$2');
  }

  // tidy up
  if (newUrl.match(/[?&]$/)) {
    newUrl = newUrl.slice(0, -1);
  }    
  window.history.pushState('', '', newUrl);
}
</pre>
<p>For each parameter in turn, clean out any valueless instance of it (meaning &#8220;without an equals sign&#8221;, really; if the browser allows valueless <strong>with</strong> an equals sign is will be handled in the if statements). Then, if the parameter has a non-default value, replace its value or add it as a new parameter to the string. If it is the default, remove it from the string. That is, the whole section between the two comments would be repeated for each parameter. All of this business might leave a trailing question mark or ampersand, so clean that away if needed and push the new URL into the browser history.</p>
<p>There&#8217;s a sample webpage in the repo as well, in which you can try this out, though you&#8217;ll need to update the internal links on the page to match its location on your localhost.</p>
<hr>
<p><small>Kate Greenaway illustrations as bookmarks via <a href="https://pixabay.com/en/kate-greenaway-vintage-bookmark-1519992/">Emmie_Norfolk on Pixabay</a>.</small></p>
<p>The post <a href="https://www.rweber.net/javascript/bookmarkable-ajax-driven-pages/">Bookmarkable Ajax-Driven Pages</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/javascript/bookmarkable-ajax-driven-pages/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">40496</post-id>	</item>
		<item>
		<title>Improving Embedded Google Maps</title>
		<link>https://www.rweber.net/css/improving-embedded-google-maps/</link>
					<comments>https://www.rweber.net/css/improving-embedded-google-maps/#respond</comments>
		
		<dc:creator><![CDATA[Rebecca]]></dc:creator>
		<pubDate>Mon, 08 Aug 2016 12:00:17 +0000</pubDate>
				<category><![CDATA[CSS]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[cross-site interaction]]></category>
		<category><![CDATA[UX]]></category>
		<guid isPermaLink="false">http://www.rweber.net/?p=39944</guid>

					<description><![CDATA[<div><img width="300" height="227" src="https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-300x227.jpg" class="attachment-medium size-medium wp-post-image" alt="vintage map collage via ArtsyBee on Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" srcset="https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-300x227.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-150x113.jpg 150w, https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640.jpg 640w" sizes="(max-width: 300px) 100vw, 300px" /></div>
<p>A simple addition to an embedded Google map greatly enhances the user-friendliness: a transparent overlay that disappears with a click.</p>
<p>The post <a href="https://www.rweber.net/css/improving-embedded-google-maps/">Improving Embedded Google Maps</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></description>
										<content:encoded><![CDATA[<div><img width="300" height="227" src="https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-300x227.jpg" class="attachment-medium size-medium wp-post-image" alt="vintage map collage via ArtsyBee on Pixabay" style="float:left; margin-right:16px; margin-bottom:16px;" decoding="async" loading="lazy" srcset="https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-300x227.jpg 300w, https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640-150x113.jpg 150w, https://www.rweber.net/wp-content/uploads/2016/08/vintage-917561_640.jpg 640w" sizes="auto, (max-width: 300px) 100vw, 300px" /></div><p>If you embed a Google map into your page via Google&#8217;s embed code, you can set a location marker and a zoom level (on the Google Maps side, before you click the &#8220;share&#8221; button), but other tweaks are reserved for users with API accounts. I was recently in a situation where we simply wanted to disable scroll-to-zoom, because it is super annoying &#8211; especially on mobile.</p>
<p>Somewhere online I found the idea to cover the map with a transparent div (you can see through it, but you can&#8217;t click through it or &#8220;scroll through&#8221; it) and add a line of JavaScript to remove that div if it is clicked on. It seemed hacky to me at first but the more I thought about it the more I liked it. We decided to use it and not even to worry about putting a &#8220;click to interact&#8221;-type note. If someone clicks once without effect they are going to click again, and then what they wanted to do will work.</p>
<style>
.iframe-wrapper {
max-width: 600px;
margin: 24px auto;
}
.iframe-sizer {
position: relative;
width: 100%;
height: 0;
padding-bottom: 75%;
}
.responsive-iframe, .iframe-shield {
position: absolute;
height: 100%;
width: 100%;
top: 0;
left: 0;
}
</style>
<div class="iframe-wrapper">
<div class="iframe-sizer">
<iframe src="https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d8169323.504260123!2d177.63283954121277!3d-1.2107823671053861!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x7aa74442cdcc4813%3A0x1ca1ca257cc16b66!2sBaker+Island!5e0!3m2!1sen!2sus!4v1470480524869" frameborder="0" style="border:0" allowfullscreen class="responsive-iframe"></iframe></p>
<div class="iframe-shield" id="iframe-shield"></div>
</div>
</div>
<p><script>
document.getElementById("iframe-shield").addEventListener("click", function() {
    this.setAttribute("style", "height:0;");
});
</script></p>
<p>If you are setting up your maps in a <a href="https://www.rweber.net/web-development/css/responsive-iframes/">responsive iframe wrapper</a>, the setup is very simple. Just tuck a second div in after the iframe (second so it will be on top), give it the same styling as the iframe, and add a line of JavaScript in the footer of your page.</p>
<p>Here&#8217;s the code for the embedded map above (<a href="http://pastebin.com/JApYCHTX">view on pastebin</a>):</p>
<p><script src="//pastebin.com/embed_js/JApYCHTX"></script></p>
<p>The post <a href="https://www.rweber.net/css/improving-embedded-google-maps/">Improving Embedded Google Maps</a> appeared first on <a href="https://www.rweber.net">rweber.net</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.rweber.net/css/improving-embedded-google-maps/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">39944</post-id>	</item>
	</channel>
</rss>
