<commit_before>//================================================================
// RS_Admob.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2016 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
 * RS_Admob.js
 * @plugindesc This plugin allows you to show up the Ads by using Google AdMob <RS_Admob>
 * @author biud436
 *
 * @param [Android]
 *
 * @param android Banner ID
 * @text Banner
 * @parent [Android]
 * @desc Banner ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param android Interstitial Ad ID
 * @text Interstitial
 * @parent [Android]
 * @desc Interstitial Ad ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param android Reward Video Ad ID
 * @text Reward Video
 * @parent [Android]
 * @desc Reward Video Ad ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param [IOS]
 *
 * @param ios Banner ID
 * @text Banner
 * @parent [IOS]
 * @desc Banner ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param ios Interstitial Ad ID
 * @text Interstitial
 * @parent [IOS]
 * @desc Interstitial Ad ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param ios Reward Video Ad ID
 * @text Reward Video
 * @parent [IOS]
 * @desc Reward Video Ad ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param [Settings]
 *
 * @param bannerAtTop
 * @parent [Settings]
 * @type boolean
 * @desc The banner shows up at the top of the screen.
 * @default false
 * @on true
 * @off false
 *
 * @param Testing
 * @parent [Settings]
 * @type boolean
 * @desc Show up the test ads.
 * @default false
 * @on true
 * @off false
 *
 * @param [Rewards]
 *
 * @param Fail Event
 * @parent [Rewards]
 * @text Fail Event
 * @type note
 * @desc Specify to run the certain code block when failed to load reward video.
 * @default "console.log(\"ad fail\");"
 *
 * @param Load Event
 * @parent [Rewards]
 * @text Load Event
 * @type note
 * @desc Specify to run the certain code block when loaded reward video.
 * @default "console.log(\"ad loaded\");"
 *
 * @param Close Event
 * @parent [Rewards]
 * @text Close Event
 * @type note
 * @desc Specify to run the certain code block when closing reward video.
 * @default "// reward\nconsole.log(\"reward\");"
 *
 * @param Reward Event
 * @parent [Rewards]
 * @text Reward Event
 * @type note
 * @desc Specify to run the certain reward code block after ended the reward video.
 * @default "console.log(\"reward : +100 gold\");"
 *
 * @help
 *
 * 1. Join and setup the AdMob:
 * - You must set up the id of the ads type at the google AdMob setup page.
 * If its id doesn't exist and invalid, then it doesn't work properly so you must
 * check it.
 *
 * 2. Check whether the internet connects:
 * - You should also connect the internet while the ads is showing up. if not,
 * then Ads-View may not seem create it.
 *
 * =============================================================================
 * Plugin Commands
 * -----------------------------------------------------------------------------
 * There are four functions here. you can use them. They could be created new Ads
 * and could already be hidden the created Ads.
 *
 * Banner show
 * Banner remove
 * Interstitial show
 *
 * ShowRewardVideo
 *
 * CheckInternet url
 *
 * =============================================================================
 * Cordova
 * -----------------------------------------------------------------------------
 * You must add plugin using cordova CLI.
 *
 *    cordova plugin add cordova-plugin-admob-free --save --variable ADMOB_APP_ID="<YOUR_ANDROID_ADMOB_APP_ID_AS_FOUND_IN_ADMOB>"
 *
 * Notice that you have to change the text called <YOUR_ANDROID_ADMOB_APP_ID_AS_FOUND_IN_ADMOB>
 *
 * =============================================================================
 * Change Log
 * -----------------------------------------------------------------------------
 * 2016.08.06 (v1.0.0) - First Release
 * 2016.10.05 (v1.0.1) - Added the function that could be checking the internet.
 * 2019.11.06 (v1.0.2) :
 * - Fixed the bug that is not working.
 * - Changed as the cordova plugin(extension) that works fine.
 * - Added reward video.
 */

var Imported = Imported || {};
Imported.RS_Admob = true;

var RS = RS || {};
RS.Admob = RS.Admob || {};

(function () {

  var parameters = $plugins.filter(function (i) {
    return i.description.contains('<RS_Admob>');
  });

  parameters = (parameters.length > 0) && parameters[0].parameters;

  if(Utils.isNwjs()) {
    console.error('This plugin is not available on the PC.');
    return false;
  }

  var jsonParse = function (str) {
    var retData = JSON.parse(str, function (k, v) {
      try { return jsonParse(v); } catch (e) { return v; }
    });
    return retData;
  };

  // Setting plugin parameters
  RS.Admob.Params = {
    andBannerID  : parameters['android Banner ID'],
    andInterstitialID  : parameters['android Interstitial Ad ID'],
    andRewardVideoID   : parameters["android Reward Video Ad ID "],
    iosBannerID  : parameters['ios Banner ID'],
    iosInterstitialID  : parameters['ios Interstitial Ad ID'],
    iosRewardVideoID   : parameters["ios Reward Video Ad ID "],
    isTesting  : Boolean(parameters['Testing'] === 'true'),
    bannerAtTop  : Boolean(parameters['bannerAtTop'] === 'true'),
    failEvent  : jsonParse(parameters["Fail Event"]),
    loadEvent  : jsonParse(parameters["Load Event"]),
    closeEvent   : jsonParse(parameters["Close Event"]),
    rewardEvent   : jsonParse(parameters["Reward Event"]),
    failMsg : "Cannot be found AdMob on the current device.",
  };

  // Reward Event
  RS.Admob.Event = {
    fail: function(event) {
      eval(RS.Admob.Params.failEvent);
    },
    load: function(event) {
      eval(RS.Admob.Params.loadEvent);
    },
    close: function(event) {
      eval(RS.Admob.Params.closeEvent);
    },
    reward: function(event) {
      eval(RS.Admob.Params.rewardEvent);
    },
  };

  RS.Admob.getAppID = function () {

    "use strict";

    var isAndroid = /(android)/i.test(navigator.userAgent);
    var isIOS = /(iPhone|iPad|iPod)/i.test(navigator.userAgent);
    var platformName = isAndroid ? 'and' : (isIOS ? 'ios' : '');

    var result = {
      'banner': RS.Admob.Params[`${platformName}BannerID`] || '',
      'interstitial': RS.Admob.Params[`${platformName}InterstitialID`] || '',
      'rewardVideo': RS.Admob.Params[`${platformName}RewardVideoID`] || '',
    };

    return result;
  };

  /**
   * @method RS.Admob.init
   */
  RS.Admob.init = function () {

    if(window.plugins && !window.plugins.AdMob) {
      throw new Error(RS.Admob.Params.failMsg);
    }

    /**
     * @see https://ratson.github.io/cordova-plugin-admob-free/function/index.html#static-function-setOptions
     */
    var admobid = RS.Admob.getAppID();

    window.plugins.AdMob.setOptions( {
      publisherId: admobid.banner,
      interstitialAdId: admobid.interstitial,
      bannerAtTop: RS.Admob.Params.bannerAtTop,
      overlap: true,
      offsetTopBar: false,
      isTesting: RS.Admob.Params.isTesting,
      autoShow: true
    });

    admob.banner.config({
      id: RS.Admob.getAppID().banner,
      isTesting: RS.Admob.Params.isTesting,
      autoShow: true,
    });
    admob.banner.prepare();

    admob.interstitial.config({
      id: RS.Admob.getAppID().interstitial,
      isTesting: true,
      autoShow: false,
    })
    admob.interstitial.prepare();

    document.addEventListener('admob.rewardvideo.events.LOAD_FAIL', RS.Admob.Event.fail);
    document.addEventListener('admob.rewardvideo.events.LOAD', RS.Admob.Event.load);
    document.addEventListener('admob.rewardvideo.events.CLOSE', RS.Admob.Event.close);
    document.addEventListener('admob.rewardvideo.events.REWARD', RS.Admob.Event.reward);

  };

  RS.Admob.remove = function() {
    document.removeEventListener('admob.rewardvideo.events.LOAD_FAIL', RS.Admob.Event.fail);
    document.removeEventListener('admob.rewardvideo.events.LOAD', RS.Admob.Event.load);
    document.removeEventListener('admob.rewardvideo.events.CLOSE', RS.Admob.Event.close);
  };

  RS.Admob.showBanner = function (bannerAtTop) {
    if(!window.plugins && !window.plugins.AdMob) console.error(RS.Admob.Params.failMsg);

    admob.banner.config({
      id: RS.Admob.getAppID().banner,
      isTesting: RS.Admob.Params.isTesting,
      bannerAtTop: bannerAtTop,
      autoShow: true,
    });

    admob.banner.prepare();
    admob.banner.show();
  };

  RS.Admob.destroyBanner = function () {
    if(!window.plugins && !window.plugins.AdMob) console.error(RS.Admob.Params.failMsg);
    admob.banner.hide();
  };

  RS.Admob.showInterstitial = function () {
    if(!window.plugins && !window.plugins.AdMob) console.error(RS.Admob.Params.failMsg);
    admob.interstitial.config({
      id: RS.Admob.getAppID().interstitial,
      isTesting: true,
      autoShow: false,
    })
    admob.interstitial.prepare();
    admob.interstitial.show();
  };

  RS.Admob.showRewardVideo = function() {
    var admobid = RS.Admob.getAppID;

    admob.rewardvideo.config({
      id: admobid.rewardVideo,
      isTesting: RS.Admob.Params.isTesting,
      autoShow: true
    });

    admob.rewardvideo.prepare();
    admob.rewardvideo.show();
  };

  Utils.checkInternet = function(url) {
    var xhr = new XMLHttpRequest();
    xhr.open('GET', url);
    xhr.onload = function() {
      if (xhr.status < 400) {
      }
    }.bind(this);
    xhr.onerror = function(err) {
      SceneManager.exit();
    }.bind(this);
    xhr.send();
  };

  var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function(command, args) {
    alias_Game_Interpreter_pluginCommand.call(this, command, args);

    if(command === "Banner" || command === "배너광고") {
      switch (args[0]) {
        case 'show':
        case '표시':
        var bannerAtTop
        if(args[1] === '' || args[1] === null || args[1] === undefined) {
          bannerAtTop = RS.Admob.Params.bannerAtTop;
        } else {
          bannerAtTop = Boolean(args[1] === 'true');
        }
        RS.Admob.showBanner(bannerAtTop);
        break;
        case 'remove':
        case '제거':
        RS.Admob.destroyBanner();
        break;
      }
    }

    if(command === "Interstitial" || command === "전면광고") {
      switch (args[0]) {
        case 'show':
        case '표시':
        RS.Admob.showInterstitial();
        break;
      }

      if(command === "RewardVideoAd" || command === "보상형광고") {
        switch (args[0]) {

          case 'show':
          case '표시':
          break;

        }
      }

      if(command === "CheckInternet" || command === "인터넷체크") {
        Utils.checkInternet(args[0]);
      }

    };

    if(command === "ShowRewardVideo") {
      RS.Admob.showRewardVideo();
    }

  };

  if(( /(ipad|iphone|ipod|android)/i.test(navigator.userAgent) )) {
    document.addEventListener('deviceready', RS.Admob.init, false);
  } else {
    RS.Admob.init();
  }

})();
<commit_msg>remove event handler<commit_after>//================================================================
// RS_Admob.js
// ---------------------------------------------------------------
// The MIT License
// Copyright (c) 2016 biud436
// ---------------------------------------------------------------
// Free for commercial and non commercial use.
//================================================================
/*:
 * RS_Admob.js
 * @plugindesc This plugin allows you to show up the Ads by using Google AdMob <RS_Admob>
 * @author biud436
 *
 * @param [Android]
 *
 * @param android Banner ID
 * @text Banner
 * @parent [Android]
 * @desc Banner ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param android Interstitial Ad ID
 * @text Interstitial
 * @parent [Android]
 * @desc Interstitial Ad ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param android Reward Video Ad ID
 * @text Reward Video
 * @parent [Android]
 * @desc Reward Video Ad ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param [IOS]
 *
 * @param ios Banner ID
 * @text Banner
 * @parent [IOS]
 * @desc Banner ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param ios Interstitial Ad ID
 * @text Interstitial
 * @parent [IOS]
 * @desc Interstitial Ad ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param ios Reward Video Ad ID
 * @text Reward Video
 * @parent [IOS]
 * @desc Reward Video Ad ID
 * @default ca-app-pub-xxxxxxxxxxx/xxxxxxxxxxx
 *
 * @param [Settings]
 *
 * @param bannerAtTop
 * @parent [Settings]
 * @type boolean
 * @desc The banner shows up at the top of the screen.
 * @default false
 * @on true
 * @off false
 *
 * @param Testing
 * @parent [Settings]
 * @type boolean
 * @desc Show up the test ads.
 * @default false
 * @on true
 * @off false
 *
 * @param [Rewards]
 *
 * @param Fail Event
 * @parent [Rewards]
 * @text Fail Event
 * @type note
 * @desc Specify to run the certain code block when failed to load reward video.
 * @default "console.log(\"ad fail\");"
 *
 * @param Load Event
 * @parent [Rewards]
 * @text Load Event
 * @type note
 * @desc Specify to run the certain code block when loaded reward video.
 * @default "console.log(\"ad loaded\");"
 *
 * @param Close Event
 * @parent [Rewards]
 * @text Close Event
 * @type note
 * @desc Specify to run the certain code block when closing reward video.
 * @default "// reward\nconsole.log(\"reward\");"
 *
 * @param Reward Event
 * @parent [Rewards]
 * @text Reward Event
 * @type note
 * @desc Specify to run the certain reward code block after ended the reward video.
 * @default "console.log(\"reward : +100 gold\");"
 *
 * @help
 *
 * 1. Join and setup the AdMob:
 * - You must set up the id of the ads type at the google AdMob setup page.
 * If its id doesn't exist and invalid, then it doesn't work properly so you must
 * check it.
 *
 * 2. Check whether the internet connects:
 * - You should also connect the internet while the ads is showing up. if not,
 * then Ads-View may not seem create it.
 *
 * =============================================================================
 * Plugin Commands
 * -----------------------------------------------------------------------------
 * There are four functions here. you can use them. They could be created new Ads
 * and could already be hidden the created Ads.
 *
 * Banner show
 * Banner remove
 * Interstitial show
 *
 * ShowRewardVideo
 *
 * CheckInternet url
 *
 * =============================================================================
 * Cordova
 * -----------------------------------------------------------------------------
 * You must add plugin using cordova CLI.
 *
 *    cordova plugin add cordova-plugin-admob-free --save --variable ADMOB_APP_ID="<YOUR_ANDROID_ADMOB_APP_ID_AS_FOUND_IN_ADMOB>"
 *
 * Notice that you have to change the text called <YOUR_ANDROID_ADMOB_APP_ID_AS_FOUND_IN_ADMOB>
 *
 * =============================================================================
 * Change Log
 * -----------------------------------------------------------------------------
 * 2016.08.06 (v1.0.0) - First Release
 * 2016.10.05 (v1.0.1) - Added the function that could be checking the internet.
 * 2019.11.06 (v1.0.2) :
 * - Fixed the bug that is not working.
 * - Changed as the cordova plugin(extension) that works fine.
 * - Added reward video.
 */

var Imported = Imported || {};
Imported.RS_Admob = true;

var RS = RS || {};
RS.Admob = RS.Admob || {};

(function () {

  var parameters = $plugins.filter(function (i) {
    return i.description.contains('<RS_Admob>');
  });

  parameters = (parameters.length > 0) && parameters[0].parameters;

  if(Utils.isNwjs()) {
    console.error('This plugin is not available on the PC.');
    return false;
  }

  var jsonParse = function (str) {
    var retData = JSON.parse(str, function (k, v) {
      try { return jsonParse(v); } catch (e) { return v; }
    });
    return retData;
  };

  // Setting plugin parameters
  RS.Admob.Params = {
    andBannerID  : parameters['android Banner ID'],
    andInterstitialID  : parameters['android Interstitial Ad ID'],
    andRewardVideoID   : parameters["android Reward Video Ad ID "],
    iosBannerID  : parameters['ios Banner ID'],
    iosInterstitialID  : parameters['ios Interstitial Ad ID'],
    iosRewardVideoID   : parameters["ios Reward Video Ad ID "],
    isTesting  : Boolean(parameters['Testing'] === 'true'),
    bannerAtTop  : Boolean(parameters['bannerAtTop'] === 'true'),
    failEvent  : jsonParse(parameters["Fail Event"]),
    loadEvent  : jsonParse(parameters["Load Event"]),
    closeEvent   : jsonParse(parameters["Close Event"]),
    rewardEvent   : jsonParse(parameters["Reward Event"]),
    failMsg : "Cannot be found AdMob on the current device.",
  };

  // Reward Event
  RS.Admob.Event = {
    fail: function(event) {
      eval(RS.Admob.Params.failEvent);
    },
    load: function(event) {
      eval(RS.Admob.Params.loadEvent);
    },
    close: function(event) {
      eval(RS.Admob.Params.closeEvent);
    },
    reward: function(event) {
      eval(RS.Admob.Params.rewardEvent);
    },
  };

  RS.Admob.getAppID = function () {

    "use strict";

    var isAndroid = /(android)/i.test(navigator.userAgent);
    var isIOS = /(iPhone|iPad|iPod)/i.test(navigator.userAgent);
    var platformName = isAndroid ? 'and' : (isIOS ? 'ios' : '');

    var result = {
      'banner': RS.Admob.Params[`${platformName}BannerID`] || '',
      'interstitial': RS.Admob.Params[`${platformName}InterstitialID`] || '',
      'rewardVideo': RS.Admob.Params[`${platformName}RewardVideoID`] || '',
    };

    return result;
  };

  /**
   * @method RS.Admob.init
   */
  RS.Admob.init = function () {

    if(window.plugins && !window.plugins.AdMob) {
      throw new Error(RS.Admob.Params.failMsg);
    }

    /**
     * @see https://ratson.github.io/cordova-plugin-admob-free/function/index.html#static-function-setOptions
     */
    var admobid = RS.Admob.getAppID();

    window.plugins.AdMob.setOptions( {
      publisherId: admobid.banner,
      interstitialAdId: admobid.interstitial,
      bannerAtTop: RS.Admob.Params.bannerAtTop,
      overlap: true,
      offsetTopBar: false,
      isTesting: RS.Admob.Params.isTesting,
      autoShow: true
    });

    admob.banner.config({
      id: RS.Admob.getAppID().banner,
      isTesting: RS.Admob.Params.isTesting,
      autoShow: true,
    });
    admob.banner.prepare();

    admob.interstitial.config({
      id: RS.Admob.getAppID().interstitial,
      isTesting: true,
      autoShow: false,
    })
    admob.interstitial.prepare();

    document.addEventListener('admob.rewardvideo.events.LOAD_FAIL', RS.Admob.Event.fail);
    document.addEventListener('admob.rewardvideo.events.LOAD', RS.Admob.Event.load);
    document.addEventListener('admob.rewardvideo.events.CLOSE', RS.Admob.Event.close);
    document.addEventListener('admob.rewardvideo.events.REWARD', RS.Admob.Event.reward);

  };

  RS.Admob.remove = function() {
    document.removeEventListener('admob.rewardvideo.events.LOAD_FAIL', RS.Admob.Event.fail);
    document.removeEventListener('admob.rewardvideo.events.LOAD', RS.Admob.Event.load);
    document.removeEventListener('admob.rewardvideo.events.CLOSE', RS.Admob.Event.close);
    document.removeEventListener('admob.rewardvideo.events.REWARD', RS.Admob.Event.reward);
  };

  RS.Admob.showBanner = function (bannerAtTop) {
    if(!window.plugins && !window.plugins.AdMob) console.error(RS.Admob.Params.failMsg);

    admob.banner.config({
      id: RS.Admob.getAppID().banner,
      isTesting: RS.Admob.Params.isTesting,
      bannerAtTop: bannerAtTop,
      autoShow: true,
    });

    admob.banner.prepare();
    admob.banner.show();
  };

  RS.Admob.destroyBanner = function () {
    if(!window.plugins && !window.plugins.AdMob) console.error(RS.Admob.Params.failMsg);
    admob.banner.hide();
  };

  RS.Admob.showInterstitial = function () {
    if(!window.plugins && !window.plugins.AdMob) console.error(RS.Admob.Params.failMsg);
    admob.interstitial.config({
      id: RS.Admob.getAppID().interstitial,
      isTesting: true,
      autoShow: false,
    })
    admob.interstitial.prepare();
    admob.interstitial.show();
  };

  RS.Admob.showRewardVideo = function() {
    var admobid = RS.Admob.getAppID;

    admob.rewardvideo.config({
      id: admobid.rewardVideo,
      isTesting: RS.Admob.Params.isTesting,
      autoShow: true
    });

    admob.rewardvideo.prepare();
    admob.rewardvideo.show();
  };

  Utils.checkInternet = function(url) {
    var xhr = new XMLHttpRequest();
    xhr.open('GET', url);
    xhr.onload = function() {
      if (xhr.status < 400) {
      }
    }.bind(this);
    xhr.onerror = function(err) {
      SceneManager.exit();
    }.bind(this);
    xhr.send();
  };

  var alias_Game_Interpreter_pluginCommand = Game_Interpreter.prototype.pluginCommand;
  Game_Interpreter.prototype.pluginCommand = function(command, args) {
    alias_Game_Interpreter_pluginCommand.call(this, command, args);

    if(command === "Banner" || command === "배너광고") {
      switch (args[0]) {
        case 'show':
        case '표시':
        var bannerAtTop
        if(args[1] === '' || args[1] === null || args[1] === undefined) {
          bannerAtTop = RS.Admob.Params.bannerAtTop;
        } else {
          bannerAtTop = Boolean(args[1] === 'true');
        }
        RS.Admob.showBanner(bannerAtTop);
        break;
        case 'remove':
        case '제거':
        RS.Admob.destroyBanner();
        break;
      }
    }

    if(command === "Interstitial" || command === "전면광고") {
      switch (args[0]) {
        case 'show':
        case '표시':
        RS.Admob.showInterstitial();
        break;
      }

      if(command === "RewardVideoAd" || command === "보상형광고") {
        switch (args[0]) {

          case 'show':
          case '표시':
          break;

        }
      }

      if(command === "CheckInternet" || command === "인터넷체크") {
        Utils.checkInternet(args[0]);
      }

    };

    if(command === "ShowRewardVideo") {
      RS.Admob.showRewardVideo();
    }

  };

  if(( /(ipad|iphone|ipod|android)/i.test(navigator.userAgent) )) {
    document.addEventListener('deviceready', RS.Admob.init, false);
  } else {
    RS.Admob.init();
  }

})();
<|endoftext|>


<commit_before>//Copyright {2016} {NIIT Limited, Wipro Limited}
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//
//   Name of Developers  Abhinav Kareer,Sunil Mekala, Pratik Sinha, Anil Sawant, Chandu
//
var express = require('express'),
		Reservoir = require('reservoir'),
		router = express.Router(),
		Profile =require("../models/profile"),
		Tournament =require("../models/tournament");

router.route('/tournaments')
	  .get(function(req, res){
	    Tournament.find()
	      .populate("leg.topics")
	          .exec(function(err,tournaments){
	            if(err){
	                return res.send(err);
	              }
	            return res.json(tournaments);
	          });
	 	});

router.route('/tournament/:tId')
	  .get(function(req , res){
			Tournament.findById(req.params.tId)
	      .populate("leg.topics")
	          .exec(function(err,tournaments){
	            if(err){
	                return res.send(err);
	              }
	            return res.json(tournaments);
	          });

	  });

module.exports= router;
<commit_msg>added service to fetch single tournament Object with full topic detail<commit_after>//Copyright {2016} {NIIT Limited, Wipro Limited}
//
//   Licensed under the Apache License, Version 2.0 (the "License");
//   you may not use this file except in compliance with the License.
//   You may obtain a copy of the License at
//
//       http://www.apache.org/licenses/LICENSE-2.0
//
//   Unless required by applicable law or agreed to in writing, software
//   distributed under the License is distributed on an "AS IS" BASIS,
//   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//   See the License for the specific language governing permissions and
//   limitations under the License.
//
//   Name of Developers  Abhinav Kareer,Sunil Mekala, Pratik Sinha, Anil Sawant, Chandu
//
var express = require('express'),
		Reservoir = require('reservoir'),
		router = express.Router(),
		Profile =require("../models/profile"),
		Tournament =require("../models/tournament");

router.route('/tournaments')
	  .get(function(req, res){
	    Tournament.find()
	      .populate("topics.name")
	          .exec(function(err,tournaments){
	            if(err){
	                return res.send(err);
	              }
	            return res.json(tournaments);
	          });
	 	});

router.route('/tournament/:tId')
	  .get(function(req , res){
			Tournament.findById(req.params.tId)
	      .populate("topics.name")
	          .exec(function(err,tournaments){
	            if(err){
	                return res.send(err);
	              }
	            return res.json(tournaments);
	          });

	  });

module.exports= router;
<|endoftext|>


<commit_before>/* global Marionette, Handlebars */

/**
 *
 * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

(function(OCA, Marionette, Handlebars) {

	'use strict';

	OCA.SpreedMe = OCA.SpreedMe || {};
	OCA.SpreedMe.Views = OCA.SpreedMe.Views || {};

	var TEMPLATE_TAB_HEADER_VIEW =
		'{{label}}';

	var TEMPLATE_TAB_VIEW =
		'
' +
		'
' +
		'
' +
		'
' +
		'
' +
		'
';

	var TabHeaderView  = Marionette.View.extend({

		tagName: 'li',
		className: 'tabHeader',

		template: Handlebars.compile(TEMPLATE_TAB_HEADER_VIEW),
		templateContext: function() {
			return {
				label: this.getOption('label')
			};
		},

		events: {
			'click': function() {
				this.triggerMethod('click:tabHeader', this.getOption('tabId'));
			}
		},

		setSelected: function(selected) {
			if (selected) {
				this.$el.addClass('selected');
			} else {
				this.$el.removeClass('selected');
			}
		}

	});

	var TabHeadersView  = Marionette.View.extend({

		tagName: 'ul',
		className: 'tabHeaders',

		// The tab headers are added dynamically using regions, so there is
		// nothing to be rendered with a template.
		template: _.noop,

		childViewEvents: {
			'click:tabHeader': 'selectTabHeader'
		},

		initialize: function() {
			// The tabIds in priority and then insertion order.
			this._tabIds = [];
		},

		addTabHeader: function(tabId, tabHeaderOptions) {
			var tabHeaderId = 'tabHeader' + tabId.charAt(0).toUpperCase() + tabId.substr(1);

			tabHeaderOptions.id = tabHeaderId;
			// The "tabId" will be passed by the TabHeaderView when triggering
			// "click:tabHeader" events.
			tabHeaderOptions.tabId = tabId;

			tabHeaderOptions.priority = tabHeaderOptions.priority || 0;

			var tabHeaderView = new TabHeaderView(tabHeaderOptions);

			var tabHeaderIndex = this._getIndexForTabHeaderPriority(tabHeaderOptions.priority);

			this._tabIds.splice(tabHeaderIndex, 0, tabId);

			// When adding a region and showing a view on it the target element
			// of the region must exist in the parent view. Therefore, a dummy
			// target element, which will be replaced with the tab header
			// itself, has to be added to the parent view.
			var dummyElement = '
';
			if (tabHeaderIndex === 0) {
				this.$el.prepend(dummyElement);
			} else {
				// When two tab headers have the same priority the new one is
				// added after the existing one.
				this.$el.children().eq(tabHeaderIndex-1).after(dummyElement);
			}

			this.addRegion(tabId, { el: '#' + tabHeaderId, replaceElement: true });
			this.showChildView(tabId, tabHeaderView);
		},

		/**
		 * Return the insertion index for a tab header based on its priority.
		 *
		 * Tab headers with higher priorities go before tab headers with lower
		 * priorities; if the priority is the same as one or more of the current
		 * tab headers the new tab header goes after the last of them.
		 *
		 * @param int priority the priority to get its insertion index.
		 * @return int the insertion index.
		 */
		_getIndexForTabHeaderPriority: function(priority) {
			// this.getRegions() returns an object that acts as a map, but it
			// has no "length" property; _.map creates an array, thus ensuring
			// that there is a "length" property to know the current number of
			// tab headers.
			var currentPriorities = _.map(this.getRegions(), function(region) {
				return region.currentView.getOption('priority');
			});

			// By default sort() converts the values to strings and sorts them
			// in ascending order using their Unicode value; a custom function
			// must be used to sort them by their numerical value instead.
			currentPriorities.sort(function(a, b) {
				return a - b;
			}).reverse();

			var index = _.findIndex(currentPriorities, function(currentPriority) {
				return priority > currentPriority;
			});

			if (index === -1) {
				return currentPriorities.length;
			}

			return index;
		},

		/**
		 * Removes the tab header for the given tabId.
		 *
		 * If the tab header to be removed is the one currently selected and
		 * there are other tab headers the next one (in priority and then
		 * insertion order) is automatically selected; if the tab header to be
		 * removed is the last one, then the previous one is selected instead.
		 *
		 * @param string tabId the ID of the tab.
		 */
		removeTabHeader: function(tabId) {
			var tabIdIndex = _.indexOf(this._tabIds, tabId);

			// If the tab header to be removed is the one currently selected
			// then select the next tab header or, if it is the last tab header,
			// the previous one (or none if there are no other tab headers).
			if (this._currentTabId === tabId) {
				if (this._tabIds.length <= 1) {
					delete this._currentTabId;
				} else if (tabIdIndex === (this._tabIds.length - 1)) {
					this.selectTabHeader(this._tabIds[tabIdIndex - 1]);
				} else {
					this.selectTabHeader(this._tabIds[tabIdIndex + 1]);
				}
			}

			this._tabIds.splice(tabIdIndex, 1);

			var removedRegion = this.removeRegion(tabId);
			// Remove the dummy target element that was replaced by the view
			// when it was shown and that is restored back when the region is
			// removed.
			removedRegion.el.remove();
		},

		selectTabHeader: function(tabId) {
			if (this._currentTabId !== undefined) {
				this.getChildView(this._currentTabId).setSelected(false);
			}

			this._currentTabId = tabId;

			this.getChildView(this._currentTabId).setSelected(true);

			this.triggerMethod('select:tabHeader', tabId);
		}

	});

	/**
	 * View for tabs (headers and content).
	 *
	 * A TabView contains a set of tab headers and a content area. When a header
	 * is selected its associated content view is shown in the content area;
	 * otherwise its content is hidden (although the header is always shown).
	 */
	var TabView = Marionette.View.extend({

		tagName: 'div',
		className: 'tabs',

		regions: {
			tabHeaders: '.tabHeaders',
			tabContent: '.tab'
		},

		template: Handlebars.compile(TEMPLATE_TAB_VIEW),

		initialize: function() {
			this._tabHeadersView = null;
			this._tabContentViews = {};
		},

		onDestroy: function() {
			_.each(this._tabContentViews, function(tabContentView) {
				// Explicitly destroy all the tab content views, as some of them
				// may be detached from the TabView.
				tabContentView.destroy();
			});
		},

		/**
		 * Adds a new tab.
		 *
		 * The tabHeaderOptions must provide a 'label' string which will be
		 * rendered as the tab header. Optionally, it can provide a 'priority'
		 * integer to set the order of the tab header with respect to the other
		 * tab headers (tabs with higher priorities appear before tabs with
		 * lower priorities; tabs with the same priority are sorted based on
		 * their insertion order); if it is not explicitly set the value 0 is
		 * used. If needed, the tabHeaderOptions can provide other values that
		 * will override the default TabHeaderView properties (for example, it
		 * can provide an 'onRender' function to extend the default rendering of
		 * the header).
		 *
		 * The TabView takes ownership of the given content view, and it will
		 * destroy it when the TabView is destroyed, except if the content view
		 * is removed first.
		 *
		 * @param string tabId the ID of the tab.
		 * @param Object tabHeaderOptions the options for the constructor of the
		 *        TabHeaderView that will be added as the header of the tab.
		 * @param Marionette.View tabContentView the View to be shown when the
		 *        tab is selected.
		 */
		addTab: function(tabId, tabHeaderOptions, tabContentView) {
			if (this._tabHeadersView === null) {
				this._tabHeadersView = new TabHeadersView();
				this.showChildView('tabHeaders', this._tabHeadersView, { replaceElement: true });
			}

			this._tabHeadersView.addTabHeader(tabId, tabHeaderOptions);

			this._tabContentViews[tabId] = tabContentView;

			if (Object.keys(this._tabContentViews).length === 1) {
				this.selectTab(tabId);
			}
		},

		/**
		 * Removes the tab for the given tabId.
		 *
		 * If the tab to be removed is the one currently selected and there are
		 * other tabs the next one (in priority and then insertion order) is
		 * automatically selected; if the tab to be removed is the last one,
		 * then the previous one is selected instead. If there are no other tabs
		 * then this TabView is simply emptied.
		 *
		 * In any case the content view given when the tab was added is
		 * returned; this TabView will no longer have ownership of the content
		 * view, and thus the content view must be explicitly destroyed when no
		 * longer needed.
		 *
		 * @param string tabId the ID of the tab to remove.
		 * @return Marionette.View the content view of the removed tab.
		 */
		removeTab: function(tabId) {
			if (!this._tabContentViews.hasOwnProperty(tabId)) {
				return undefined;
			}

			var removedTabContentView = this._tabContentViews[tabId];

			this._tabHeadersView.removeTabHeader(tabId);

			delete this._tabContentViews[tabId];

			// Removing the tab header selects a new tab header, which in turn
			// changes the content view, except when there are no other tabs. In
			// that case the content view would be being shown in the region and
			// thus would have to be removed from there.
			if (Object.keys(this._tabContentViews).length === 0) {
				this.getRegion('tabContent').empty({preventDestroy: true});
			}

			return removedTabContentView;
		},

		/**
		 * Select the tab associated to the given tabId.
		 *
		 * @param string tabId the ID of the tab to select.
		 */
		selectTab: function(tabId) {
			if (!this._tabContentViews.hasOwnProperty(tabId)) {
				return;
			}

			this._tabHeadersView.selectTabHeader(tabId);
		},

		/**
		 * Shows the content view associated to the selected tab header.
		 *
		 * Only for internal use as an event handler.
		 *
		 * @param string tabId the ID of the selected tab.
		 */
		onChildviewSelectTabHeader: function(tabId) {
			// With Marionette 3.1 "this.detachChildView('tabContent')" would be
			// used instead of the "preventDestroy" option.
			this.showChildView('tabContent', this._tabContentViews[tabId], { preventDestroy: true } );
		}

	});

	OCA.SpreedMe.Views.TabView = TabView;

})(OCA, Marionette, Handlebars);
<commit_msg>Get the current priorities using the tabIds list instead of the regions<commit_after>/* global Marionette, Handlebars */

/**
 *
 * @copyright Copyright (c) 2017, Daniel Calviño Sánchez (danxuliu@gmail.com)
 *
 * @license GNU AGPL version 3 or any later version
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

(function(OCA, Marionette, Handlebars) {

	'use strict';

	OCA.SpreedMe = OCA.SpreedMe || {};
	OCA.SpreedMe.Views = OCA.SpreedMe.Views || {};

	var TEMPLATE_TAB_HEADER_VIEW =
		'{{label}}';

	var TEMPLATE_TAB_VIEW =
		'
' +
		'
' +
		'
' +
		'
' +
		'
' +
		'
';

	var TabHeaderView  = Marionette.View.extend({

		tagName: 'li',
		className: 'tabHeader',

		template: Handlebars.compile(TEMPLATE_TAB_HEADER_VIEW),
		templateContext: function() {
			return {
				label: this.getOption('label')
			};
		},

		events: {
			'click': function() {
				this.triggerMethod('click:tabHeader', this.getOption('tabId'));
			}
		},

		setSelected: function(selected) {
			if (selected) {
				this.$el.addClass('selected');
			} else {
				this.$el.removeClass('selected');
			}
		}

	});

	var TabHeadersView  = Marionette.View.extend({

		tagName: 'ul',
		className: 'tabHeaders',

		// The tab headers are added dynamically using regions, so there is
		// nothing to be rendered with a template.
		template: _.noop,

		childViewEvents: {
			'click:tabHeader': 'selectTabHeader'
		},

		initialize: function() {
			// The tabIds in priority and then insertion order.
			this._tabIds = [];
		},

		addTabHeader: function(tabId, tabHeaderOptions) {
			var tabHeaderId = 'tabHeader' + tabId.charAt(0).toUpperCase() + tabId.substr(1);

			tabHeaderOptions.id = tabHeaderId;
			// The "tabId" will be passed by the TabHeaderView when triggering
			// "click:tabHeader" events.
			tabHeaderOptions.tabId = tabId;

			tabHeaderOptions.priority = tabHeaderOptions.priority || 0;

			var tabHeaderView = new TabHeaderView(tabHeaderOptions);

			var tabHeaderIndex = this._getIndexForTabHeaderPriority(tabHeaderOptions.priority);

			this._tabIds.splice(tabHeaderIndex, 0, tabId);

			// When adding a region and showing a view on it the target element
			// of the region must exist in the parent view. Therefore, a dummy
			// target element, which will be replaced with the tab header
			// itself, has to be added to the parent view.
			var dummyElement = '
';
			if (tabHeaderIndex === 0) {
				this.$el.prepend(dummyElement);
			} else {
				// When two tab headers have the same priority the new one is
				// added after the existing one.
				this.$el.children().eq(tabHeaderIndex-1).after(dummyElement);
			}

			this.addRegion(tabId, { el: '#' + tabHeaderId, replaceElement: true });
			this.showChildView(tabId, tabHeaderView);
		},

		/**
		 * Return the insertion index for a tab header based on its priority.
		 *
		 * Tab headers with higher priorities go before tab headers with lower
		 * priorities; if the priority is the same as one or more of the current
		 * tab headers the new tab header goes after the last of them.
		 *
		 * @param int priority the priority to get its insertion index.
		 * @return int the insertion index.
		 */
		_getIndexForTabHeaderPriority: function(priority) {
			// _.map creates an array, so "currentPriorities" will contain a
			// "length" property.
			var currentPriorities = _.map(this._tabIds, _.bind(function(tabId) {
				return this.getRegion(tabId).currentView.getOption('priority');
			}, this));

			var index = _.findIndex(currentPriorities, function(currentPriority) {
				return priority > currentPriority;
			});

			if (index === -1) {
				return currentPriorities.length;
			}

			return index;
		},

		/**
		 * Removes the tab header for the given tabId.
		 *
		 * If the tab header to be removed is the one currently selected and
		 * there are other tab headers the next one (in priority and then
		 * insertion order) is automatically selected; if the tab header to be
		 * removed is the last one, then the previous one is selected instead.
		 *
		 * @param string tabId the ID of the tab.
		 */
		removeTabHeader: function(tabId) {
			var tabIdIndex = _.indexOf(this._tabIds, tabId);

			// If the tab header to be removed is the one currently selected
			// then select the next tab header or, if it is the last tab header,
			// the previous one (or none if there are no other tab headers).
			if (this._currentTabId === tabId) {
				if (this._tabIds.length <= 1) {
					delete this._currentTabId;
				} else if (tabIdIndex === (this._tabIds.length - 1)) {
					this.selectTabHeader(this._tabIds[tabIdIndex - 1]);
				} else {
					this.selectTabHeader(this._tabIds[tabIdIndex + 1]);
				}
			}

			this._tabIds.splice(tabIdIndex, 1);

			var removedRegion = this.removeRegion(tabId);
			// Remove the dummy target element that was replaced by the view
			// when it was shown and that is restored back when the region is
			// removed.
			removedRegion.el.remove();
		},

		selectTabHeader: function(tabId) {
			if (this._currentTabId !== undefined) {
				this.getChildView(this._currentTabId).setSelected(false);
			}

			this._currentTabId = tabId;

			this.getChildView(this._currentTabId).setSelected(true);

			this.triggerMethod('select:tabHeader', tabId);
		}

	});

	/**
	 * View for tabs (headers and content).
	 *
	 * A TabView contains a set of tab headers and a content area. When a header
	 * is selected its associated content view is shown in the content area;
	 * otherwise its content is hidden (although the header is always shown).
	 */
	var TabView = Marionette.View.extend({

		tagName: 'div',
		className: 'tabs',

		regions: {
			tabHeaders: '.tabHeaders',
			tabContent: '.tab'
		},

		template: Handlebars.compile(TEMPLATE_TAB_VIEW),

		initialize: function() {
			this._tabHeadersView = null;
			this._tabContentViews = {};
		},

		onDestroy: function() {
			_.each(this._tabContentViews, function(tabContentView) {
				// Explicitly destroy all the tab content views, as some of them
				// may be detached from the TabView.
				tabContentView.destroy();
			});
		},

		/**
		 * Adds a new tab.
		 *
		 * The tabHeaderOptions must provide a 'label' string which will be
		 * rendered as the tab header. Optionally, it can provide a 'priority'
		 * integer to set the order of the tab header with respect to the other
		 * tab headers (tabs with higher priorities appear before tabs with
		 * lower priorities; tabs with the same priority are sorted based on
		 * their insertion order); if it is not explicitly set the value 0 is
		 * used. If needed, the tabHeaderOptions can provide other values that
		 * will override the default TabHeaderView properties (for example, it
		 * can provide an 'onRender' function to extend the default rendering of
		 * the header).
		 *
		 * The TabView takes ownership of the given content view, and it will
		 * destroy it when the TabView is destroyed, except if the content view
		 * is removed first.
		 *
		 * @param string tabId the ID of the tab.
		 * @param Object tabHeaderOptions the options for the constructor of the
		 *        TabHeaderView that will be added as the header of the tab.
		 * @param Marionette.View tabContentView the View to be shown when the
		 *        tab is selected.
		 */
		addTab: function(tabId, tabHeaderOptions, tabContentView) {
			if (this._tabHeadersView === null) {
				this._tabHeadersView = new TabHeadersView();
				this.showChildView('tabHeaders', this._tabHeadersView, { replaceElement: true });
			}

			this._tabHeadersView.addTabHeader(tabId, tabHeaderOptions);

			this._tabContentViews[tabId] = tabContentView;

			if (Object.keys(this._tabContentViews).length === 1) {
				this.selectTab(tabId);
			}
		},

		/**
		 * Removes the tab for the given tabId.
		 *
		 * If the tab to be removed is the one currently selected and there are
		 * other tabs the next one (in priority and then insertion order) is
		 * automatically selected; if the tab to be removed is the last one,
		 * then the previous one is selected instead. If there are no other tabs
		 * then this TabView is simply emptied.
		 *
		 * In any case the content view given when the tab was added is
		 * returned; this TabView will no longer have ownership of the content
		 * view, and thus the content view must be explicitly destroyed when no
		 * longer needed.
		 *
		 * @param string tabId the ID of the tab to remove.
		 * @return Marionette.View the content view of the removed tab.
		 */
		removeTab: function(tabId) {
			if (!this._tabContentViews.hasOwnProperty(tabId)) {
				return undefined;
			}

			var removedTabContentView = this._tabContentViews[tabId];

			this._tabHeadersView.removeTabHeader(tabId);

			delete this._tabContentViews[tabId];

			// Removing the tab header selects a new tab header, which in turn
			// changes the content view, except when there are no other tabs. In
			// that case the content view would be being shown in the region and
			// thus would have to be removed from there.
			if (Object.keys(this._tabContentViews).length === 0) {
				this.getRegion('tabContent').empty({preventDestroy: true});
			}

			return removedTabContentView;
		},

		/**
		 * Select the tab associated to the given tabId.
		 *
		 * @param string tabId the ID of the tab to select.
		 */
		selectTab: function(tabId) {
			if (!this._tabContentViews.hasOwnProperty(tabId)) {
				return;
			}

			this._tabHeadersView.selectTabHeader(tabId);
		},

		/**
		 * Shows the content view associated to the selected tab header.
		 *
		 * Only for internal use as an event handler.
		 *
		 * @param string tabId the ID of the selected tab.
		 */
		onChildviewSelectTabHeader: function(tabId) {
			// With Marionette 3.1 "this.detachChildView('tabContent')" would be
			// used instead of the "preventDestroy" option.
			this.showChildView('tabContent', this._tabContentViews[tabId], { preventDestroy: true } );
		}

	});

	OCA.SpreedMe.Views.TabView = TabView;

})(OCA, Marionette, Handlebars);
<|endoftext|>


<commit_before>//todo write angular scripts for developer page.

var forumModule = angular.module('app', []).
	controller("forumCtrl", function forumCtrl($scope, $window){

		$scope.forum = {
			threads: [{subject: "blah blah blah", posts: [{user: "user1", message: "hi how u doing"}, {user: "user2", message: "lol wassup"}]},
				{subject: "how to add your own functions", posts: [{user: "user1", message: "asdfasdf"}, {user: "user2", message: "j jajajajajajh"}]}]
		};

		$scope.currentThread = {};
		$scope.currentThreadOn = false;

		$scope.setThread = function(thread){
			$scope.currentThread = thread;
			$scope.currentThreadOn = true;
		}

		$scope.backToForum = function(){
			$scope.currentThreadOn = false;
		}
	});
<commit_msg>Update script.js<commit_after>//todo write angular scripts for developer page.

var forumModule = angular.module('app', []).
	controller("guideCtrl", function guideCtrl($scope, $window){

	}).
	controller("forumCtrl", function forumCtrl($scope, $window){

		$scope.forum = {
			threads: [{subject: "blah blah blah", posts: [{user: "user1", message: "hi how u doing"}, {user: "user2", message: "lol wassup"}]},
				{subject: "how to add your own functions", posts: [{user: "user1", message: "asdfasdf"}, {user: "user2", message: "j jajajajajajh"}]}]
		};

		$scope.currentThread = {};
		$scope.currentThreadOn = false;

		$scope.setThread = function(thread){
			$scope.currentThread = thread;
			$scope.currentThreadOn = true;
		}

		$scope.backToForum = function(){
			$scope.currentThreadOn = false;
		}
	});
<|endoftext|>


<commit_before>var els = "";

function LoadCSSJS(e, t, m) {

	"use strict";

	if (els.indexOf("["+e+"]") == -1) {
		Loader(e, t, m);
		els += "["+e+"]";
	}
	else
		alert("File "+e+" already added!");

}
function Loader(e, t, m){

	if (t == "css") {
		var f=document.createElement("link");
		f.setAttribute("rel", "stylesheet");
    		f.setAttribute("href", e);
    		(m ? "" : m="all");
    		f.setAttribute("media", m);
    		f.setAttribute("type", "text/css");
	} else if (t == "js") {
		var f = document.createElement("script");
		f.setAttribute("type", "text/javascript");
        	f.setAttribute("src", e);
	}
	if (typeof f != "undefined") {
		var a = document.getElementsByTagName("head");
		a = a[a.length-1];
		a.appendChild(s,a);
	}

}
<commit_msg>Update LoadCSSJS.js<commit_after>var els = "";

function LoadCSSJS(e, t, m) {

	"use strict";

	if (els.indexOf("["+e+"]") == -1) {
		Loader(e, t, m);
		els += "["+e+"]";
	}
	else
		alert("File "+e+" already added!");

}
function Loader(e, t, m){

	if (t == "css") {
		var f=document.createElement("link");
		f.setAttribute("rel", "stylesheet");
    		f.setAttribute("href", e);
    		(m ? "" : m="all");
    		f.setAttribute("media", m);
    		f.setAttribute("type", "text/css");
	} else if (t == "js") {
		var f = document.createElement("script");
		f.setAttribute("type", "text/javascript");
        	f.setAttribute("src", e);
	}
	if (typeof f != "undefined") {
		var a = document.getElementsByTagName("head");
		a = a[a.length-1];
		a.appendChild(s);
	}

}
<|endoftext|>


<commit_before>var definition = {
    frame: {
        header: [ 16, {
            fin: 1, rsv1: 1, rsv2: 1, rsv3: 1, opcode: 4,
            mask: 1, length: 7
        } ],
        length: [ function (object) {
            switch (object.header.length) {
                case 127:
                    return 0
                case 126:
                    return 1
                default:
                    object.length = object.header.length
            }
        }, 16, 32 ],
        mask: [ function (object) {
            return object.mask ? 1 : 0
        }, 0, 16 ]
    },
    mysql: {
        value: [ 8, function (value) {
            if (value < 0xfb) {
                return 0
            } else if (value & 0xfc) {
                return 1
            }
        }, 'b8', [ 'x8', 'b16' ] ]
    }
}

var packets = {
    frame: function (object, parsing) {
        if (!parsing) {
            header.mask = object.mask == null ? 0 : 1
        }
        _(object.header, {
            fin: 1, rsv1: 1, rsv2: 2, rsv3: 3, opcode: 4,
            mask: 1, length: 7
        })
        if (header.length == 127) {
            _(header.length, 16)
        } else if (header.length == 126) {
            _(header.length, 32)
        } else if (parsing) {
            object.length = header.length
        }
        if (header.mask) {
            _(object.mask, 16)
        }
    },
    mysql: function (object) {
        if (parsing) {
            _(object.value, 8)
            if (object.value & 0x0fc) {
                _(object.value, 16)
            } else if (object.value & 0xfd) {
                _(object.value, 24)
            } else if (object.value & 0xfe) {
                _(object.value, 64)
            }
        } else {
            if (object.value < 251) {
                _(object.value, 8)
            } else if (object.value > 251 && object.value < 0xffff) {
                _(0xfc)
                _(object.value, 16)
            } else if (object.value >= 0xffff && object.value < 0xffffff) {
                _(0xfd)
                _(object.value, 24)
            } else {
                _(0xfe)
                _(object.value, 64)
            }
        }
    },
    nested: function (object) {
        _(object.numbers, 16, [32])
        _(object.structures, 16, [function (struct) {
            _(struct.count, packets.mysql)
            _(struct.string, [8], [0])
        }])
    }
}

packets.lengthEncoded = function (packet, object) {
    packet(object.array, [16, function (record) {
        if (parsing) {
            var flag = packet({ flag: 3, _skip_: 5 }, 'flag')
        } else {
            if (record.key < 10) {
            }
        }
        _(record.key, 16)
        _(record.value, 32)
    }])
}

var packet = function () {}

packets.websocket = packet(function (packet, object) {
    if (parsing) {
        var peek = packet({ flag: 3, $padding: 5 }, 'flag')
        if (peek & ~0x7f == 0) {
            packet('id', { $flag: 1, value: 7 }, 'value')
        } else {
            packet('id', { $flag: 2, value: 14 }, 'value')
        }
    } else {
        if (object.id < 0x7f) {
            packet('id', 8, 0x80 & object.id)
        } else if (object.id < 65500) {
            packet('id', 16, 0xb000 & object.id)
        } else if (object.id < 222) {
        }
    }
    packet('.', {
        fin: 1, rsv1: 1, rsv2: 1, rsv3: 1, opcode: 4, masked: 1, length: 7
    })
    if (object.length == 127) {
        packet('length', 16)
    } else if (object.length == 126) {
        packet('length', 32)
    }
    if (object.masked == 1) {
        packet(object.mask, 16)
    }
})

var packets = {
    frame: function (object) {
        if (serializing) {
            header.mask = object.mask == null ? 0 : 1
        }
        header = packed(object.header, 16, {
            fin: 1, rsv1: 1, rsv2: 2, rsv3: 3, opcode: 4,
            mask: 1, length: 7
        })
        switch (header.length) {
        case 127:
            unsigned(header.length, 16)
        case 126:
            unsigned(header.length, 32)
        default:
            if (parsing) {
                object.length = header.length
            }
        }
        if (header.mask) {
            unsigned(object.mask, 16)
        }
    },
    mysql: function (object) {
        object.value = get(8)
        if (object.value & 0xfc) {
            object.value = get(16)
        }
    },
    nested: function (object) {
    }
}
<commit_msg>Delete `langauge.js` sketch.<commit_after><|endoftext|>


<commit_before>Modules.VERSION = '2.1.6';

this.FITMini = {
	get broadcaster() { return $(objName+'-findInTabs-broadcaster'); },

	// triggers a find operation, to make sure we have hits to show when selecting one, and that we actually show them as well
	receiveMessage: function(m) {
		var bar = (viewSource) ? gFindBar : gBrowser.getFindBar(gBrowser.getTabForBrowser(m.target));

		// don't actually perform the fastFind operation, as it already will have been commanded by the message sender
		bar.browser.finder.workAroundFind = true;
		bar._findField.value = m.data.query;
		bar._setCaseSensitivity(m.data.caseSensitive ? 1 : 0); // implies bar._find()
		bar.browser.finder.workAroundFind = false;

		dispatch(bar, { type: 'SelectedFITHit', cancelable: false });
	},

	handleEvent: function(e) {
		switch(e.type) {
			case 'TabClose':
				if(FITSandbox.fulls.size > 0) {
					Observers.notify('FIT:Update', e.target.linkedBrowser, 'removeBrowser');
				}
				break;

			case 'TabSelect':
				this.sendToUpdate();
				break;

			case 'TabOpen':
				// if any FIT window is open, we need to make sure the findInTabs content script is loaded, even if its findbar isn't initialized yet
				if(FITSandbox.fulls.size > 0) {
					Messenger.loadInBrowser(e.target.linkedBrowser, 'findInTabs');
				}
				break;
		}
	},

	observe: function(aSubject, aTopic) {
		switch(aTopic) {
			case 'FIT:Load':
				// already opened tabs need to have their findBar created, otherwise FIT won't work there
				if(!viewSource) {
					for(let browser of gBrowser.browsers) {
						Messenger.loadInBrowser(browser, 'findInTabs');
					}
				} else {
					Messenger.loadInBrowser(gFindBar.browser, 'findInTabs');
				}
				break;

			case 'FIT:Unload':
				if(!viewSource) {
					for(let browser of gBrowser.browsers) {
						Messenger.unloadFromBrowser(browser, 'findInTabs');
					}
				} else {
					Messenger.unloadFromBrowser(gFindBar.browser, 'findInTabs');
				}
				break;
		}
	},

	onFindResult: function(data, browser) {
		FITMini.sendToUpdate(browser);
	},

	onPDFJSState: function(browser) {
		if(FITSandbox.fulls.size == 0) { return; }

		// We do with a delay to allow the page to render the selected element
		aSync(() => {
			this.sendToUpdate(browser);
		}, 10);
	},

	command: function() {
		if(!FITFull) {
			this.toggle();
			return;
		}

		FIT.shouldFindAll();
	},

	toggle: function() {
		if(FITFull) {
			gFindBar.onFindCommand();
			FIT.updateFilterTooltip(); // in findInTabs.jsm, so its placeholder text isn't replaced by the default string
			return;
		}

		// Re-use an already opened window if possible
		if(!Prefs.multipleFITFull && FITSandbox.fulls.size > 0) {
			for(let aWindow of FITSandbox.fulls) {
				if(aWindow.document.readyState != 'uninitialized'
				&& (viewSource || gFindBarInitialized)
				&& !gFindBar.hidden
				&& findQuery
				&& findQuery != aWindow.document.getElementById('FindToolbar')._findField.value) {
					aWindow.document.getElementById('FindToolbar')._findField.value = findQuery;
					aWindow[objName].FIT.shouldFindAll();
				}
				aWindow.document.getElementById('FindToolbar').onFindCommand();
				aWindow.focus();

				// we only really care about the first window in the set, it's highly unlikely there will be more anyway
				return;
			}
		}

		// No window found, we need to open a new one
		var aWindow = window.open("chrome://"+objPathString+"/content/findInTabsFull.xul", '', 'chrome,extrachrome,toolbar,resizable,centerscreen');
		callOnLoad(aWindow, () => {
			if((viewSource || gFindBarInitialized) && (!gFindBar.hidden || documentHighlighted) && findQuery) {
				aWindow.document.getElementById('FindToolbar')._findField.value = findQuery;
			}

			if(typeof(aWindow[objName].FIT) == 'undefined') {
				Listeners.add(aWindow, 'FITLoaded', function() {
					aWindow[objName].FIT.lastBrowser = (viewSource) ? gFindBar.browser : gBrowser.mCurrentBrowser;
				}, false, true);
			} else {
				aWindow[objName].FIT.lastBrowser = (viewSource) ? gFindBar.browser : gBrowser.mCurrentBrowser;
			}
		});
	},

	sendToUpdate: function(browser) {
		if(FITSandbox.fulls.size == 0) { return; }

		browser = browser || (viewSource ? gFindBar.browser : gBrowser.mCurrentBrowser);
		Observers.notify('FIT:Update', browser, 'updateBrowser');
	},

	onLoad: function() {
		if(viewSource) {
			FITSandbox.viewSources.add(window);
		} else {
			FITSandbox.navigators.add(window);
		}

		initFindBar('findInTabsMini',
			(bar) => {
				var toggleButton = document.createElement('toolbarbutton');
				setAttribute(toggleButton, 'anonid', objName+'-find-tabs');
				setAttribute(toggleButton, 'class', 'findbar-button findbar-tabs tabbable findbar-no-find-fast');
				setAttribute(toggleButton, 'observes', objName+'-findInTabs-broadcaster');
				bar.getElement("findbar-container").insertBefore(toggleButton, bar.getElement('find-case-sensitive').nextSibling);

				// make sure the australis styling is also applied to the FIT button
				buttonLabels.toggle();

				bar.browser.finder.addResultListener(this);
			},
			(bar) => {
				if(bar._destroying) { return; }

				bar.browser.finder.removeResultListener(this);

				bar.getElement(objName+'-find-tabs').remove();
			}
		);

		Messenger.listenWindow(window, 'FIT:Find', this);

		if(!viewSource) {
			// Update FIT lists as needed
			Listeners.add(gBrowser.tabContainer, 'TabClose', this);
			Listeners.add(gBrowser.tabContainer, 'TabSelect', this);
			Listeners.add(gBrowser.tabContainer, 'TabOpen', this);
		}

		Observers.add(this, 'FIT:Load');
		Observers.add(this, 'FIT:Unoad');

		// make sure all browsers in this window have the FIT content script loaded, in case it is needed
		if(FITSandbox.fulls.size > 0) {
			this.observe(null, 'FIT:Load');
		}

		if(Services.wm.getMostRecentWindow(null) == window) {
			this.sendToUpdate();
		}
	},

	onUnload: function() {
		deinitFindBar('findInTabsMini');

		Observers.remove(this, 'FIT:Load');
		Observers.remove(this, 'FIT:Unoad');

		if(!viewSource) {
			Listeners.remove(gBrowser.tabContainer, 'TabClose', this);
			Listeners.remove(gBrowser.tabContainer, 'TabSelect', this);
			Listeners.remove(gBrowser.tabContainer, 'TabOpen', this);
		}

		Messenger.unlistenWindow(window, 'FIT:Find', this);

		if((window.closed || window.willClose) && !UNLOADED && Prefs.findInTabs) {
			if(!viewSource) {
				FITSandbox.navigators.delete(window);
				// Ensure we remove tabs of closing windows from lists
				for(let browser of gBrowser.browsers) {
					Observers.notify('FIT:Update', browser, 'removeBrowser');
				}
			}
			else {
				FITSandbox.viewSources.delete(window);
				Observers.notify('FIT:Update', gFindBar.browser, 'removeBrowser');
			}
		}
	}
};

Modules.LOADMODULE = function() {
	if(FITFull) {
		Modules.load('findInTabs');
		return;
	}

	Overlays.overlayWindow(window, 'findInTabsMini', FITMini);
};

Modules.UNLOADMODULE = function() {
	if(FITFull) {
		Modules.unload('findInTabs');
		return;
	}

	Overlays.removeOverlayWindow(window, 'findInTabsMini');
};
<commit_msg>bugfix FIT handling of tab events<commit_after>Modules.VERSION = '2.1.7';

this.FITMini = {
	get broadcaster() { return $(objName+'-findInTabs-broadcaster'); },

	// triggers a find operation, to make sure we have hits to show when selecting one, and that we actually show them as well
	receiveMessage: function(m) {
		var bar = (viewSource) ? gFindBar : gBrowser.getFindBar(gBrowser.getTabForBrowser(m.target));

		// don't actually perform the fastFind operation, as it already will have been commanded by the message sender
		bar.browser.finder.workAroundFind = true;
		bar._findField.value = m.data.query;
		bar._setCaseSensitivity(m.data.caseSensitive ? 1 : 0); // implies bar._find()
		bar.browser.finder.workAroundFind = false;

		dispatch(bar, { type: 'SelectedFITHit', cancelable: false });
	},

	handleEvent: function(e) {
		switch(e.type) {
			case 'TabClose':
				// make sure any focus or state changes that may happen while the browser is being removed don't recreate the tab entry
				Messenger.unloadFromBrowser(e.target.linkedBrowser, 'findInTabs');

				if(FITSandbox.fulls.size > 0) {
					Observers.notify('FIT:Update', e.target.linkedBrowser, 'removeBrowser');
				}
				break;

			case 'TabSelect':
				this.sendToUpdate();
				break;

			case 'TabOpen':
			case 'TabRemotenessChange':
				// if any FIT window is open, we need to make sure the findInTabs content script is loaded, even if its findbar isn't initialized yet
				if(FITSandbox.fulls.size > 0) {
					Messenger.loadInBrowser(e.target.linkedBrowser, 'findInTabs');
				}
				break;
		}
	},

	observe: function(aSubject, aTopic) {
		switch(aTopic) {
			case 'FIT:Load':
				// already opened tabs need to have their findBar created, otherwise FIT won't work there
				if(!viewSource) {
					for(let browser of gBrowser.browsers) {
						Messenger.loadInBrowser(browser, 'findInTabs');
					}
				} else {
					Messenger.loadInBrowser(gFindBar.browser, 'findInTabs');
				}
				break;

			case 'FIT:Unload':
				if(!viewSource) {
					for(let browser of gBrowser.browsers) {
						Messenger.unloadFromBrowser(browser, 'findInTabs');
					}
				} else {
					Messenger.unloadFromBrowser(gFindBar.browser, 'findInTabs');
				}
				break;
		}
	},

	onFindResult: function(data, browser) {
		FITMini.sendToUpdate(browser);
	},

	onPDFJSState: function(browser) {
		if(FITSandbox.fulls.size == 0) { return; }

		// We do with a delay to allow the page to render the selected element
		aSync(() => {
			this.sendToUpdate(browser);
		}, 10);
	},

	command: function() {
		if(!FITFull) {
			this.toggle();
			return;
		}

		FIT.shouldFindAll();
	},

	toggle: function() {
		if(FITFull) {
			gFindBar.onFindCommand();
			FIT.updateFilterTooltip(); // in findInTabs.jsm, so its placeholder text isn't replaced by the default string
			return;
		}

		// Re-use an already opened window if possible
		if(!Prefs.multipleFITFull && FITSandbox.fulls.size > 0) {
			for(let aWindow of FITSandbox.fulls) {
				if(aWindow.document.readyState != 'uninitialized'
				&& (viewSource || gFindBarInitialized)
				&& !gFindBar.hidden
				&& findQuery
				&& findQuery != aWindow.document.getElementById('FindToolbar')._findField.value) {
					aWindow.document.getElementById('FindToolbar')._findField.value = findQuery;
					aWindow[objName].FIT.shouldFindAll();
				}
				aWindow.document.getElementById('FindToolbar').onFindCommand();
				aWindow.focus();

				// we only really care about the first window in the set, it's highly unlikely there will be more anyway
				return;
			}
		}

		// No window found, we need to open a new one
		var aWindow = window.open("chrome://"+objPathString+"/content/findInTabsFull.xul", '', 'chrome,extrachrome,toolbar,resizable,centerscreen');
		callOnLoad(aWindow, () => {
			if((viewSource || gFindBarInitialized) && (!gFindBar.hidden || documentHighlighted) && findQuery) {
				aWindow.document.getElementById('FindToolbar')._findField.value = findQuery;
			}

			if(typeof(aWindow[objName].FIT) == 'undefined') {
				Listeners.add(aWindow, 'FITLoaded', function() {
					aWindow[objName].FIT.lastBrowser = (viewSource) ? gFindBar.browser : gBrowser.mCurrentBrowser;
				}, false, true);
			} else {
				aWindow[objName].FIT.lastBrowser = (viewSource) ? gFindBar.browser : gBrowser.mCurrentBrowser;
			}
		});
	},

	sendToUpdate: function(browser) {
		if(FITSandbox.fulls.size == 0) { return; }

		browser = browser || (viewSource ? gFindBar.browser : gBrowser.mCurrentBrowser);
		Observers.notify('FIT:Update', browser, 'updateBrowser');
	},

	onLoad: function() {
		if(viewSource) {
			FITSandbox.viewSources.add(window);
		} else {
			FITSandbox.navigators.add(window);
		}

		initFindBar('findInTabsMini',
			(bar) => {
				var toggleButton = document.createElement('toolbarbutton');
				setAttribute(toggleButton, 'anonid', objName+'-find-tabs');
				setAttribute(toggleButton, 'class', 'findbar-button findbar-tabs tabbable findbar-no-find-fast');
				setAttribute(toggleButton, 'observes', objName+'-findInTabs-broadcaster');
				bar.getElement("findbar-container").insertBefore(toggleButton, bar.getElement('find-case-sensitive').nextSibling);

				// make sure the australis styling is also applied to the FIT button
				buttonLabels.toggle();

				bar.browser.finder.addResultListener(this);
			},
			(bar) => {
				if(bar._destroying) { return; }

				bar.browser.finder.removeResultListener(this);

				bar.getElement(objName+'-find-tabs').remove();
			}
		);

		Messenger.listenWindow(window, 'FIT:Find', this);

		if(!viewSource) {
			// Update FIT lists as needed
			Listeners.add(gBrowser.tabContainer, 'TabClose', this);
			Listeners.add(gBrowser.tabContainer, 'TabSelect', this);
			Listeners.add(gBrowser.tabContainer, 'TabOpen', this);
			Listeners.add(gBrowser.tabContainer, 'TabRemotenessChange', this);
		}

		Observers.add(this, 'FIT:Load');
		Observers.add(this, 'FIT:Unoad');

		// make sure all browsers in this window have the FIT content script loaded, in case it is needed
		if(FITSandbox.fulls.size > 0) {
			this.observe(null, 'FIT:Load');
		}

		if(Services.wm.getMostRecentWindow(null) == window) {
			this.sendToUpdate();
		}
	},

	onUnload: function() {
		deinitFindBar('findInTabsMini');

		Observers.remove(this, 'FIT:Load');
		Observers.remove(this, 'FIT:Unoad');

		if(!viewSource) {
			Listeners.remove(gBrowser.tabContainer, 'TabClose', this);
			Listeners.remove(gBrowser.tabContainer, 'TabSelect', this);
			Listeners.remove(gBrowser.tabContainer, 'TabOpen', this);
			Listeners.remove(gBrowser.tabContainer, 'TabRemotenessChange', this);
		}

		Messenger.unlistenWindow(window, 'FIT:Find', this);

		if((window.closed || window.willClose) && !UNLOADED && Prefs.findInTabs) {
			if(!viewSource) {
				FITSandbox.navigators.delete(window);
				// Ensure we remove tabs of closing windows from lists
				for(let browser of gBrowser.browsers) {
					Observers.notify('FIT:Update', browser, 'removeBrowser');
				}
			}
			else {
				FITSandbox.viewSources.delete(window);
				Observers.notify('FIT:Update', gFindBar.browser, 'removeBrowser');
			}
		}
	}
};

Modules.LOADMODULE = function() {
	if(FITFull) {
		Modules.load('findInTabs');
		return;
	}

	Overlays.overlayWindow(window, 'findInTabsMini', FITMini);
};

Modules.UNLOADMODULE = function() {
	if(FITFull) {
		Modules.unload('findInTabs');
		return;
	}

	Overlays.removeOverlayWindow(window, 'findInTabsMini');
};
<|endoftext|>


<commit_before>
function each(els, fn) {
  for (var i = 0, len = (els || []).length, el; i < len; i++) {
    el = els[i]
    // return false -> remove current item during loop
    if (el != null && fn(el, i) === false) i--
  }
  return els
}

function isFunction(v) {
  return typeof v === 'function' || false   // avoid IE problems
}

function remAttr(dom, name) {
  dom.removeAttribute(name)
}

function fastAbs(nr) {
  return (nr ^ (nr >> 31)) - (nr >> 31)
}

function getTag(dom) {
  var tagName = dom.tagName.toLowerCase()
  return tagImpl[dom.getAttribute(RIOT_TAG) || tagName]
}

function getTagName(dom) {
  var child = getTag(dom),
    namedTag = dom.getAttribute('name'),
    tagName = namedTag && namedTag.indexOf(brackets(0)) < 0 ? namedTag : child ? child.name : dom.tagName.toLowerCase()

  return tagName
}

function extend(src) {
  var obj, args = arguments
  for (var i = 1; i < args.length; ++i) {
    if ((obj = args[i])) {
      for (var key in obj) {      // eslint-disable-line guard-for-in
        src[key] = obj[key]
      }
    }
  }
  return src
}

// with this function we avoid that the current Tag methods get overridden
function cleanUpData(data) {
  if (!(data instanceof Tag)) return data

  var o = {},
      blackList = ['update', 'root', 'mount', 'unmount', 'mixin', 'isMounted', 'isloop', 'tags', 'parent']
  for (var key in data) {
    if (!~blackList.indexOf(key))
      o[key] = data[key]
  }
  return o
}

function mkdom(template) {
  var checkie = ieVersion && ieVersion < 10,
      matches = /^\s*<([\w-]+)/.exec(template),
      tagName = matches ? matches[1].toLowerCase() : '',
      rootTag = (tagName === 'th' || tagName === 'td') ? 'tr' :
                (tagName === 'tr' ? 'tbody' : 'div'),
      el = mkEl(rootTag)

  el.stub = true

  if (checkie) {
    if (tagName === 'optgroup')
      optgroupInnerHTML(el, template)
    else if (tagName === 'option')
      optionInnerHTML(el, template)
    else if (rootTag !== 'div')
      tbodyInnerHTML(el, template, tagName)
    else
      checkie = 0
  }
  if (!checkie) el.innerHTML = template

  return el
}

function walk(dom, fn) {
  if (dom) {
    if (fn(dom) === false) walk(dom.nextSibling, fn)
    else {
      dom = dom.firstChild

      while (dom) {
        walk(dom, fn)
        dom = dom.nextSibling
      }
    }
  }
}

function isInStub(dom) {
  while (dom) {
    if (dom.inStub) return true
    dom = dom.parentNode
  }
  return false
}

function mkEl(name) {
  return document.createElement(name)
}

function replaceYield (tmpl, innerHTML) {
  return tmpl.replace(/<(yield)\/?>(<\/\1>)?/gim, innerHTML || '')
}

function $$(selector, ctx) {
  return (ctx || document).querySelectorAll(selector)
}

function $(selector, ctx) {
  return (ctx || document).querySelector(selector)
}

function inherit(parent) {
  function Child() {}
  Child.prototype = parent
  return new Child()
}

function setNamed(dom, parent, keys) {
  each(dom.attributes, function(attr) {
    if (dom._visited) return
    if (attr.name === 'id' || attr.name === 'name') {
      dom._visited = true
      var p, v = attr.value
      if (~keys.indexOf(v)) return

      p = parent[v]
      if (!p)
        parent[v] = dom
      else
        isArray(p) ? p.push(dom) : (parent[v] = [p, dom])
    }
  })
}
<commit_msg>added: do not override the tag opts<commit_after>
function each(els, fn) {
  for (var i = 0, len = (els || []).length, el; i < len; i++) {
    el = els[i]
    // return false -> remove current item during loop
    if (el != null && fn(el, i) === false) i--
  }
  return els
}

function isFunction(v) {
  return typeof v === 'function' || false   // avoid IE problems
}

function remAttr(dom, name) {
  dom.removeAttribute(name)
}

function fastAbs(nr) {
  return (nr ^ (nr >> 31)) - (nr >> 31)
}

function getTag(dom) {
  var tagName = dom.tagName.toLowerCase()
  return tagImpl[dom.getAttribute(RIOT_TAG) || tagName]
}

function getTagName(dom) {
  var child = getTag(dom),
    namedTag = dom.getAttribute('name'),
    tagName = namedTag && namedTag.indexOf(brackets(0)) < 0 ? namedTag : child ? child.name : dom.tagName.toLowerCase()

  return tagName
}

function extend(src) {
  var obj, args = arguments
  for (var i = 1; i < args.length; ++i) {
    if ((obj = args[i])) {
      for (var key in obj) {      // eslint-disable-line guard-for-in
        src[key] = obj[key]
      }
    }
  }
  return src
}

// with this function we avoid that the current Tag methods get overridden
function cleanUpData(data) {
  if (!(data instanceof Tag)) return data

  var o = {},
      blackList = ['update', 'root', 'mount', 'unmount', 'mixin', 'isMounted', 'isloop', 'tags', 'parent', 'opts']
  for (var key in data) {
    if (!~blackList.indexOf(key))
      o[key] = data[key]
  }
  return o
}

function mkdom(template) {
  var checkie = ieVersion && ieVersion < 10,
      matches = /^\s*<([\w-]+)/.exec(template),
      tagName = matches ? matches[1].toLowerCase() : '',
      rootTag = (tagName === 'th' || tagName === 'td') ? 'tr' :
                (tagName === 'tr' ? 'tbody' : 'div'),
      el = mkEl(rootTag)

  el.stub = true

  if (checkie) {
    if (tagName === 'optgroup')
      optgroupInnerHTML(el, template)
    else if (tagName === 'option')
      optionInnerHTML(el, template)
    else if (rootTag !== 'div')
      tbodyInnerHTML(el, template, tagName)
    else
      checkie = 0
  }
  if (!checkie) el.innerHTML = template

  return el
}

function walk(dom, fn) {
  if (dom) {
    if (fn(dom) === false) walk(dom.nextSibling, fn)
    else {
      dom = dom.firstChild

      while (dom) {
        walk(dom, fn)
        dom = dom.nextSibling
      }
    }
  }
}

function isInStub(dom) {
  while (dom) {
    if (dom.inStub) return true
    dom = dom.parentNode
  }
  return false
}

function mkEl(name) {
  return document.createElement(name)
}

function replaceYield (tmpl, innerHTML) {
  return tmpl.replace(/<(yield)\/?>(<\/\1>)?/gim, innerHTML || '')
}

function $$(selector, ctx) {
  return (ctx || document).querySelectorAll(selector)
}

function $(selector, ctx) {
  return (ctx || document).querySelector(selector)
}

function inherit(parent) {
  function Child() {}
  Child.prototype = parent
  return new Child()
}

function setNamed(dom, parent, keys) {
  each(dom.attributes, function(attr) {
    if (dom._visited) return
    if (attr.name === 'id' || attr.name === 'name') {
      dom._visited = true
      var p, v = attr.value
      if (~keys.indexOf(v)) return

      p = parent[v]
      if (!p)
        parent[v] = dom
      else
        isArray(p) ? p.push(dom) : (parent[v] = [p, dom])
    }
  })
}
<|endoftext|>


<commit_before>(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var C_lib_Hash = C_lib.Hash;
    var C_algo = C.algo;

    // Algorithm
    var C_algo_MD5 = C_algo.MD5 = C_lib_Hash.extend({
        _doReset: function () {
            // Shortcut
            var H = this._hash.words;

            // Initial values
            H[0] = 0x67452301;
            H[1] = 0xefcdab89;
            H[2] = 0x98badcfe;
            H[3] = 0x10325476;
        },

        _doHashBlock: function (offset) {
            // Shortcuts
            var m = this._message.words;
            var H = this._hash.words;

            // Swap endian
            for (var i = 0; i < 16; i++) {
                // Shortcuts
                var i_offset = i + offset;
                var m_i_offset = m[i_offset];

                m[i_offset] = (
                    (((m_i_offset <<  8) | (m_i_offset >>> 24)) & 0x00ff00ff) |
                    (((m_i_offset << 24) | (m_i_offset >>>  8)) & 0xff00ff00)
                );
            }

            // Shortcuts
            var m_0_offset  = m[0  + offset];
            var m_1_offset  = m[1  + offset];
            var m_2_offset  = m[2  + offset];
            var m_3_offset  = m[3  + offset];
            var m_4_offset  = m[4  + offset];
            var m_5_offset  = m[5  + offset];
            var m_6_offset  = m[6  + offset];
            var m_7_offset  = m[7  + offset];
            var m_8_offset  = m[8  + offset];
            var m_9_offset  = m[9  + offset];
            var m_10_offset = m[10 + offset];
            var m_11_offset = m[11 + offset];
            var m_12_offset = m[12 + offset];
            var m_13_offset = m[13 + offset];
            var m_14_offset = m[14 + offset];
            var m_15_offset = m[15 + offset];

            var a = H[0];
            var b = H[1];
            var c = H[2];
            var d = H[3];

            a = FF(a, b, c, d, m_0_offset,   7, 0xd76aa478);
            d = FF(d, a, b, c, m_1_offset,  12, 0xe8c7b756);
            c = FF(c, d, a, b, m_2_offset,  17, 0x242070db);
            b = FF(b, c, d, a, m_3_offset,  22, 0xc1bdceee);
            a = FF(a, b, c, d, m_4_offset,   7, 0xf57c0faf);
            d = FF(d, a, b, c, m_5_offset,  12, 0x4787c62a);
            c = FF(c, d, a, b, m_6_offset,  17, 0xa8304613);
            b = FF(b, c, d, a, m_7_offset,  22, 0xfd469501);
            a = FF(a, b, c, d, m_8_offset,   7, 0x698098d8);
            d = FF(d, a, b, c, m_9_offset,  12, 0x8b44f7af);
            c = FF(c, d, a, b, m_10_offset, 17, 0xffff5bb1);
            b = FF(b, c, d, a, m_11_offset, 22, 0x895cd7be);
            a = FF(a, b, c, d, m_12_offset,  7, 0x6b901122);
            d = FF(d, a, b, c, m_13_offset, 12, 0xfd987193);
            c = FF(c, d, a, b, m_14_offset, 17, 0xa679438e);
            b = FF(b, c, d, a, m_15_offset, 22, 0x49b40821);

            a = GG(a, b, c, d, m_1_offset,   5, 0xf61e2562);
            d = GG(d, a, b, c, m_6_offset,   9, 0xc040b340);
            c = GG(c, d, a, b, m_11_offset, 14, 0x265e5a51);
            b = GG(b, c, d, a, m_0_offset,  20, 0xe9b6c7aa);
            a = GG(a, b, c, d, m_5_offset,   5, 0xd62f105d);
            d = GG(d, a, b, c, m_10_offset,  9, 0x02441453);
            c = GG(c, d, a, b, m_15_offset, 14, 0xd8a1e681);
            b = GG(b, c, d, a, m_4_offset,  20, 0xe7d3fbc8);
            a = GG(a, b, c, d, m_9_offset,   5, 0x21e1cde6);
            d = GG(d, a, b, c, m_14_offset,  9, 0xc33707d6);
            c = GG(c, d, a, b, m_3_offset,  14, 0xf4d50d87);
            b = GG(b, c, d, a, m_8_offset,  20, 0x455a14ed);
            a = GG(a, b, c, d, m_13_offset,  5, 0xa9e3e905);
            d = GG(d, a, b, c, m_2_offset,   9, 0xfcefa3f8);
            c = GG(c, d, a, b, m_7_offset,  14, 0x676f02d9);
            b = GG(b, c, d, a, m_12_offset, 20, 0x8d2a4c8a);

            a = HH(a, b, c, d, m_5_offset,   4, 0xfffa3942);
            d = HH(d, a, b, c, m_8_offset,  11, 0x8771f681);
            c = HH(c, d, a, b, m_11_offset, 16, 0x6d9d6122);
            b = HH(b, c, d, a, m_14_offset, 23, 0xfde5380c);
            a = HH(a, b, c, d, m_1_offset,   4, 0xa4beea44);
            d = HH(d, a, b, c, m_4_offset,  11, 0x4bdecfa9);
            c = HH(c, d, a, b, m_7_offset,  16, 0xf6bb4b60);
            b = HH(b, c, d, a, m_10_offset, 23, 0xbebfbc70);
            a = HH(a, b, c, d, m_13_offset,  4, 0x289b7ec6);
            d = HH(d, a, b, c, m_0_offset,  11, 0xeaa127fa);
            c = HH(c, d, a, b, m_3_offset,  16, 0xd4ef3085);
            b = HH(b, c, d, a, m_6_offset,  23, 0x04881d05);
            a = HH(a, b, c, d, m_9_offset,   4, 0xd9d4d039);
            d = HH(d, a, b, c, m_12_offset, 11, 0xe6db99e5);
            c = HH(c, d, a, b, m_15_offset, 16, 0x1fa27cf8);
            b = HH(b, c, d, a, m_2_offset,  23, 0xc4ac5665);

            a = II(a, b, c, d, m_0_offset,   6, 0xf4292244);
            d = II(d, a, b, c, m_7_offset,  10, 0x432aff97);
            c = II(c, d, a, b, m_14_offset, 15, 0xab9423a7);
            b = II(b, c, d, a, m_5_offset,  21, 0xfc93a039);
            a = II(a, b, c, d, m_12_offset,  6, 0x655b59c3);
            d = II(d, a, b, c, m_3_offset,  10, 0x8f0ccc92);
            c = II(c, d, a, b, m_10_offset, 15, 0xffeff47d);
            b = II(b, c, d, a, m_1_offset,  21, 0x85845dd1);
            a = II(a, b, c, d, m_8_offset,   6, 0x6fa87e4f);
            d = II(d, a, b, c, m_15_offset, 10, 0xfe2ce6e0);
            c = II(c, d, a, b, m_6_offset,  15, 0xa3014314);
            b = II(b, c, d, a, m_13_offset, 21, 0x4e0811a1);
            a = II(a, b, c, d, m_4_offset,   6, 0xf7537e82);
            d = II(d, a, b, c, m_11_offset, 10, 0xbd3af235);
            c = II(c, d, a, b, m_2_offset,  15, 0x2ad7d2bb);
            b = II(b, c, d, a, m_9_offset,  21, 0xeb86d391);

            H[0] = (H[0] + a) >>> 0;
            H[1] = (H[1] + b) >>> 0;
            H[2] = (H[2] + c) >>> 0;
            H[3] = (H[3] + d) >>> 0;
        },

        _doCompute: function () {
            // Shortcuts
            var message = this._message;
            var messageWords = message.words;

            var nBitsTotal = this._length * 8;
            var nBitsLeft = message.sigBytes * 8;

            // Add padding
            messageWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
            messageWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
                (((nBitsTotal <<  8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
                (((nBitsTotal << 24) | (nBitsTotal >>>  8)) & 0xff00ff00)
            );
            message.sigBytes = (messageWords.length + 1) * 4;

            // Hash final blocks
            this._hashBlocks();

            // Shortcut
            var H = this._hash.words;

            // Swap endian
            for (var i = 0; i < 4; i++) {
                // Shortcut
                var H_i = H[i];

                H[i] = (((H_i <<  8) | (H_i >>> 24)) & 0x00ff00ff) |
                       (((H_i << 24) | (H_i >>>  8)) & 0xff00ff00);
            }
        }
    });

    function FF(a, b, c, d, x, s, t) {
        var n = a + ((b & c) | (~b & d)) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    function GG(a, b, c, d, x, s, t) {
        var n = a + ((b & d) | (c & ~d)) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    function HH(a, b, c, d, x, s, t) {
        var n = a + (b ^ c ^ d) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    function II(a, b, c, d, x, s, t) {
        var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    // Helpers
    C.MD5 = function (message) {
        return C_algo_MD5.create().compute(message);
    };
    C.HMAC_MD5 = function (message, key) {
        return C_algo.HMAC.create(C_algo_MD5, key).compute(message);
    };
}());
<commit_msg>Cosmetic.<commit_after>(function () {
    // Shortcuts
    var C = CryptoJS;
    var C_lib = C.lib;
    var C_lib_Hash = C_lib.Hash;
    var C_algo = C.algo;

    // Algorithm
    var C_algo_MD5 = C_algo.MD5 = C_lib_Hash.extend({
        _doReset: function () {
            // Shortcut
            var H = this._hash.words;

            // Initial values
            H[0] = 0x67452301;
            H[1] = 0xefcdab89;
            H[2] = 0x98badcfe;
            H[3] = 0x10325476;
        },

        _doHashBlock: function (offset) {
            // Shortcuts
            var m = this._message.words;
            var H = this._hash.words;

            // Swap endian
            for (var i = 0; i < 16; i++) {
                // Shortcuts
                var offset_i = offset + i;
                var m_offset_i = m[offset_i];

                m[offset_i] = (
                    (((m_offset_i <<  8) | (m_offset_i >>> 24)) & 0x00ff00ff) |
                    (((m_offset_i << 24) | (m_offset_i >>>  8)) & 0xff00ff00)
                );
            }

            // Shortcuts
            var m_offset_0  = m[offset + 0];
            var m_offset_1  = m[offset + 1];
            var m_offset_2  = m[offset + 2];
            var m_offset_3  = m[offset + 3];
            var m_offset_4  = m[offset + 4];
            var m_offset_5  = m[offset + 5];
            var m_offset_6  = m[offset + 6];
            var m_offset_7  = m[offset + 7];
            var m_offset_8  = m[offset + 8];
            var m_offset_9  = m[offset + 9];
            var m_offset_10 = m[offset + 10];
            var m_offset_11 = m[offset + 11];
            var m_offset_12 = m[offset + 12];
            var m_offset_13 = m[offset + 13];
            var m_offset_14 = m[offset + 14];
            var m_offset_15 = m[offset + 15];

            var a = H[0];
            var b = H[1];
            var c = H[2];
            var d = H[3];

            a = FF(a, b, c, d, m_offset_0,   7, 0xd76aa478);
            d = FF(d, a, b, c, m_offset_1,  12, 0xe8c7b756);
            c = FF(c, d, a, b, m_offset_2,  17, 0x242070db);
            b = FF(b, c, d, a, m_offset_3,  22, 0xc1bdceee);
            a = FF(a, b, c, d, m_offset_4,   7, 0xf57c0faf);
            d = FF(d, a, b, c, m_offset_5,  12, 0x4787c62a);
            c = FF(c, d, a, b, m_offset_6,  17, 0xa8304613);
            b = FF(b, c, d, a, m_offset_7,  22, 0xfd469501);
            a = FF(a, b, c, d, m_offset_8,   7, 0x698098d8);
            d = FF(d, a, b, c, m_offset_9,  12, 0x8b44f7af);
            c = FF(c, d, a, b, m_offset_10, 17, 0xffff5bb1);
            b = FF(b, c, d, a, m_offset_11, 22, 0x895cd7be);
            a = FF(a, b, c, d, m_offset_12,  7, 0x6b901122);
            d = FF(d, a, b, c, m_offset_13, 12, 0xfd987193);
            c = FF(c, d, a, b, m_offset_14, 17, 0xa679438e);
            b = FF(b, c, d, a, m_offset_15, 22, 0x49b40821);

            a = GG(a, b, c, d, m_offset_1,   5, 0xf61e2562);
            d = GG(d, a, b, c, m_offset_6,   9, 0xc040b340);
            c = GG(c, d, a, b, m_offset_11, 14, 0x265e5a51);
            b = GG(b, c, d, a, m_offset_0,  20, 0xe9b6c7aa);
            a = GG(a, b, c, d, m_offset_5,   5, 0xd62f105d);
            d = GG(d, a, b, c, m_offset_10,  9, 0x02441453);
            c = GG(c, d, a, b, m_offset_15, 14, 0xd8a1e681);
            b = GG(b, c, d, a, m_offset_4,  20, 0xe7d3fbc8);
            a = GG(a, b, c, d, m_offset_9,   5, 0x21e1cde6);
            d = GG(d, a, b, c, m_offset_14,  9, 0xc33707d6);
            c = GG(c, d, a, b, m_offset_3,  14, 0xf4d50d87);
            b = GG(b, c, d, a, m_offset_8,  20, 0x455a14ed);
            a = GG(a, b, c, d, m_offset_13,  5, 0xa9e3e905);
            d = GG(d, a, b, c, m_offset_2,   9, 0xfcefa3f8);
            c = GG(c, d, a, b, m_offset_7,  14, 0x676f02d9);
            b = GG(b, c, d, a, m_offset_12, 20, 0x8d2a4c8a);

            a = HH(a, b, c, d, m_offset_5,   4, 0xfffa3942);
            d = HH(d, a, b, c, m_offset_8,  11, 0x8771f681);
            c = HH(c, d, a, b, m_offset_11, 16, 0x6d9d6122);
            b = HH(b, c, d, a, m_offset_14, 23, 0xfde5380c);
            a = HH(a, b, c, d, m_offset_1,   4, 0xa4beea44);
            d = HH(d, a, b, c, m_offset_4,  11, 0x4bdecfa9);
            c = HH(c, d, a, b, m_offset_7,  16, 0xf6bb4b60);
            b = HH(b, c, d, a, m_offset_10, 23, 0xbebfbc70);
            a = HH(a, b, c, d, m_offset_13,  4, 0x289b7ec6);
            d = HH(d, a, b, c, m_offset_0,  11, 0xeaa127fa);
            c = HH(c, d, a, b, m_offset_3,  16, 0xd4ef3085);
            b = HH(b, c, d, a, m_offset_6,  23, 0x04881d05);
            a = HH(a, b, c, d, m_offset_9,   4, 0xd9d4d039);
            d = HH(d, a, b, c, m_offset_12, 11, 0xe6db99e5);
            c = HH(c, d, a, b, m_offset_15, 16, 0x1fa27cf8);
            b = HH(b, c, d, a, m_offset_2,  23, 0xc4ac5665);

            a = II(a, b, c, d, m_offset_0,   6, 0xf4292244);
            d = II(d, a, b, c, m_offset_7,  10, 0x432aff97);
            c = II(c, d, a, b, m_offset_14, 15, 0xab9423a7);
            b = II(b, c, d, a, m_offset_5,  21, 0xfc93a039);
            a = II(a, b, c, d, m_offset_12,  6, 0x655b59c3);
            d = II(d, a, b, c, m_offset_3,  10, 0x8f0ccc92);
            c = II(c, d, a, b, m_offset_10, 15, 0xffeff47d);
            b = II(b, c, d, a, m_offset_1,  21, 0x85845dd1);
            a = II(a, b, c, d, m_offset_8,   6, 0x6fa87e4f);
            d = II(d, a, b, c, m_offset_15, 10, 0xfe2ce6e0);
            c = II(c, d, a, b, m_offset_6,  15, 0xa3014314);
            b = II(b, c, d, a, m_offset_13, 21, 0x4e0811a1);
            a = II(a, b, c, d, m_offset_4,   6, 0xf7537e82);
            d = II(d, a, b, c, m_offset_11, 10, 0xbd3af235);
            c = II(c, d, a, b, m_offset_2,  15, 0x2ad7d2bb);
            b = II(b, c, d, a, m_offset_9,  21, 0xeb86d391);

            H[0] = (H[0] + a) >>> 0;
            H[1] = (H[1] + b) >>> 0;
            H[2] = (H[2] + c) >>> 0;
            H[3] = (H[3] + d) >>> 0;
        },

        _doCompute: function () {
            // Shortcuts
            var message = this._message;
            var messageWords = message.words;

            var nBitsTotal = this._length * 8;
            var nBitsLeft = message.sigBytes * 8;

            // Add padding
            messageWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
            messageWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
                (((nBitsTotal <<  8) | (nBitsTotal >>> 24)) & 0x00ff00ff) |
                (((nBitsTotal << 24) | (nBitsTotal >>>  8)) & 0xff00ff00)
            );
            message.sigBytes = (messageWords.length + 1) * 4;

            // Hash final blocks
            this._hashBlocks();

            // Shortcut
            var H = this._hash.words;

            // Swap endian
            for (var i = 0; i < 4; i++) {
                // Shortcut
                var H_i = H[i];

                H[i] = (((H_i <<  8) | (H_i >>> 24)) & 0x00ff00ff) |
                       (((H_i << 24) | (H_i >>>  8)) & 0xff00ff00);
            }
        }
    });

    function FF(a, b, c, d, x, s, t) {
        var n = a + ((b & c) | (~b & d)) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    function GG(a, b, c, d, x, s, t) {
        var n = a + ((b & d) | (c & ~d)) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    function HH(a, b, c, d, x, s, t) {
        var n = a + (b ^ c ^ d) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    function II(a, b, c, d, x, s, t) {
        var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
    }

    // Helpers
    C.MD5 = function (message) {
        return C_algo_MD5.create().compute(message);
    };
    C.HMAC_MD5 = function (message, key) {
        return C_algo.HMAC.create(C_algo_MD5, key).compute(message);
    };
}());
<|endoftext|>


<commit_before>//orangeStand by Michael Leonffu

This handles putting the data into the database to present onto the website; all this really does is a mongodb insert or update.
<commit_msg>Added some stuff that'll beed ot bechanged<commit_after>//orangeStand by Michael Leonffu

This handles putting the data into the database to present onto the website; all this really does is a mongodb insert or update.

module.exports = {
	orangeStang: CHAGHHEIGEGHIGHLATTTEERRRr
}

// To use in another file:
// var orangeStand = require('./orangeStand')
// orangeStand.CHAGHHEIGEGHIGHLATTTEERRRr(pickedOranges, STUFf)
// Where STUFf is the callback function returning a json<|endoftext|>