From 28e713caac1582e30b9ab8f7364ac8a564f4ffd7 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Fri, 23 Mar 2018 09:13:45 +0000 Subject: [PATCH] Add screen width/height to platform information exposed at startup --- core/modules/info/platform.js | 5 ++++- editions/tw5.com/tiddlers/mechanisms/InfoMechanism.tid | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/core/modules/info/platform.js b/core/modules/info/platform.js index c30f5b83c..ce258daea 100644 --- a/core/modules/info/platform.js +++ b/core/modules/info/platform.js @@ -18,8 +18,8 @@ exports.getInfoTiddlerFields = function() { // Basics infoTiddlerFields.push({title: "$:/info/browser", text: mapBoolean(!!$tw.browser)}); infoTiddlerFields.push({title: "$:/info/node", text: mapBoolean(!!$tw.node)}); - // Document location if($tw.browser) { + // Document location var setLocationProperty = function(name,value) { infoTiddlerFields.push({title: "$:/info/url/" + name, text: value}); }, @@ -32,6 +32,9 @@ exports.getInfoTiddlerFields = function() { setLocationProperty("pathname", location.pathname); setLocationProperty("search", location.search); setLocationProperty("origin", location.origin); + // Screen size + infoTiddlerFields.push({title: "$:/info/browser/screen/width", text: window.screen.width.toString()}); + infoTiddlerFields.push({title: "$:/info/browser/screen/height", text: window.screen.height.toString()}); } return infoTiddlerFields; }; diff --git a/editions/tw5.com/tiddlers/mechanisms/InfoMechanism.tid b/editions/tw5.com/tiddlers/mechanisms/InfoMechanism.tid index 137819bf1..3187bea2f 100644 --- a/editions/tw5.com/tiddlers/mechanisms/InfoMechanism.tid +++ b/editions/tw5.com/tiddlers/mechanisms/InfoMechanism.tid @@ -14,6 +14,8 @@ System tiddlers in the namespace `$:/info/` are used to expose information about |!Title |!Description | |[[$:/info/browser]] |Running in the browser? ("yes" or "no") | +|[[$:/info/browser/screen/width]] |Screen width in pixels | +|[[$:/info/browser/screen/height]] |Screen height in pixels | |[[$:/info/node]] |Running under [[Node.js]]? ("yes" or "no") | |[[$:/info/url/full]] |<<.from-version "5.1.14">> Full URL of wiki (eg, ''<>'') | |[[$:/info/url/host]] |<<.from-version "5.1.14">> Host portion of URL of wiki (eg, ''<>'') |