Thursday 15 March 2012

html - Javascript Selection returns wrong offset -



html - Javascript Selection returns wrong offset -

problem: selection#anchoroffset, selection#baseoffset & selection#focusoffset time time returns wrong values.

expected behavior: create double click on sec word in code snippet (feature). should see alert 'anchor: feature'.

question: how right value?

jsfiddle demo: http://jsfiddle.net/v2mmabzm/5/

demo:

class="snippet-code-js lang-js prettyprint-override">$(document).ready(function() { var p = $('p.text-container') p.css({ cursor: 'pointer' }); p.dblclick(function(e) { var html = $(e.target).html(); var range = window.getselection() || document.getselection() || document.selection.createrange(); var selectedword = $.trim(range.tostring()); debugger; var anchoroffset = range.anchoroffset; var baseoffset = range.baseoffset; var focusoffset = range.focusoffset; alert('anchor: ' + html.substring(anchoroffset, anchoroffset + selectedword.length)); alert('base: ' + html.substring(baseoffset, baseoffset + selectedword.length)); alert('focus: ' + html.substring(focusoffset, focusoffset + selectedword.length)); }); }); class="snippet-code-css lang-css prettyprint-override">span.touched { font-weight: bold; } class="snippet-code-html lang-html prettyprint-override"><script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> <p class="text-container"> future of manned space exploration , development of space depends critically on creation of dramatically more proficient propulsion architecture in-space transportation. persuasive reason investigating applicability of nuclear powerfulness in rockets vast energy density gain of nuclear fuel when compared chemical combustion energy. current nuclear fusion efforts have focused on generation of electrical grid powerfulness , wholly inappropriate space transportation application of reactor based fusion-electric scheme creates colossal mass , heat rejection problem space application. fusion driven rocket (fdr) represents revolutionary approach fusion propulsion powerfulness source releases energy straight propellant, not requiring conversion electricity. employs solid lithium propellant requires no important tankage mass. propellant rapidly heated , accelerated high exhaust velocity (&gt; 30 km/s), while having no important physical interaction spacecraft thereby avoiding harm rocket , limiting both thermal heat load , radiator mass. in addition, believed fdr can realized little extrapolation existing technology, @ high specific powerfulness (~ 1 kw/kg), @ reasonable mass scale (&lt;100 mt), , hence cost. if realized, not enable manned interplanetary space travel, allow become mutual place. key achieving stems research @ msnw on magnetically driven implosion of metal foils onto magnetized plasma target obtain fusion conditions. logical extension of work leads method utilizes these metal shells (or liners) not accomplish fusion conditions, serve propellant well. several low-mass, magnetically-driven metal liners inductively driven converge radially , axially , form thick blanket surrounding target plasmoid , compress plasmoid fusion conditions. virtually of radiant, neutron , particle energy plasma absorbed encapsulating, metal blanket thereby isolating spacecraft fusion process , eliminating need big radiator mass. energy, in add-on intense ohmic heating @ peak magnetic field compression, adequate vaporize , ionize metal blanket. expansion of hot, ionized metal propellant through magnetically insulated nozzle produces high thrust @ optimal isp. energy fusion process, utilized @ high efficiency. expanding on results phase effort, phase ii focus on achieving 3 key criteria fusion driven rocket move forwards technological development: </p> </body>

just change

var html = p.text();

javascript html

No comments:

Post a Comment