<commit_before>/* Copyright (c) 2012-2013 The TagSpaces Authors. All rights reserved.
 * Use of this source code is governed by a AGPL3 license that
 * can be found in the LICENSE file. */
/* global Offline */
/**
 * A implementation of the IOAPI for the Chrome/Chromium extensions platform
 * @class WebDAV
 * @memberof IOAPI
 */
define(function(require, exports, module) {
  "use strict";

  // Activating browser specific exports modul
  console.log("Loading web.js..");

  var TSCORE = require("tscore");
  var TSPOSTIO = require("tspostioapi");

  require("webdav");
  require("offlinelib");

  // Offline notification
  Offline.options = {
    checkOnLoad: true,
    //interceptRequests: true,
    reconnect: {
      initialDelay: 3
    },
    requests: true,
    game: false,
    checks: {xhr: {url: 'assets/icon16.png'}}
  };

  Offline.check();

  function showLostConnectionDialog() {
    $('#dialogLostConnection').modal({
      backdrop: 'static',
      show: true,
    });
    $('#dialogLostConnection').draggable({
      handle: ".modal-header"
    });
  }

  Offline.on('confirmed-up', function() {
    $('#dialogLostConnection').modal('hide');
  });
  Offline.on('confirmed-down', showLostConnectionDialog);

  var davClient;
  //exact copy of getAjax with timeout added
  nl.sara.webdav.Client.prototype.getAjax = function(method, url, callback, headers) {
    var /** @type XMLHttpRequest */ ajax = (((typeof Components !== 'undefined') && (typeof Components.classes !== 'undefined')) ? Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Components.interfaces.nsIXMLHttpRequest) : new XMLHttpRequest());
    if (this._username !== null) {
      ajax.open(method, url, true, this._username, this._password);
    } else {
      ajax.open(method, url, true);
    }
    ajax.onreadystatechange = function() {
      nl.sara.webdav.Client.ajaxHandler(ajax, callback);
    };

    ajax.ontimeout = function() {
      ajax.readyState = 4;
      ajax.ajax.status = -1;<commit_msg>merging changes<commit_after>/* Copyright (c) 2012-2013 The TagSpaces Authors. All rights reserved.
 * Use of this source code is governed by a AGPL3 license that
 * can be found in the LICENSE file. */
/* global Offline */
/**
 * A implementation of the IOAPI for the Chrome/Chromium extensions platform
 * @class WebDAV
 * @memberof IOAPI
 */
define(function(require, exports, module) {
  "use strict";

  // Activating browser specific exports modul
  console.log("Loading web.js..");

  var TSCORE = require("tscore");
  var TSPOSTIO = require("tspostioapi");

  require("webdav");
  require("offlinelib");

  // Offline notification
  Offline.options = {
    checkOnLoad: true,
    //interceptRequests: true,
    reconnect: {
      initialDelay: 3
    },
    requests: true,
    game: false,
    checks: {xhr: {url: 'assets/icon16.png'}}
  };

  Offline.check();

  function showLostConnectionDialog() {
    $('#dialogLostConnection').modal({
      backdrop: 'static',
      show: true,
    });
    $('#dialogLostConnection').draggable({
      handle: ".modal-header"
    });
  }

  Offline.on('confirmed-up', function() {
    $('#dialogLostConnection').modal('hide');
  });
  Offline.on('confirmed-down', showLostConnectionDialog);

/*  var run = function() {
    if (Offline.state === 'up') {
      $('#dialogLostConnection').modal('hide');
      Offline.check();
      //});
    } else if (Offline.state === 'down') {
      Offline.check();
      showLostConnectionDialog();
      console.log("Server is down");
    }
  };
  setInterval(run, 5000);*/

  var davClient;
  //exact copy of getAjax with timeout added
  nl.sara.webdav.Client.prototype.getAjax = function(method, url, callback, headers) {
    var /** @type XMLHttpRequest */ ajax = (((typeof Components !== 'undefined') && (typeof Components.classes !== 'undefined')) ? Components.classes["@mozilla.org/xmlextras/xmlhttprequest;1"].createInstance(Components.interfaces.nsIXMLHttpRequest) : new XMLHttpRequest());
    if (this._username !== null) {
      ajax.open(method, url, true, this._username, this._password);
    } else {
      ajax.open(method, url, true);
    }
    ajax.onreadystatechange = function() {
      nl.sara.webdav.Client.ajaxHandler(ajax, callback);
    };

    ajax.ontimeout = function() {
      ajax.readyState = 4;
      ajax.ajax.status = -1;
{'fraction_non_alphanumeric': 0.15207902595910866, 'fraction_numerical': 0.00781070526073972, 'mean_word_length': 3.4247967479674797, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5788787', 'n_tokens_mistral': 1401, 'n_tokens_neox': 1324, 'n_words': 315}