range

How to know if there is a link element within the selection

喜欢而已 提交于 2019-11-30 17:59:03
问题 In Javascript, I'd like determine whether an element, say an A element, exists inside a given range/textRange. The aim is to determine if the user's current selection contains a link. I am building a rich text editor control. The range object has a commonAncestorContainer (W3C) or parentElement() (Microsoft) method which returns the closest common anscestor of all elements in the range. However, looking inside this element for A elements won't work, since this common ancestor may also contain

Python's `range` function with 3 parameters

流过昼夜 提交于 2019-11-30 17:43:26
问题 I understand that the following line will give the given result: for in range(5): print(i) 0 1 2 3 4 But I don't understand how if adding 3 separate parameters the result is confusing. How is this returning these particular results? (4 6 and 8) ???? for i in range(4, 10, 2): print(i) 4 6 8 回答1: Starts at 4, then increments by 2, to end at 8 because 10 < 10 is false. So 4 6 8 来源: https://stackoverflow.com/questions/32096391/pythons-range-function-with-3-parameters

Problem detecting Newlines in JavaScript Range Object

五迷三道 提交于 2019-11-30 17:33:04
I have some javascript that manipulates html based on what the user has selected. For real browsers the methods I'm using leverage the "Range" object, obtained as such: var sel = window.getSelection(); var range = sel.getRangeAt(0); var content = range.toString(); The content variable contains all the selected text, which works fine. However I'm finding that I cannot detect the newlines in the resulting string. For example: Selected text is: abc def ghi range.toString() evaluates to "abcdefghi". Any search on special characters returns no instance of \n \f \r or even \s. If, however, I write

Oracle - Convert value from rows into ranges

岁酱吖の 提交于 2019-11-30 17:18:33
问题 Are there any techniques that would allow a row set like this WITH base AS ( SELECT 1 N FROM DUAL UNION ALL SELECT 2 N FROM DUAL UNION ALL SELECT 3 N FROM DUAL UNION ALL SELECT 6 N FROM DUAL UNION ALL SELECT 7 N FROM DUAL UNION ALL SELECT 17 N FROM DUAL UNION ALL SELECT 18 N FROM DUAL UNION ALL SELECT 19 N FROM DUAL UNION ALL SELECT 21 N FROM DUAL ) SELECT a.N FROM base a to yield results 1 3 6 7 17 19 21 21 It is in effect a rows to ranges operation. I'm playing in Oracle Land, and would

Autolink URL in contenteditable

痞子三分冷 提交于 2019-11-30 16:18:54
问题 When the user finishes to type in a URL in a contenteditable div, I want to autolink it, like Medium does: ). I'm wondering how it is possible to achieve that using selection/range (I do not need to support IE, only modern versions of Chrome, Firefox and Safari), if possible without rangy (but if that is the only solution I would use it). I'm able to detect if an URL preceed the caret after a user presses the space key, but I can't have execcommand('createLink'...) work on my range. Here is a

What does “ for (const auto &s : strs) {} ” mean?

做~自己de王妃 提交于 2019-11-30 15:44:27
What does for (const auto &s : strs) mean? What is the function of colon : ? vector<string> &strs; for (const auto &s : strs){ // } It's actually a C++11 feature called "range-based for-loops". In this case, it's basically an easier-to-write replacement for: // Let's assume this vector is not empty. vector<string> strs; const vector<string>::iterator end_it = strs.end(); for (vector<string>::iterator it = strs.begin(); it != end_it; ++it) { const string& s = *it; // Some code here... } The : is part of the new syntax . On the left you basically have a variable declaration that will be bound to

Python - Count occurrences of certain ranges in a list

北慕城南 提交于 2019-11-30 15:39:27
So basically I want to count the number of occurrences a floating point appears in a given list. For example: a list of grades (all scores out of 100) are inputted by the user and they are sorted in groups of ten. How many times do scores from 0-10, 10-20, 20-30.. etc) appear? Like test score distribution. I know I can use the count function but since I'm not looking for specific numbers I'm having trouble. Is there a away to combine the count and range? Thanks for any help. To group the data, divide it by the interval width. To count the number in each group, consider using collections

How do I delegate a call to [0..<n] in swift?

99封情书 提交于 2019-11-30 15:32:40
Background For convenience, I used this alias: typealias Deck = [Int] My needs are expanding so I have now converted my code to: class Deck { var deck : [Int] // ... other members } I am able to delegate most of my calls through to self.deck , but after googling around somewhat, I am still having trouble figuring out how to delegate this call: let deck = Deck() for i in deck[0..<5] { } // <--- PROBLEMS HERE Question How do I implement the delegation of this call? I think it has something to do with subscript and range (or maybe sequence ?), but I had no luck googling the intersection of these

What is the status of ranges in C++?

大兔子大兔子 提交于 2019-11-30 14:40:26
问题 Sometimes I get tired of all this my_vector.begin(), my_vector.end() noise. Last year at boostcon, Andrei Alexandrescu's keynote speech was titled Iterators Must Go (video) Is there any progress on introducing ranges into C++, so I can finally say std::sort(my_vector) ? 回答1: Range in C++ still has an insufficient experience. As current experimental implementation, there are Boost.Range 2.0 and Oven Range Library. 回答2: As far as I know, no progress has been made toward that end. 回答3: #include

ionic range cannot click on ios

时光毁灭记忆、已成空白 提交于 2019-11-30 14:03:00
问题 I am using ionic "range" input in a cross platform project. For android and PC browser, if I click on the area away from the slider node, the slider node will jump to the point I click and the value will be updated. But for IOS, when I click the area away from the slider node, no value change is happening. And this also make my slider difficult to click, I need to click very accurate right on the slider node, else the slider will not slide. Any idea? 回答1: I believe I have found a solution for