小编Tow*_*kir的帖子

为Winston传输添加不同的格式化程序

我需要为每个传输使用不同类型的格式化程序.

logger = new (winston.Logger)({
    transports: [
        new (winston.transports.LogstashUDP)({
            // some config here. Do noting on formatting
        }),
        new (winston.transports.Mail)({
            // do formatting one way
        }),
        new (winston.transports.File)({
            // write to file as json (maybe format it here)
        }),
        new (winston.transports.Console)({
            // do another formatting
        })
    ]
});
Run Code Online (Sandbox Code Playgroud)

正如我从winston transports 文档中看到的那样,只有Console支持自定义格式化程序.

我正在使用winston-mailer模块邮件和winston-logstash-upd

有没有办法用Winston解决这个问题?或者也许如何围绕其中一个模块创建包装以支持格式化?

javascript formatting logging node.js winston

7
推荐指数
1
解决办法
697
查看次数

ES2015模板在Emacs JavaScript模式下格式不正确

现在,如果我使用ES2015模板,它看起来很丑陋:

 let template =`<div data-value="${text}"
 class="label label-success">
     ${text}
     <span data-nr="${nr}" 
 class="background-switch glyphicon glyphicon-remove"
 style="border-radius:50%;margin-left: 2px; padding: 3px;"
 aria-hidden="true">
    </span>
    </div>`;
Run Code Online (Sandbox Code Playgroud)

有没有办法禁用某个区域的默认缩进设置?或者还有其他方法可以正确格式化ES6模板吗?

javascript emacs

7
推荐指数
0
解决办法
252
查看次数

无法在沙箱环境中加载iframe

我正在尝试在我的网页中启用沙箱加载iframe,但它显示错误:

加载pad时发生错误Uncaught SecurityError:无法在'Document'上设置'domain'属性:禁止为沙盒iframe分配.

嵌入iframe的代码是:

<iframe 
    id="iframe1" 
    name="iframe1" 
    src="http://localhost:9002/p/6dN6dkWRmd" 
    height="700px" width="500px" 
    sandbox="allow-scripts allow-top-navigation">
</iframe>
Run Code Online (Sandbox Code Playgroud)

在iframe javascript中我发现此代码抛出错误:

<iframe 
    id="iframe1" 
    name="iframe1" 
    src="http://localhost:9002/p/6dN6dkWRmd" 
    height="700px" width="500px" 
    sandbox="allow-scripts allow-top-navigation">
</iframe>
Run Code Online (Sandbox Code Playgroud)

有人可以解释这个document.domain正在做什么,我该怎么做才能在沙箱环境中运行这个iframe?

注意:没有沙箱,它工作正常.

javascript iframe jquery etherpad

7
推荐指数
1
解决办法
4125
查看次数

Facebook yoga/react-native flexbox css-layout位置:"固定"支持

为了支持位置:css-layout中的"fixed"(react-native),

使用案例:我有(很多)视频深度嵌套在视图层次结构中 - 想想视频列表,其中任何一个我想全屏.

当前方法(hack):使视频视图与屏幕一样大(css样式中高度宽度的固定值),跟踪视频视图的父布局位置,并为视频提供负边距以正确显示.

期望的方法:想知道是否有一种简单的方法可以做到这一点(如位置:固定)

欢迎任何建议或帮助

css layout fullscreen react-native

7
推荐指数
0
解决办法
1020
查看次数

iOS Safari在与video.js播放器交互时向下滚动

通过第二次单击菜单按钮关闭video.js播放器弹出菜单时iOS(10.3)上的Safari跳跃(向下滚动).

如何重现:

  1. https://codepen.io/mkhazov/full/PjBJvb/.在iPhone或xcode模拟器上的Safari中打开此笔.
  2. 向下滚动
  3. 单击质量选择按钮
  4. 再次单击它.

录制视频:http://www.screencast.com/t/IPkjEo2dxW7

这绝对是移动Safari的bug(没有js代码负责滚动),但我找不到合适的解决方法.

这可以通过这里提出的CSS来修复:

html,
body {
  height: 100%;
  -webkit-overflow-scrolling: touch;
  overflow: auto;
}
Run Code Online (Sandbox Code Playgroud)

但它打破了其他的东西(例如,window.scrollY/$(window).scrollTop())所以我不能使用它.

任何想法/建议将不胜感激.

css safari bug-reporting ios video.js

7
推荐指数
0
解决办法
695
查看次数

Websocket - WebSocket握手期间出错:意外的响应代码:404

我在我的应用程序中使用websocket,当我使用localhost时一切正常.问题开始时,我将localhost更改为我的服务器IP地址,然后我收到此错误: WebSocket握手期间出错:意外的响应代码:404

这是我的httpd.conf

...

听25.48.63.220:80

听25.48.63.220:8081

...

ServerName 25.48.63.220:80

...

我认为我能够连接我的服务器,因为当我键入错误的IP地址时,我不会收到此错误.

还有什么需要改变的?

javascript php apache websocket

6
推荐指数
1
解决办法
2万
查看次数

加载Gif在Safari中不起作用..!

加载GIF在Safari浏览器中不起作用.. :(

<style>
    #divLoading {
        display : none;
    }
    #divLoading.show {
        display : block;
        position : fixed;
        z-index: 100;
        background-image : url('<?php echo base_url('assets/logo/loading2.gif'); ?>');
        background-color:#666;
        opacity : 0.4;
        background-repeat : no-repeat;
        background-position : center;
        left : 0;
        bottom : 0;
        right : 0;
        top : 0;
    }

    #loadinggif.show {
        left : 50%;
        top : 50%;
        position : absolute;
        z-index : 101;
        width : 32px;
        height : 32px;
        margin-left : -16px;
        margin-top : -16px;
    }

    div.content {
       width : 1000px; …
Run Code Online (Sandbox Code Playgroud)

css safari

6
推荐指数
0
解决办法
1281
查看次数

无法在div上应用动态高度-时间轴视图

我正在尝试建立水平时间表。一个月中的任何一天都有很多事件。

因此,当事件更多时,列表项将无法容纳可用高度(来自min-height:),并且出现垂直滚动。

如果我尝试删除min-height整个内容,则会失真。我希望容器在不垂直滚动的情况下占用任何数量的项目。

另外,还有一个问题,当窗口较小时(在Codepen上可以看到),出现水平滚动(预期和需要)。但是,连接器没有占据整个滚动宽度。

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

.timeline__container {
  background: #c0ffee;
  overflow-x: auto;
  display: flex;
  position: relative;
}
.timeline__connector {
  position: absolute;
  width: 100%;
  left: 0;
  top: calc(50% - 4px);
  height: 8px;
  background: #ccc;
}
.timeline__item {
  background: gold;
  min-width: 85px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.timeline__item:nth-child(2n) {
  flex-direction: column-reverse;
}
.timeline__up {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.timeline__down { …
Run Code Online (Sandbox Code Playgroud)

html css flexbox css-grid

6
推荐指数
1
解决办法
286
查看次数

使用javascript设置样式值时使用数字或字符串

有一些css用数字定义的值,例如opacity

我知道在编写CSS时,我会这样做:

#element {
  opacity: 1; /* without a quote mark, just 1 */
}
Run Code Online (Sandbox Code Playgroud)

但是,当我要opacity使用javascript 进行修改时,我应该提供什么?只有0.5还是"0.5"

如果我运行:

typeof document.getElementById('element').style.opacity // returns "srting"
Run Code Online (Sandbox Code Playgroud)

所以我经常在修改字符串时提供字符串。但是有人检查了我的代码,建议我提供如下数字:

document.getElementById('element').style.opacity = 0.5
Run Code Online (Sandbox Code Playgroud)

使用javascript修改它时,实际上应该在这里使用哪种类型?字符串还是数字?

javascript optimization

6
推荐指数
1
解决办法
140
查看次数

在Firefox中更改非活动选择颜色

当我在Firefox中选择一些文本,然后窗口或iframe失去焦点(例如,选择地址栏)时,即使在CSS中指定了其他颜色,选择也会变成灰色。

如何在Firefox中更改禁用选择的颜色?

我尝试过的

<style>::selection { background-color: green; }</style>
<p>lorem ipsum</p>
Run Code Online (Sandbox Code Playgroud)

行为的屏幕截图

编辑:

我想在这里使用的似乎是::inactive-selection,但尚未在firefox中实现。参见https://drafts.c​​sswg.org/css-pseudo-4/#selectordef-inactive-selection

相关错误:https//bugzilla.mozilla.org/show_bug.cgi?id = 706209

有谁知道解决方法?此时,即时通讯正在考虑使用一些JavaScript技巧。任何想法如何做到这一点?

css firefox

6
推荐指数
1
解决办法
217
查看次数