2014-07-21 12:17:16 +00:00
|
|
|
/*\
|
|
|
|
title: $:/core/modules/info/platform.js
|
|
|
|
type: application/javascript
|
|
|
|
module-type: info
|
|
|
|
|
|
|
|
Initialise basic platform $:/info/ tiddlers
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
2020-11-24 19:01:33 +00:00
|
|
|
exports.getInfoTiddlerFields = function(updateInfoTiddlersCallback) {
|
2014-08-30 19:44:26 +00:00
|
|
|
var mapBoolean = function(value) {return value ? "yes" : "no";},
|
2014-07-21 12:17:16 +00:00
|
|
|
infoTiddlerFields = [];
|
|
|
|
// Basics
|
|
|
|
infoTiddlerFields.push({title: "$:/info/browser", text: mapBoolean(!!$tw.browser)});
|
2014-07-22 14:16:18 +00:00
|
|
|
infoTiddlerFields.push({title: "$:/info/node", text: mapBoolean(!!$tw.node)});
|
2020-05-06 10:05:54 +00:00
|
|
|
infoTiddlerFields.push({title: "$:/info/startup-timestamp", text: $tw.utils.stringifyDate(new Date())});
|
2016-10-18 08:12:55 +00:00
|
|
|
if($tw.browser) {
|
2018-03-23 09:13:45 +00:00
|
|
|
// Document location
|
2016-10-18 08:12:55 +00:00
|
|
|
var setLocationProperty = function(name,value) {
|
2021-05-30 18:20:17 +00:00
|
|
|
infoTiddlerFields.push({title: "$:/info/url/" + name, text: value});
|
2016-10-18 08:12:55 +00:00
|
|
|
},
|
|
|
|
location = document.location;
|
|
|
|
setLocationProperty("full", (location.toString()).split("#")[0]);
|
|
|
|
setLocationProperty("host", location.host);
|
|
|
|
setLocationProperty("hostname", location.hostname);
|
|
|
|
setLocationProperty("protocol", location.protocol);
|
|
|
|
setLocationProperty("port", location.port);
|
|
|
|
setLocationProperty("pathname", location.pathname);
|
|
|
|
setLocationProperty("search", location.search);
|
|
|
|
setLocationProperty("origin", location.origin);
|
2018-03-23 09:13:45 +00:00
|
|
|
// 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()});
|
2019-03-07 18:42:49 +00:00
|
|
|
// Language
|
|
|
|
infoTiddlerFields.push({title: "$:/info/browser/language", text: navigator.language || ""});
|
2016-10-18 08:12:55 +00:00
|
|
|
}
|
2014-07-21 12:17:16 +00:00
|
|
|
return infoTiddlerFields;
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|