我的jQuery"比较"功能有些问题.它的任务是比较两个文本区域并突出差异.
例如."我的名字是迈克尔"在一个文本区域,"我的名字是米歇尔"在另一个文本区域.
我的函数将返回两个输入并突出显示第一个输入中的char"a",并突出显示第二个输入中缺少的char.
到目前为止,这是该函数的外观,但它似乎并没有100%的工作时间.
$(function () {
$('#btnCompare').on('click', function () {
compare();
});
function compare() {
$('#divColLeft').empty();
$('#divColRight').empty();
var textOne = $('#taOneComp').val();
var textTwo = $('#taTwoComp').val();
var output;
var outputX;
var arrTextOne = [];
var arrTextTwo = [];
for (var i = 0; i < textOne.length; i++) {
output = textOne.charAt(i);
arrTextOne.push(output);
}
for (var x = 0; x < textTwo.length; x++) {
outputX = textTwo.charAt(x);
arrTextTwo.push(outputX);
}
$.each(arrTextOne, function (y, e) {
if ($.inArray(e, arrTextTwo) == -1) {
$('#divColLeft').append(e); …Run Code Online (Sandbox Code Playgroud) 介绍
花了两天时间试图让Umbraco与visual studio 2012,iis和某种页面构建器一起工作.在跟随包括Umbraco 5在内的许多指南之后发现Umbraco 5已经死了,我得到了它的工作.
我只是这样做,以帮助像我这样的新Umbraco用户在他们的发展中获得一个良好的开端.
使用VS 2012设置Umbraco
设置uSiteBuilder以便能够轻松地从Code构建DocumentTypes和Templates等
DocumentTypes - http://usitebuilder.vegaitsourcing.rs/tutorials?id=22389
模板 - http://usitebuilder.vegaitsourcing.rs/tutorials?id=22391
成品
当我们完成所有这些步骤后,我们准备在uSiteBuilder的帮助下从代码构建Umbracosites.
我想通过提升不同的日期来订购所选的值.
例如,我在我的数据库中有这些值.
ID | Value | Date
1 | 35 | 2012/01/20
2 | 0 | 2012/01/20
3 | 10 | 2012/02/01
4 | 0 | 2012/02/01
5 | 0 | 2012/03/01
6 | 0 | 2012/03/01
Run Code Online (Sandbox Code Playgroud)
由于ID 1在1月20日具有值,而ID 3在2月1日具有值,因此我希望将这两个日期选择到我的不同日期值列表中.但是对于ID 5和6都具有值0.因此,如果值为0,我还希望添加值0.
现在我的linqquery看起来像这样
var totalHours = (from u in context.Users
join r in context.Reports on u.Id equals r.UserId
join w in context.Weeks on r.Id equals w.ReportId
join d in context.Days on w.DayId equals d.Id
orderby d.Date ascending
where r.weekNr.Equals(currentWeek)
select d.Hour).ToList(); …Run Code Online (Sandbox Code Playgroud) 我有一个查询,应该返回当前报告的总小时数.下面的代码返回正确的小时总数,但不是数据库中特定用户的小时数.
public int reportedWeekTime(int currentWeek, string username)
{
var totalTime = (from u in context.Users
from r in context.Reports
from w in context.Weeks
from d in context.Days
where u.Id == r.UserId && r.weekNr.Equals(currentWeek) && r.Id == w.ReportId && w.DayId == d.Id
select d.Hour).DefaultIfEmpty(0).Sum();
return totalTime;
}
Run Code Online (Sandbox Code Playgroud)
第一种方法返回数字24,这是正确的,但正如我所说,不是针对特定用户.
我试图这样做,但它给了我0作为回报.我究竟做错了什么?
public int reportedWeekTime(int currentWeek, string username)
{
var totalTime = (from u in context.Users
from r in context.Reports
from w in context.Weeks
from d in context.Days
where u.Id == r.UserId && r.weekNr.Equals(currentWeek) …Run Code Online (Sandbox Code Playgroud) c# silverlight linq-to-entities entity-framework windows-phone-7