Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | <!DOCTYPE> |
michael@0 | 2 | <head> |
michael@0 | 3 | <style> |
michael@0 | 4 | body { |
michael@0 | 5 | border: 0px; |
michael@0 | 6 | margin: 0px; |
michael@0 | 7 | padding: 0px; |
michael@0 | 8 | } |
michael@0 | 9 | </style> |
michael@0 | 10 | </head> |
michael@0 | 11 | <body> |
michael@0 | 12 | <img src="image-orientation-no-viewbox-and-size.svg"> |
michael@0 | 13 | |
michael@0 | 14 | <script> |
michael@0 | 15 | var orientation = location.search.substring(1).split("&"); |
michael@0 | 16 | var angle = orientation[0]; |
michael@0 | 17 | var flip = orientation[1] == "flip" ? true : false; |
michael@0 | 18 | |
michael@0 | 19 | // Construct a style. "from-image" is special-cased. |
michael@0 | 20 | var style; |
michael@0 | 21 | if (angle == "from-image") { |
michael@0 | 22 | style = "img { image-orientation: from-image; }\n"; |
michael@0 | 23 | } else { |
michael@0 | 24 | style = "img { image-orientation: " |
michael@0 | 25 | + angle + "deg" |
michael@0 | 26 | + (flip ? " flip" : "") |
michael@0 | 27 | + "; }\n"; |
michael@0 | 28 | } |
michael@0 | 29 | |
michael@0 | 30 | // Apply the style to the document. |
michael@0 | 31 | var sheet = document.createElement('style'); |
michael@0 | 32 | sheet.innerHTML = style; |
michael@0 | 33 | document.body.appendChild(sheet); |
michael@0 | 34 | </script> |
michael@0 | 35 | </body> |