Guest User

Untitled

a guest
Jun 18th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.16 KB | None | 0 0
  1. function ipsclass(){
  2. this.cookies=new Array();
  3. this.ignore_cookies=new Array(ipb_var_cookieid+'ipb_stronghold',ipb_var_cookieid+'session_id',ipb_var_cookieid+'ipb_admin_session_id',ipb_var_cookieid+'member_id',ipb_var_cookieid+'pass_hash');
  4. this.settings={
  5. 'do_linked_resize':0,'resize_percent':50}
  6. ;
  7. this.init=function(){
  8. var _tmp=document.cookie.split(';
  9. ');
  10. if(_tmp.length){
  11. for(i=0;
  12. i<_tmp.length;
  13. i++){
  14. if(_tmp[i].match(new RegExp(ipb_var_cookieid+".*$"))){
  15. var _data=_tmp[i].split('=');
  16. var _key=this.trim(_data[0]);
  17. var _value=unescape(this.trim(_data[1]));
  18. if(_key&&(!this.in_array(_key,this.ignore_cookies))){
  19. this.cookies[_key.replace(ipb_var_cookieid,'')]=_value}
  20. }
  21. }
  22. }
  23. _tmp=null}
  24. ;
  25. this.trim=function(text){
  26. if(typeof(text)=='undefined'){
  27. return''}
  28. text=text.replace(/^\s+/,'');
  29. return text.replace(/\s+$/,'')}
  30. ;
  31. this.html_entity_decode=function(text){
  32. if(typeof ca=='undefined'){
  33. var ca=document.createElement('textarea')}
  34. ca.innerHTML=text.replace(/</g,'<
  35. ').replace(/>/g,'>
  36. ');
  37. return ca.value}
  38. ;
  39. this.in_array=function(needle,haystack){
  40. if(!haystack.length){
  41. return false}
  42. for(var i=0;
  43. i<haystack.length;
  44. i++){
  45. if(haystack[i]===needle){
  46. return true}
  47. }
  48. return false}
  49. ;
  50. this.htmlspecialchars=function(text){
  51. text=text.replace(/</g,'<
  52. ');
  53. text=text.replace(/>/g,'>
  54. ');
  55. text=text.replace(/"/g,'"
  56. ');
  57. return text}
  58. ;
  59. this.un_htmlspecialchars=function(text){
  60. text=text.replace(/<
  61. /g,'<');
  62. text=text.replace(/>
  63. /g,'>');
  64. text=text.replace(/"
  65. /g,'"');
  66. return text}
  67. ;
  68. this.get_editor_contents=function(editor_id,editor_array){
  69. var aIPS_editor=editor_array?editor_array:IPS_editor;
  70. if(!editor_id){
  71. for(var i in aIPS_editor){
  72. if(typeof(aIPS_editor[i])!='object'){
  73. continue}
  74. editor_id=i;
  75. break}
  76. }
  77. return aIPS_editor[editor_id].editor_get_contents}
  78. ;
  79. this.add_editor_contents=function(text,editor_id,editor_array){
  80. var aIPS_editor=editor_array?editor_array:IPS_editor;
  81. if(!editor_id){
  82. for(var i in aIPS_editor){
  83. if(typeof(aIPS_editor[i])!='object'){
  84. continue}
  85. editor_id=i;
  86. break}
  87. }
  88. return aIPS_editor[editor_id].insert_text(text)}
  89. ;
  90. this.convert_saved_tags_to_display_tags=function(text){
  91. text=text.replace(/(<|<
  92. |<
  93. )!--/,"{
  94. ");
  95. text=text.replace(/--(>|>
  96. |>
  97. )/,"}
  98. ");
  99. return text}
  100. ;
  101. this.include_javascript=function(_file,div_id){
  102. var _doc=(div_id)?document.getElementById(div_id):document.getElementsByTagName('head').item(0);
  103. var _js=document.createElement('script');
  104. _js.setAttribute('language','javascript');
  105. _js.setAttribute('type','text/javascript');
  106. _js.setAttribute('src',_file);
  107. _doc.appendChild(_js);
  108. return false}
  109. ;
  110. this.fade_in_element=function(div){
  111. var hash='#';
  112. var color_items="0123456789abcdef";
  113. var start_color='#ffff66';
  114. var orig_color=document.getElementById(div).style.backgroundColor;
  115. var temp_end='#ffffff';
  116. var iter=20;
  117. var time=80;
  118. var rbeg=color_items.indexOf(start_color.substr(1,1))*16+color_items.indexOf(start_color.substr(2,1));
  119. var gbeg=color_items.indexOf(start_color.substr(3,1))*16+color_items.indexOf(start_color.substr(4,1));
  120. var bbeg=color_items.indexOf(start_color.substr(5,1))*16+color_items.indexOf(start_color.substr(6,1));
  121. var rend=color_items.indexOf(temp_end.substr(1,1))*16+color_items.indexOf(temp_end.substr(2,1));
  122. var gend=color_items.indexOf(temp_end.substr(3,1))*16+color_items.indexOf(temp_end.substr(4,1));
  123. var bend=color_items.indexOf(temp_end.substr(5,1))*16+color_items.indexOf(temp_end.substr(6,1));
  124. for(i=1,r=rbeg,g=gbeg,b=bbeg;
  125. i<=iter;
  126. r=Math.round(rbeg+i*((rend-rbeg)/(iter-1))),g=Math.round(gbeg+i*((gend-gbeg)/(iter-1))),b=Math.round(bbeg+i*((bend-bbeg)/(iter-1))),i++){
  127. hstr='#'+color_items.charAt(Math.floor(r/16))+color_items.charAt(r%16)+color_items.charAt(Math.floor(g/16))+color_items.charAt(g%16)+color_items.charAt(Math.floor(b/16))+color_items.charAt(b%16);
  128. setTimeout('var div = document.getElementById("'+div+'");
  129. div.style.backgroundColor = "'+hstr+'";
  130. ',i*time)}
  131. setTimeout('var div = document.getElementById("'+div+'");
  132. div.style.backgroundColor = "'+orig_color+'";
  133. ',(i+1)*time)}
  134. ;
  135. this.lang_build_string=function(){
  136. if(!arguments.length||!arguments){
  137. return}
  138. var string=arguments[0];
  139. for(var i=1;
  140. i<arguments.length;
  141. i++){
  142. var match=new RegExp('<%'+i+'>','gi');
  143. string=string.replace(match,arguments[i])}
  144. return string}
  145. ;
  146. this.get_id_from_text=function(id){
  147. return id.replace(/.*(\-|_)(\S+)/,"$2")}
  148. ;
  149. this.get_name_from_text=function(id){
  150. return id.replace(/(.*)(\-|_)(\S+)/,"$1")}
  151. ;
  152. this.location_jump=function(url,full){
  153. url=url.replace(/&
  154. /g,'&');
  155. if(full){
  156. window.location.href=url}
  157. else{
  158. window.location.href=ipb_var_base_url+url}
  159. }
  160. ;
  161. this.confirm_action=function(url,msg){
  162. if(!msg){
  163. msg='Для подтверждения нажмите ОК'}
  164. if(url){
  165. url=url.replace('&
  166. ','&')}
  167. else{
  168. url=''}
  169. if(confirm(msg)){
  170. window.location.href=url}
  171. else{
  172. alert(ipb_global_lang['action_cancelled']);
  173. return false}
  174. }
  175. ;
  176. this.pop_up_window=function(url,width,height,name){
  177. if(!name){
  178. var mydate=new Date();
  179. name=mydate.getTime()}
  180. var Win=window.open(url.replace('&
  181. ','&'),name,'width='+width+',height='+height+',resizable=1,scrollbars=1,location=no,directories=no,status=no,menubar=no,toolbar=no');
  182. Win.focus();
  183. return false}
  184. ;
  185. this.set_unselectable=function(obj){
  186. if(!is_ie4&&typeof(obj.tagName)!='undefined'){
  187. if(obj.hasChildNodes()){
  188. for(var i=0;
  189. i<obj.childNodes.length;
  190. i++){
  191. this.set_unselectable(obj.childNodes[i])}
  192. }
  193. obj.unselectable='on'}
  194. }
  195. ;
  196. this.get_obj_leftpos=function(obj){
  197. var curleft=0;
  198. if(obj.offsetParent){
  199. while(obj.offsetParent){
  200. curleft+=obj.offsetLeft;
  201. obj=obj.offsetParent}
  202. }
  203. else if(obj.x){
  204. curleft+=obj.x}
  205. return curleft}
  206. ;
  207. this.get_obj_toppos=function(obj){
  208. var curtop=0;
  209. if(obj.offsetParent){
  210. while(obj.offsetParent){
  211. curtop+=obj.offsetTop;
  212. obj=obj.offsetParent}
  213. }
  214. else if(obj.y){
  215. curtop+=obj.y}
  216. return curtop}
  217. ;
  218. this.cancel_bubble=function(obj,extra){
  219. if(extra!==false){
  220. extra=true}
  221. if(!obj||is_ie){
  222. if(extra){
  223. window.event.returnValue=false}
  224. window.event.cancelBubble=true;
  225. return window.event}
  226. else{
  227. obj.stopPropagation();
  228. if(extra){
  229. obj.preventDefault()}
  230. return obj}
  231. }
  232. ;
  233. this.cancel_bubble_all=function(obj){
  234. return ipsclass.cancel_bubble(obj,true)}
  235. ;
  236. this.cancel_bubble_low=function(obj){
  237. return ipsclass.cancel_bubble(obj,false)}
  238. ;
  239. this.my_getcookie=function(name){
  240. return this.cookies[name]}
  241. ;
  242. this.my_setcookie=function(name,value,sticky){
  243. expire="";
  244. domain="";
  245. path="/";
  246. if(sticky){
  247. expire=";
  248. expires=Wed, 1 Jan 2020 00:00:00 GMT"}
  249. if(ipb_var_cookie_domain!=""){
  250. domain=';
  251. domain='+ipb_var_cookie_domain}
  252. if(ipb_var_cookie_path!=""){
  253. path=ipb_var_cookie_path}
  254. document.cookie=ipb_var_cookieid+name+"="+value+";
  255. path="+path+expire+domain+';
  256. ';
  257. this.cookies[name]=value}
  258. ;
  259. this.array_stacksize=function(thearray){
  260. for(i=0;
  261. i<thearray.length;
  262. i++){
  263. if((thearray[i]=="")||(thearray[i]==null)||(thearray=='undefined')){
  264. return i}
  265. }
  266. return thearray.length}
  267. ;
  268. this.array_pushstack=function(thearray,newval){
  269. var arraysize=this.array_stacksize(thearray);
  270. thearray[arraysize]=newval}
  271. ;
  272. this.array_popstack=function(thearray){
  273. var arraysize=this.array_stacksize(thearray);
  274. var theval=thearray[arraysize-1];
  275. delete thearray[arraysize-1];
  276. return theval}
  277. }
Add Comment
Please, Sign In to add comment