Commits

Nick Freear committed ba37678

Adding an initial version of a Track OER bookmarklet..

* toer-bookmarklet.js Javascript,
* bookmarklet.php site_layout view

  • Participants
  • Parent commits 0cdd25d

Comments (0)

Files changed (2)

File application/assets/public/js/toer-bookmarklet.js

+/*!
+ Track OER bookmarklet.
+ (c)2012-09-11 The Open University.
+*/
+/*jslint browser: true, devel: true, indent: 4 */
+
+(function () {
+
+	var params = 'edge=1',
+		PWL = parent.window.location,
+		D = document,
+		//DL = d.location,
+		enc = encodeURIComponent;
+	if (typeof D.trackoer_srvurl == 'undefined') {
+		alert("Error!");
+	}
+	else if (PWL.host.match(/(labspace.*?\.open.ac.uk|openlearn.*?\.open.ac.uk|oercommons\.org)/)) {
+		PWL.href = D.trackoer_srvurl + 'oerform?' + params + '&url=' + enc(PWL.href);
+	} else {
+		alert(
+			"Sorry, '"
+			+ PWL.host + 
+			"' is not supported by Track OER.\n\n The license-tracker service currently supports:\nOpenlearn.open.ac.uk, Labspace.open.ac.uk and OERCommons.org"
+		);
+	}
+
+})();

File application/views/site_layout/bookmarklet.php

+<?php if ($this->input->get('edge')): ?>
+
+<?php
+	$base_url = base_url();
+?>
+<span id="bookmarklet" title="Drag the bookmarklet link to your bookmarks toolbar">Bookmarklet: <a href=
+"javascript:(function(){var d=document,s=d.createElement('script');s.type='text/javascript';s.src='<?php
+echo $base_url ?>public/js/toer-bookmarklet.js?x='+(Math.random());d.getElementsByTagName('head')[0].appendChild(s);d.trackoer_srvurl='<?php
+echo $base_url ?>'})();"
+	>Track OER</a></span>
+
+<?php endif; ?>