小编Dar*_*ght的帖子

在zip.js完成操作之前,HTML5 ondrop事件返回

我的问题的关键在于我需要异步使用datatransferitemlist,这与规范中描述的功能不一致,即事件结束后您将被锁定在dataTransfer.items集合之外.

https://bugs.chromium.org/p/chromium/issues/detail?id=137231 http://www.whatwg.org/specs/web-apps/current-work/multipage/dnd.html#drag-data -商店

案件罪犯如下.更详细地描述了我的问题和下面的想法.

drophandler: function(event) {
    event.stopPropagation();
    event.preventDefault();
    event.dataTransfer.dropEffect = 'copy';
    zip.workerScriptsPath = "../bower_components/zip.js/WebContent/";
    zip.useWebWorkers = false; // Disabled because it just makes life more complicated
    // Check if files contains just a zip
    if (event.dataTransfer.files[0].name.match(/(?:\.([^.]+))?$/) == 'zip') {
        var reader = new FileReader();
        that = this;
        reader.onload = function(e) {
            that.fire('zipuploaded', e.target.result.split(',')[1]);
        }
        reader.readAsDataURL(event.dataTransfer.files[0]);
        // Rev up that in browser zipping
    } else {
        var that = this;
        var items = event.dataTransfer.items;
        // Async operation, execution falls …
Run Code Online (Sandbox Code Playgroud)

javascript html5 asynchronous drag-and-drop zip.js

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

这个算法的时间复杂度是多少?

编写一个带整数的程序,并打印出所有方法来乘以等于原始数字的较小整数,而不重复多组因子.换句话说,如果您的输出包含4*3,则不应再次打印3*4,因为这将是重复集.请注意,这不是仅要求素数分解.此外,您可以假设输入整数的大小合理; 正确性比效率更重要.PrintFactors(12)12*1 6*2 4*3 3*2*2

public void printFactors(int number) {
    printFactors("", number, number);
}

public void printFactors(String expression, int dividend, int previous) {
    if(expression == "")
        System.out.println(previous + " * 1");

    for (int factor = dividend - 1; factor >= 2; --factor) {
        if (dividend % factor == 0 && factor <= previous) {
            int next = dividend / factor;
            if (next <= factor)
                if (next <= previous)
                    System.out.println(expression + factor + " * " + next);

            printFactors(expression + factor …
Run Code Online (Sandbox Code Playgroud)

algorithm time-complexity number-theory

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