From b03d939a11c531c874b05fb38bf3b9287fd876c3 Mon Sep 17 00:00:00 2001 From: juan Date: Thu, 5 Sep 2024 15:47:14 -0400 Subject: [PATCH] added augment buttons (full functionality pending) --- lib/api_service.dart | 4 ++- lib/augment.dart | 71 +++++++++++++++++++++++--------------------- 2 files changed, 40 insertions(+), 35 deletions(-) diff --git a/lib/api_service.dart b/lib/api_service.dart index 90041df..15babea 100644 --- a/lib/api_service.dart +++ b/lib/api_service.dart @@ -368,9 +368,11 @@ class _EmailViewState extends State { } void _scrollToNumber(String spanId) { - AugmentClasses.handleJump(viewTypeId, spanId); + AugmentClasses.handleJump(viewTypeId); } + // void _invisibility(String ) + @override Widget build(BuildContext context) { // print(currentContent); diff --git a/lib/augment.dart b/lib/augment.dart index 2d18ca2..d1f37e2 100644 --- a/lib/augment.dart +++ b/lib/augment.dart @@ -120,6 +120,13 @@ class _DynamicClassesAugment extends State { Stack(children: [ Row( children: [ + ElevatedButton( + onPressed: () => AugmentClasses.JumpButton(context), + child: Text('JumpItem:'), + ), + // SizedBox( + // width: 8, + // ), Container( width: 150, height: 30, @@ -225,39 +232,7 @@ class AugmentClasses { print("Stop button pressed"); } - static void handleJump(String viewTypeId, String spanId) { - print(spanId); - // final jsCode = ''' - // var iframe = document.getElementById("iframe#$viewTypeId").contentWindow; - // var element = iframe.document.getElementById('$spanId'); - // if (element) { - // element.scrollIntoView({behavior: "smooth", block: "start"}); - // } - // '''; -// final jsCode = ''' -// var iframe = document.getElementById("$viewTypeId"); -// if (iframe) { -// var iframeWindow = iframe.contentWindow; -// if (iframeWindow && iframeWindow.document) { -// var element = iframeWindow.document.getElementById('$spanId'); -// if (element) { -// element.scrollIntoView({behavior: "smooth", block: "start"}); -// console.log("Scrolling to element with ID: $spanId"); -// } else { -// console.error("Element with ID $spanId not found in iframe."); -// } -// } else { -// console.error("Iframe contentWindow or document is not accessible."); -// } -// } else { -// console.error("Iframe with ID $viewTypeId not found."); -// } -// '''; - // print('jumped'); // For debugging in Dart - - // // Execute the JavaScript code - // js.context.callMethod('eval', [jsCode]); - // Select the first iframe on the page + static void handleJump(String spanId) { String js_code = ''' var iframe = document.getElementsByTagName('iframe')[0]; // 0 for the first iframe, 1 for the second, etc. @@ -280,6 +255,34 @@ class AugmentClasses { console.log('Iframe not found or not loaded.'); } '''; - js.context.callMethod('eval', [js_code]); + js.context.callMethod('eval', [js_code]); + } + + static void invisibility(String htmlClass) {} + static JumpButton(context) { + showDialog( + context: context, + builder: (context) => AlertDialog( + title: Text('Jump Item:'), + content: Column( + children: [ + Text('Jump (to) Item (at)'), + TextField(), + // ElevatedButton( + // onPressed: AugmentClasses.ViewSpecsButton(context), + // child: Text('ViewSpecs'), + // ), + ] + ), + ) + ); + } + static ViewSpecsButton(context) { + showDialog( + context: context, + builder:(context) => AlertDialog( + title: Text('Viewspecs(short)') , + ) + ); } }