Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
723 changes: 546 additions & 177 deletions README.md

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions Resources/Skins/WebView2/@Resources/JSInteraction/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JS Interaction Demo</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>JS Interaction</h1>

<div class="container">
<div class="card">
<div class="card-header">
<span class="card-title">OnUpdate Cycle</span>
<span class="card-subtitle">Updates every second</span>
</div>
<div id="update-display" class="value-display">Waiting...</div>
</div>

<div class="card">
<div class="card-header">
<span class="card-title">Event Log</span>
<span class="card-subtitle">Recent activity</span>
</div>
<div id="log-container" class="log-container"></div>
</div>

<div class="card">
<div class="card-header">
<span class="card-title">CallJS Demo</span>
</div>
<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.5rem;">
Rainmeter is calling <code>addNumbers(15, 25)</code> via section variable.
</p>
<p style="color: var(--text-muted); font-size: 0.9rem;">
Check the Rainmeter skin to see the result!
</p>
</div>
</div>

<script src="script.js"></script>
</body>
</html>
46 changes: 46 additions & 0 deletions Resources/Skins/WebView2/@Resources/JSInteraction/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
let updateCount = 0;

// Called once when the plugin is ready
window.OnInitialize = function() {
log("🚀 OnInitialize called!");
return "Initialized!";
};

// Called on every Rainmeter update cycle
window.OnUpdate = function() {
updateCount++;
const message = `Update #${updateCount}`;

// Update the display in HTML
const display = document.getElementById('update-display');
if (display) {
display.textContent = message;
}

// Return value updates the measure's string value in Rainmeter
return message;
};

// Function callable from Rainmeter via [Measure:CallJS('addNumbers', 'a', 'b')]
window.addNumbers = function(a, b) {
const sum = parseInt(a) + parseInt(b);
log(`🧮 addNumbers called: ${a} + ${b} = ${sum}`);
return sum;
};

// Helper to log to HTML
function log(message) {
const container = document.getElementById('log-container');
if (container) {
const entry = document.createElement('div');
entry.className = 'log-entry';
entry.textContent = `[${new Date().toLocaleTimeString()}] ${message}`;
container.insertBefore(entry, container.firstChild);

// Keep log size manageable
if (container.children.length > 50) {
container.removeChild(container.lastChild);
}
}
console.log(message);
}
128 changes: 128 additions & 0 deletions Resources/Skins/WebView2/@Resources/JSInteraction/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
:root {
--primary: #6366f1;
--secondary: #a855f7;
--bg: #0f172a;
--card-bg: rgba(30, 41, 59, 0.7);
--text: #f8fafc;
--text-muted: #94a3b8;
--success: #22c55e;
--error: #ef4444;
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

body {
font-family: 'Segoe UI', system-ui, sans-serif;
background: var(--bg);
color: var(--text);
height: 100vh;
overflow: hidden;
display: flex;
flex-direction: column;
padding: 20px;
}

h1 {
font-size: 1.5rem;
margin-bottom: 1rem;
background: linear-gradient(to right, var(--primary), var(--secondary));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
text-align: center;
}

.container {
flex: 1;
display: flex;
flex-direction: column;
gap: 1rem;
overflow-y: auto;
padding-right: 5px;
}

.card {
background: var(--card-bg);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 255, 255, 0.1);
border-radius: 12px;
padding: 1rem;
transition: transform 0.2s;
}

.card:hover {
transform: translateY(-2px);
border-color: rgba(255, 255, 255, 0.2);
}

.card-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 0.5rem;
}

.card-title {
font-weight: 600;
color: var(--text);
}

.card-subtitle {
font-size: 0.8rem;
color: var(--text-muted);
}

.value-display {
font-family: 'Consolas', monospace;
background: rgba(0, 0, 0, 0.3);
padding: 0.5rem;
border-radius: 6px;
color: var(--success);
word-break: break-all;
text-align: center;
font-size: 1.2rem;
}

.log-container {
font-family: 'Consolas', monospace;
font-size: 0.8rem;
color: var(--text-muted);
background: rgba(0, 0, 0, 0.3);
padding: 0.5rem;
border-radius: 6px;
height: 150px;
overflow-y: auto;
}

.log-entry {
margin-bottom: 4px;
border-bottom: 1px solid rgba(255,255,255,0.05);
padding-bottom: 2px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
width: 8px;
height: 8px;
}

::-webkit-scrollbar-track {
background: rgba(255, 255, 255, 0.05);
border-radius: 4px;
}

::-webkit-scrollbar-thumb {
background: linear-gradient(to bottom, var(--primary), var(--secondary));
border-radius: 4px;
border: 2px solid transparent;
background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
background: linear-gradient(to bottom, var(--secondary), var(--primary));
border-radius: 2px solid transparent;
background-clip: content-box;
}
2 changes: 1 addition & 1 deletion Resources/Skins/WebView2/BangCommand/BangCommand.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DynamicWindowSize=1
Name=BangCommand
Author=nstechbytes
Information=Demonstrates controlling WebView2 via !CommandMeasure bangs.
Version=1.0
Version=0.0.6
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
Expand Down
4 changes: 2 additions & 2 deletions Resources/Skins/WebView2/Calendar/Calendar.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Update=1000
Name=Calendar
Author=nstechbytes
Information=Calendar Widget using WebView2
Version=0.0.3
License=MIT
Version=0.0.6
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
; ========================================
; Measure
; ========================================
Expand Down
4 changes: 2 additions & 2 deletions Resources/Skins/WebView2/Clock/Clock.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Update=1000
Name=Calendar
Author=nstechbytes
Information=Calendar Widget using WebView2
Version=0.0.3
License=MIT
Version=0.0.6
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
; ========================================
; Measure
; ========================================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DynamicWindowSize=1
Name=InformationProperty
Author=nstechbytes
Information=Shows Rainmeter information properties via WebView2.
Version=1.0
Version=0.0.6
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
; ========================================
; Measure
Expand Down
4 changes: 2 additions & 2 deletions Resources/Skins/WebView2/IslamicDate/IslamicDate.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ Update=1000
Name=Islamic Date
Author=nstechbytes
Information=Islamic (Hijri) Date Widget using WebView2
Version=0.0.1
License=MIT
Version=0.0.6
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
; ========================================
; Measure
; ========================================
Expand Down
93 changes: 93 additions & 0 deletions Resources/Skins/WebView2/JSInteraction/JSInteraction.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Metadata]
Name=JSInteraction
Author=nstechbytes
Information=Demonstrates JavaScript interaction (OnInitialize, OnUpdate, CallJS) with the WebView2 plugin.
Version=0.0.6
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

; ========================================
; Measure
; ========================================
[MeasureWebView]
Measure=Plugin
Plugin=WebView2
URL=file://#@#JSInteraction\index.html
W=400
H=450
X=25
Y=25
DynamicVariables=1

; ==================================================
; Background
; ==================================================

[MeterBackground]
Meter=Shape
Shape=Rectangle 0,0,450,650,12 | FillColor 136,93,244,200 | StrokeWidth 0

; ==================================================
; Meters
; ==================================================

[MeterTitle]
Meter=String
MeasureName=MeasureWebView
X=225
Y=500
W=400
H=20
FontFace=Segoe UI
FontSize=14
FontWeight=700
FontColor=255,255,255,255
StringAlign=Center
AntiAlias=1
Text=JS Interaction Demo

[MeterStatus]
Meter=String
MeasureName=MeasureWebView
X=225
Y=5R
W=400
H=40
FontFace=Consolas
FontSize=10
FontColor=100,255,100,255
StringAlign=Center
AntiAlias=1
Text=Status: %1

[MeterCallJSResult]
Meter=String
X=225
Y=5R
W=400
H=40
FontFace=Segoe UI
FontSize=11
FontColor=200,200,255,255
StringAlign=Center
AntiAlias=1
Text=Result from JS: [MeasureWebView:CallJS('addNumbers', '15', '25')]
DynamicVariables=1

[MeterInstruction]
Meter=String
X=225
Y=5R
W=380
H=40
FontFace=Segoe UI
FontSize=9
FontColor=150,150,150,255
StringAlign=Center
AntiAlias=1
Text=Check the console (F12) for logs
ClipString=1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DynamicWindowSize=1
Name=ReadMeasureOption
Author=nstechbytes
Information=Demonstrates reading options from the current measure using the WebView2 plugin.
Version=1.0
Version=0.0.6
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
; ========================================
; Measure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ DynamicWindowSize=1
Name=ReadSectionOption Demo
Author=nstechbytes
Information=Demonstrates reading options from other sections using WebView2
Version=1.0
License=MIT
Version=0.0.6
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
TestVar=Hello from Variables!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DynamicWindowSize=1
Name=UtilityFunction
Author=nstechbytes
Information=Demonstrates RainmeterAPI utility functions using the WebView2 plugin.
Version=1.0
Version=0.0.6
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
Expand Down
Loading
Loading