Skip to content

Instantly share code, notes, and snippets.

@unicornist
Last active August 29, 2015 14:15
Show Gist options
  • Save unicornist/92c0ce66f6c3bba179db to your computer and use it in GitHub Desktop.
Save unicornist/92c0ce66f6c3bba179db to your computer and use it in GitHub Desktop.
Windows 7 Gadget
rm Gadget.gadget
"C:\Program Files\WinRAR\WinRAR" a Gadget.zip gadget.html gadget.xml settings.html
ren Gadget.zip Gadget.gadget
call Gadget.gadget
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Gadget</title>
<style>
body
{
margin: 0;
width: 800px;
height: 600px;
}
#gadgetContent
{
width: 130px;
top: 24px;
text-align: center;
font-family: Tahoma;
font-size: 10pt;
position: absolute;
}
#background
{
width: 130px;
height: 65px;
position: absolute;
z-index: -1;
background-repeat: no-repeat;
}
</style>
</head>
<body>
<iframe id="frame" src="about:blank" height="100%" width="100%" scrolling="auto" frameborder="0"></iframe>
</body>
<script>
// var System = {Gadget:{Settings:{read: function(){}}}};
System.Gadget.settingsUI = "settings.html";
System.Gadget.onSettingsClosed = window.onload = function () {
document.body.style.width = System.Gadget.Settings.read("GadgetWidth") || 800;
document.body.style.height = System.Gadget.Settings.read("GadgetHeight") || 600;
document.getElementById("frame").src = System.Gadget.Settings.read("GadgetURL") || "http://www.google.com";
};
</script>
</html>
<?xml version="1.0" encoding="utf-8" ?>
<gadget>
<name>Gadget</name>
<namespace>Unicornist</namespace>
<version>1.0.0.0</version>
<author name="Unicornist">
<info url="unicornist.com" />
</author>
<copyright>GPL</copyright>
<description>Some Gadget</description>
<hosts>
<host name="sidebar">
<base type="HTML" apiVersion="1.10" src="gadget.html" />
<permissions>Full</permissions>
<platform minPlatformVersion="0.3" />
</host>
</hosts>
</gadget>
<html>
<head>
<style>
body {
width: 250px;
height: 150px;
font-family: Tahoma;
font-size: 10px;
}
</style>
<script>
window.onload = function () {
envVar.value = System.Gadget.Settings.read("GadgetURL") || "http://www.google.com";
envVar1.value = System.Gadget.Settings.read("GadgetWidth") || 800;
envVar2.value = System.Gadget.Settings.read("GadgetHeight") || 600;
};
System.Gadget.onSettingsClosing = function (e) {
if (e.closeAction == e.Action.commit) {
System.Gadget.Settings.write("GadgetURL", envVar.value);
System.Gadget.Settings.write("GadgetWidth", envVar1.value);
System.Gadget.Settings.write("GadgetHeight", envVar2.value);
}
};
</script>
</head>
<body>
URL: (eg. http://www.microsoft.com)<br>
<input type="text" name="envVar" id="envVar" length="40" />
Gadget&nbsp;Width:<br>
<input type="text" name="envVar1" id="envVar1" length="40" />&nbsp;px
Gadget&nbsp;Height:<br>
<input type="text" name="envVar2" id="envVar2" length="40" />&nbsp;px
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment