JS function to calculate complementary colour?

Does anybody know, off the top of your heads, a Javascript solution for calculating the complementary colour of a hex value? There is a number of colour picking suites and palette generators on the web but I haven't seen any that calculate the colour live using JS. A detailed hint or a snippet would be very much appreciated. 通过http://design.geckotribe.com/colorwheel/解析// complement t

JS函数计算互补色?

有人知道,从头到尾,计算十六进制值的互补色的JavaScript解决方案? 网上有很多颜色选择套件和调色板生成器,但我还没有看到任何使用JS计算颜色的方法。 一个详细的提示或摘录将非常感激。 通过http://design.geckotribe.com/colorwheel/解析// complement temprgb=thisrgb; temphsv=RGB2HSV(temprgb); temphsv.hue=HueShift(temphsv.hue,180.0); temprgb=HSV2RGB(temphsv); function RGB2HSV(rgb) { hsv = new Object

Is there a version of JavaScript's String.indexOf() that allows for regular expressions?

In javascript, is there an equivalent of String.indexOf() that takes a regular expression instead of a string for the first first parameter while still allowing a second parameter ? I need to do something like str.indexOf(/[abc]/ , i); and str.lastIndexOf(/[abc]/ , i); While String.search() takes a regexp as a parameter it does not allow me to specify a second argument! Edit: This turne

是否有允许正则表达式的JavaScript的String.indexOf()版本?

在JavaScript中,是否有等价的String.indexOf(),它需要一个正则表达式而不是第一个参数的字符串,同时还允许第二个参数? 我需要做类似的事情 str.indexOf(/[abc]/ , i); 和 str.lastIndexOf(/[abc]/ , i); 虽然String.search()将一个正则表达式作为参数,但它不允许我指定第二个参数! 编辑: 事实证明,这比我原先想象的要难,于是我编写了一个小测试函数来测试所有提供的解决方案......它假定regexIndexOf和re

regex to get the number from the end of a string

我有一个像stringNumber变量的id,如下所示:example12我需要一些javascript正则表达式从字符串中提取12,“example”对于所有id都是不变的,只是数字会不同。 This regular expression matches numbers at the end of the string. var matches = str.match(/d+$/); It will return an Array with its 0 th element the match, if successful. Otherwise, it will return null . Before accessing the 0 member, ensure the ma

正则表达式从字符串的末尾获取数字

我有一个像stringNumber变量的id,如下所示:example12我需要一些javascript正则表达式从字符串中提取12,“example”对于所有id都是不变的,只是数字会不同。 这个正则表达式匹配字符串末尾的数字。 var matches = str.match(/d+$/); 如果成功,它将返回一个Array ,其第0个元素匹配。 否则,它将返回null 。 在访问0成员之前,请确保匹配成功。 if (matches) { number = matches[0]; } 的jsfiddle。 如果你必须把它

Regular expression for IP Address Validation

i want to validate the value is valid IP Address or not..! I Used to validate like ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"; it's working fine, but when i give the values like 12345678 , its also return true .. How to solve this? There is a simpler way. You just need to split the string on . and ch

IP地址验证的正则表达式

我想验证该值是否为有效的IP地址。 我用来验证像 ValidIpAddressRegex = "^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$"; 它工作正常,但是当我给像12345678这样的值时,它也返回true ..如何解决这个问题? 有一种更简单的方法。 你只需要分开字符串. 并检查每个数字是否在0到255之间。 另外,您可以检查hexa并拆分: for IPv6。 仅仅因为我认为这很

Typescript side

Having used side by side editing for Typescript and its compiled Javascript output using Web Essentials 2013 in Visual Studio 2013, now that I have updated to Visual Studio 2015 the side by side capability seems to have completely vanished, does anyone know how to get it working? Or has it been dropped completely?! You can get this functionality without needing any plugin in any version of VS.

打字稿方

在Visual Studio 2013中使用Web Essentials 2013并行编辑Typescript及其编译的Javascript输出后,现在我已更新到Visual Studio 2015,并排功能似乎已完全消失,是否有人知道如何使其工作? 还是它完全被丢弃? 您可以在任何版本的VS中无需任何插件即可获得此功能。 首先允许在visual studio选项中重新加载更改。 然后你可以打开一个带有JS输出的选项卡,并将它放在打字稿标签旁边。

'This' scope in TypeScript

On my webpage I have remove icons on rows in a table like this: I am using TypeScript where I have attached an onClick listener to execute a function called OnRemoveClick , like this $('.remove').click(this.OnRemoveClick); OnRemoveClick zeros 2 fields (on the row the remove icon is clicked) and then executes 2 functions, like this: private OnRemoveClick(): void { $(this).parents(

'这'范围在TypeScript中

在我的网页上,我删除了像这样的表中的行上的图标: 我使用的打字稿,我已经连接了onClick监听器执行被称为功能OnRemoveClick ,像这样$('.remove').click(this.OnRemoveClick); OnRemoveClick 2个字段(在行上单击删除图标),然后执行2个函数,如下所示: private OnRemoveClick(): void { $(this).parents('tr').find('.input-qty').val('0'); $(this).parents('tr').find('.sub-total').html('0');

How to manage Services in Angular2

Angular 2 : 2.0.0-alpha.31 / Typescript 1.5 Currently I manage my service as a simple Class , then I inject this Class into an other component. Example: export class PlayerService { http: Http; players = []; constructor( @Inject(Http) http) { this.http = http; } getAll(callback) { this.http.get('/data/players.json') .toRx() .map((res) =&

如何在Angular2中管理服务

Angular 2 :2.0.0-alpha.31 / Typescript 1.5 目前我管理我的服务作为一个简单的Class ,然后我注入这个Class到其他组件。 例: export class PlayerService { http: Http; players = []; constructor( @Inject(Http) http) { this.http = http; } getAll(callback) { this.http.get('/data/players.json') .toRx() .map((res) => res.json()) .s

Overwriting Meteor's default login handler

I'm using NPM ldapjs and this Meteor LDAP project to try to enable LDAP on my test Telescope website. The main issue is that I want LDAP to be the sole method of logging in. My plan is to have a wrapper around the built-in Telescope (Meteor?) login method. If the LDAP credentials pass, it runs the Telescope login script and continues as normal. Perhaps this is a hacky solution and a bette

覆盖Meteor的默认登录处理程序

我正在使用NPM ldapjs和这个Meteor LDAP项目来尝试在我的测试Telescope网站上启用LDAP。 主要问题是我希望LDAP是登录的唯一方法。我的计划是围绕内置Telescope(Meteor?)登录方法进行封装。 如果LDAP凭证通过,它将运行Telescope登录脚本并继续正常。 也许这是一个拙劣的解决方案,存在一个更好的解决方案? 无论如何,我需要LDAP来工作。 现在,我试图用这个覆盖默认的登录方法: Template.signin.events({ 'submit

How set up my directory to work with eyeglass on fetching modularscale

I'm trying to include the Sassy Modular Scale project into my build by using eyeglass. I was able to get it Modular Scale via the terminal by executing the command npm install modularscale-sass --save-dev in my project directory. Then I took a look in my package.json and I saw that "modularscale-sass": "^2.1.1" was added and in my directory I could access the files unde

如何设置我的目录以获取modularscale与眼镜工作

我试图通过使用眼镜将Sassy Modular Scale项目包括到我的作品中。 我可以通过执行命令npm install modularscale-sass --save-dev在我的项目目录中通过终端获得它的模块化缩放。 然后我看了看package.json ,看到"modularscale-sass": "^2.1.1"添加了"modularscale-sass": "^2.1.1" ,并且在我的目录中我可以访问node-modules目录下的文件。 都好! 然后,模块化比例文档指导我在ma

Are loops really faster in reverse?

I've heard this quite a few times. Are JavaScript loops really faster when counting backward? If so, why? I've seen a few test suite examples showing that reversed loops are quicker, but I can't find any explanation as to why! I'm assuming it's because the loop no longer has to evaluate a property each time it checks to see if it's finished and it just checks against

循环是否真的更快?

我已经听过好几次了。 向后计数时JavaScript循环速度真的快吗? 如果是这样,为什么? 我见过一些测试套件的例子,显示反向循环更快,但我找不到任何解释为什么! 我假设这是因为循环不再需要评估一个属性,每次检查它是否完成,它只是检查最终的数值。 即 for (var i = count - 1; i >= 0; i--) { // count is only evaluated once and then the comparison is always on 0. } 这并不是说i--快于i++ 。 事实上,