AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-826912

Dennis's questions

Martin Hope
Dennis
Asked: 2025-02-05 04:07:57 +0800 CST

如何在选择菜单后查看 Google Apps 脚本日志

  • 5

我有一个脚本,它从 JDBC 连接获取输入并将其写入工作表。有时此操作的结果并非预期结果,因此我在脚本的关键点处散布了如下代码:

          Logger.log("Trying to delete rows, received: "
                      +  e.message) ;
              Logger.log("   Continuing.") ;

当我从脚本编辑器的“运行”按钮运行此类代码时,我可以毫不费力地看到最新的执行日志 - 它就在我面前。但是当我从像这样创建的菜单中运行相同的代码时:

function onOpen() {
    var menuItems ;
    var spreadsheet = SpreadsheetApp.getActive();
    var user = Session.getEffectiveUser().getEmail() ;
    var validUsers = [ validUsersList ]

    if (spreadsheet.getDataRange().canEdit()) {
        menuItems = [
            {name: 'Process all streams' , functionName: 'processAllStreams'}
            , {name: 'Build covered artists'           , functionName: 'rebuildCoversSheet'}
            //, {name: 'Add to song list'              , functionName: 'buildSongList'}
            //, {name: 'Process selective streams'       , functionName: 'processStreams'}
            //, {name: 'Move suggestions to top'         , functionName: 'moveSuggestionsToTop'}
            , {name: 'Go to bottom'                    , functionName: 'showBottomRange'}
            , {name: 'New livestream details'          , functionName: 'getNewLivestreamDetails'}
                ];
        spreadsheet.addMenu('Process it', menuItems);

             etc.

从该菜单运行时,我看不到日志。我已进入编辑器并在那里检查;它似乎不知道在开发环境之外运行的脚本。

我必须做什么才能看到这些日志?我知道有一个云日志选项,但看起来设置起来并不那么简单。文档中没有提到通过菜单或脚本编辑器运行脚本的限制。文档 确实提到了一些限制:

These logs are intended for simple checks during development and debugging, and do not persist very long.

但他们似乎没有解决这个问题。有简单的方法吗?

顺便说一句,对于某些正在执行的操作,从脚本编辑器运行不是一个选项。原因是其中涉及提示和对话框(getUi.prompt() 等),而这些在脚本编辑器模式下是不允许的。所以目前这是一个两难的局面。

编辑-添加了可测试脚本

以下代码:

function onOpen() {
    var menuItems = [
            { name: 'Make a log entry', functionName: 'makeEntry' }
        ];
        SpreadsheetApp.getActive().addMenu('Process it', menuItems);
}

function makeEntry() {
  Logger.log('here you go....') ;
}

如果您创建一个新的 Google Sheet 并将此代码添加到脚本编辑器中:

从脚本编辑器运行脚本,您将看到创建的日志条目。

从创建(“处理它”)菜单运行脚本,我找不到该日志条目。

google-apps-script
  • 1 个回答
  • 50 Views
Martin Hope
Dennis
Asked: 2025-01-21 07:29:56 +0800 CST

div 显示状态未被 javascript 改变

  • 5

不久前,我发布了一个类似的问题,但有一个拼写错误,造成了混淆。对此我深表歉意,它对我们任何人都没有好处,并且已被删除。我已尽最大努力确保此代码干净且无拼写错误。此代码也显示了所描述的问题。

这个问题更好地代表了我遇到的问题:当 div 的显示属性设置为“block”时,div 不会显示。简化的代码如下:

function selectVidId(youtubeId, tableRowNbr, tableRowId, videoWidth, videoHeight) {
  const embedElement = document.getElementById('embedDiv');
  const videoElement = document.getElementById('videoDiv');

  let response = "<div id='muteYouTubeVideoPlayer'></div> \
    <script> \
      function onYouTubeIframeAPIReady() \
        {
        var player = new YT.Player('muteYouTubeVideoPlayer', \
            { videoId : 'f5JVDUI81nk' // YouTube Video ID    \
            , width   : 480          // Player width (in px) \
            , height  : 360         // Player height (in px) \
            , playerVars: \
              { autoplay       : 0  // Auto-play the video on load       \
              , controls       : 1  // Show pause/play buttons in player \
              , showinfo       : 1  // Show the video title              \
              , modestbranding : 1  // Hide the Youtube Logo             \
              , loop           : 0  // Don't run the video in a loop     \
              , fs             : 0  // Don't hide the full screen button \
              , cc_load_policy : 0  // Hide closed captions              \
              , iv_load_policy : 3  // Hide the Video Annotations        \
              , autohide       : 0  // Hide video controls when playing  \
              } // playerVars \
            , events: {} // events \
            } \
          ) ; // new .Player \
        } // function \
      // Written by @labnol \
    </script>";

  videoElement.style.display = 'none';
  embedElement.innerHTML = response;
  embedElement.style.display = 'block';
}
<!DOCTYPE html>
<html lang='en'>

<head>
  <title>Livestreams</title>
  <style>
  </style>
</head>
<script src="dbg.js">
</script>
</head>

<body>
  <div id='fullPageDiv' style='width: 100%; overflow:hidden;'>
    <div id='livestreamTable' style='width: 60%;float:left;'>
      <table border='1'>
        <thead>
          <tr>
            <th>Started</th>
            <th>Channel</th>
            <th>Songs noted</th>
            <th style='text-align:right;'>Duration</th>
            <th style='text-align:right;'>Dimensions</th>
            <th>Livestream Title</th>
          </tr>
        </thead>
        <tbody>
          <tr id='livestream_row_0'>
            <td>2021-12-04 07:15:08</td>
            <td style='text-align:left;'>Primary</td>
            <td style='text-align:right;'></td>
            <td style='text-align:right;'>1:04:54</td>
            <td style='text-align:right;' id='videoDimensions0'>1280x720*</td>
            <td><span onclick='selectVidId("f5JVDUI81nk", 0, "livestream_row_0", "1280", "720");'>Click-this-element</span></td>
          </tr>
        </tbody>
      </table>
    </div><!-- Livestream table -->
    <div id='videoDiv' style='display: none;'>
      <video id='idVideo' width="320" height="240" controls>
                <!-- <source src='replaceme.mp4' type='video/mp4'> -->
                Need top insert some video content here.
        </video>
    </div><!--videoDiv-->
    <div id='embedDiv' style='display: none;'>
      <p>Why, hello there!</p>
    </div><!-- embedDiv-->
  </div><!-- This is the "page" division (the whole page after the form) -->

</html>

此页面未实现的目的是显示项目列表,当单击其中一个项目时,右上角将显示相关的 YouTube 视频。当我通过 Chrome 调试器运行此代码时,每行 javascript 代码都会被执行。最后,embedElement.style.display 值确实设置为“block”,但 embedDiv 中没有显示任何内容。(我插入了愚蠢的“你好”文本,仅仅是因为即使其他内容有问题,它也应该出现。)

我再次问一下,我缺少了什么基本的东西导致这个 div(显然)无法显示?

以何种方式替换 embedDiv 的内容以便真正执行必要的代码的正确方法是什么?

javascript
  • 1 个回答
  • 50 Views
Martin Hope
Dennis
Asked: 2024-08-14 21:12:53 +0800 CST

使用 S_ISREG()(和其他宏)作为函数参数

  • 6

我正在尝试创建一个函数,通常用于确定文件/目录是否存在、是否在某个路径内以及是否属于指定类型(S_ISREG、S_ISDIR、...

以下是与该问题相关的部分来源:

int checkExists(const char *name, void *func(int))) {
   struct stat st ;
   int returnValue = DOES_NOT_EXIST ;
   BOOL isInSourceHierarchy, isInTargetHierarchy ;

   if (stat(name, &st) != -1) {
      returnValue = EXISTS ;
      if (memcmp(name, top_dir, strlen(top_dir)))
         returnValue |= IN_SOURCE_STRUCTURE ;
      if (memcmp(name, tgt_dir, strlen(tgt_dir)))
         returnValue |= IN_TARGET_STRUCTURE ;
      if (func != NULL) {
         if (objType == func(st.st_mode))
            returnValue |= RIGHT_TYPE ;
      }
   }

   return returnValue ;
}

. . . 

if (S_ISREG(0)) {} // Yes, I know, I know.  This is for demonstration only.
if (checkExists(old, S_ISREG)) {
   // Do something
 } else { // Old file doesn't exist
   // Do something else
 }

当我尝试编译它时,我得到:

linkStructure.c:642:31: error: ‘S_ISREG’ undeclared (first use in this function)
  642 |          if (checkExists(old, S_ISREG)) {
      |                               ^~~~~~~

可以看出,当然,对于按设计使用的宏没有任何抱怨。所以我的问题是:有没有办法让我像这样在源代码中引用宏?或者我只能在函数中模拟宏?(我想我可以传递预期的类型而不是函数,但为了清楚起见,我想了解这个限制。)

c
  • 3 个回答
  • 59 Views
Martin Hope
Dennis
Asked: 2023-08-29 02:23:43 +0800 CST

float:left 在 HTML CSS 中对我不起作用

  • 5

我开发了一个脚本来呈现活跃的 YouTube 聊天以及聊天中的人员摘要。这个想法是聊天项目表将出现在聊天成员列表的右侧。然而,在最新版本的 Safari 和 Chrome 中,浮动似乎不起作用,并且表格呈现一个在另一个之上。以下是生成的 HTML 的示例摘录,该 HTML 存在问题。

body {
  background-image: '/bg-standard.jpg';
  background-attachment: fixed;
}

.twoTables {
  margin-left: -5px;
  margin-right: -5px;
}

.tableLeft {
  float: left;
  width: 50%;
  padding: 5px;
}

.tableRight {
  float: left;
  width: 50%;
  padding: 5px;
}

.twoTables::after {
  content: "";
  clear: both;
  display: table;
}

headingLink {
  color: white;
  text-decoration: none;
}

.dummyRow {
  line-height: 1px;
  visibility: hidden;
}

.freeze-table {
  border-spacing: 0;
  border-collapse: collapse;
  padding: 0;
}

thead th {
  top: 0;
  position: sticky;
  background-color: #666;
  color: #fff;
  z-index: 20;
  min-height: 30px;
  height: 30px;
  text-align: left;
}

tr:nth-child(even) {
  background-color: #f2f2f2;
}

xth,
xtd {
  padding: 0 5px;
  border-collapse: collapse;
  font-size: 100%;
  outline: 1px solid #ccc;
  border: none;
  outline-offset: -1px;
  padding-left: 5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th,
td {
  padding: 0 0px;
  border-collapse: collapse;
  font-size: 100%;
  border: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 5px;
}

tr {
  min-height: 25px;
  height: 25px;
  background-color: #ffffff
}

pageElement {
  display: flex;
  flex-wrap: nowrap;
  align-items: center
}

a:link {
  color: white;
  text-decoration: none;
}

* {
  padding: 0;
  margin: 0;
}

.fit {
  /* set relative picture size */
  max-width: 100%;
  max-height: 100%;
}

.center {
  display: block;
  margin: auto;
}

.imgbox {
  display: grid;
  width: 100%;
}

.center-fit {
  max-width: 100%;
  max-height: 100vh;
  margin: auto;
}

@media screen and (max-width: 600px) {
  .tableLeft {
    width: 100%;
  }
  .tableRight {
    width: 100%;
  }
}
<form method='POST' action=/ YouTube/latestChats.php>
  <table style='border-collapse:collapse;'>
    <tr>
      <td><input type='checkbox' name='highlightMsg' id='highlightMsg' checked>
        <label for='highlightMsg'>Highlight messages</label></td>
      <td><input type='checkbox' name='msgUseRegEx' id='msgUseRegEx'>
        <label for='msgUseRegEx'>Use REGEX</label></td>
      <td>Message filter</td>
      <td><input type='text' name='msg' value='request' size=30></td>
    </tr>
    <tr>
      <td><input type='checkbox' name='invertOrder' id='invertOrder' checked>
        <label for='invertOrder'>Latest first</label></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>
        <input type='radio' name='emoteMgmt' value='text'>&nbsp;Emoticons&nbsp;as&nbsp;text&nbsp;&nbsp;&nbsp;&nbsp;
        <input type='radio' name='emoteMgmt' checked value='icon'>&nbsp;Emoticons&nbsp;as&nbsp;image&nbsp;&nbsp;&nbsp;&nbsp;
        <input type='radio' name='emoteMgmt' value='strip'>&nbsp;Strip&nbsp;emoticons&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      </td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
  </table>
  <br>
  <input type='submit' name='submit' value='Submit'> &nbsp;&nbsp;&nbsp;
  <input type='submit' name='backToYouTubeStuff' value='Go Back'>
  <br>
</form>
<br>
<div class='twoTables'>
  <div id='watchers' class='tableLeft'>
    <table>
      <tr>
        <th>Watcher</th>
        <th>*</th>
        <th>Joined</th>
        <th>Latest</th>
      </tr>
      <tr>
        <td>request</td>
        <td>*</td>
        <td>07:47</td>
        <td>1805.0m</td>
      </tr>
      <tr>
        <td>Joe Something - guru</td>
        <td>*</td>
        <td>07:44</td>
        <td>1805.2m</td>
      </tr>
      <tr>
        <td>(<span style="font-weight:bold; font-style:italic;">Tony</span>) Tropic</td>
        <td>*</td>
        <td>06:48</td>
        <td>1839.9m</td>
      </tr>
    </table>
  </div>
  <div id='chats' class='tableRight'>
    <table style='border-collapse:collapse;border:0px solid white;'>
      <tr style='color:white; border:0px;'>
        <td colspan=3 style='text-align:center;background-color:darkblue;color:white;font-size:115%;font-weight:bold;border:solid white;'>2023-08-27</td>
        <td colspan=2 style='background-color:darkblue;color:white;font-size:115%;font-weight:bold;border:solid white;'><a href='https://youtu.be/ForShow'>2023-08-27 Livestream Title (23-074)</a></td>
      </tr>

      <tr>
        <td style='text-align:right;color:Blue;'>1</td>
        <td style='text-align:center;color:Blue;'>07:47</td>
        <td style='text-align:right;color:Blue;'>(58:51)</td>
        <td style='text-align:left;color:Blue;'>Tropic</td>
        <td style='text-align:left;color:Blue;'>
          <a style='color:blue;text-decoration:none;' href='https://youtu.be/ForShow?t=3531' target='_blank'>_&nbsp;
               Ty dad</a></td>
      </tr>
      <tr>
        <td style='text-align:right;color:Blue;'>2</td>
        <td style='text-align:center;color:Blue;'>07:47</td>
        <td style='text-align:right;color:Blue;'>(58:41)</td>
        <td style='text-align:left;color:Blue;'>Joe Something</td>
        <td style='text-align:left;color:Blue;'>
          <a style='color:blue;text-decoration:none;' href='https://youtu.be/ForShow?t=3521' target='_blank'>_&nbsp;
               c ya guys</a></td>
      </tr>
      <tr>
        <td style='text-align:right;color:Blue;'>3</td>
        <td style='text-align:center;color:Blue;'>07:47</td>
        <td style='text-align:right;color:Blue;'>(58:37)</td>
        <td style='text-align:left;color:Blue;'>request</td>
        <td style='text-align:left;color:Blue;'>
          <a style='color:blue;text-decoration:none;' href='https://youtu.be/ForShow?t=3517' target='_blank'>_&nbsp;
               Sold it Brad</a></td>
      </tr>
      <tr>
        <td style='text-align:right;color:Blue;'>5</td>
        <td style='text-align:center;color:Blue;'>07:46</td>
        <td style='text-align:right;color:Blue;'>(58:28)</td>
        <td style='text-align:left;color:Blue;'>Silent Chatter</td>
        <td style='text-align:left;color:Blue;'>
          <a style='color:blue;text-decoration:none;' href='https://youtu.be/ForShow?t=3508' target='_blank'>_&nbsp;
               HAPPY Bday Son</a></td>
      </tr>
      <tr>
        <td style='text-align:right;color:Blue;'>6</td>
        <td style='text-align:center;color:Blue;'>07:46</td>
        <td style='text-align:right;color:Blue;'>(58:27)</td>
        <td style='text-align:left;color:Blue;'>request</td>
        <td style='text-align:left;color:Blue;'>
          <a style='color:blue;text-decoration:none;' href='https://youtu.be/ForShow?t=3507' target='_blank'>_&nbsp;
               good job george</a></td>
      </tr>
      <tr>
        <td style='text-align:right;color:Blue;'>7</td>
        <td style='text-align:center;color:Blue;'>07:46</td>
        <td style='text-align:right;color:Blue;'>(58:23)</td>
        <td style='text-align:left;color:Blue;'>Danny Incognito</td>
        <td style='text-align:left;color:Blue;'>
          <a style='color:blue;text-decoration:none;' href='https://youtu.be/ForShow?t=3503' target='_blank'>_&nbsp;
               bye bye guys</a></td>
      </tr>
      <tr>
        <th colspan=5 style='background-color: #666 ;color: #fff ;z-index: 20 ;min-height: 30px ;height: 30px ;text-align: left ;'>End of data. </th>
      </tr>
    </table>
  </div>
</div>

我已经搜索了类似问题的解决方案,但似乎没有一个与我的问题完全匹配,保存这个。对于这个,我对接受的答案有两个问题(“你需要将文本包装在 div 内并将其向左浮动,而包装 div 应该有高度......):(1)我的代码已经被包装并指定浮动; (2)我还没有看到证据表明我必须指定高度。我认为这是问题的另一种变体。然后是令人讨厌的评论,认为所接受的答案不起作用。

关于使浮动工作,我在这里做了明显错误的事情吗?我什么也没看到。

注意:这里定义了很多样式属性但未使用。实际成品的功能远不止这副桌子那么简单。

感谢您的任何见解。

html
  • 1 个回答
  • 20 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    重新格式化数字,在固定位置插入分隔符

    • 6 个回答
  • Marko Smith

    为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会?

    • 2 个回答
  • Marko Smith

    VScode 自动卸载扩展的问题(Material 主题)

    • 2 个回答
  • Marko Smith

    Vue 3:创建时出错“预期标识符但发现‘导入’”[重复]

    • 1 个回答
  • Marko Smith

    具有指定基础类型但没有枚举器的“枚举类”的用途是什么?

    • 1 个回答
  • Marko Smith

    如何修复未手动导入的模块的 MODULE_NOT_FOUND 错误?

    • 6 个回答
  • Marko Smith

    `(表达式,左值) = 右值` 在 C 或 C++ 中是有效的赋值吗?为什么有些编译器会接受/拒绝它?

    • 3 个回答
  • Marko Smith

    在 C++ 中,一个不执行任何操作的空程序需要 204KB 的堆,但在 C 中则不需要

    • 1 个回答
  • Marko Smith

    PowerBI 目前与 BigQuery 不兼容:Simba 驱动程序与 Windows 更新有关

    • 2 个回答
  • Marko Smith

    AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String”

    • 1 个回答
  • Martin Hope
    Fantastic Mr Fox msvc std::vector 实现中仅不接受可复制类型 2025-04-23 06:40:49 +0800 CST
  • Martin Hope
    Howard Hinnant 使用 chrono 查找下一个工作日 2025-04-21 08:30:25 +0800 CST
  • Martin Hope
    Fedor 构造函数的成员初始化程序可以包含另一个成员的初始化吗? 2025-04-15 01:01:44 +0800 CST
  • Martin Hope
    Petr Filipský 为什么 C++20 概念会导致循环约束错误,而老式的 SFINAE 不会? 2025-03-23 21:39:40 +0800 CST
  • Martin Hope
    Catskul C++20 是否进行了更改,允许从已知绑定数组“type(&)[N]”转换为未知绑定数组“type(&)[]”? 2025-03-04 06:57:53 +0800 CST
  • Martin Hope
    Stefan Pochmann 为什么 {2,3,10} 和 {x,3,10} (x=2) 的顺序不同? 2025-01-13 23:24:07 +0800 CST
  • Martin Hope
    Chad Feller 在 5.2 版中,bash 条件语句中的 [[ .. ]] 中的分号现在是可选的吗? 2024-10-21 05:50:33 +0800 CST
  • Martin Hope
    Wrench 为什么双破折号 (--) 会导致此 MariaDB 子句评估为 true? 2024-05-05 13:37:20 +0800 CST
  • Martin Hope
    Waket Zheng 为什么 `dict(id=1, **{'id': 2})` 有时会引发 `KeyError: 'id'` 而不是 TypeError? 2024-05-04 14:19:19 +0800 CST
  • Martin Hope
    user924 AdMob:MobileAds.initialize() - 对于某些设备,“java.lang.Integer 无法转换为 java.lang.String” 2024-03-20 03:12:31 +0800 CST

热门标签

python javascript c++ c# java typescript sql reactjs html

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve