I have designed a widget for converting temperature from Celsius degrees to Fahrenheit and vice versa. In this widget a text box is provided for the user to enter the values. Up on entering the values the user can then choose between two options of C to F or F to C.
I have approached as follows:
- First I have created the config.xml. In that I have provided name for the widget ( tempconverter) along with the icon, description.
- Secondly I have created a javascript file named script.js. In this I have defined 2 functions. Both of them gets the input from the html file and converts the values respectively from C to F and F to C. And the result is displayed in html format with bold text by using getElementById().innerHTML.
- Then I have created html page named index.html. In this page I have created the form.The form has the following elements.
- A paragraph to give little description about the widget and how a user can use it.
- A text field through which the user can enter the value.
- Two buttons, one with the value C to F (which converts form Celsius to Fahrenheit) and the other from F to C (converts from Fahrenheit to Celcius).
- A div element which is used to display the result of the above buttons.
- And I have included my external java script file in the header. And I have called the java script functions in their respective onClick attributes of the buttons.
When the user runs the widget, the widget will give an opputunity to enter the number. And if the user wants to convert to Fahrenheit then the user can clicks on C to F. Then the “toF()” function is called and result is displayed in the div element of the html page. And if the user clicks on F to C button then “toC()” function is called. The result is displayed in bold text for visible clarity.
No comments:
Post a Comment