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
8 changes: 1 addition & 7 deletions vscode-wpilib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@
"onCommand:wpilibcore.openApiDocumentation",
"onCommand:wpilibcore.getProjectInformation",
"onCommand:wpilibcore.runGradleClean",
"onCommand:wpilib.refreshVendordeps",
"onCommand:extension.showWebsite"
"onCommand:wpilib.refreshVendordeps"
],
"main": "./out/extension",
"contributes": {
Expand Down Expand Up @@ -419,12 +418,7 @@
"command": "wpilib.refreshVendordeps",
"title": "Refresh",
"icon": "$(refresh)"
},
{
"command": "extension.showWebsite",
"title": "Show Website"
}

],
"views": {
"explorer": [
Expand Down
6 changes: 1 addition & 5 deletions vscode-wpilib/src/dependencyView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,11 +234,7 @@ export class DependencyViewProvider implements vscode.WebviewViewProvider {

if (success) {
if (avail.instructions) {
await vscode.commands.executeCommand(
'extension.showWebsite',
avail.instructions,
dep.name
);
await vscode.commands.executeCommand('simpleBrowser.show', avail.instructions);
}
this.changed = Date.now();

Expand Down
61 changes: 0 additions & 61 deletions vscode-wpilib/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -538,71 +538,10 @@ export async function activate(context: vscode.ExtensionContext) {
gradle2025import,
help
);

// Register the command with arguments
let disposable = vscode.commands.registerCommand(
'extension.showWebsite',
(url: string, tabTitle: string) => {
// If no arguments were passed, you can prompt the user (optional):
if (!url) {
vscode.window.showErrorMessage('URL not provided!');
return;
}
if (!tabTitle) {
tabTitle = 'My Website'; // fallback title if not provided
}

// Create and show a new webview panel
const panel = vscode.window.createWebviewPanel(
'myWebview', // internal identifier
tabTitle, // use the dynamic title
vscode.ViewColumn.One,
{
enableScripts: true,
retainContextWhenHidden: true,
}
);

// Set the HTML content of the webview
panel.webview.html = getWebviewContent(url);
}
);

context.subscriptions.push(disposable);

return externalApi;
}

// this method is called when your extension is deactivated
export function deactivate() {
closeLogger();
}

function getWebviewContent(url: string): string {
// Basic HTML that includes an iframe to your target website.
// NOTE: This will only work if the site allows iframes.
return `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body, html {
padding: 0;
margin: 0;
height: 100%;
overflow: hidden;
background: #fff;
}
iframe {
border: none;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<iframe src="${url}" sandbox="allow-scripts allow-same-origin"></iframe>
</body>
</html>`;
}