<commit_before>/**
 *
 * Utility method to compare value of fields between actual and extected object.
 *
 * For 1 argument, @param {String} value represents the field to be compared between
 * assertValue._expected and assertValue._actual objects.
 *
 * For 2 argument, @param {String} value, @param {String} objectOne represents the field to be compared
 * between {assertValue._expected.objectOne} and {assertValue._actual.objectOne} objects.
 *
 * For 3 argument, @param {String} value, @param {String} objectOne, @param {String} objectTwo
 * represents the field to be compared between
 * {assertValue._expected.objectTwo.objectOne} and {assertValue._actual.objectTwo.objectOne} objects.
 *
 * This function can be further extend following the pattern above.
 *
 * @param {String} value
 * @param {String} objectOne
 * @param {String} objectTwo
 */

function assertValue (value, objectOne, objectTwo) {

	assert = assertValue._assertMethod;

	if(!assertValue._expected) {
		assertValue._expected = {};
	}

	if(!assertValue._actual) {
		assertValue._actual = {};
	}

	var length = arguments.length;

	switch(length) {
		case 1:
			if (typeof assertValue._actual.get(value) === "function") {
				assert.ok(assertValue._expected[value].toString() === assertValue._actual.get(value).toString() , "Passed - " + value );
			} else {
				assert.ok(assertValue._expected[value] === assertValue._actual.get(value) , "Passed - " + value );
			}

		break;

		case 2:
			assert.ok(assertValue._expected[objectOne][value] === assertValue._actual.get(objectOne)[value] , "Passed - " + objectOne + " " + value );
		break;

		case 3:
			assert.ok(assertValue._expected[objectTwo][objectOne][value] === assertValue._actual.get(objectTwo)[objectOne][value] , "Passed - " + objectTwo + " " + objectOne + " " + value );
		break;

		default:
		break;
	}
}

/*QUnit.module("Configuration Test", {
	beforeEach: function(assert) {
		console.log("\n");
		console.log("############### Testing Module Configuration ###############")
	}
});*/

QUnit.test("Test Configuration for undefined/no options",function(assert) {
	assertValue._assertMethod = assert;
	assertValue._expected = {
		data: 'required',
		url: 'required',
		maxNoOfContent: 10,
		paginated: false
	}

	var actual = new SmartAutocomplete.Configuration();

	assert.ok(actual, "Passed : Configuration created succesfully for no options");

	assertValue._actual = actual;
	assertValue('data');
	assertValue('url');
	assertValue('maxNoOfContent');
	assertValue('paginated');
	assert.ok(typeof actual.get("listLocation") === 'function', "Passed : listLocation of type function");
	assert.ok(typeof actual.get("getValue") 	=== 'function', "Passed : getValue of type function");

	assert.expect(7);
});

QUnit.test("Test Defualt Configuration", function (assert) {
    assertValue._assertMethod = assert;
	assertValue._expected = {
		data: 'required',
		url: 'required',
		maxNoOfContent: 10,
		paginated: false
	}

	var actual = new SmartAutocomplete.Configuration({});

	assertValue._actual = actual;

	assertValue('data');
	assertValue('url');
	assertValue('maxNoOfContent');
	assertValue('paginated');
	assert.ok(typeof actual.get("listLocation") === 'function', "Passed : listLocation of type function");
	assert.ok(typeof actual.get("getValue") 	=== 'function', "Passed : getValue of type function");
	assert.expect(6);
});

QUnit.test("Basic Configuration Test", function (assert) {

	assertValue._assertMethod = assert;

	var options = {
		data: ['A', 'B', 'C'],
		maxNoOfContent: 20,
		paginated: true,
		paginationQuery: {
			offset: 0,
			length: 10
		},
		url: function (phrase) {
			return 'url?'+phrase;
		},
		getValue: function (element) {
			return element;
		},
		listLocation: function(data) {
			return data;
		},
		getPaginationQuery: function(prevPaginationQuery){
			return prevPaginationQuery;
		}
	};
	var actual = new SmartAutocomplete.Configuration(options);

	assertValue._expected = options;
	assertValue._actual = actual;

	assertValue('data');
	assertValue('url');
	assertValue('getValue');
	assertValue('listLocation');
	assertValue('maxNoOfContent');
	assertValue('paginated');

});

QUnit.test("getValue Test", function(assert) {

	var options = {
		getValue: 'name'
	}

	var testData = {
			name: ['A', 'B', 'C', 'D', 'E'],
			name2: ['A', 'B', 'C', 'D'],
			length: 5
		};

	var actual = new SmartAutocomplete.Configuration(options);

	assert.ok(testData.name === actual.get('getValue')(testData),
	"Passed: fieldName assigned to getValue");

	options = {
		getValue: function(data) {
			return data.fruits.dataList;
		}
	};

	testData = {
		fruits: {
			dataList:['apple', 'orange', 'grapes']
		}
	}

	actual = new SmartAutocomplete.Configuration(options);

	assert.ok(testData.fruits.dataList === actual.get('getValue')(testData),
	"Passed: function assigned to getValue for complicated data");
});

QUnit.test("pagination Configuration Test", function(assert) {

	var options = {
		pagination:{
			query: {
				offset: 0,
				length: 10
			},
			next: function (currentPaginationQuery) {
				return currentPaginationQuery;
			},
			prev: function (currentPaginationQuery) {
				return currentPaginationQuery;
			}
		}
	}

	var actual = new SmartAutocomplete.Configuration(options);

	assertValue._assertMethod = assert;
	assertValue._expected = options;
	assertValue._actual = actual;

	assertValue('offset', 'query', 'pagination');
	assertValue('length', 'query', 'pagination');
	assert.ok(typeof actual.get('pagination').next === 'function',
	"Passed: pagination.next is of type function");

	assert.ok(typeof actual.get('pagination').prev === 'function',
	"Passed: pagination.prev is of type function");

	assert.ok(options.pagination.query.offset === actual.get('pagination').next().offset);
	assert.ok(options.pagination.query.length === actual.get('pagination').next().length);
	assert.ok(options.pagination.query.offset === actual.get('pagination').prev().offset);
	assert.ok(options.pagination.query.length === actual.get('pagination').prev().length);

	options.pagination.next = function(currentPaginationQuery){
		currentPaginationQuery.offset = currentPaginationQuery.offset+currentPaginationQuery.length;
		return currentPaginationQuery;
	}

	options.pagination.prev = function(currentPaginationQuery){
		currentPaginationQuery.offset = currentPaginationQuery.offset-currentPaginationQuery.length;
		return currentPaginationQuery;
	}

	actual = new SmartAutocomplete.Configuration(options);

	assert.ok((options.pagination.query.offset+10) === actual.get('pagination').next().offset);
	assert.ok(options.pagination.query.length === actual.get('pagination').next().length);
	assert.ok((options.pagination.query.offset-10) === actual.get('pagination').prev().offset);
	assert.ok(options.pagination.query.length === actual.get('pagination').prev().length);

	// Checking if original pagination query is not modified
	assert.ok(options.pagination.query.length === SmartAutocomplete.Configuration.currentPaginationQuery.length)
	assert.ok(options.pagination.query.offset === SmartAutocomplete.Configuration.currentPaginationQuery.offset)

});<commit_msg>Test case updated<commit_after>/**
 *
 * Utility method to compare value of fields between actual and extected object.
 *
 * For 1 argument, @param {String} value represents the field to be compared between
 * assertValue._expected and assertValue._actual objects.
 *
 * For 2 argument, @param {String} value, @param {String} objectOne represents the field to be compared
 * between {assertValue._expected.objectOne} and {assertValue._actual.objectOne} objects.
 *
 * For 3 argument, @param {String} value, @param {String} objectOne, @param {String} objectTwo
 * represents the field to be compared between
 * {assertValue._expected.objectTwo.objectOne} and {assertValue._actual.objectTwo.objectOne} objects.
 *
 * This function can be further extend following the pattern above.
 *
 * @param {String} value
 * @param {String} objectOne
 * @param {String} objectTwo
 */

function assertValue (value, objectOne, objectTwo) {

	assert = assertValue._assertMethod;

	if(!assertValue._expected) {
		assertValue._expected = {};
	}

	if(!assertValue._actual) {
		assertValue._actual = {};
	}

	var length = arguments.length;

	switch(length) {
		case 1:
			if (typeof assertValue._actual.get(value) === "function") {
				assert.ok(assertValue._expected[value].toString() === assertValue._actual.get(value).toString() , "Passed - " + value );
			} else {
				assert.ok(assertValue._expected[value] === assertValue._actual.get(value) , "Passed - " + value );
			}

		break;

		case 2:
			assert.ok(assertValue._expected[objectOne][value] === assertValue._actual.get(objectOne)[value] , "Passed - " + objectOne + " " + value );
		break;

		case 3:
			assert.ok(assertValue._expected[objectTwo][objectOne][value] === assertValue._actual.get(objectTwo)[objectOne][value] , "Passed - " + objectTwo + " " + objectOne + " " + value );
		break;

		default:
		break;
	}
}

/*QUnit.module("Configuration Test", {
	beforeEach: function(assert) {
		console.log("\n");
		console.log("############### Testing Module Configuration ###############")
	}
});*/

QUnit.test("Test Configuration for undefined/no options",function(assert) {
	assertValue._assertMethod = assert;
	assertValue._expected = {
		data: 'required',
		url: 'required',
		maxNoOfContent: 10,
		paginated: false
	}

	var actual = new SmartAutocomplete.Configuration();

	assert.ok(actual, "Passed : Configuration created succesfully for no options");

	assertValue._actual = actual;
	assertValue('data');
	assertValue('url');
	assertValue('maxNoOfContent');
	assertValue('paginated');
	assert.ok(typeof actual.get("listLocation") === 'function', "Passed : listLocation of type function");
	assert.ok(typeof actual.get("getValue") 	=== 'function', "Passed : getValue of type function");

	assert.expect(7);
});

QUnit.test("Test Defualt Configuration", function (assert) {
    assertValue._assertMethod = assert;
	assertValue._expected = {
		data: 'required',
		url: 'required',
		maxNoOfContent: 10,
		paginated: false
	}

	var actual = new SmartAutocomplete.Configuration({});

	assertValue._actual = actual;

	assertValue('data');
	assertValue('url');
	assertValue('maxNoOfContent');
	assertValue('paginated');
	assert.ok(typeof actual.get("listLocation") === 'function', "Passed : listLocation of type function");
	assert.ok(typeof actual.get("getValue") 	=== 'function', "Passed : getValue of type function");
	assert.expect(6);
});

QUnit.test("Basic Configuration Test", function (assert) {

	assertValue._assertMethod = assert;

	var options = {
		data: ['A', 'B', 'C'],
		maxNoOfContent: 20,
		paginated: true,
		paginationQuery: {
			offset: 0,
			length: 10
		},
		url: function (phrase) {
			return 'url?'+phrase;
		},
		getValue: function (element) {
			return element;
		},
		listLocation: function(data) {
			return data;
		},
		getPaginationQuery: function(prevPaginationQuery){
			return prevPaginationQuery;
		}
	};
	var actual = new SmartAutocomplete.Configuration(options);

	assertValue._expected = options;
	assertValue._actual = actual;

	assertValue('data');
	assertValue('url');
	assertValue('getValue');
	assertValue('listLocation');
	assertValue('maxNoOfContent');
	assertValue('paginated');

});

QUnit.test("getValue Test", function(assert) {

	var options = {
		getValue: 'name'
	}

	var testData = {
			name: ['A', 'B', 'C', 'D', 'E'],
			name2: ['A', 'B', 'C', 'D'],
			length: 5
		};

	var actual = new SmartAutocomplete.Configuration(options);

	assert.ok(testData.name === actual.get('getValue')(testData),
	"Passed: fieldName assigned to getValue");

	options = {
		getValue: function(data) {
			return data.fruits.dataList;
		}
	};

	testData = {
		fruits: {
			dataList:['apple', 'orange', 'grapes']
		}
	}

	actual = new SmartAutocomplete.Configuration(options);

	assert.ok(testData.fruits.dataList === actual.get('getValue')(testData),
	"Passed: function assigned to getValue for complicated data");
});

QUnit.test("pagination Configuration Test", function(assert) {

	var options = {
		pagination:{
			query: {
				offset: 1,
				length: 20
			},
			next: function (currentPaginationQuery) {
				return currentPaginationQuery;
			},
			prev: function (currentPaginationQuery) {
				return currentPaginationQuery;
			}
		}
	}

	var actual = new SmartAutocomplete.Configuration(options);

	assertValue._assertMethod = assert;
	assertValue._expected = options;
	assertValue._actual = actual;

	assertValue('offset', 'query', 'pagination');
	assertValue('length', 'query', 'pagination');
	assert.ok(typeof actual.get('pagination').next === 'function',
	"Passed: pagination.next is of type function");

	assert.ok(typeof actual.get('pagination').prev === 'function',
	"Passed: pagination.prev is of type function");

	assert.ok(options.pagination.query.offset === actual.get('pagination').next().offset);
	assert.ok(options.pagination.query.length === actual.get('pagination').next().length);
	assert.ok(options.pagination.query.offset === actual.get('pagination').prev().offset);
	assert.ok(options.pagination.query.length === actual.get('pagination').prev().length);

	options.pagination.next = function(currentPaginationQuery){
		currentPaginationQuery.offset = currentPaginationQuery.offset+currentPaginationQuery.length;
		return currentPaginationQuery;
	}

	options.pagination.prev = function(currentPaginationQuery){
		currentPaginationQuery.offset = currentPaginationQuery.offset-currentPaginationQuery.length;
		return currentPaginationQuery;
	}

	actual = new SmartAutocomplete.Configuration(options);

	assert.ok((options.pagination.query.offset+options.pagination.query.length) === actual.get('pagination').next().offset);
	assert.ok(options.pagination.query.length === actual.get('pagination').next().length);
	assert.ok((options.pagination.query.offset-options.pagination.query.length) === actual.get('pagination').prev().offset);
	assert.ok(options.pagination.query.length === actual.get('pagination').prev().length);

	// Checking if original pagination query is not modified
	assert.ok(options.pagination.query.length === SmartAutocomplete.Configuration.currentPaginationQuery.length)
	assert.ok(options.pagination.query.offset === SmartAutocomplete.Configuration.currentPaginationQuery.offset)

});<|endoftext|>


<commit_before>
md.messages = ({storage: {defaults, state, set}, compilers, mathjax, webrequest}) => {

  return (req, sender, sendResponse) => {

    if (req.message === 'markdown') {
      var markdown = req.markdown

      if (state.content.mathjax) {
        var jax = mathjax()
        markdown = jax.tokenize(markdown)
      }

      var html = compilers[state.compiler].compile(markdown)

      if (state.content.mathjax) {
        html = jax.detokenize(html)
      }

      sendResponse({message: 'html', html})
    }

    // popup
    else if (req.message === 'popup') {
      sendResponse(Object.assign({}, state, {
        options: state[state.compiler],
        description: compilers[state.compiler].description,
        compilers: Object.keys(compilers),
        themes: state.themes,
      }))
    }
    else if (req.message === 'popup.theme') {
      set({theme: req.theme})
      notifyContent({message: 'theme', theme: req.theme})
      sendResponse()
    }
    else if (req.message === 'popup.raw') {
      set({raw: req.raw})
      notifyContent({message: 'raw', raw: req.raw})
      sendResponse()
    }
    else if (req.message === 'popup.defaults') {
      var options = Object.assign({}, defaults)
      options.origins = state.origins
      set(options)
      notifyContent({message: 'reload'})
      sendResponse()
    }
    else if (req.message === 'popup.compiler.name') {
      set({compiler: req.compiler})
      notifyContent({message: 'reload'})
      sendResponse()
    }
    else if (req.message === 'popup.compiler.options') {
      set({[req.compiler]: req.options})
      notifyContent({message: 'reload'})
      sendResponse()
    }
    else if (req.message === 'popup.content') {
      set({content: req.content})
      notifyContent({message: 'reload'})
      webrequest()
      sendResponse()
    }
    else if (req.message === 'popup.advanced') {
      // ff: opens up about:addons with openOptionsPage
      if (/Firefox/.test(navigator.userAgent)) {
        chrome.management.getSelf((extension) => {
          chrome.tabs.create({url: extension.optionsUrl})
        })
      }
      else {
        chrome.runtime.openOptionsPage()
      }
      sendResponse()
    }

    // options
    else if (req.message === 'options') {
      sendResponse({
        origins: state.origins,
        header: state.header,
        match: state.match,
        themes: state.themes,
      })
    }
    else if (req.message === 'options.header') {
      set({header: req.header})
      sendResponse()
    }

    // origins
    else if (req.message === 'origin.add') {
      state.origins[req.origin] = {
        match: defaults.match,
        csp: false,
        encoding: '',
      }
      set({origins: state.origins})
      sendResponse()
    }
    else if (req.message === 'origin.remove') {
      delete state.origins[req.origin]
      set({origins: state.origins})
      webrequest()
      sendResponse()
    }
    else if (req.message === 'origin.update') {
      state.origins[req.origin] = req.options
      set({origins: state.origins})
      webrequest()
      sendResponse()
    }

    // themes
    else if (req.message === 'themes') {
      set({themes: req.themes})
      sendResponse()
    }
  }

  function notifyContent (req, res) {
    chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
      chrome.tabs.sendMessage(tabs[0].id, req, res)
    })
  }
}
<commit_msg>Fix custom theme message handling<commit_after>
md.messages = ({storage: {defaults, state, set}, compilers, mathjax, webrequest}) => {

  return (req, sender, sendResponse) => {

    if (req.message === 'markdown') {
      var markdown = req.markdown

      if (state.content.mathjax) {
        var jax = mathjax()
        markdown = jax.tokenize(markdown)
      }

      var html = compilers[state.compiler].compile(markdown)

      if (state.content.mathjax) {
        html = jax.detokenize(html)
      }

      sendResponse({message: 'html', html})
    }

    // popup
    else if (req.message === 'popup') {
      sendResponse(Object.assign({}, state, {
        options: state[state.compiler],
        description: compilers[state.compiler].description,
        compilers: Object.keys(compilers),
        themes: state.themes,
      }))
    }
    else if (req.message === 'popup.theme') {
      set({theme: req.theme})
      notifyContent({message: 'theme', theme: req.theme})
      sendResponse()
    }
    else if (req.message === 'popup.raw') {
      set({raw: req.raw})
      notifyContent({message: 'raw', raw: req.raw})
      sendResponse()
    }
    else if (req.message === 'popup.defaults') {
      var options = Object.assign({}, defaults)
      options.origins = state.origins
      set(options)
      notifyContent({message: 'reload'})
      sendResponse()
    }
    else if (req.message === 'popup.compiler.name') {
      set({compiler: req.compiler})
      notifyContent({message: 'reload'})
      sendResponse()
    }
    else if (req.message === 'popup.compiler.options') {
      set({[req.compiler]: req.options})
      notifyContent({message: 'reload'})
      sendResponse()
    }
    else if (req.message === 'popup.content') {
      set({content: req.content})
      notifyContent({message: 'reload'})
      webrequest()
      sendResponse()
    }
    else if (req.message === 'popup.advanced') {
      // ff: opens up about:addons with openOptionsPage
      if (/Firefox/.test(navigator.userAgent)) {
        chrome.management.getSelf((extension) => {
          chrome.tabs.create({url: extension.optionsUrl})
        })
      }
      else {
        chrome.runtime.openOptionsPage()
      }
      sendResponse()
    }

    // options
    else if (req.message === 'options') {
      sendResponse({
        origins: state.origins,
        header: state.header,
        match: state.match,
        themes: state.themes,
      })
    }
    else if (req.message === 'options.header') {
      set({header: req.header})
      sendResponse()
    }

    // origins
    else if (req.message === 'origin.add') {
      state.origins[req.origin] = {
        match: defaults.match,
        csp: false,
        encoding: '',
      }
      set({origins: state.origins})
      sendResponse()
    }
    else if (req.message === 'origin.remove') {
      delete state.origins[req.origin]
      set({origins: state.origins})
      webrequest()
      sendResponse()
    }
    else if (req.message === 'origin.update') {
      state.origins[req.origin] = req.options
      set({origins: state.origins})
      webrequest()
      sendResponse()
    }

    // themes
    else if (req.message === 'themes') {
      set({themes: req.themes})

      ;(() => {
        var defaults = chrome.runtime.getManifest().web_accessible_resources
          .filter((file) => file.indexOf('/themes/') === 0)
          .map((file) => file.replace(/\/themes\/(.*)\.css/, '$1'))
        var custom = state.themes.map(({name}) => name)
        var all = custom.concat(defaults)

        if (!all.includes(state.theme.name)) {
          var theme = {
            name: 'github',
            url: chrome.runtime.getURL('/themes/github.css')
          }
          set({theme})
        }
        else if (custom.includes(state.theme.name)) {
          var theme = state.themes.find(({name}) => state.theme.name === name)
          set({theme})
        }
      })()

      sendResponse()
    }
  }

  function notifyContent (req, res) {
    chrome.tabs.query({active: true, currentWindow: true}, (tabs) => {
      chrome.tabs.sendMessage(tabs[0].id, req, res)
    })
  }
}
<|endoftext|>


<commit_before>function Support_B_M(aSupportnums,aChara) {
	for(var i=0;i<aSupportnums.length;i++){
		switch (aSupportnums[i]) {
			case 0://自傷　威力１
				var tDamege = calcDamage(aChara.ATK,aChara.DEF,1);

				var tCard=mCard[aChara.x+aChara.y*8];
				if(tCard[1]==aChara.TYPE){
					tDamege = Math.floor(tDamege*1.5);
				}

				aChara.HP-=tDamege;
				damageLog(aChara,tDamege);
				displayStatus();
				if(aChara.HP<=0){
					aChara.HP=0;
					if(aChara.team=="T"){
						winner("F");
					}
					else{
						winner("T");
					}
				}
				break;
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			default:

		}
	}
}
function Support_A_M(aSupportnums,aChara) {
	for(var i=0;i<aSupportnums.length;i++){
		switch (aSupportnums[i]) {
			case 0://威力５の回復
				var tDamege = calcDamage(aChara.ATK,aChara.DEF,5);
				var tCard=mCard[aChara.x+aChara.y*8];
				if(tCard[1]==aChara.TYPE){
					tDamege = Math.floor(tDamege*1.5);
				}

				aChara.HP+=tDamege;
				damageLog(aChara,-tDamege);
				if(aChara.HP>aChara.originalHP){
					aChara.HP = aChara.originalHP;
				}
				displayStatus();
				break;
			case 1:
				var tDelay = Math.floor(100000/aChara.SPD);//初期値
				aChara.Delay= (-tDelay);
				break;
			case 2:
				break;
			case 3:
				break;
			default:

		}
	}
}
function Support_B_E(aSupportnums,aChara) {
	for(var i=0;i<aSupportnums.length;i++){
		switch (aSupportnums[i]) {
			case 0:
				break;
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			default:

		}
	}
}
function Support_A_E(aSupportnums,aChara) {
	for(var i=0;i<aSupportnums.length;i++){
		switch (aSupportnums[i]) {
			case 0:
				break;
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			default:

		}
	}
}
function Support_O(aSupportnums,aChara) {
	for(var i=0;i<aSupportnums.length;i++){
		switch (aSupportnums[i]) {
			case 0:
				//シャッフルする
				mCard=shuffle(mCard);
				//トランプを並べる
				displayCard();
				addLog("シャッフル");
				break;
			case 1://裏カードを表に向ける
				$("#cardTable")[0].getElementsByTagName("tr")[aChara.y].getElementsByTagName("td")[aChara.x].getElementsByTagName("img")[0].src="../image/card.png";
				break;
			case 2:
				break;
			case 3:
				break;
			default:

		}
	}
}<commit_msg>サポート関数のループを再起法に変更<commit_after>function Support_B_M(aSupportnums,aChara){
	if(aSupportnums.length>0){
		Support_B_M_Play(aSupportnums[0],aChara);
		Support_B_M(aSupportnums.shift,aChara)
	}
	return;
}

function Support_B_M_Play(aSupportnum,aChara) {
	// if(var i=0;i<aSupportnums.length;i++){
		switch (aSupportnum) {
			case 0://自傷　威力１
				var tDamege = calcDamage(aChara.ATK,aChara.DEF,1);

				var tCard=mCard[aChara.x+aChara.y*8];
				if(tCard[1]==aChara.TYPE){
					tDamege = Math.floor(tDamege*1.5);
				}

				aChara.HP-=tDamege;
				damageLog(aChara,tDamege);
				displayStatus();
				if(aChara.HP<=0){
					aChara.HP=0;
					if(aChara.team=="T"){
						winner("F");
					}
					else{
						winner("T");
					}
				}
				break;
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			default:

		}
	// }
}

function Support_A_M(aSupportnums,aChara){
	if(aSupportnums.length>0){
		Support_A_M_Play(aSupportnums[0],aChara);
		Support_A_M(aSupportnums.shift,aChara)
	}
	return;
}
function Support_A_M_Play(aSupportnum,aChara) {
	// for(var i=0;i<aSupportnums.length;i++){
		switch (aSupportnum) {
			case 0://威力５の回復
				var tDamege = calcDamage(aChara.ATK,aChara.DEF,5);
				var tCard=mCard[aChara.x+aChara.y*8];
				if(tCard[1]==aChara.TYPE){
					tDamege = Math.floor(tDamege*1.5);
				}

				aChara.HP+=tDamege;
				damageLog(aChara,-tDamege);
				if(aChara.HP>aChara.originalHP){
					aChara.HP = aChara.originalHP;
				}
				displayStatus();
				break;
			case 1:
				var tDelay = Math.floor(100000/aChara.SPD);//初期値
				aChara.Delay= (-tDelay);
				break;
			case 2:
				break;
			case 3:
				break;
			default:

		}
	// }
}

function Support_B_E(aSupportnums,aChara){
	if(aSupportnums.length>0){
		Support_B_E_Play(aSupportnums[0],aChara);
		Support_B_E(aSupportnums.shift,aChara)
	}
	return;
}
function Support_B_E_Play(aSupportnum,aChara) {
	// for(var i=0;i<aSupportnums.length;i++){
		switch (aSupportnum) {
			case 0:
				break;
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			default:

		}
	// }
}

function Support_A_E(aSupportnums,aChara){
	if(aSupportnums.length>0){
		Support_A_E_Play(aSupportnums[0],aChara);
		Support_A_E(aSupportnums.shift,aChara)
	}
	return;
}
function Support_A_E_Play(aSupportnum,aChara) {
	// for(var i=0;i<aSupportnums.length;i++){
		switch (aSupportnum) {
			case 0:
				break;
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			default:

		}
	// }
}

function Support_O(aSupportnums,aChara){
	if(aSupportnums.length>0){
		Support_O_Play(aSupportnums[0],aChara);
		Support_O(aSupportnums.shift,aChara)
	}
	return;
}
function Support_O_Play(aSupportnum,aChara) {
	// for(var i=0;i<aSupportnums.length;i++){
		switch (aSupportnum) {
			case 0:
				//シャッフルする
				mCard=shuffle(mCard);
				//トランプを並べる
				displayCard();
				addLog("シャッフル");
				break;
			case 1://裏カードを表に向ける
				$("#cardTable")[0].getElementsByTagName("tr")[aChara.y].getElementsByTagName("td")[aChara.x].getElementsByTagName("img")[0].src="../image/card.png";
				break;
			case 2:
				break;
			case 3:
				break;
			default:

		}
	// }
}<|endoftext|>


<commit_before>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
(function () {
    "use strict";

    function projectElement($q, $resource, linkName) {
        return {
            add: function (project, element) {
                var defer = $q.defer();
                $resource(project._links[linkName].href).save(element, function (data) {
                    defer.resolve(data);
                });
                return defer.promise;
            },
            remove: function (element) {
                var defer = $q.defer();
                $resource(element._links.self.href).delete(function (data) {
                    defer.resolve(data);
                });
                return defer.promise;
            }
        };
    }

    function projectTask($q, $resource) {
        return projectElement($q, $resource, "tasks");
    }

    function projectMember($q, $resource) {
        return projectElement($q, $resource, "members");
    }

    function projectCategory($q, $resource) {
        return projectElement($q, $resource, "category");
    }

    function projectState($q, $resource) {
        return projectElement($q, $resource, "states");
    }
    function projectSwimlane($q, $resource) {
        return projectElement($q, $resource, "swimlanes");
    }

    function projectResourceAssembler($q, $resource, taskResourceAssembler) {
        return {
            assemble: function (project, withSwimlanes) {
                project.states = $resource(project._links.states.href).query();
                if (withSwimlanes) {
                    project.swimlanes = $resource(project._links.swimlanes.href).query();
                }
                return project;
            },
            tasks: function (project, page) {
                var defer = $q.defer();
                $resource(project._links.tasks.href).get({page: page.page, size: page.size}, function (response) {
                    var taskPage = {
                        page: response.page,
                        tasks: []
                    };
                    if (response._embedded) {
                        angular.forEach(response._embedded.taskResources, function (task) {
                            taskPage.tasks.push(taskResourceAssembler.assemble(task, true));
                        });
                    }
                    defer.resolve(taskPage);
                });
                return defer.promise;
            },
            kanban: function (project) {
                var tasksByState = {};
                var tabDefer = [];
                for (var i = 0; i < project._links.taskByState.length; i++) {
                    var state = project._links.taskByState[i];
                    var deferState = $resource(state.href).get();
                    deferState.$promise.then(function (data) {
                        tasksByState[data.id] = data;
                        tasksByState[data.id].tasks = [];
                        if (data._links) {
                            angular.forEach(data._links.tasks, function (task) {
                                var link = task;
                                if (task.href) {
                                    link = task.href;
                                }
                                $resource(link).get(function (result) {
                                    tasksByState[data.id].tasks.push(taskResourceAssembler.assemble(result, true));
                                });
                            });
                        }
                    });
                    tabDefer.push(deferState.$promise);
                }
                return $q.all(tabDefer);
            },
            members: function (project, page) {
                var defer = $q.defer();
                $resource(project._links.members.href).get({page: page.page, size: page.size}, function (response) {
                    var membersPage = {
                        page: response.page,
                        members: []
                    };
                    if (response._embedded) {
                        angular.forEach(response._embedded.memberResources, function (member) {
                            membersPage.members.push(member);
                        });
                    }
                    defer.resolve(membersPage);
                });
                return defer.promise;
            },
            states: function (project) {
                return $resource(project._links.states.href).query();
            },
            swimlane: function (project) {
                return $resource(project._links.swimlanes.href).query();
            },
            category: function (project) {
                return $resource(project._links.category.href).query();
            }
        };
    }

    function taskResourceAssembler($resource) {
        return {
            assemble: function (task, withStateAndSwimlane) {
                if (withStateAndSwimlane) {
                    task.state = $resource(task._links.state.href).get();
                    if (task._links.swimlane) {
                        task.swimlane = $resource(task._links.swimlane.href).get();
                    }
                }
                if (task._links.assignee) {
                    task.assignee = $resource(task._links.assignee.href).get();
                }
                if (task._links.backup) {
                    task.backup = $resource(task._links.backup.href).get();
                }
                if (task._links.category) {
                    task.category = $resource(task._links.category.href).get();
                }
                return task;
            },
            allocations: function (task) {
                return $resource(task._links.allocations.href).query();
            },
            history: function (task) {
                return $resource(task._links.history.href).query();
            },
            comments: function (task) {
                return $resource(task._links.comments.href).query();
            },
            update: function(task) {
                return $resource(task._links.self.href).save(task);
            }
        };
    }

    function currentUserResourceAssembler($q, $resource, projectResourceAssembler,
            taskResourceAssembler) {
        return {
            projects: function (user, page) {
                var defer = $q.defer();
                if (user._links && user._links.project) {
                    $resource(user._links.project.href).get({page: page.page, size: page.size}, function (response) {
                        var projectPage = {
                            page: response.page,
                            projects: []
                        };
                        if (response._embedded) {
                            angular.forEach(response._embedded.projectResources, function (project) {
                                projectPage.projects.push(projectResourceAssembler.assemble(project));
                            });
                        }
                        defer.resolve(projectPage);
                    });
                } else {
                    defer.resolve();
                }
                return defer.promise;
            },
            tasks: function (user, page) {
                var defer = $q.defer();
                $resource(user._links.task.href).get({page: page.page, size: page.size}, function (response) {
                    var taskPage = {
                        page: response.page,
                        tasks: []
                    };
                    if (response._embedded) {
                        angular.forEach(response._embedded.taskResources, function (task) {
                            taskPage.tasks.push(taskResourceAssembler.assemble(task));
                        });
                    }
                    defer.resolve(taskPage);
                });
                return defer.promise;
            },
            projectsrole: function (user) {
                return $resource(user._links.roles.href).query();
            }
        };
    }

    function userResourceAssembler($q, $resource) {
        var userResource = $resource("/api/user/:id");
        return {
            page: function (page) {
                var defer = $q.defer();
                userResource.get({page: page.page, size: page.size}, function (response) {
                    var userPage = {
                        page: response.page,
                        users: []
                    };
                    if (response._embedded) {
                        angular.forEach(response._embedded.userResources, function (user) {
                            userPage.users.push(user);
                        });
                    }
                    defer.resolve(userPage);
                });
                return defer.promise;
            },
            add: function (user) {
                var defer = $q.defer();
                userResource.save(user, function (data) {
                    defer.resolve(data);
                });
                return defer.promise;
            }
            ,
            delete: function (id) {
                var defer = $q.defer();
                userResource.delete({id: id}, function (data) {
                    defer.resolve(data);
                });
                return defer.promise;
            }
        };
    }

    function projectResource($q, $resource, projectResourceAssembler) {
        var resource = $resource("/api/project/:id", {id: "@id"}, {
            query: {isArray: false}});
        return {
            query: function (page) {
                var defer = $q.defer();
                resource.query(page, function (response) {
                    var projectPage = {
                        page: response.page,
                        projects: []
                    };
                    if (response._embedded) {
                        angular.forEach(response._embedded.projectResources, function (project) {
                            projectPage.projects.push(projectResourceAssembler.assemble(project));
                        });
                    }
                    defer.resolve(projectPage);
                });
                return defer.promise;
            },
            get: function (id) {
                var defer = $q.defer();
                resource.get({id: id}, function (response) {
                    return defer.resolve(response);
                });
                return defer.promise;
            },
            save: function (project) {
                var defer = $q.defer();
                resource.save(project, function (response) {
                    return defer.resolve(response);
                });
                return defer.promise;
            },
            remove: function (id) {
                var defer = $q.defer();
                resource.delete({id: id}, function (response) {
                    return defer.resolve(response);
                });
                return defer.promise;
            }
        };
    }

    function applicationRoleResource($resource) {
        return $resource("/api/role");
    }

    function projectRoleResource($resource) {
        return $resource("/api/role/project");
    }

    projectResource.$inject = ["$q", "$resource", "projectResourceAssembler"];
    projectRoleResource.$inject = ["$resource"];
    applicationRoleResource.$inject = ["$resource"];
    userResourceAssembler.$inject = ["$q", "$resource"];
    projectResourceAssembler.$inject = ["$q", "$resource", "taskResourceAssembler"];
    projectMember.$inject = ["$q", "$resource"];
    projectCategory.$inject = ["$q", "$resource"];
    projectState.$inject = ["$q", "$resource"];
    projectTask.$inject = ["$q", "$resource"];
    projectSwimlane.$inject = ["$q", "$resource"];
    taskResourceAssembler.$inject = ["$resource"];
    currentUserResourceAssembler.$inject = ["$q", "$resource", "projectResourceAssembler",
        "taskResourceAssembler"];
    angular.module("kanban.api", ["ngResource"])
            .service("projectResourceAssembler", projectResourceAssembler)
            .service("projectResource", projectResource)
            .service("projectRoleResource", projectRoleResource)
            .service("projectMember", projectMember)
            .service("projectCategory", projectCategory)
            .service("projectState", projectState)
            .service("projectTask", projectTask)
            .service("projectSwimlane", projectSwimlane)
            .service("taskResourceAssembler", taskResourceAssembler)
            .service("currentUserResourceAssembler", currentUserResourceAssembler)
            .service("userResourceAssembler", userResourceAssembler)
            .service("applicationRoleResource", applicationRoleResource);
})();<commit_msg>Refactor hypermedia : sauvegarde task<commit_after>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
(function () {
    "use strict";

    function projectElement($q, $resource, linkName) {
        return {
            add: function (project, element) {
                var defer = $q.defer();
                $resource(project._links[linkName].href).save(element, function (data) {
                    defer.resolve(data);
                });
                return defer.promise;
            },
            remove: function (element) {
                var defer = $q.defer();
                $resource(element._links.self.href).delete(function (data) {
                    defer.resolve(data);
                });
                return defer.promise;
            }
        };
    }

    function projectTask($q, $resource) {
        return projectElement($q, $resource, "tasks");
    }

    function projectMember($q, $resource) {
        return projectElement($q, $resource, "members");
    }

    function projectCategory($q, $resource) {
        return projectElement($q, $resource, "category");
    }

    function projectState($q, $resource) {
        return projectElement($q, $resource, "states");
    }
    function projectSwimlane($q, $resource) {
        return projectElement($q, $resource, "swimlanes");
    }

    function projectResourceAssembler($q, $resource, taskResourceAssembler) {
        return {
            assemble: function (project, withSwimlanes) {
                project.states = $resource(project._links.states.href).query();
                if (withSwimlanes) {
                    project.swimlanes = $resource(project._links.swimlanes.href).query();
                }
                return project;
            },
            tasks: function (project, page) {
                var defer = $q.defer();
                $resource(project._links.tasks.href).get({page: page.page, size: page.size}, function (response) {
                    var taskPage = {
                        page: response.page,
                        tasks: []
                    };
                    if (response._embedded) {
                        angular.forEach(response._embedded.taskResources, function (task) {
                            taskPage.tasks.push(taskResourceAssembler.assemble(task, true));
                        });
                    }
                    defer.resolve(taskPage);
                });
                return defer.promise;
            },
            kanban: function (project) {
                var tasksByState = {};
                var tabDefer = [];
                for (var i = 0; i < project._links.taskByState.length; i++) {
                    var state = project._links.taskByState[i];
                    var deferState = $resource(state.href).get();
                    deferState.$promise.then(function (data) {
                        tasksByState[data.id] = data;
                        tasksByState[data.id].tasks = [];
                        if (data._links) {
                            angular.forEach(data._links.tasks, function (task) {
                                var link = task;
                                if (task.href) {
                                    link = task.href;
                                }
                                var result = $resource(link).get();
                                result.$promise.then(function (data)
                                {
                                    result = taskResourceAssembler.assemble(data, true);
                                });
                                tasksByState[data.id].tasks.push(result);
                            });
                        }
                    });
                    tabDefer.push(deferState.$promise);
                }
                return $q.all(tabDefer);
            },
            members: function (project, page) {
                var defer = $q.defer();
                $resource(project._links.members.href).get({page: page.page, size: page.size}, function (response) {
                    var membersPage = {
                        page: response.page,
                        members: []
                    };
                    if (response._embedded) {
                        angular.forEach(response._embedded.memberResources, function (member) {
                            membersPage.members.push(member);
                        });
                    }
                    defer.resolve(membersPage);
                });
                return defer.promise;
            },
            states: function (project) {
                return $resource(project._links.states.href).query();
            },
            swimlane: function (project) {
                return $resource(project._links.swimlanes.href).query();
            },
            category: function (project) {
                return $resource(project._links.category.href).query();
            }
        };
    }

    function taskResourceAssembler($resource) {
        return {
            assemble: function (task, withStateAndSwimlane) {
                if (withStateAndSwimlane) {
                    task.state = $resource(task._links.state.href).get();
                    if (task._links.swimlane) {
                        task.swimlane = $resource(task._links.swimlane.href).get();
                    }
                }
                if (task._links.assignee) {
                    task.assignee = $resource(task._links.assignee.href).get();
                }
                if (task._links.backup) {
                    task.backup = $resource(task._links.backup.href).get();
                }
                if (task._links.category) {
                    task.category = $resource(task._links.category.href).get();
                }
                return task;
            },
            allocations: function (task) {
                return $resource(task._links.allocations.href).query();
            },
            history: function (task) {
                return $resource(task._links.history.href).query();
            },
            comments: function (task) {
                return $resource(task._links.comments.href).query();
            },
            update: function (task) {
                return $resource(task._links.self.href).save(task);
            }
        };
    }

    function currentUserResourceAssembler($q, $resource, projectResourceAssembler,
            taskResourceAssembler) {
        return {
            projects: function (user, page) {
                var defer = $q.defer();
                if (user._links && user._links.project) {
                    $resource(user._links.project.href).get({page: page.page, size: page.size}, function (response) {
                        var projectPage = {
                            page: response.page,
                            projects: []
                        };
                        if (response._embedded) {
                            angular.forEach(response._embedded.projectResources, function (project) {
                                projectPage.projects.push(projectResourceAssembler.assemble(project));
                            });
                        }
                        defer.resolve(projectPage);
                    });
                } else {
                    defer.resolve();
                }
                return defer.promise;
            },
            tasks: function (user, page) {
                var defer = $q.defer();
                if (user._links && user._links.task) {
                    $resource(user._links.task.href).get({page: page.page, size: page.size}, function (response) {
                        var taskPage = {
                            page: response.page,
                            tasks: []
                        };
                        if (response._embedded) {
                            angular.forEach(response._embedded.taskResources, function (task) {
                                taskPage.tasks.push(taskResourceAssembler.assemble(task));
                            });
                        }
                        defer.resolve(taskPage);
                    });
                } else {
                    defer.resolve();
                }
                return defer.promise;
            },
            projectsrole: function (user) {
                return $resource(user._links.roles.href).query();
            }
        };
    }

    function userResourceAssembler($q, $resource) {
        var userResource = $resource("/api/user/:id");
        return {
            page: function (page) {
                var defer = $q.defer();
                userResource.get({page: page.page, size: page.size}, function (response) {
                    var userPage = {
                        page: response.page,
                        users: []
                    };
                    if (response._embedded) {
                        angular.forEach(response._embedded.userResources, function (user) {
                            userPage.users.push(user);
                        });
                    }
                    defer.resolve(userPage);
                });
                return defer.promise;
            },
            add: function (user) {
                var defer = $q.defer();
                userResource.save(user, function (data) {
                    defer.resolve(data);
                });
                return defer.promise;
            }
            ,
            delete: function (id) {
                var defer = $q.defer();
                userResource.delete({id: id}, function (data) {
                    defer.resolve(data);
                });
                return defer.promise;
            }
        };
    }

    function projectResource($q, $resource, projectResourceAssembler) {
        var resource = $resource("/api/project/:id", {id: "@id"}, {
            query: {isArray: false}});
        return {
            query: function (page) {
                var defer = $q.defer();
                resource.query(page, function (response) {
                    var projectPage = {
                        page: response.page,
                        projects: []
                    };
                    if (response._embedded) {
                        angular.forEach(response._embedded.projectResources, function (project) {
                            projectPage.projects.push(projectResourceAssembler.assemble(project));
                        });
                    }
                    defer.resolve(projectPage);
                });
                return defer.promise;
            },
            get: function (id) {
                var defer = $q.defer();
                resource.get({id: id}, function (response) {
                    return defer.resolve(response);
                });
                return defer.promise;
            },
            save: function (project) {
                var defer = $q.defer();
                resource.save(project, function (response) {
                    return defer.resolve(response);
                });
                return defer.promise;
            },
            remove: function (id) {
                var defer = $q.defer();
                resource.delete({id: id}, function (response) {
                    return defer.resolve(response);
                });
                return defer.promise;
            }
        };
    }

    function applicationRoleResource($resource) {
        return $resource("/api/role");
    }

    function projectRoleResource($resource) {
        return $resource("/api/role/project");
    }

    projectResource.$inject = ["$q", "$resource", "projectResourceAssembler"];
    projectRoleResource.$inject = ["$resource"];
    applicationRoleResource.$inject = ["$resource"];
    userResourceAssembler.$inject = ["$q", "$resource"];
    projectResourceAssembler.$inject = ["$q", "$resource", "taskResourceAssembler"];
    projectMember.$inject = ["$q", "$resource"];
    projectCategory.$inject = ["$q", "$resource"];
    projectState.$inject = ["$q", "$resource"];
    projectTask.$inject = ["$q", "$resource"];
    projectSwimlane.$inject = ["$q", "$resource"];
    taskResourceAssembler.$inject = ["$resource"];
    currentUserResourceAssembler.$inject = ["$q", "$resource", "projectResourceAssembler",
        "taskResourceAssembler"];
    angular.module("kanban.api", ["ngResource"])
            .service("projectResourceAssembler", projectResourceAssembler)
            .service("projectResource", projectResource)
            .service("projectRoleResource", projectRoleResource)
            .service("projectMember", projectMember)
            .service("projectCategory", projectCategory)
            .service("projectState", projectState)
            .service("projectTask", projectTask)
            .service("projectSwimlane", projectSwimlane)
            .service("taskResourceAssembler", taskResourceAssembler)
            .service("currentUserResourceAssembler", currentUserResourceAssembler)
            .service("userResourceAssembler", userResourceAssembler)
            .service("applicationRoleResource", applicationRoleResource);
})();<|endoftext|>


<commit_before>"use strict";

ddescribe('example directive', function() {
  var rootScope, compile, interpolate, directive;

  angular.module('exampleModule', []);

  beforeEach(module('exampleModule', function($compileProvider) {
    directive = $compileProvider.directive;
  }));

  beforeEach(inject(function($injector) {
    compile = $injector.get('$compile');
    rootScope = $injector.get('$rootScope');
    interpolate = $injector.get('$interpolate');
  }));

  it('should inherit parent scope when property scope is not an object', function() {
    directive('example', function() {
      return {
        //scope: no scope property
        link: function(scope, element, attributes) {
          expect(scope.foo.bar).toBe(1);
          expect(scope.$eval('foo.bar')).toBe(1);
          scope.$apply('foo.bar = 42');
          expect(rootScope.foo.bar).toBe(42);
        }
      }
    });
    rootScope.$apply('foo.bar = 1');
    compile('<one example>')(rootScope);
  });

  it('must not inherit parent scope when property scope is an object', function() {
    directive('example', function() {
      return {
        scope: {},
        link: function(scope, element, attributes) {
          expect(scope.foo).toBeUndefined();
          expect(scope.$eval('foo.bar')).toBeUndefined();
          scope.$apply('foo.bar = 42');
          expect(rootScope.foo.bar).toBe(1);
        }
      }
    });
    rootScope.$apply('foo.bar = 1');
    compile('<one example>')(rootScope);
  });

  it('@scopes', function() {
    var watchCalls = 0;

    directive('example', function() {
      return {
        scope: {
          //atScope: '@at-isolated', Error: Invalid isolate scope definition for directive example: @at-isolated
          atIsolated: '@isolated',
          atInterpolated: '@interpolated'
        },
        link: function(scope, element, attributes) {
          expect(scope.atIsolated).toBeUndefined();
          expect(scope.atInterpolated).toBeUndefined();

          scope.$watch('atInterpolated', function(newVal, oldVal) {
            watchCalls++;
            if (1 == watchCalls) {
              expect(newVal).toBe(oldVal);
              expect(newVal).toBe('1');
            }
            if (2 == watchCalls) {
              expect(oldVal).toBe('1');
              expect(newVal).toBe('2');
            }
          });

          scope.$apply();
          expect(watchCalls).toBe(1);

          expect(scope.atIsolated).toBe('iso.foo');
          expect(scope.atInterpolated).toBe('1');
        }
      }
    });
    rootScope.$apply('iso.foo = 1');
    compile('<one isolated="iso.foo" interpolated="{{iso.foo}}" example>')(rootScope);
    rootScope.$apply('iso.foo = 2');
    expect(watchCalls).toBe(2);
  });
});
<commit_msg>remove d from ddescribe<commit_after>"use strict";

describe('example directive', function() {
  var rootScope, compile, interpolate, directive;

  angular.module('exampleModule', []);

  beforeEach(module('exampleModule', function($compileProvider) {
    directive = $compileProvider.directive;
  }));

  beforeEach(inject(function($injector) {
    compile = $injector.get('$compile');
    rootScope = $injector.get('$rootScope');
    interpolate = $injector.get('$interpolate');
  }));

  it('should inherit parent scope when property scope is not an object', function() {
    directive('example', function() {
      return {
        //scope: no scope property
        link: function(scope, element, attributes) {
          expect(scope.foo.bar).toBe(1);
          expect(scope.$eval('foo.bar')).toBe(1);
          scope.$apply('foo.bar = 42');
          expect(rootScope.foo.bar).toBe(42);
        }
      }
    });
    rootScope.$apply('foo.bar = 1');
    compile('<one example>')(rootScope);
  });

  it('must not inherit parent scope when property scope is an object', function() {
    directive('example', function() {
      return {
        scope: {},
        link: function(scope, element, attributes) {
          expect(scope.foo).toBeUndefined();
          expect(scope.$eval('foo.bar')).toBeUndefined();
          scope.$apply('foo.bar = 42');
          expect(rootScope.foo.bar).toBe(1);
        }
      }
    });
    rootScope.$apply('foo.bar = 1');
    compile('<one example>')(rootScope);
  });

  it('@scopes', function() {
    var watchCalls = 0;

    directive('example', function() {
      return {
        scope: {
          //atScope: '@at-isolated', Error: Invalid isolate scope definition for directive example: @at-isolated
          atIsolated: '@isolated',
          atInterpolated: '@interpolated'
        },
        link: function(scope, element, attributes) {
          expect(scope.atIsolated).toBeUndefined();
          expect(scope.atInterpolated).toBeUndefined();

          scope.$watch('atInterpolated', function(newVal, oldVal) {
            watchCalls++;
            if (1 == watchCalls) {
              expect(newVal).toBe(oldVal);
              expect(newVal).toBe('1');
            }
            if (2 == watchCalls) {
              expect(oldVal).toBe('1');
              expect(newVal).toBe('2');
            }
          });

          scope.$apply();
          expect(watchCalls).toBe(1);

          expect(scope.atIsolated).toBe('iso.foo');
          expect(scope.atInterpolated).toBe('1');
        }
      }
    });
    rootScope.$apply('iso.foo = 1');
    compile('<one isolated="iso.foo" interpolated="{{iso.foo}}" example>')(rootScope);
    rootScope.$apply('iso.foo = 2');
    expect(watchCalls).toBe(2);
  });
});
<|endoftext|>


<commit_before>'use strict';

/**
 * Allows for the extension of built-in Discord.js structures that are instantiated by {@link DataStore DataStores}.
 */
class Structures {
  constructor() {
    throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
  }

  /**
   * Retrieves a structure class.
   * @param {string} structure Name of the structure to retrieve
   * @returns {Function}
   */
  static get(structure) {
    if (typeof structure === 'string') return structures[structure];
    throw new TypeError(`"structure" argument must be a string (received ${typeof structure})`);
  }

  /**
   * Extends a structure.
   * <warn> Make sure to extend all structures before instantiating your client.
   * Extending after doing so may not work as expected. </warn>
   * @param {string} structure Name of the structure class to extend
   * @param {Function} extender Function that takes the base class to extend as its only parameter and returns the
   * extended class/prototype
   * @returns {Function} Extended class/prototype returned from the extender
   * @example
   * const { Structures } = require('discord.js');
   *
   * Structures.extend('Guild', Guild => {
   *   class CoolGuild extends Guild {
   *     constructor(client, data) {
   *       super(client, data);
   *       this.cool = true;
   *     }
   *   }
   *
   *   return CoolGuild;
   * });
   */
  static extend(structure, extender) {
    if (!structures[structure]) throw new RangeError(`"${structure}" is not a valid extensible structure.`);
    if (typeof extender !== 'function') {
      const received = `(received ${typeof extender})`;
      throw new TypeError(
        `"extender" argument must be a function that returns the extended structure class/prototype ${received}`
      );
    }

    const extended = extender(structures[structure]);
    if (typeof extended !== 'function') {
      throw new TypeError('The extender function must return the extended structure class/prototype.');
    }
    if (Object.getPrototypeOf(extended) !== structures[structure]) {
      throw new Error(
        'The class/prototype returned from the extender function must extend the existing structure class/prototype.'
      );
    }

    structures[structure] = extended;
    return extended;
  }
}

const structures = {
  GuildEmoji: require('../structures/GuildEmoji'),
  DMChannel: require('../structures/DMChannel'),
  TextChannel: require('../structures/TextChannel'),
  VoiceChannel: require('../structures/VoiceChannel'),
  CategoryChannel: require('../structures/CategoryChannel'),
  GuildChannel: require('../structures/GuildChannel'),
  GuildMember: require('../structures/GuildMember'),
  Guild: require('../structures/Guild'),
  Message: require('../structures/Message'),
  MessageReaction: require('../structures/MessageReaction'),
  Presence: require('../structures/Presence').Presence,
  ClientPresence: require('../structures/ClientPresence'),
  VoiceState: require('../structures/VoiceState'),
  Role: require('../structures/Role'),
  User: require('../structures/User'),
};

module.exports = Structures;
<commit_msg>Improve structure extension errors<commit_after>'use strict';

/**
 * Allows for the extension of built-in Discord.js structures that are instantiated by {@link DataStore DataStores}.
 */
class Structures {
  constructor() {
    throw new Error(`The ${this.constructor.name} class may not be instantiated.`);
  }

  /**
   * Retrieves a structure class.
   * @param {string} structure Name of the structure to retrieve
   * @returns {Function}
   */
  static get(structure) {
    if (typeof structure === 'string') return structures[structure];
    throw new TypeError(`"structure" argument must be a string (received ${typeof structure})`);
  }

  /**
   * Extends a structure.
   * <warn> Make sure to extend all structures before instantiating your client.
   * Extending after doing so may not work as expected. </warn>
   * @param {string} structure Name of the structure class to extend
   * @param {Function} extender Function that takes the base class to extend as its only parameter and returns the
   * extended class/prototype
   * @returns {Function} Extended class/prototype returned from the extender
   * @example
   * const { Structures } = require('discord.js');
   *
   * Structures.extend('Guild', Guild => {
   *   class CoolGuild extends Guild {
   *     constructor(client, data) {
   *       super(client, data);
   *       this.cool = true;
   *     }
   *   }
   *
   *   return CoolGuild;
   * });
   */
  static extend(structure, extender) {
    if (!structures[structure]) throw new RangeError(`"${structure}" is not a valid extensible structure.`);
    if (typeof extender !== 'function') {
      const received = `(received ${typeof extender})`;
      throw new TypeError(
        `"extender" argument must be a function that returns the extended structure class/prototype ${received}.`
      );
    }

    const extended = extender(structures[structure]);
    if (typeof extended !== 'function') {
      const received = `(received ${typeof extended})`;
      throw new TypeError(`The extender function must return the extended structure class/prototype ${received}.`);
    }

    const prototype = Object.getPrototypeOf(extended);
    if (prototype !== structures[structure]) {
      const received = `${extended.name || 'unnamed'}${prototype.name ? ` extends ${prototype.name}` : ''}`;
      throw new Error(
        'The class/prototype returned from the extender function must extend the existing structure class/prototype' +
        ` (received function ${received}; expected extension of ${structures[structure].name}).`
      );
    }

    structures[structure] = extended;
    return extended;
  }
}

const structures = {
  GuildEmoji: require('../structures/GuildEmoji'),
  DMChannel: require('../structures/DMChannel'),
  TextChannel: require('../structures/TextChannel'),
  VoiceChannel: require('../structures/VoiceChannel'),
  CategoryChannel: require('../structures/CategoryChannel'),
  GuildChannel: require('../structures/GuildChannel'),
  GuildMember: require('../structures/GuildMember'),
  Guild: require('../structures/Guild'),
  Message: require('../structures/Message'),
  MessageReaction: require('../structures/MessageReaction'),
  Presence: require('../structures/Presence').Presence,
  ClientPresence: require('../structures/ClientPresence'),
  VoiceState: require('../structures/VoiceState'),
  Role: require('../structures/Role'),
  User: require('../structures/User'),
};

module.exports = Structures;
<|endoftext|>


<commit_before>$(document).ready(function() {

  /** Load the help page */
  $('#key').jqm({ajax: 'key.html', trigger: 'a.keytrigger'});
  if(this.getElementById('projectname'))
    {
    var projectname = this.getElementById('projectname').value;
    $('#groupsdescription').jqm({ajax: 'groupsDescription.php?project='+projectname, trigger: 'a.grouptrigger'});
    }

  /** Build name */
  $.tablesorter.addParser({
      // set a unique id
      id: 'buildname',
      is: function(s) {
            // return false so this parser is not auto detected
            return false;
        },
        format: function(s) {
            // format your data for normalization
            var t = s;
            var i = s.indexOf("0)
              {
              var j = s.indexOf(">",i);
              var k = s.indexOf("",j);
              t = s.substr(j+1,k-j-1);
              }
            return t.toLowerCase();
        },
        // set type, either numeric or text
        type: 'text'
    });

  /** Update */
  $.tablesorter.addParser({
      // set a unique id
      id: 'numericvalue',
      is: function(s) {
            // return false so this parser is not auto detected
            return false;
        },
        format: function(s) {
            // format your data for normalization
            var i = s.indexOf("<a href");
            if(i==-1) // IE
              {
              i = s.indexOf("",i);
            var k = s.indexOf("",j);
            if(k==-1) // IE
              {
              k = s.indexOf("");
              }
            var t = s.substr(j+1,k-j-1);
            return t.toLowerCase();
        },
        // set type, either numeric or text
        type: 'numeric'
    });

  // Initialize the viewTest tables
  $tabs = $("#viewTestTable");
  $tabs.each(function(index) {
     $(this).tablesorter({
            headers: {
                0: { sorter:'buildname'},
                1: { sorter:'buildname'},
                2: { sorter:'buildname'},
                3: { sorter:'numeric'},
                4: { sorter:'text'},
            },
          debug: false,
          widgets: ['zebra']
        });

    });

  // Initialize the testSummary tables
  if($tabs.length==0)
    {
    $tabs = $("#testSummaryTable");
    $tabs.each(function(index) {
     $(this).tablesorter({
            headers: {
                0: { sorter:'text'},
                1: { sorter:'buildname'},
                2: { sorter:'text'},
                3: { sorter:'buildname'},
                4: { sorter:'numeric'},
                5: { sorter:'text'}
            },
          debug: false,
          widgets: ['zebra']
        });
      });
    }

  // If all the above are not working
  if($tabs.length==0)
    {
    // Initialize the Index tables
    $tabs = $(".tabb",this);
    $tabs.each(function(index) {
       $(this).tablesorter({
              headers: {
                  0: { sorter:'buildname'},
                  1: { sorter:'buildname'},
                  2: { sorter:'numericvalue'},
                  3: { sorter:'numericvalue'},
                  4: { sorter:'numericvalue'},
                  5: { sorter:'numericvalue'},
                  7: { sorter:'numericvalue'},
                  8: { sorter:'numericvalue'},
                  9: { sorter:'numericvalue'},
                  11: { sorter:'text'}
              },
            debug: false,
            widgets: ['zebra']
          });

      // Get the cookie
      var tableid = this.id;
      var cookiename = "cdash_table_sort_"+tableid;
      var cook = $.cookie(cookiename); // get cookie
      if(cook)
        {
        var cookArray = cook.split(',');
        var sortArray = new Array();
        var j=0;
        for(var i=0; i < cookArray.length; i+=2)
          {
          sortArray[j] = [cookArray[i],cookArray[i+1]];
          j++;
          }
        $(this).trigger("sorton",[sortArray]);
        }
      });
    }

});
<commit_msg>COMP: too many commas<commit_after>$(document).ready(function() {

  /** Load the help page */
  $('#key').jqm({ajax: 'key.html', trigger: 'a.keytrigger'});
  if(this.getElementById('projectname'))
    {
    var projectname = this.getElementById('projectname').value;
    $('#groupsdescription').jqm({ajax: 'groupsDescription.php?project='+projectname, trigger: 'a.grouptrigger'});
    }

  /** Build name */
  $.tablesorter.addParser({
      // set a unique id
      id: 'buildname',
      is: function(s) {
            // return false so this parser is not auto detected
            return false;
        },
        format: function(s) {
            // format your data for normalization
            var t = s;
            var i = s.indexOf("0)
              {
              var j = s.indexOf(">",i);
              var k = s.indexOf("",j);
              t = s.substr(j+1,k-j-1);
              }
            return t.toLowerCase();
        },
        // set type, either numeric or text
        type: 'text'
    });

  /** Update */
  $.tablesorter.addParser({
      // set a unique id
      id: 'numericvalue',
      is: function(s) {
            // return false so this parser is not auto detected
            return false;
        },
        format: function(s) {
            // format your data for normalization
            var i = s.indexOf("<a href");
            if(i==-1) // IE
              {
              i = s.indexOf("",i);
            var k = s.indexOf("",j);
            if(k==-1) // IE
              {
              k = s.indexOf("");
              }
            var t = s.substr(j+1,k-j-1);
            return t.toLowerCase();
        },
        // set type, either numeric or text
        type: 'numeric'
    });

  // Initialize the viewTest tables
  $tabs = $("#viewTestTable");
  $tabs.each(function(index) {
     $(this).tablesorter({
            headers: {
                0: { sorter:'buildname'},
                1: { sorter:'buildname'},
                2: { sorter:'buildname'},
                3: { sorter:'numeric'},
                4: { sorter:'text'}
            },
          debug: false,
          widgets: ['zebra']
        });

    });

  // Initialize the testSummary tables
  if($tabs.length==0)
    {
    $tabs = $("#testSummaryTable");
    $tabs.each(function(index) {
     $(this).tablesorter({
            headers: {
                0: { sorter:'text'},
                1: { sorter:'buildname'},
                2: { sorter:'text'},
                3: { sorter:'buildname'},
                4: { sorter:'numeric'},
                5: { sorter:'text'}
            },
          debug: false,
          widgets: ['zebra']
        });
      });
    }

  // If all the above are not working
  if($tabs.length==0)
    {
    // Initialize the Index tables
    $tabs = $(".tabb",this);
    $tabs.each(function(index) {
       $(this).tablesorter({
              headers: {
                  0: { sorter:'buildname'},
                  1: { sorter:'buildname'},
                  2: { sorter:'numericvalue'},
                  3: { sorter:'numericvalue'},
                  4: { sorter:'numericvalue'},
                  5: { sorter:'numericvalue'},
                  7: { sorter:'numericvalue'},
                  8: { sorter:'numericvalue'},
                  9: { sorter:'numericvalue'},
                  11: { sorter:'text'}
              },
            debug: false,
            widgets: ['zebra']
          });

      // Get the cookie
      var tableid = this.id;
      var cookiename = "cdash_table_sort_"+tableid;
      var cook = $.cookie(cookiename); // get cookie
      if(cook)
        {
        var cookArray = cook.split(',');
        var sortArray = new Array();
        var j=0;
        for(var i=0; i < cookArray.length; i+=2)
          {
          sortArray[j] = [cookArray[i],cookArray[i+1]];
          j++;
          }
        $(this).trigger("sorton",[sortArray]);
        }
      });
    }

});
<|endoftext|>


<commit_before>import SPELLS from 'common/SPELLS';

// Based on spelldata for Avenging Wrath, Retribution(buff) and Inquisition
// Avenging Wrath and Retribution also increase melee damage by 20% - this is added in their modules.
export const ABILITIES_AFFECTED_BY_DAMAGE_INCREASES = [
  SPELLS.CRUSADER_STRIKE,
  SPELLS.JUDGMENT_CAST,
  SPELLS.TEMPLARS_VERDICT_DAMAGE,
  SPELLS.BLADE_OF_JUSTICE,
  SPELLS.DIVINE_STORM_DAMAGE,
  SPELLS.EXECUTION_SENTENCE_TALENT,
  SPELLS.CONSECRATION_TALENT,
  SPELLS.ZEAL_DAMAGE,
  SPELLS.HAMMER_OF_WRATH_TALENT,
  SPELLS.WAKE_OF_ASHES_TALENT,
  SPELLS.JUSTICARS_VENGEANCE_TALENT,
  SPELLS.EYE_FOR_AN_EYE_TALENT,
  SPELLS.LIGHTS_DECREE_DAMAGE,
  SPELLS.EXPURGATION_DAMAGE,
];

// Stuff like Retribution mastery and Execution sentence increases damage done by these sources of holy damage
export const ABILITIES_AFFECTED_BY_HOLY_DAMAGE_INCREASES = [
  SPELLS.JUDGMENT_CAST,
  SPELLS.TEMPLARS_VERDICT_DAMAGE,
  SPELLS.EXECUTION_SENTENCE_TALENT,
  SPELLS.CONSECRATION_TALENT,
  SPELLS.ZEAL_DAMAGE,
  SPELLS.HAMMER_OF_WRATH_TALENT,
  SPELLS.WAKE_OF_ASHES_TALENT,
  SPELLS.JUSTICARS_VENGEANCE_TALENT,
  SPELLS.LIGHTS_DECREE_DAMAGE,
  SPELLS.EXPURGATION_DAMAGE,
];
<commit_msg>Add DS damage to ret holy damage constants<commit_after>import SPELLS from 'common/SPELLS';

// Based on spelldata for Avenging Wrath, Retribution(buff) and Inquisition
// Avenging Wrath and Retribution also increase melee damage by 20% - this is added in their modules.
export const ABILITIES_AFFECTED_BY_DAMAGE_INCREASES = [
  SPELLS.CRUSADER_STRIKE,
  SPELLS.JUDGMENT_CAST,
  SPELLS.TEMPLARS_VERDICT_DAMAGE,
  SPELLS.BLADE_OF_JUSTICE,
  SPELLS.DIVINE_STORM_DAMAGE,
  SPELLS.EXECUTION_SENTENCE_TALENT,
  SPELLS.CONSECRATION_TALENT,
  SPELLS.ZEAL_DAMAGE,
  SPELLS.HAMMER_OF_WRATH_TALENT,
  SPELLS.WAKE_OF_ASHES_TALENT,
  SPELLS.JUSTICARS_VENGEANCE_TALENT,
  SPELLS.EYE_FOR_AN_EYE_TALENT,
  SPELLS.LIGHTS_DECREE_DAMAGE,
  SPELLS.EXPURGATION_DAMAGE,
];

// Stuff like Retribution mastery and Execution sentence increases damage done by these sources of holy damage
export const ABILITIES_AFFECTED_BY_HOLY_DAMAGE_INCREASES = [
  SPELLS.JUDGMENT_CAST,
  SPELLS.TEMPLARS_VERDICT_DAMAGE,
  SPELLS.DIVINE_STORM_DAMAGE,
  SPELLS.EXECUTION_SENTENCE_TALENT,
  SPELLS.CONSECRATION_TALENT,
  SPELLS.ZEAL_DAMAGE,
  SPELLS.HAMMER_OF_WRATH_TALENT,
  SPELLS.WAKE_OF_ASHES_TALENT,
  SPELLS.JUSTICARS_VENGEANCE_TALENT,
  SPELLS.LIGHTS_DECREE_DAMAGE,
  SPELLS.EXPURGATION_DAMAGE,
];
<|endoftext|>


<commit_before>// ==UserScript==
// @name         fuckjb51
// @namespace    https://github.com/zhangolve/fuckjb51
// @version      0.1
// @description  filter something you don't like
// @author       zhangolve contact   zhangolve@gmail.com
// @license      GPL version 2 or any later version; http://www.gnu.org/licenses/gpl-2.0.txt
// @match        https://www.baidu.com/*
// @grant             GM_setValue
// @grant             GM_getValue
//@grant              GM_deleteValue
// @grant		    GM_addStyle
// ==/UserScript==

    if(window.location.search!=='')
    {
    var re="www.jb51.net\/.*?";
    var getRe = GM_getValue('re', re);

    var reg = new RegExp(getRe);
       var items=[];
       var urls=[];
       for(var i=1;i<11;i++)
       {

           items.push(document.getElementById(i));

           urls.push(items[i-1].getElementsByClassName('c-showurl')[0].innerHTML);

          console.log(i,reg.test(urls[i-1]));
           console.log(i,urls[i-1]);
           console.log(i,reg.test(urls[i-1]));
           console.log(i,urls[i-1]);
             console.log(i,reg.test(urls[i-1]));
           console.log(i,urls[i-1]);
           if(reg.test(urls[i-1]))
           {

              items[i-1].remove();

           }

       }
        console.log(items,urls);
    var s_tab=document.getElementById("s_tab");
    var inputFilter=document.createElement("input");
    inputFilter.setAttribute("id","inputFilter");
    inputFilter.setAttribute("placeholder","过滤域名");
    var filterButton=document.createElement("input");
    filterButton.setAttribute('type','submit');
    filterButton.setAttribute('value','过滤');
    filterButton.setAttribute('id','filter');
    s_tab.appendChild(inputFilter);
    s_tab.appendChild(filterButton);
  document.getElementById("filter").addEventListener("click", filter );
          }
    function filter(){
    var inputFilter=document.getElementById('inputFilter');
        if(inputFilter.value!=='')
        {
         re=re+"|"+inputFilter.value+"\/.*?";
        getRe=re;
        GM_setValue('re',getRe);
         alert('已添加过滤地址');
        window.location.reload(true);
        }
        else{
        alert("请输入需要过滤的域名");
        }
    }
    GM_addStyle("#inputFilter {width: 140px;height:25px;font-size:14px} #filter{width:40px;height:25px;color:red} ");
  <commit_msg>通过获取keyword自己拼凑url来将异步变为同步<commit_after>// ==UserScript==
// @name         fuckjb51
// @namespace    https://github.com/zhangolve/fuckjb51
// @version      0.1
// @description  filter something you don't like
// @author       zhangolve contact   zhangolve@gmail.com
// @license      GPL version 2 or any later version; http://www.gnu.org/licenses/gpl-2.0.txt
// @match        https://www.baidu.com/*
// @grant             GM_setValue
// @grant             GM_getValue
//@grant              GM_deleteValue
// @grant			  GM_addStyle
// ==/UserScript==

     var searchUrl= 'https://www.baidu.com/s?ie=utf-8&f=8&wd=';
    if(window.location.search!=='')
    {
    var re="www.jb51.net\/.*?";
    var getRe = GM_getValue('re', re);

    var reg = new RegExp(getRe);
       var items=[];
       var urls=[];
       for(var i=1;i<11;i++)
       {

           items.push(document.getElementById(i));
           urls.push(items[i-1].getElementsByClassName('c-showurl')[0].innerHTML);
           if(reg.test(urls[i-1]))
           {

              items[i-1].remove();

           }

       }
        var button=document.getElementById('su');
      button.addEventListener('click',timeout);
      document.addEventListener("keypress",enter);
    var s_tab=document.getElementById("s_tab");
    var inputFilter=document.createElement("input");
    inputFilter.setAttribute("id","inputFilter");
    inputFilter.setAttribute("placeholder","过滤域名");
    var filterButton=document.createElement("input");
    filterButton.setAttribute('type','submit');
    filterButton.setAttribute('value','过滤');
    filterButton.setAttribute('id','filter');
    s_tab.appendChild(inputFilter);
    s_tab.appendChild(filterButton);
  document.getElementById("filter").addEventListener("click", filter );
          }
    function filter(){
    var inputFilter=document.getElementById('inputFilter');
        if(inputFilter.value!=='')
        {
         re=re+"|"+inputFilter.value+"\/.*?";
        getRe=re;
        GM_setValue('re',getRe);
         alert('已添加过滤地址');
        window.location.reload(true);
        }
        else{
        alert("请输入需要过滤的域名");
        }
    }
       function timeout(){

           var kw=document.getElementById('kw').value;
           searchUrl+=kw;
           document.location.href=searchUrl;

      }
      function enter(event){
      if(event.keyCode==13) {
            this.timeout();
        }

      }

    GM_addStyle("#inputFilter {width: 140px;height:25px;font-size:14px} #filter{width:40px;height:25px;color:red} ");
  /*

  */<|endoftext|>


<commit_before>/* global describe, it, expect */

'use strict'

import sinon from 'sinon'
import CloudWatchClient from '../../src/lib/CloudWatchClient'
import LogItem from '../../src/lib/LogItem'

const logGroupName = 'testGroup'
const logStreamName = 'testStream'

let tokens = 0
let streams = 0

const mapRequest = (stub, includeExpected, token, nextToken) => {
  const suffixes = [++streams, ++streams, includeExpected ? '' : ++streams]
  const res = Promise.resolve({
    logStreams: suffixes.map(suf => ({logStreamName: logStreamName + suf})),
    nextToken
  })
  if (token) {
    stub.withArgs(sinon.match({nextToken: token}))
      .returns(res)
  } else {
    stub.returns(res)
  }
}

const mapRequests = (stub, pages, includeExpected) => {
  let prevToken = null
  for (let i = 0; i < pages - 1; ++i) {
    let token = 'token' + ++tokens
    mapRequest(stub, false, prevToken, token)
    prevToken = token
  }
  mapRequest(stub, includeExpected, prevToken)
}

const strategies = {
  default: stub => mapRequest(stub, true),
  notFound: stub => mapRequest(stub, false),
  paged: stub => mapRequests(stub, 3, true),
  pagedNotFound: stub => mapRequests(stub, 3, false)
}

const createClient = (options, streamsStrategy = strategies.default) => {
  const client = new CloudWatchClient(logGroupName, logStreamName, options)
  sinon.stub(client._client, 'putLogEventsAsync')
    .returns(Promise.resolve({nextSequenceToken: '42'}))
  const stub = sinon.stub(client._client, 'describeLogStreamsAsync')
  streamsStrategy(stub)
  return client
}

const createBatch = size => {
  const batch = []
  for (let i = 0; i < size; ++i) {
    batch.push(new LogItem(+new Date(), 'info', 'Test', {foo: 'bar'}))
  }
  return batch
}

describe('CloudWatchClient', () => {
  describe('#submit()', () => {
    it('calls putLogEvents', () => {
      const client = createClient()
      const batch = createBatch(1)
      return expect(
          client.submit(batch)
            .then(() => client._client.putLogEventsAsync.calledOnce)
        ).to.eventually.equal(true)
    })

    it('handles log stream paging', () => {
      const client = createClient(null, strategies.paged)
      const batch = createBatch(1)
      return expect(
          client.submit(batch)
            .then(() => client._client.describeLogStreamsAsync.callCount)
        ).to.eventually.equal(3)
    })

    it('rejects if the log stream is not found in a single page', () => {
      const client = createClient(null, strategies.notFound)
      const batch = createBatch(1)
      return expect(
          client.submit(batch)
        ).to.be.rejected
    })

    it('rejects if the log stream is not found in multiple pages', () => {
      const client = createClient(null, strategies.pagedNotFound)
      const batch = createBatch(1)
      return expect(
          client.submit(batch)
        ).to.be.rejected
    })

    it('caches the sequence token', () => {
      const client = createClient({maxSequenceTokenAge: 1000})
      return expect(
          client.submit(createBatch(1))
            .then(() => client.submit(createBatch(1)))
            .then(() => client._client.describeLogStreamsAsync.calledOnce)
        ).to.eventually.equal(true)
    })
  })
})
<commit_msg>Same token structure for good measure<commit_after>/* global describe, it, expect */

'use strict'

import sinon from 'sinon'
import CloudWatchClient from '../../src/lib/CloudWatchClient'
import LogItem from '../../src/lib/LogItem'

const logGroupName = 'testGroup'
const logStreamName = 'testStream'

let tokens = 0
let streams = 0

const mapRequest = (stub, includeExpected, token, nextToken) => {
  const suffixes = [++streams, ++streams, includeExpected ? '' : ++streams]
  const res = Promise.resolve({
    logStreams: suffixes.map(suf => ({logStreamName: logStreamName + suf})),
    nextToken
  })
  if (token) {
    stub.withArgs(sinon.match({nextToken: token}))
      .returns(res)
  } else {
    stub.returns(res)
  }
}

const mapRequests = (stub, pages, includeExpected) => {
  let prevToken = null
  for (let i = 0; i < pages - 1; ++i) {
    let token = 'token' + ++tokens
    mapRequest(stub, false, prevToken, token)
    prevToken = token
  }
  mapRequest(stub, includeExpected, prevToken)
}

const strategies = {
  default: stub => mapRequest(stub, true),
  notFound: stub => mapRequest(stub, false),
  paged: stub => mapRequests(stub, 3, true),
  pagedNotFound: stub => mapRequests(stub, 3, false)
}

const createClient = (options, streamsStrategy = strategies.default) => {
  const client = new CloudWatchClient(logGroupName, logStreamName, options)
  sinon.stub(client._client, 'putLogEventsAsync')
    .returns(Promise.resolve({nextSequenceToken: 'token42'}))
  const stub = sinon.stub(client._client, 'describeLogStreamsAsync')
  streamsStrategy(stub)
  return client
}

const createBatch = size => {
  const batch = []
  for (let i = 0; i < size; ++i) {
    batch.push(new LogItem(+new Date(), 'info', 'Test', {foo: 'bar'}))
  }
  return batch
}

describe('CloudWatchClient', () => {
  describe('#submit()', () => {
    it('calls putLogEvents', () => {
      const client = createClient()
      const batch = createBatch(1)
      return expect(
          client.submit(batch)
            .then(() => client._client.putLogEventsAsync.calledOnce)
        ).to.eventually.equal(true)
    })

    it('handles log stream paging', () => {
      const client = createClient(null, strategies.paged)
      const batch = createBatch(1)
      return expect(
          client.submit(batch)
            .then(() => client._client.describeLogStreamsAsync.callCount)
        ).to.eventually.equal(3)
    })

    it('rejects if the log stream is not found in a single page', () => {
      const client = createClient(null, strategies.notFound)
      const batch = createBatch(1)
      return expect(
          client.submit(batch)
        ).to.be.rejected
    })

    it('rejects if the log stream is not found in multiple pages', () => {
      const client = createClient(null, strategies.pagedNotFound)
      const batch = createBatch(1)
      return expect(
          client.submit(batch)
        ).to.be.rejected
    })

    it('caches the sequence token', () => {
      const client = createClient({maxSequenceTokenAge: 1000})
      return expect(
          client.submit(createBatch(1))
            .then(() => client.submit(createBatch(1)))
            .then(() => client._client.describeLogStreamsAsync.calledOnce)
        ).to.eventually.equal(true)
    })
  })
})
<|endoftext|>


<commit_before>$(document).ready(function() {

  /** Load the help page */
  $('#key').jqm({ajax: 'key.html', trigger: 'a.keytrigger'});
  if(this.getElementById('projectname'))
    {
    var projectname = this.getElementById('projectname').value;
    $('#groupsdescription').jqm({ajax: 'groupsDescription.php?project='+projectname, trigger: 'a.grouptrigger'});
    }

  /** Build name */
  $.tablesorter.addParser({
      // set a unique id
      id: 'buildname',
      is: function(s) {
            // return false so this parser is not auto detected
            return false;
        },
        format: function(s) {
            // format your data for normalization
            var t = s;
            var i = s.indexOf("0)
              {
              var j = s.indexOf(">",i);
              var k = s.indexOf("",j);
              t = s.substr(j+1,k-j-1);
              }
            return t.toLowerCase();
        },
        // set type, either numeric or text
        type: 'text'
    });

  /** Update */
  $.tablesorter.addParser({
      // set a unique id
      id: 'numericvalue',
      is: function(s) {
            // return false so this parser is not auto detected
            return false;
        },
        format: function(s) {
            // format your data for normalization
            var i = s.indexOf("<a href");
            if(i==-1) // IE
              {
              i = s.indexOf("",i);
            var k = s.indexOf("",j);
            if(k==-1) // IE
              {
              k = s.indexOf("");
              }
            var t = s.substr(j+1,k-j-1);
            return t.toLowerCase();
        },
        // set type, either numeric or text
        type: 'numeric'
    });

  // Initialize the viewTest tables
  $tabs = $("#viewTestTable");
  var nrows = 0;
  if(document.getElementById('viewTestTable'))
    {
    var nrows = document.getElementById('viewTestTable').getElementsByTagName('thead')[0].getElementsByTagName('th').length;
    }

  if(nrows==4)
    {
    $tabs.each(function(index) {
     $(this).tablesorter({
            headers: {
                0: { sorter:'buildname'},
                1: { sorter:'buildname'},
                2: { sorter:'numeric'},
                3: { sorter:'text'}
            },
          debug: false,
          widgets: ['zebra']
        });
      });
    }

  if(nrows==5)
    {
    $tabs.each(function(index) {
     $(this).tablesorter({
            headers: {
                0: { sorter:'buildname'},
                1: { sorter:'buildname'},
                2: { sorter:'buildname'},
                3: { sorter:'numeric'},
                4: { sorter:'text'}
            },
          debug: false,
          widgets: ['zebra']
        });
      });
    }

  // Initialize the testSummary tables
  if($tabs.length==0)
    {
    $tabs = $("#testSummaryTable");
    $tabs.each(function(index) {
     $(this).tablesorter({
            headers: {
                0: { sorter:'text'},
                1: { sorter:'buildname'},
                2: { sorter:'text'},
                3: { sorter:'buildname'},
                4: { sorter:'numeric'},
                5: { sorter:'text'}
            },
          debug: false,
          widgets: ['zebra']
        });
      });
    }

  // If all the above are not working
  if($tabs.length==0)
    {
    // Initialize the Index tables
    $tabs = $(".tabb",this);
    $tabs.each(function(index) {
       $(this).tablesorter({
              headers: {
                  0: { sorter:'buildname'},
                  1: { sorter:'buildname'},
                  2: { sorter:'numericvalue'},
                  4: { sorter:'numericvalue'},
                  5: { sorter:'numericvalue'},
                  7: { sorter:'numericvalue'},
                  8: { sorter:'numericvalue'},
                  10: { sorter:'numericvalue'},
                  11: { sorter:'numericvalue'},
                  12: { sorter:'numericvalue'},
                  13: { sorter:'numericvalue'},
                  15: { sorter:'text'}
              },
            debug: false,
            widgets: ['zebra']
          });

      // Get the cookie
      var tableid = this.id;
      var cookiename = "cdash_table_sort_"+tableid;
      var cook = $.cookie(cookiename); // get cookie
      if(cook)
        {
        var cookArray = cook.split(',');
        var sortArray = new Array();
        var j=0;
        for(var i=0; i < cookArray.length; i+=2)
          {
          sortArray[j] = [cookArray[i],cookArray[i+1]];
          j++;
          }
        $(this).trigger("sorton",[sortArray]);
        }
      });
    }

});
<commit_msg>ENH: Fixing issue with the table sorter<commit_after>$(document).ready(function() {

  /** Load the help page */
  $('#key').jqm({ajax: 'key.html', trigger: 'a.keytrigger'});
  if(this.getElementById('projectname'))
    {
    var projectname = this.getElementById('projectname').value;
    $('#groupsdescription').jqm({ajax: 'groupsDescription.php?project='+projectname, trigger: 'a.grouptrigger'});
    }

  /** Build name */
  $.tablesorter.addParser({
      // set a unique id
      id: 'buildname',
      is: function(s) {
            // return false so this parser is not auto detected
            return false;
        },
        format: function(s) {
            // format your data for normalization
            var t = s;
            var i = s.indexOf("0)
              {
              var j = s.indexOf(">",i);
              var k = s.indexOf("",j);
              t = s.substr(j+1,k-j-1);
              }
            return t.toLowerCase();
        },
        // set type, either numeric or text
        type: 'text'
    });

  /** Update */
  $.tablesorter.addParser({
      // set a unique id
      id: 'numericvalue',
      is: function(s) {
            // return false so this parser is not auto detected
            return false;
        },
        format: function(s) {
            // format your data for normalization
            var i = s.indexOf("<a href");
            if(i==-1) // IE
              {
              i = s.indexOf("",i);
            var k = s.indexOf("",j);
            if(k==-1) // IE
              {
              k = s.indexOf("");
              }
            var t = s.substr(j+1,k-j-1);
            return t.toLowerCase();
        },
        // set type, either numeric or text
        type: 'numeric'
    });

  // Initialize the viewTest tables
  $tabs = $("#viewTestTable");
  var nrows = 0;
  if(document.getElementById('viewTestTable'))
    {
    var nrows = document.getElementById('viewTestTable').getElementsByTagName('thead')[0].getElementsByTagName('th').length;
    }

  if(nrows==4)
    {
    $tabs.each(function(index) {
     $(this).tablesorter({
            headers: {
                0: { sorter:'buildname'},
                1: { sorter:'buildname'},
                2: { sorter:'numeric'},
                3: { sorter:'text'}
            },
          debug: false,
          widgets: ['zebra']
        });
      });
    }

  if(nrows==5)
    {
    $tabs.each(function(index) {
     $(this).tablesorter({
            headers: {
                0: { sorter:'buildname'},
                1: { sorter:'buildname'},
                2: { sorter:'buildname'},
                3: { sorter:'numeric'},
                4: { sorter:'text'}
            },
          debug: false,
          widgets: ['zebra']
        });
      });
    }

  // Initialize the testSummary tables
  if($tabs.length==0)
    {
    $tabs = $("#testSummaryTable");
    $tabs.each(function(index) {
     $(this).tablesorter({
            headers: {
                0: { sorter:'text'},
                1: { sorter:'buildname'},
                2: { sorter:'text'},
                3: { sorter:'buildname'},
                4: { sorter:'numeric'},
                5: { sorter:'text'}
            },
          debug: false,
          widgets: ['zebra']
        });
      });
    }

  // If all the above are not working
  if($tabs.length==0)
    {
    // Initialize the Index tables
    $tabs = $(".tabb",this);
    $tabs.each(function(index) {
       $(this).tablesorter({
              headers: {
                  0: { sorter:'buildname'},
                  1: { sorter:'buildname'},
                  2: { sorter:'numericvalue'},
                  4: { sorter:'numericvalue'},
                  5: { sorter:'numericvalue'},
                  7: { sorter:'numericvalue'},
                  8: { sorter:'numericvalue'},
                  10: { sorter:'numericvalue'},
                  11: { sorter:'numericvalue'},
                  12: { sorter:'numericvalue'},
                  13: { sorter:'numericvalue'},
                  14: { sorter:'text'}
              },
            debug: false,
            widgets: ['zebra']
          });

      // Get the cookie
      var tableid = this.id;
      var cookiename = "cdash_table_sort_"+tableid;
      var cook = $.cookie(cookiename); // get cookie
      if(cook)
        {
        var cookArray = cook.split(',');
        var sortArray = new Array();
        var j=0;
        for(var i=0; i < cookArray.length; i+=2)
          {
          sortArray[j] = [cookArray[i],cookArray[i+1]];
          j++;
          }
        $(this).trigger("sorton",[sortArray]);
        }
      });
    }

});
<|endoftext|>


<commit_before>import React from 'react';

import { Chizu } from 'CONTRIBUTORS';

import SpellLink from 'common/SpellLink';
import SPELLS from 'common/SPELLS';

export default [
  {
    date: new Date('2018-11-02'),
    changes: <><SpellLink id={SPELLS.FIRE_AND_BRIMSTONE_TALENT.id} /> should now correctly track bonus fragments and cleaved damage again.</>,
    contributors: [Chizu],
  },
  {
    date: new Date('2018-10-02'),
    changes: <>Fixed <SpellLink id={SPELLS.ERADICATION_TALENT.id} /> to snapshot the debuff on cast instead of damage.</>,
    contributors: [Chizu],
  },
  {
    date: new Date('2018-10-02'),
    changes: <>Added <SpellLink id={SPELLS.GRIMOIRE_OF_SUPREMACY_TALENT.id} /> stack tracker.</>,
    contributors: [Chizu],
  },
  {
    date: new Date('2018-10-01'),
    changes: <>Added <SpellLink id={SPELLS.REVERSE_ENTROPY_TALENT.id} /> uptime tracking.</>,
    contributors: [Chizu],
  },
  {
    date: new Date('2018-09-21'),
    changes: 'Removed all legendaries and tier set modules.',
    contributors: [Chizu],
  },
  {
    date: new Date('2018-06-25'),
    changes: 'Updated the basics of the spec for BFA. Reworked Soul Shard Fragment tracking.',
    contributors: [Chizu],
  },
];
<commit_msg>Changelog entry<commit_after>import React from 'react';

import { Chizu } from 'CONTRIBUTORS';

import SpellLink from 'common/SpellLink';
import SPELLS from 'common/SPELLS';

export default [
  {
    date: new Date('2018-11-04'),
    changes: <>Added <SpellLink id={SPELLS.GRIMOIRE_OF_SACRIFICE_TALENT.id} /> module, damage estimate to <SpellLink id={SPELLS.SOUL_CONDUIT_TALENT.id} /> and moved <SpellLink id={SPELLS.ERADICATION_TALENT.id} /> to the rest of the talents.</>,
    contributors: [Chizu],
  },
  {
    date: new Date('2018-11-02'),
    changes: <><SpellLink id={SPELLS.FIRE_AND_BRIMSTONE_TALENT.id} /> should now correctly track bonus fragments and cleaved damage again.</>,
    contributors: [Chizu],
  },
  {
    date: new Date('2018-10-02'),
    changes: <>Fixed <SpellLink id={SPELLS.ERADICATION_TALENT.id} /> to snapshot the debuff on cast instead of damage.</>,
    contributors: [Chizu],
  },
  {
    date: new Date('2018-10-02'),
    changes: <>Added <SpellLink id={SPELLS.GRIMOIRE_OF_SUPREMACY_TALENT.id} /> stack tracker.</>,
    contributors: [Chizu],
  },
  {
    date: new Date('2018-10-01'),
    changes: <>Added <SpellLink id={SPELLS.REVERSE_ENTROPY_TALENT.id} /> uptime tracking.</>,
    contributors: [Chizu],
  },
  {
    date: new Date('2018-09-21'),
    changes: 'Removed all legendaries and tier set modules.',
    contributors: [Chizu],
  },
  {
    date: new Date('2018-06-25'),
    changes: 'Updated the basics of the spec for BFA. Reworked Soul Shard Fragment tracking.',
    contributors: [Chizu],
  },
];
<|endoftext|>