From 329477c61fcfffb9aac61af55a0db3f1f0f0a8bb Mon Sep 17 00:00:00 2001 From: michael-n-cooper Date: Fri, 19 Jan 2018 16:45:45 -0500 Subject: [PATCH] Common files: utility.js and mapping-tables.js that works without respec --- common/script/mapping-tables.js | 22 +++++++++++++++++----- common/script/utility.js | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 common/script/utility.js diff --git a/common/script/mapping-tables.js b/common/script/mapping-tables.js index d508bf1166..495c7d9b79 100644 --- a/common/script/mapping-tables.js +++ b/common/script/mapping-tables.js @@ -1,6 +1,18 @@ -var respecEvents = respecEvents || false; +//check for require() and respec context +if (typeof require !== "undefined") { + /* globals $, require */ + require(["core/pubsubhub"], function(respecEvents) { + mapTables(respecEvents); + }); +} else { + $(document).ready(function() { + mapTables(false); + }); +} -(function() { +function mapTables(respecEvents) { + + "use strict"; var mappingTableInfos = []; @@ -82,7 +94,7 @@ var respecEvents = respecEvents || false; //remove the tr's @id since same id will be used in the relevant summary element $row.removeAttr('id'); //store the row's cells in array rowCells - rowCells = []; + var rowCells = []; //add row cells to array rowCells for use in the details' table $('td', $row).each(function() { rowCells.push($(this).html()); @@ -248,6 +260,6 @@ var respecEvents = respecEvents || false; }); }); } else { - $(document).ready(mappingTables); + mappingTables(); } -}()); +} diff --git a/common/script/utility.js b/common/script/utility.js new file mode 100644 index 0000000000..5384e24cf5 --- /dev/null +++ b/common/script/utility.js @@ -0,0 +1,15 @@ +/* Utility functions */ + +// Change the authors credit to mapping contributors credit +// Right now this will run on any author credit, not scoped to AAMs +require(["core/pubsubhub"], function(respecEvents) { + "use strict"; + respecEvents.sub('end', function(message) { + if (message === 'core/link-to-dfn') { + document.querySelectorAll("div.head dt").forEach(function(node){ + if (node.textContent == "Authors:") node.textContent = "Platform Mapping Maintainers:"; + }); + } + }) +}) +