Kawiesh

CSS SECTORS ON TOUCH

Jun 19th, 2021 (edited)
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //------------------------OLD-SELECTORS-ON-TOUCH-------------------------
  2. let stop= false;
  3. let input= document.querySelector("input");
  4.  
  5. document.body.ontouchstart=()=>{
  6. let target= event.target;
  7. let sel=[];
  8.  
  9. while(!stop){
  10. if(target.tagName.toLowerCase()=="body"){
  11. sel.unshift("body");
  12. break;
  13. }
  14.  
  15. if(target.parentNode.id){
  16. sel.unshift("#"+target.parentNode.id,target.tagName.toLowerCase());
  17. break;
  18. }
  19. else if(target.parentNode.className){
  20. sel.unshift("."+target.parentNode.className,target.tagName.toLowerCase());
  21. break;
  22. }
  23. else{
  24. sel.unshift(target.parentNode.tagName.toLowerCase(),target.tagName.toLowerCase());
  25. target= target.parentNode;
  26. }
  27. }
  28.  
  29. input.value= sel.join(">");
  30. };
  31.  
  32. //-----------------
  33. let
  34. a= document.createElement("div"),
  35. b= document.createElement("style"),
  36. c=`outline: 2px solid rgb(255,192,203);
  37. background-image:none!important;
  38. background-color:rgb(255,192,203,0.5)!important;`;
  39.  
  40. a.style.cssText=`
  41. pointer-events:none;
  42. font: bold 15px "Courier New";
  43. position:fixed; left:2ch; top:0;
  44. text-align:center;
  45. background: yellow;
  46. color:black; padding:2px`;
  47.  
  48. document.body.append(a,b);
  49.  
  50. document.body.ontouchstart=()=>{
  51. let target= event.target,
  52. id= target.id,
  53. klass= target.className,
  54. tag= target.tagName.toLowerCase(),
  55. sel= [];
  56.  
  57. if(id!=(null||"")){
  58. a.innerHTML= "#"+id;
  59. }
  60. else if(klass!=(null||"")){
  61. a.innerHTML= "."+ klass.split(" ").join(".");
  62. }
  63. else{
  64. while(target.tagName.toLowerCase()!="body"){
  65.       if(target.parentNode.id){
  66.       sel.unshift("#"+target.parentNode.id,target.tagName.toLowerCase());
  67.       break;
  68.       }
  69.       else if(target.parentNode.className){
  70.       sel.unshift("."+target.parentNode.className,target.tagName.toLowerCase());
  71.       break;
  72.       }
  73.       else{
  74.       sel.unshift(target.parentNode.tagName.toLowerCase(),target.tagName.toLowerCase());
  75.       target= target.parentNode;
  76.       }
  77. }
  78.  
  79. a.innerHTML= sel.join(">");
  80. }
  81.  
  82.  
  83. target.style.cssText+= c;
  84. };
  85.  
  86. document.body.ontouchend=()=>{
  87. a.innerHTML= "NO SELECTION";
  88. target.style.cssText-= c;
  89. };
  90.  
  91. //------------------------NEW-SELECTORS-ON-TOUCH-------------------------
  92. let
  93. a= document.createElement("div"),
  94. b= document.createElement("style");
  95. document.body.append(a,b);
  96.  
  97. a.style.cssText=`
  98. font: bold 15px "Courier New";
  99. position:fixed; left:2ch; top:0;
  100. text-align:center;
  101. background: yellow;
  102. color:black; padding:2px`;
  103.  
  104. document.body.ontouchstart=()=>{
  105. let target= event.target,
  106. id= target.id,
  107. klass= target.className,
  108. tag= target.tagName.toLowerCase();
  109.  
  110. if(id!=(null||"")){
  111. a.innerHTML= "#"+id;
  112. }
  113. else if(klass!=(null||"")){
  114. a.innerHTML= "."+ klass.split(" ").join(".");
  115. }
  116. else{
  117. a.innerHTML= tag;
  118. }
  119.  
  120. target.classList.add("kaydee");
  121. b.innerHTML=`.kaydee{
  122. outline: 2px solid rgb(255,192,203);
  123. background-image:none!important;
  124. background-color:rgb(255,192,203,0.5)!important;}`;
  125. };
  126.  
  127.  
  128. document.body.ontouchend=()=>{
  129. event.target.classList.remove("kaydee");
  130. b.innerHTML= "";
  131. };
  132.  
  133. //--------------------------OLD-VIEW SOURCE ON TOUCH-----------------------------
  134. let a= document.createElement("textarea");
  135. a.style.cssText= `width:30em;
  136. height:15em; color:yellow;
  137. font: bold 10px "Courier New";
  138. position:fixed;top:1px; left:1px;
  139. background: rgb(0,0,0,0.6);`;
  140.  
  141. document.body.append(a);
  142.  
  143. let regex= /<style>\.qc-cmp-showing.+?<\/textarea>/;
  144.  
  145. document.body.ontouchstart= (e)=>{
  146. if(e.target!=a){
  147. a.value= e.target.outerHTML.replace(regex,"");
  148. }};
  149.  
  150. //--------------------------NEW-VIEW SOURCE ON TOUCH-----------------------------
  151. let a= document.createElement("textarea"),
  152. b= document.createElement("style");
  153. a.classList.add("qcksrcvwr");
  154.  
  155. document.body.append(a,b);
  156.  
  157. b.innerHTML= `.qcksrcvwr{
  158. width:30em; height:15em;
  159. font: bold 10px "Courier New";
  160. position:fixed; top:1px; left:1px;
  161. background: rgb(0,0,0,0.7);color: white;
  162. }
  163. .nowtouching{
  164. background:rgb(255,192,203,0.5)!important;
  165. transition: none!important;
  166. }`;
  167.  
  168. let regex= /\n?<style>\.qc-cmp-showing.+<\/style>/;
  169.  
  170. document.body.ontouchstart= (e)=>{
  171. if(e.target!=a){
  172. event.target.classList.add("nowtouching");
  173. a.value= e.target.outerHTML
  174. .split(regex).join("")
  175. .split(` nowtouching`).join("")
  176. .split(` class="nowtouching"`).join("")
  177. .split(` class=""`).join("");
  178. }
  179. };
  180.  
  181. document.body.ontouchend=()=>{
  182. event.target.classList.remove("nowtouching");
  183. };
Add Comment
Please, Sign In to add comment