exports.run = function() {
const queryString = window.location.search;
try {
const urlParams = new URLSearchParams(queryString);
const wikicontext = urlParams.get('context');
var output = wikicontext;
if ( (output !== "OffGridding") && (output !== "HydroCutting") && (output !== "Chromebook") ){
output = "ProductReviews";
};
document.title = output;
}
catch(err) {
output = "ProductReviews";
}
return output;
Mark, you had me a "solar cooker". To me, there is nothing that is more environmentally friendly than building a solar cooker, and nothing more sustainable than using the energy of the sun. Well, in summertime, to avoid generating heat inside the house. I had thought of buying something pre-frabricated, but what I've found is so frigging expensive. So I must find the time and quickly build one next summer.I've been so focused on winter time heating, and just recently really focused on the notion of "heating oneself instead of heating the entire room."
Well, not so much that I want to support Internet Explorer. That thing cannot go the way of the dodo quick enough for my liking.And trying to support all the browsers in the wild is much too great of a pain in the caboose for my liking. I see no joy in that.I much prefer the approach: I've got this thing working on my computer and browser; now, how do I go about simply making sure that if this doesn't work for somebody out there, that it just gracefully does nothing at all versus generate some nasty javascript error.
Honestly, though: as much as I loath javascript, I'm not quite sure I'm loving the "look" of the wikitext (purely subjective, just how my old sponge works.)
exports.run = function() {
/* Settings */
const contexts = [
"ProductReviews",
"OffGridding",
"HydroCutting",
"Chromebook",
];
const defaultContext = "ProductReviews";
const ctxre = /context=(\w+)/i;
let currentContext = defaultContext;
const queryString = window.location.search;
const match = queryString.match(ctxre);
if(match){
let tmpContext = match[1];
for(let i = 0; i < contexts.length; i++){
if(contexts[i] == tmpContext){
currentContext = tmpContext;
break;
}
}
}
document.title = currentContext;
return currentContext;
};
So, yes, javascript is easier to understand . But it's also a bit fragile and you have to deal with browser idiosyncracies.
Charlie,Looks like javascript is your hammer. To people who have a hammer everything looks like a nail.
As mark said "wikitext/macros" are most likely easy. Just ask for what you want to achieve and we can help. I am not keen to try and reverse engineer your Javascript code (I am not fluent in) before I provide a tiddlywiki solution.
plural noun: predilections
a preference or special liking for something; a bias in favour of something.
"my predilection for Asian food"