mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2026-09-21 00:48:49 +00:00
Limited implementation of external text tiddlers in the browser
Triggered by the discussion in #1917
This commit is contained in:
@@ -26,6 +26,23 @@ Attributes are stored as hashmaps of the following objects:
|
||||
|
||||
var WikiParser = function(type,text,options) {
|
||||
this.wiki = options.wiki;
|
||||
var self = this;
|
||||
// Check for an externally linked tiddler
|
||||
if($tw.browser && options._canonical_uri) {
|
||||
$tw.utils.httpRequest({
|
||||
url: options._canonical_uri,
|
||||
type: "GET",
|
||||
callback: function(err,data) {
|
||||
if(!err) {
|
||||
var tiddlers = self.wiki.deserializeTiddlers(".tid",data,self.wiki.getCreationFields())
|
||||
if(tiddlers) {
|
||||
self.wiki.addTiddlers(tiddlers);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
text = "Loading external text from ''" + options._canonical_uri + "''\n\nIf this message doesn't disappear you may be using a browser that doesn't support external text in this configuration. See http://tiddlywiki.com/#ExternalText";
|
||||
}
|
||||
// Initialise the classes if we don't have them already
|
||||
if(!this.pragmaRuleClasses) {
|
||||
WikiParser.prototype.pragmaRuleClasses = $tw.modules.createClassesFromModules("wikirule","pragma",$tw.WikiRuleBase);
|
||||
|
||||
@@ -43,7 +43,7 @@ exports.convertStyleNameToPropertyName = function(styleName) {
|
||||
// Convert it by first removing any hyphens
|
||||
var propertyName = $tw.utils.unHyphenateCss(styleName);
|
||||
// Then check if it needs a prefix
|
||||
if(document.body.style[propertyName] === undefined) {
|
||||
if($tw.browser && document.body.style[propertyName] === undefined) {
|
||||
var prefixes = ["O","MS","Moz","webkit"];
|
||||
for(var t=0; t<prefixes.length; t++) {
|
||||
var prefixedName = prefixes[t] + propertyName.substr(0,1).toUpperCase() + propertyName.substr(1);
|
||||
|
||||
@@ -58,7 +58,11 @@ exports.httpRequest = function(options) {
|
||||
if(data && !$tw.utils.hop(headers,"Content-type")) {
|
||||
request.setRequestHeader("Content-type","application/x-www-form-urlencoded; charset=UTF-8");
|
||||
}
|
||||
request.send(data);
|
||||
try {
|
||||
request.send(data);
|
||||
} catch(e) {
|
||||
options.callback(e);
|
||||
}
|
||||
return request;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user