11// scripts/ui-enhancements.js
22
3- // PATHWAYS mapping
3+ // Pathway to colors mapping
44const pathways = {
55 pain : [ 'gold' , 'orange' ] ,
66 practical : [ 'yellow' , 'green' ] ,
@@ -13,29 +13,45 @@ const pathways = {
1313 direct : [ 'red' , 'orange' ] ,
1414} ;
1515
16- const colorGNH = {
17- grey : 'Economic Wellness' ,
18- pink : 'Mental Wellness' ,
19- gold : 'Workplace Wellness' ,
20- nude : 'Physical Wellness' ,
21- orange : 'Social Wellness' ,
22- white : 'Political Wellness' ,
23- blue : 'Environmental Wellness' ,
24- green : 'Ecological Diversity' ,
25- red : 'Health' ,
26- black : 'Good Governance' ,
27- brown : 'Education Value' ,
28- yellow : 'Living Standards' ,
29- purple : 'Cultural Diversity'
30- } ;
16+ // Color details including matrice1, english-words, and GNH
17+ const colorData = [
18+ { color : 'grey' , matrice1 : 'Cover' , 'english-words' : 'respectful effective apposite precary' , gnh : 'Economic Wellness' } ,
19+ { color : 'pink' , matrice1 : 'Category' , 'english-words' : 'incredibly exquisite and ambitious' , gnh : 'Mental Wellness' } ,
20+ { color : 'gold' , matrice1 : 'Pull' , 'english-words' : 'undepartable preflorating technocracy lotiform' , gnh : 'Workplace Wellness' } ,
21+ { color : 'nude' , matrice1 : 'Approach' , 'english-words' : 'felicitously deft satisfied unextenuable' , gnh : 'Physical Wellness' } ,
22+ { color : 'orange' , matrice1 : 'Hit' , 'english-words' : 'blurry artesian awesome' , gnh : 'Social Wellness' } ,
23+ { color : 'white' , matrice1 : 'Hope' , 'english-words' : 'unlavish analeptical' , gnh : 'Political Wellness' } ,
24+ { color : 'blue' , matrice1 : 'Collect' , 'english-words' : 'daintily perfect, intelligent photopathy' , gnh : 'Environmental Wellness' } ,
25+ { color : 'green' , matrice1 : 'Transition' , 'english-words' : 'bulbous spontaneous heroic' , gnh : 'Ecological Diversity' } ,
26+ { color : 'red' , matrice1 : 'Limit' , 'english-words' : 'candid apophantic, distinct and radiant' , gnh : 'Health' } ,
27+ { color : 'black' , matrice1 : 'Order' , 'english-words' : 'undertreated paleoatavistic obeyable swabble' , gnh : 'Good Governance' } ,
28+ { color : 'brown' , matrice1 : 'Learn' , 'english-words' : 'abundantly notable and unique submissive' , gnh : 'Education Value' } ,
29+ { color : 'yellow' , matrice1 : 'Structure' , 'english-words' : 'exhilarating redressible authority plausible' , gnh : 'Living Standards' } ,
30+ { color : 'purple' , matrice1 : 'Free' , 'english-words' : 'perfectly great - imaginative, brave, gifted' , gnh : 'Cultural Diversity' }
31+ ] ;
32+
33+ // 1️⃣ Global mode variable: matrice1, english-words, gnh
34+ let currentMode = 'gnh' ;
35+
36+ // 2️⃣ Handle mode button clicks
37+ document . getElementById ( 'matrice1Btn' ) . addEventListener ( 'click' , ( ) => {
38+ currentMode = 'matrice1' ;
39+ rerenderWords ( ) ;
40+ } ) ;
41+ document . getElementById ( 'englishBtn' ) . addEventListener ( 'click' , ( ) => {
42+ currentMode = 'english-words' ;
43+ rerenderWords ( ) ;
44+ } ) ;
45+ // Optional: Add a GNH button if needed, otherwise default is GNH
3146
47+ // 3️⃣ Handle pathway selection
48+ document . getElementById ( 'pathway' ) . addEventListener ( 'change' , ( ) => {
49+ rerenderWords ( ) ;
50+ } ) ;
51+
52+ // 4️⃣ Populate dropdown on load
3253function populatePathwaysDropdown ( ) {
3354 const pathwaySelect = document . getElementById ( 'pathway' ) ;
34- if ( ! pathwaySelect ) {
35- console . error ( 'Pathway select element not found!' ) ;
36- return ;
37- }
38-
3955 Object . keys ( pathways ) . forEach ( path => {
4056 const option = document . createElement ( 'option' ) ;
4157 option . value = path ;
@@ -44,19 +60,34 @@ function populatePathwaysDropdown() {
4460 } ) ;
4561}
4662
47- function addTooltips ( ) {
48- const colorElements = document . querySelectorAll ( '#colorGrid input' ) ;
63+ // 5️⃣ Render words dynamically
64+ function rerenderWords ( ) {
65+ const selectedPathway = document . getElementById ( 'pathway' ) . value ;
66+ const colorGrid = document . getElementById ( 'colorGrid' ) ;
67+ colorGrid . innerHTML = '' ;
68+
69+ if ( ! selectedPathway ) return ;
70+
71+ const selectedColors = pathways [ selectedPathway ] ;
72+
73+ selectedColors . forEach ( colorName => {
74+ const colorInfo = colorData . find ( c => c . color === colorName ) ;
75+
76+ let word = '' ;
77+ if ( currentMode === 'matrice1' ) word = colorInfo . matrice1 ;
78+ else if ( currentMode === 'english-words' ) word = colorInfo [ 'english-words' ] ;
79+ else word = colorInfo . gnh ;
4980
50- colorElements . forEach ( input => {
51- const color = input . getAttribute ( 'data-color' ) ;
52- if ( color && colorGNH [ color ] ) {
53- input . title = `GNH Indicator: ${ colorGNH [ color ] } ` ;
54- }
81+ const wrapper = document . createElement ( 'div' ) ;
82+ wrapper . innerHTML = `
83+ <label class="block mb-1">${ colorName . toUpperCase ( ) } - <span class="text-gray-600">${ word } </span></label>
84+ <input type="text" data-color="${ colorName } " placeholder="Interpret here..." class="w-full p-2 border rounded" />
85+ ` ;
86+ colorGrid . appendChild ( wrapper ) ;
5587 } ) ;
5688}
5789
58- // Always wait for full page load!!
90+ // 6️⃣ Initialize after DOM ready
5991document . addEventListener ( 'DOMContentLoaded' , function ( ) {
6092 populatePathwaysDropdown ( ) ;
61- addTooltips ( ) ;
6293} ) ;
0 commit comments