BrickJax

Welcome to the provisional home of BrickJax.

This is a work-in-progress proof-of-concept to show how we might provide some script to replace some tags on LEGO Answers with pictures sourced from LUGNet Parts Guide.

When it's complete, the aim is that you would be able to take a reference to the BrickJax script and then where ever it finds matching tags, it replaces them with an image.

Simple proof of concept call:

Intermediate User Script

While we wait for the inclusion of this script on LEGO Answers you can download a UserScript from here:

Install BrickJax UserScript

Web Response

To reduce calls and roundtrips, if the request results in an image, the returned object contains the Alt Text and the image data that can be added directly to an <img src="[data.Src]" alt="[data.AltText]" /> element.

The JSON object returned contains the following properties:

AltText
A pre-build alt text containing the English name and colour in the form "Brick 2x4 - Yellow"
BrickName
The English name of the brick, as defined by common consensus and sites like LUGNet Parts Guide.
ColourId
The ID of the colour as defined by the LDraw Colour Definitions File
ColourName
The English name of the colour as defined by the LDraw Colour Definitions File
PartId
The Part Id (where known this is the LEGO Element ID), otherwise it's the LUGNet Parts Reference Id.
Src
The Base64 encoded image data as lifted from LUGNet.

Examples/Test cases

Unchanged Parts

The following should not be replaced because it is inside a <code> element:
[parT:2337]
[part:884]
[part:777p06]
[part:6260c01:21]
[PartLink:777p06]
[set:5590]
[bs:5509]
[bl:5509]

Parts

These codes should be replaced by images:
[PART:3001:14] [parT:2337] [part:777p06] [part:6260c01:21] [part:884]

Part in a nested div: [part:32181c02:0]

PartLink examples: [Partlink:2552], [partlink:32181c02:0]

Broken Parts

Example of broken code: [pARt:3712c01:7] (code should work, but LUGNET Partsref is out of date vs LDRAW)

Example of broken image on link: [pARtlink:3712c01:7]

Set Links