📄 microformats.js
字号:
plural: true, datatype: "microformat", microformat: "tag", microformat_property: "tag" }, "class" : { values: ["public", "private", "confidential"] }, "description" : { datatype: "HTML" }, "dtstart" : { datatype: "dateTime" }, "dtend" : { datatype: "dateTime" }, "dtstamp" : { datatype: "dateTime" }, "duration" : { }, "geo" : { datatype: "microformat", microformat: "geo" }, "location" : { datatype: "microformat", microformat: "hCard" }, "status" : { values: ["tentative", "confirmed", "cancelled"] }, "summary" : {}, "transp" : { values: ["opaque", "transparent"] }, "uid" : { datatype: "anyURI" }, "url" : { datatype: "anyURI" }, "last-modified" : { datatype: "dateTime" }, "rrule" : { subproperties: { "interval" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "interval"); } }, "freq" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "freq"); } }, "bysecond" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "bysecond"); } }, "byminute" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "byminute"); } }, "byhour" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "byhour"); } }, "bymonthday" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "bymonthday"); } }, "byyearday" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "byyearday"); } }, "byweekno" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "byweekno"); } }, "bymonth" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "bymonth"); } }, "byday" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "byday"); } }, "until" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "until"); } }, "count" : { virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { return Microformats.hCalendar.properties.rrule.retrieve(mfnode, "count"); } } }, retrieve: function(mfnode, property) { var value = Microformats.parser.textGetter(mfnode); var rrule; rrule = value.split(';'); for (let i=0; i < rrule.length; i++) { if (rrule[i].match(property)) { return rrule[i].split('=')[1]; } } } } }};Microformats.add("hCalendar", hCalendar_definition);function geo(node, validate) { if (node) { Microformats.parser.newMicroformat(this, node, "geo", validate); }}geo.prototype.toString = function() { if (this.latitude != undefined) { if (!isFinite(this.latitude) || (this.latitude > 360) || (this.latitude < -360)) { return; } } if (this.longitude != undefined) { if (!isFinite(this.longitude) || (this.longitude > 360) || (this.longitude < -360)) { return; } } if ((this.latitude != undefined) && (this.longitude != undefined)) { var s; if ((this.node.localName.toLowerCase() == "abbr") || (this.node.localName.toLowerCase() == "html:abbr")) { s = this.node.textContent; } if (s) { return s; } /* check if geo is contained in a vcard */ var xpathExpression = "ancestor::*[contains(concat(' ', @class, ' '), ' vcard ')]"; var xpathResult = this.node.ownerDocument.evaluate(xpathExpression, this.node, null, Components.interfaces.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE, null); if (xpathResult.singleNodeValue) { var hcard = new hCard(xpathResult.singleNodeValue); if (hcard.fn) { return hcard.fn; } } /* check if geo is contained in a vevent */ xpathExpression = "ancestor::*[contains(concat(' ', @class, ' '), ' vevent ')]"; xpathResult = this.node.ownerDocument.evaluate(xpathExpression, this.node, null, Components.interfaces.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE, xpathResult); if (xpathResult.singleNodeValue) { var hcal = new hCalendar(xpathResult.singleNodeValue); if (hcal.summary) { return hcal.summary; } } if (s) { return s; } else { return this.latitude + ", " + this.longitude; } }}var geo_definition = { mfObject: geo, className: "geo", required: ["latitude","longitude"], properties: { "latitude" : { datatype: "float", virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { var value = Microformats.parser.textGetter(mfnode); var latlong; if (value.match(';')) { latlong = value.split(';'); if (latlong[0]) { if (!isNaN(latlong[0])) { return parseFloat(latlong[0]); } } } } }, "longitude" : { datatype: "float", virtual: true, /* This will only be called in the virtual case */ virtualGetter: function(mfnode) { var value = Microformats.parser.textGetter(mfnode); var latlong; if (value.match(';')) { latlong = value.split(';'); if (latlong[1]) { if (!isNaN(latlong[1])) { return parseFloat(latlong[1]); } } } } } }, validate: function(node) { var latitude = Microformats.parser.getMicroformatProperty(node, "geo", "latitude"); var longitude = Microformats.parser.getMicroformatProperty(node, "geo", "longitude"); if (latitude != undefined) { if (!isFinite(latitude) || (latitude > 360) || (latitude < -360)) { throw("Invalid latitude"); } } else { throw("No latitude specified"); } if (longitude != undefined) { if (!isFinite(longitude) || (longitude > 360) || (longitude < -360)) { throw("Invalid longitude"); } } else { throw("No longitude specified"); } return true; }};Microformats.add("geo", geo_definition);function tag(node, validate) { if (node) { Microformats.parser.newMicroformat(this, node, "tag", validate); }}tag.prototype.toString = function() { return this.tag;}var tag_definition = { mfObject: tag, attributeName: "rel", attributeValues: "tag", properties: { "tag" : { virtual: true, virtualGetter: function(mfnode) { if (mfnode.href) { var ioService = Components.classes["@mozilla.org/network/io-service;1"]. getService(Components.interfaces.nsIIOService); var uri = ioService.newURI(mfnode.href, null, null); var url_array = uri.path.split("/"); for(let i=url_array.length-1; i > 0; i--) { if (url_array[i] !== "") { var tag if (tag = Microformats.tag.validTagName(url_array[i].replace(/\+/g, ' '))) { try { return decodeURIComponent(tag); } catch (ex) { return unescape(tag); } } } } } return null; } }, "link" : { virtual: true, datatype: "anyURI" }, "text" : { virtual: true } }, validTagName: function(tag) { var returnTag = tag; if (tag.indexOf('?') != -1) { if (tag.indexOf('?') === 0) { return false; } else { returnTag = tag.substr(0, tag.indexOf('?')); } } if (tag.indexOf('#') != -1) { if (tag.indexOf('#') === 0) { return false; } else { returnTag = tag.substr(0, tag.indexOf('#')); } } if (tag.indexOf('.html') != -1) { if (tag.indexOf('.html') == tag.length - 5) { return false; } } return returnTag; }, validate: function(node) { var tag = Microformats.parser.getMicroformatProperty(node, "tag", "tag"); if (!tag) { if (node.href) { var url_array = node.getAttribute("href").split("/"); for(let i=url_array.length-1; i > 0; i--) { if (url_array[i] !== "") { throw("Invalid tag name (" + url_array[i] + ")");; } } } else { throw("No href specified on tag"); } } return true; }};Microformats.add("tag", tag_definition);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -