小编Vic*_*ves的帖子

固定位置不适用于移动浏览器

如何在移动浏览器(ios和android)中修复元素位置?元素仍然使用以下代码滚动ios <5和android <4

<html>
 <head>
<style>
     .fixed{
      position:fixed;
      top:0;
      left:0;
    }
</style>
</head>
<body>
     <div class="fixed">
     Hi I m Position Fixed 
     </div>
    <div>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample text<br/>
       sample …
Run Code Online (Sandbox Code Playgroud)

html javascript css android position

20
推荐指数
1
解决办法
5万
查看次数

使用Loopback实现更改密码

我正在尝试使用Loopback的内置方法实现更改密码功能,它工作正常,但它不会更新密码,hash而只是在db中保存纯文本.我loopback-component-passport在这个项目中使用npm包.我搜索了很多网站,但我无法找到实现此功能的正确方法.有谁知道如何做到这一点?

//Change user's pasword
app.post('/change-password', function(req, res, next) {
  var User = app.models.user;
  if (!req.accessToken) return res.sendStatus(401);
  //verify passwords match
  if (!req.body.password || !req.body.confirmation ||
    req.body.password !== req.body.confirmation) {
    return res.sendStatus(400, new Error('Passwords do not match'));
  }

  User.findById(req.accessToken.userId, function(err, user) {
    if (err) return res.sendStatus(404);
    user.hasPassword(req.body.oldPassword, function(err, isMatch) {
      if (!isMatch) {
        return res.sendStatus(401);
      } else {
        user.updateAttribute('password', req.body.password, function(err, user) {
          if (err) return res.sendStatus(404);
          console.log('> password change request processed successfully');
          res.status(200).json({msg: 'password change request …
Run Code Online (Sandbox Code Playgroud)

javascript node.js strongloop loopbackjs

10
推荐指数
1
解决办法
7521
查看次数

使用参数变量将参数传递给ES6箭头函数

我理解箭头函数在ES6中是如何工作的,以及词汇这个,但是我想知道是否有人知道如何将参数传递给箭头函数?

在ES5中,您可以简单地执行以下操作:

function foo( bar, baz ){
    console.log('Args:', arguments.join(', '))
}
Run Code Online (Sandbox Code Playgroud)

但是,在ES6中,如果使用箭头功能,如下所示:

const foo = ( bar, baz ) => {
    console.log('Args:', arguments.join(', '))
}
Run Code Online (Sandbox Code Playgroud)

arguments变量返回一个对象,该对象与参数无关.

所以,我想知道是否有人有办法将参数传递给箭头函数?


编辑

我想也许我应该提供一些关于我想要完成的事情的信息,也许如果以上是不可能的,有人有更好的主意.

基本上,我正在向BluebirdJS asCallback方法添加一个IIEF ,它将确定是否实际提供了回调,如果没有,则返回promise.

下面是ES5中的一个工作示例:

var _ = require('lodash')
var Promise = require('bluebird')

function testFunc( foo, callback ) {
    return new Promise( function ( res, rej ){
        res('You Said: ' + (_.isString( foo ) ? foo : 'NOTHING') )
    })
        .asCallback((function ( args ) {
            return _.findLast(args, function(a) { …
Run Code Online (Sandbox Code Playgroud)

javascript arguments lexical-closures callback ecmascript-6

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

在IOS上的Cordova/Phonegap中播放视频javascript blob

我正在播放在Cordova应用程序包装器中播放在IOS 7上编码为blob的视频.我从本地数据存储中提取视频作为base64编码的字符串,然后将其转回Uint8Array.从那里使用createObjectURL获取blob /文件URI,并将其用作标记的源.这是代码.我使用相同的方法从数据存储区中提取PDF并使用PDF.js渲染它,但是

// ignore the first 12 bytes of the base64EncodedVideo
var base64EncodedVideo = collateral.body.substring(12);
var array= str_to_ab(b64_to_utf8(base64EncodedVideo));
var blob = new Blob([array.buffer], {type: 'video/mp4'});
var url = window.URL.createObjectURL(blob);
$j("#videoContent").prop("src", url);
$j.mobile.changePage('#videoPage', {changeHash: true}); 
Run Code Online (Sandbox Code Playgroud)

....

function str_to_ab(str) { 
    var bufView = new Uint8Array(str.length);
    for (var i=0; i< str.length; i++) {
        bufView[i] = str.charCodeAt(i);
    }
    return bufView;
}

function b64_to_utf8( str ) {
    return (window.atob(str));
}
Run Code Online (Sandbox Code Playgroud)

我已经确认该对象正确地从数据存储区出来并且可以作为文件播放(一旦删除base64编码等).

我也尝试使用数据URI传递base64编码的字符串,但这在IOS上都不起作用.

有什么想法或建议吗?

javascript html5-video ios cordova

5
推荐指数
0
解决办法
960
查看次数

如何更改Intel XDK中的闪屏?

我正在使用英特尔XDK创建一个HTML5应用程序,我想从默认的项目开发中更改启动画面.我该怎么做呢?

如果这不可能,那么如何删除闪屏?

html5 splash-screen intel-xdk

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

在javascript中将名称大写

我有一个将句子大写的函数。但它不能将名称大写,例如,

D'agostino, Fred  
D'agostino, Ralph B.  
D'allonnes, C. Revault  
D'amanda, Christopher 
Run Code Online (Sandbox Code Playgroud)

我期待:

D'Agostino, Fred  
D'Agostino, Ralph B.  
D'Allonnes, C. Revault  
D'Amanda, Christopher 
Run Code Online (Sandbox Code Playgroud)

功能

getCapitalized(str){
    var smallWords = /^(a|an|and|as|at|but|by|en|for|if|in|nor|of|on|or|per|the|to|vs?\.?|via)$/i;
    return str.replace(/[A-Za-z0-9\u00C0-\u00FF]+[^\s-]*/g, function (match, index, title) {
      if (index > 0 && index + match.length !== title.length &&
        match.search(smallWords) > -1 && title.charAt(index - 2) !== ":" &&
        (title.charAt(index + match.length) !== '-' || title.charAt(index - 1) === '-') &&
        (title.charAt(index + match.length) !== "'" || title.charAt(index - 1) === "'") …
Run Code Online (Sandbox Code Playgroud)

javascript typescript

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

如何使用 AngularJS 获取具有唯一值的数组

我有一个包含重复项的数组。如何获得具有唯一项的数组?

a= [{id: "1", campus: "c1"}, {id: "1", campus: "c1"}, {id: "2", campus: "c2"}, {id: "2", campus: "c2"}]
Run Code Online (Sandbox Code Playgroud)

我想要具有独特对象的结果

a= [{id: "1", campus: "c1"}, {id: "2", campus: "c2"}]
Run Code Online (Sandbox Code Playgroud)

javascript angularjs

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

如何使用jquery和css隐藏和淡化div

我有一个下面的HTML,我想让这些下面的div显示在彼此之上,"world"被隐藏,而id为"hello"的div淡出,而id为"world"的div此后消失了?

我正在使用jquery和css:

<div id="main">
  <div id="hello">test</div>
  <div id="world">test</div>
</div>
Run Code Online (Sandbox Code Playgroud)

html css jquery

0
推荐指数
1
解决办法
449
查看次数