From 1132049da4afccdb3229f2cc9f2041d0728067e9 Mon Sep 17 00:00:00 2001 From: jeena Date: Sun, 31 Mar 2013 13:09:34 -0700 Subject: [PATCH] Updated Plugins (markdown) --- Plugins.md | 47 ----------------------------------------------- 1 file changed, 47 deletions(-) diff --git a/Plugins.md b/Plugins.md index 06acc69..d687465 100644 --- a/Plugins.md +++ b/Plugins.md @@ -108,51 +108,4 @@ ol li .message a.name { ol li:hover .message a.name { background: #efefef; } -``` - -

Add converted temperature

- -``` javascript -// A Bungloo plugin to automatically convert Fahrenheit to Celsius -// and vice versa. Change the unit in the line: var unit = "F"; - -$(document).ready(function() { - if(bungloo_instance && bungloo_instance.body) { - bungloo_instance.body.addEventListener( - 'DOMNodeInserted', - tmpConv, - false - ); - } -}); - -function tmpConv(e) { - - var unit = "F"; // either F or C, the one you want to convert - - var element = e.target; - if(element.parentNode != bungloo_instance.body) return; - - var message = $(element).find(".message"); - - var callback = f2cCallback; - if (unit == "C") callback = c2fCallback; - - var regex = new RegExp("(-?[0-9]+) ?°? ?" + unit + "+", "ig"); - - text = message.html().replace(regex, callback); - message.html(text); -} - -function f2cCallback(f, fahrenheit) { - fahrenheit = parseInt(fahrenheit, 10); - var celsius = (fahrenheit - 32) * 5 / 9; - return f + " (" + parseInt(celsius) + "°C)"; -} - -function c2fCallback(c, celsius) { - celsius = parseInt(celsius, 10); - var fahrenheit = celsius * 1.8 + 32; - return c + " (" + parseInt(fahrenheit) + "°F)"; -} ``` \ No newline at end of file