小编Ale*_*kov的帖子

重构JavaScript和PHP代码[求职面试]

最近我接受了面试.我有两个任务:

1)重构JavaScript代码

// The library 'jsUtil' has a public function that compares 2 arrays, returning true if
// they're the same. Refactor it so it's more robust, performs better and is easier to maintain.
/**
  @name jsUtil.arraysSame
  @description Compares 2 arrays, returns true if both are comprised of the same items, in the same order
  @param {Object[]} a Array to compare with
  @param {Object[]} b Array to compare to
  @returns {boolean} true if both contain the same items, otherwise false …
Run Code Online (Sandbox Code Playgroud)

javascript php refactoring

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

在PHP中获取ftp_get()的警告

我尝试使用ftp_get()检索文本文件,当我执行脚本时,我收到警告:

ftp_get() [function.ftp-get]: Can't open data connection
Run Code Online (Sandbox Code Playgroud)

有人可以给出一些错误的线索.这是在我以前的托管/服务器上工作,因为我把它移动了它.是否有一些特定的PHP配置.我检查了phpinfo并启用了FTP支持.连接获得资源ID,用户名,密码和ftp主机通过CuteFTP工作.

function _getFtpFile( $fileName = '' ) {
    if($fileName == '') {
        return false;
    }

    $model = $this->getModel();
    $params =& $model->getParams();

    $vebraHost = $params->get('vebra_host');
    $vebraUser = $params->get('vebra_username');
    $vebraPass = $params->get('vebra_password');
    $localFile = JPATH_BASE.'/tmp/tmp.csv';

    // Delete the file in case it exists
    @unlink($localFile);

    // set up basic connection
    $connId = ftp_connect($vebraHost);

    // login with username and password
    $loginResult = ftp_login($connId, $vebraUser, $vebraPass);

    // turn on passive mode transfers
    ftp_pasv($connId, true);

    // try to download …
Run Code Online (Sandbox Code Playgroud)

php ftp

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

实现 GTM 数据层

需要一些有关向我们的开发人员提供与 GTM 代码一起使用的 dataLayer 代码的建议。如果 dataLayer 与容器标记代码一起出现在每个页面上,我如何为域中的许多事件定义所有变量?

dataLayer = [];
Run Code Online (Sandbox Code Playgroud)

我读过使用宏是最好的前进方式,这应该意味着将来与开发人员打交道的时间更少。我不是编码员,所以我很难理解要提供什么代码。与当前缺乏非开发人员的文档作斗争。

该网站是一个非电子商务网站,但我们将许多事件作为微转化进行跟踪。

google-analytics google-tag-manager universal-analytics google-datalayer

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

在服务Angularjs中使用服务

我正在尝试向我的工厂注入一个bootstrap-ui $ modal服务,但是当我这样做时,我得到一个循环依赖问题,而当我没有定义$ modal时.代码如下:

retryModule = angular.module('g4plus.retry-call', ['ui.bootstrap'])

retryModule.factory 'RetryCall', ($q, $rootScope)->
  requests = {}
  failedRequests = {}
  uniqueId = 0
  modalInstance = undefined
  modalClose = true

### Some more code

    alertUser = ()->
    modalInstance = $modal.open
      template: """
        <div class="modal-dialog">
          ... Some more code ...
Run Code Online (Sandbox Code Playgroud)

我如何在工厂内使用$ modal?请不要让我把这个代码放在一个指令中,因为这会破坏目的.如果我能把它放在一个指令中,我就已经完成了这个项目.控制器也是如此.

谢谢!

如果我将$ modal注入我的工厂,循环依赖性错误是:

未捕获错误:[$ injector:cdep]找到循环依赖项:$ modal < - RetryCall < - $ http < - $ compile

javascript twitter-bootstrap angularjs angular-ui angular-ui-bootstrap

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