Posts

How can typescript generate single one javascript file without reference typescript file code -

can typescript generate single 1 javascript file without reference typescript file code? here 2 typescript source files. class source1{...}; class source 2{...}; here 2 typescript files. ///reference path=’source1’ class reference1{...}; ///reference path=’source2’ class reference2{...}; i generate reference1 , reference2 single 1 js file. in js file, there source1 , source2 code. how can single javascript file without souce1 , soucre2 code? thanks. looks me need split compilation 2 phases, 1 generate soruce1 , soruce2, , 1 generate reference1 , reference2. best way generate .d.ts first batch of files reference in second compilation. to generate sources.d.ts: tsc --declaration --out soruces.js soruce1.ts source2.ts now files should like: ///reference path=’sources.d.ts’ class reference1{...}; ///reference path=’source.s.ts’ class reference2{...}; the second compilation be: tsc --out references.js reference1.ts reference2.ts

javascript - Trigger after every 3rd time -

this question has answer here: javascript run function inside loop every x iterations 5 answers i want trigger event after every 3rd time. for (i = 0; < 5000; i++) { // when == 3, == 6, == 9 etc. if () { trigger(); } } i can't figure out how represent in code, brain stuck. unless write: if == 3 if == 6 etc. but write millions of these since unlimited. you could... increment i 3, not 1 use modulo check so for (i = 0; < 5000; i=i+3) { ... } or for (i = 0; < 5000; i++) { // when == 3, == 6, == 9 etc. if (i % 3 == 0) { trigger(); } }

regex - How to match the exact number of digits with regular expression in Javascript -

in javascript, have done following: var matched = searched.match(/\d{7}/) it works great if searched 1234567 or xyz1234567 . both return 1234567 , good. 123 , xyz123 return null, expected. but 1 condition fails when searched 12345678 or xyz12345678 . both return null because exact 7 digit match. both return 2345678 instead. /\d{7}$/ not work either. can please advise? thank you (?:\d|^) : begins non-digit (?:\d|$) : ends non-digit var matched = searched.match(/(?:\d|^)(\d{7})(?:\d|$)/); if (matched) { matched = matched[1]; }

html - hide specific divs after clicking on other div using jQuery -

i quite new in jquery. i have html code below generated on fly , added page: <div class="outstandingcallback"> <span>a</span> <span>b</span> </div> <div class="outstandingcallback"> <span>c</span> <span>d</span> </div> ...... i need hide 1 of them when click on other one. used following jquery not sure how can hide div element. $('.outstandingcallback').bind('click', function () { var selectdcallitemid = $(".callitemid", this).html(); var myhtmlcode = $('#callbacks').html(); $('' + myhtmlcode + '').find('div').each(function () { var thiscallid = $(".callitemid", this).html(); if (thiscallid == selectdcallitemid ) { alert("test"); $('' + myhtmlcode + ...

iphone - Convert number to phone format using regular expression -

Image
my problem have text field number , must convert number phone format 1 (xxx) xxx-xxxx . have tried regular expression code: wholetext = [wholetext stringbyreplacingoccurrencesofstring:@"(\\d{1,3})(\\d{0,3})(\\d{0,4})" withstring:@"($1) $2-$3" options:nsregularexpressionsearch range:nsmakerange(0, wholetext.length)]; nslog(@"wholetext = %@", wholetext); if gradually enter text in text field, nslog output this: wholetext = (1) - wholetext = (12) - wholetext = (123) - wholetext = (123) 4- wholetext = (123) 45- wholetext = (123) 456- wholetext = (123) 456-7 so problem do not need brackets , hyphens if there no number before it , i.e. closing bracket should appear after enter 4th number , hyphen should appear after enter 7th number. use utility uitextfield subclass allows...

java - printing only filled data from JTable with logo -

my program hava jtable 100 blank rows. let user fills 10 rows. want print filled rows logo on top. how ? here code used: if(e.getsource() == print){ try { table.print(jtable.printmode.fit_width, head, null); } catch (java.awt.print.printerexception e1) { system.err.format("cannot print %s%n", e1.getmessage()); } } it prints 100 rows. i want print filled rows( let first 10 rows filled) you can filter empty rows before printing: table.setautocreaterowsorter(true); rowfilter filter = new rowfilter() { public void include(entry entry) { // here add loop checks if // of values in entry not-null // return true if yes, false otherwise (that empty) } }; ((defaultrowsorter) table.getrowsorter()).setrowfilter(filter); table.print(....);

math - How to get the true Euclidean remainder? -

i have 2 unsigned long s a , q , find number n between 0 , q-1 such n + divisible q (without overflow). in other words, i'm trying find (portable) way of computing (-a)%q lies between 0 , q-1. (the sign of expression implementation-defined in c89.) what's way this? what you're looking mathematically equivalent (q - a) mod q, in turn equivalent (q - (a mod q)) mod q. think should therefore able compute follows: unsigned long result = (q - (a % q)) % q;