Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: clintharrison/doi-bookmarklet
base: 7e80e52e76
...
head fork: clintharrison/doi-bookmarklet
compare: aef1dd43c0
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Showing with 69 additions and 14 deletions.
  1. +1 −0  .gitignore
  2. +40 −13 index.html
  3. +28 −1 stylesheets/styles.css
View
1  .gitignore
@@ -0,0 +1 @@
+.DS_Store
View
53 index.html
@@ -21,27 +21,34 @@
<p></p>
<p class="view"><a href="https://github.com/Clinteger/doi-bookmarklet">View the Project on GitHub <small>Clinteger/doi-bookmarklet</small></a></p>
<ul>
- <li><a href="https://github.com/Clinteger/doi-bookmarklet/zipball/master">Download <strong>ZIP File</strong></a></li>
- <li><a href="https://github.com/Clinteger/doi-bookmarklet/tarball/master">Download <strong>TAR Ball</strong></a></li>
- <li><a href="https://github.com/Clinteger/doi-bookmarklet">View On <strong>GitHub</strong></a></li>
+ <li class="single"><a href="https://github.com/Clinteger/doi-bookmarklet">View On <strong>GitHub</strong></a></li>
</ul>
</header>
<section>
<h2>About</h2>
-<p>The DOI Bookmarklet provides access to access-restricted documents by redirecting through a ProQuest EZproxy as used by many university libraries.</p>
+<p>The DOI Bookmarklet opens access-restricted documents (like scientific journals) by redirecting through a ProQuest EZproxy as used by many university libraries.</p>
<h2>Installation</h2>
-<p>Enter your ProQuest EZproxy URL:
-</p>
+<p>Enter your ProQuest EZproxy URL:<input type="url" id="proxy-url-input" placeholder="http://proxy.lib.umich.edu"></input></p>
-<p>Bookmark the following link:
-<a href="">DOI Bookmarklet</a></p>
+<p>Bookmark the following link: <a href="" id="doi-bookmarklet">DOI Bookmarklet</a></p>
-<p>The bookmarklet consists of the following generated and minified JavaScript:</p>
-
-<div class="highlight"><pre><span class="p">(</span><span class="kd">function</span><span class="p">(){</span><span class="kd">var</span> <span class="nx">a</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">getSelection</span><span class="o">?</span><span class="nb">document</span><span class="p">.</span><span class="nx">getSelection</span><span class="p">().</span><span class="nx">toString</span><span class="p">()</span><span class="o">:</span><span class="nb">document</span><span class="p">.</span><span class="nx">selection</span><span class="p">.</span><span class="nx">createRange</span><span class="p">().</span><span class="nx">text</span><span class="p">,</span><span class="nx">a</span><span class="o">=</span><span class="sr">/\w?(?:doi:|hdl:(?:\/\/)?)\s*([0-9./a-z]+)\w?/i</span><span class="p">.</span><span class="nx">exec</span><span class="p">(</span><span class="nx">a</span><span class="p">);</span><span class="k">if</span><span class="p">(</span><span class="kc">null</span><span class="o">!=</span><span class="nx">a</span><span class="p">){</span><span class="kd">var</span> <span class="nx">a</span><span class="o">=</span><span class="nx">a</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span><span class="nx">b</span><span class="o">=</span><span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s2">"a"</span><span class="p">);</span><span class="nx">b</span><span class="p">.</span><span class="nx">href</span><span class="o">=</span><span class="s2">""</span><span class="p">;</span><span class="nx">console</span><span class="p">.</span><span class="nx">log</span><span class="p">(</span><span class="nx">b</span><span class="p">.</span><span class="nx">protocol</span><span class="o">+</span><span class="s2">"//dx.doi.org."</span><span class="o">+</span><span class="nx">b</span><span class="p">.</span><span class="nx">host</span><span class="o">+</span><span class="s2">"/"</span><span class="o">+</span><span class="nx">a</span><span class="p">)}})();</span>
+<p>The bookmarklet consists of the following JavaScript minified:</p>
+
+<div class="highlight"><pre><span class="p">(</span><span class="kd">function</span><span class="p">()</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">proxyUrl</span> <span class="o">=</span> <span class="s2">&quot;<span id="proxy-url-preview">http://proxy.lib.umich.edu</span>&quot;</span><span class="p">;</span>
+ <span class="kd">var</span> <span class="nx">selection</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getSelection</span> <span class="o">?</span> <span class="nb">document</span><span class="p">.</span><span class="nx">getSelection</span><span class="p">().</span><span class="nx">toString</span><span class="p">()</span> <span class="o">:</span> <span class="nb">document</span><span class="p">.</span><span class="nx">selection</span><span class="p">.</span><span class="nx">createRange</span><span class="p">().</span><span class="nx">text</span><span class="p">;</span>
+ <span class="kd">var</span> <span class="nx">regex</span> <span class="o">=</span> <span class="sr">/\w?(?:doi:|hdl:(?:\/\/)?)\s*([0-9./a-z]+)\w?/i</span><span class="p">;</span>
+ <span class="kd">var</span> <span class="nx">match</span> <span class="o">=</span> <span class="nx">regex</span><span class="p">.</span><span class="nx">exec</span><span class="p">(</span><span class="nx">selection</span><span class="p">);</span>
+ <span class="k">if</span> <span class="p">(</span><span class="nx">match</span> <span class="o">!=</span> <span class="kc">null</span><span class="p">)</span> <span class="p">{</span>
+ <span class="kd">var</span> <span class="nx">doi</span> <span class="o">=</span> <span class="nx">match</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
+ <span class="kd">var</span> <span class="nx">tempAnchor</span> <span class="o">=</span> <span class="nb">document</span><span class="p">.</span><span class="nx">createElement</span><span class="p">(</span><span class="s1">'a'</span><span class="p">);</span>
+ <span class="nx">tempAnchor</span><span class="p">.</span><span class="nx">href</span> <span class="o">=</span> <span class="nx">proxyUrl</span><span class="p">;</span>
+ <span class="nb">document</span><span class="p">.</span><span class="nx">location</span> <span class="o">=</span> <span class="nx">tempAnchor</span><span class="p">.</span><span class="nx">protocol</span> <span class="o">+</span> <span class="s1">'//dx.doi.org.'</span> <span class="o">+</span> <span class="nx">tempAnchor</span><span class="p">.</span><span class="nx">host</span> <span class="o">+</span> <span class="s1">'/'</span> <span class="o">+</span> <span class="nx">doi</span><span class="p">;</span>
+ <span class="p">}</span>
+<span class="p">})();</span>
</pre></div>
<h2>How it works</h2>
@@ -60,6 +67,26 @@
<p>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></p>
</footer>
<!--[if !IE]><script>fixScale(document);</script><!--<![endif]-->
-
+ <script>
+(function() {
+ var buildAnchorHref = function(elAnchor, strProxyUrl) {
+ elAnchor.href = 'javascript:(function(){var a=document.getSelection?document.getSelection().toString():document.selection.createRange().text,a=/\\w?(?:doi:|hdl:(?:\\/\\/)?)\\s*([0-9./a-z]+)\\w?/i.exec(a);if(null!=a){var a=a[1],b=document.createElement("a");b.href="' + strProxyUrl + '";document.location=b.protocol+"//dx.doi.org."+b.host+"/"+a}})();';
+ }
+ var inputProxyUrl = document.getElementById("proxy-url-input");
+ var spanProxyUrlPreview = document.getElementById("proxy-url-preview");
+ var anchorBookmarklet = document.getElementById("doi-bookmarklet");
+ var updateLinkAndPreview = function() {
+ // trim whitespace from input value
+ var proxyUrl = inputProxyUrl.value.replace(/^\s*([\S\s]*)\b\s*$/, '$1');
+ if (proxyUrl.match(/https?:\/\/.*/i) == null) {
+ proxyUrl = "http://" + proxyUrl;
+ }
+ buildAnchorHref(anchorBookmarklet, proxyUrl);
+ console.log(spanProxyUrlPreview);
+ spanProxyUrlPreview.innerText = proxyUrl;
+ }
+ inputProxyUrl.onkeyup = inputProxyUrl.onblur = updateLinkAndPreview;
+})();
+ </script>
</body>
-</html>
+</html>
View
29 stylesheets/styles.css
@@ -134,7 +134,7 @@ header ul:before {
-ms-border-radius: 8px;
-o-border-radius: 8px;
border-radius: 8px;
- -webkit-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0, inset rgba(255, 255, 255, 0.7) 0 -1px 0;
+ -webkit-box-shadow: rgb5a(0, 0, 0, 0.2) 0 -1px 0, inset rgba(255, 255, 255, 0.7) 0 -1px 0;
-moz-box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0, inset rgba(255, 255, 255, 0.7) 0 -1px 0;
box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 0, inset rgba(255, 255, 255, 0.7) 0 -1px 0;
}
@@ -273,6 +273,33 @@ th {
color: #222;
}
+input#proxy-url-input {
+ font-size: 14px;
+ line-height: 1.5em;
+ margin-left: 4px;
+ width: 250px;
+}
+
+a#doi-bookmarklet {
+ background: #5198DF; /* rgb(81, 152, 223) */
+ background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(0%, #77b9fb), color-stop(100%, #3782cd));
+ background: -webkit-linear-gradient(#77b9fb, #3782cd);
+ background: -moz-linear-gradient(#77b9fb, #3782cd);
+ background: -o-linear-gradient(#77b9fb, #3782cd);
+ background: -ms-linear-gradient(#77b9fb, #3782cd);
+ background: linear-gradient(#77b9fb, #3782cd);
+ border-radius: 5px;
+ -webkit-box-shadow: inset rgba(255, 255, 255, 0.45) 0 1px 0, inset rgba(0, 0, 0, 0.2) 0 -1px 0;
+ -moz-box-shadow: inset rgba(255, 255, 255, 0.45) 0 1px 0, inset rgba(0, 0, 0, 0.2) 0 -1px 0;
+ box-shadow: inset rgba(255, 255, 255, 0.45) 0 1px 0, inset rgba(0, 0, 0, 0.2) 0 -1px 0;
+ color: #f6faff;
+ margin-left: 4px;
+ padding: 5px 8px;
+ text-shadow: rgba(0, 0, 0, 0.4) 0 -1px 0;
+ font-weight: 700;
+ -webkit-font-smoothing: antialiased;
+}
+
small {
font-size: 11px;
}

No commit comments for this range

Something went wrong with that request. Please try again.