<! DOCTYPE html>
 <html>
   <head>
     <title> Hello World! </ title>
   </ head>
   <body>
     <p> Hello World! </ p>
   </ body>
 </ html> </ code>
 <? xml version = '1.0' encoding = 'UTF-8'?>
 <widget>
   <widgetname> Hello World! </ widgetname>
   <description> Demo widget from the Hello World tutorial. </ description>
   <width> 440 </ width>
   <height> 200 </ height>
   <author>
     <name> John Doe </ name>
     <email> john.doe@example.com </ email>
     <link> http://acme-widget.example.com </ link>
     <organization> Acme Examples, Inc. </ organization>
   </ author>
   <id>
     <host> example.com </ host>
     <name> HelloWorld </ name>
     <revised> 2008-01 </ revised>
   </ id>
 </ widget> 

  <! DOCTYPE html>
 <html>
   <head>
     <title> Hello World! </ title>
     <link rel = "stylesheet" type = "text / css" href = "style / helloworld.css">
   </ head>
   <body>
     <div id = "container">
       <div id = "header">
       </ div>
       <div id = "content">
         <h1> Hello World! </ h1>
       </ div>
       <div id = "footer"> Powered by Opera </ div>
     </ div>
   </ body>
 </ html> </ code>
  / ** Basic styles ** /
 body {
   font-family: Verdana, Helvetica, sans-serif;
   font-size: 16px;
 }
 h1 {
   margin: 0;
   font-size: 1.1em;
   padding: 7px 0 0 10px;
   font-weight: normal;
 }
 h2 {
     font-weight: normal;
     font-size: 1.1em;
     margin: 0px;
 }
 / ** Structure ** /
 #container {
   width: 429px;
 }
 #header {
   background-image: url (../ images / back_top.png);
   padding: 4px 10px 0px 10px;
   height: 35px;
 }
 #content {
   background-image: url (../ images / back_center.png);
   color: # 333;
 }
 .view {
     padding: 10px 10px 10px 20px;
     height: 60px;
     max-height: 60px;
     max-width: 393px;
     overflow: auto;
     -apple-dashboard-region: dashboardregion (control rectangle 0px 0px 0px 0px);
 }
 #footer {
   background-image: url (../ images / back_bottom.png);
   height: 23px;
   padding: 2px 0 0 20px;
   font-size: 0.6em;
   text-decoration: underline;
   color: # dd2222;
 }
 </ code>

  <! DOCTYPE html>
 <html>
   <head>
     <title> Hello World! </ title>
     <link rel = "stylesheet" type = "text / css" href = "style / helloworld.css">
     <script type = "text / javascript" src = "script / helloworld.js"> </ script>
   </ head>
   <body>
     <div id = "container">
       <div id = "header">
         <div id = "controlbuttons">
           <button id = "flipbutton" class = "controlbutton" type = "button"> </ button>
           <button id = "closebutton" class = "controlbutton" type = "button"> </ button>
         </ div>
         <h1> Hello World! </ h1>
       </ div>
       <div id = "content">
         <div id = "front" class = "view">
           <h2 id = "hellotext"> Welcome to the world of Opera Widgets! </ h2>
         </ div>
         <div id = "config" class = "view">
           <h2> Hello World!  Configuration </ h2>
           <p>
              <label for = "frontlabel"> Text to display </ label>
              <input id = "frontlabel" type = "text" size = "25">
              <button id = "updatebutton" type = "button"> Update </ button>
           </ p>
         </ div>
       </ div>
       <div id = "footer"> Powered by Opera </ div>
     </ div>
   </ body>
 </ html> </ code>
  / * Hide the configuration view by default * / 
 #config {
   display: none;
 }
 / ** Button styles ** /
 #controlbuttons {
   float: right;
 }
 .controlbutton {
   opacity: 0.0;
   overflow: hidden;
   height: 30px;
   width: 30px;
   background-position: left top;
   border: 0;
 }
 #flipbutton {
   background: transparent url (../ images / btn_config.png) scroll no-repeat 0 0;
 }
 #closebutton {
   background: transparent url (../ images / btn_close.png) scroll no-repeat 0 0;
 }
 / ** Button effects ** /
 #container: hover.controlButton {
   opacity: 0.3;
 }
 #container .controlButton: hover {
   opacity: 1.0;
 }
 #container .controlButton: active {
   opacity: 1.0;
   background-position: left bottom;
 } </ code>

 
 // create a namespace for the widget functions // to avoid clogging the global namespace var helloWorld = helloWorld ||  {};  // function for changing the state of the widget between setting and running helloWorld.flip = function (e) {var display = document.getElementById ('front'). style.display;  if (display == 'block' || display == '') {document.getElementById ('front'). style.display = "none";  document.getElementById ('config'). style.display = "block";  } else {document.getElementById ('config'). style.display = "none";  document.getElementById ('front'). style.display = "block";  }} // initialize the widget window.addEventListener ('load', function (ev) {// add behavior to the flip button document.getElementById ('flipbutton'). addEventListener ('click', function (ev) {helloWorld.flip ();}, false); // handler of the close button document.getElementById ('closebutton'). addEventListener ('click', function (ev) {window.close ();}, false); // this button is not present, but just in case I left it. document.getElementById ('wocbutton'). addEventListener ('click', function (ev) {widget.openURL ('http://widgets.opera.com');}, false); / / handler for the button in the settings. Changes the text on the widget, and // returns the widget to the working state document.getElementById ('updatebutton'). addEventListener ('click', function (ev) {document.getElementById ('hellotext'). textContent = document.getElementById ('frontlabel'). value; helloWorld.  flip ();}, false); // assigns the initial value to the text entry field in the document.getElementById ('frontlabel') settings. setAttribute ('value', document.getElementById ('hellotext'). textContent);  }, false); 
Source: https://habr.com/ru/post/31441/
All Articles