PHP.SU

Программирование на PHP, MySQL и другие веб-технологии
PHP.SU Портал     На главную страницу форума Главная     Помощь Помощь     Поиск Поиск     Поиск Яндекс Поиск Яндекс     Вакансии  Пользователи Пользователи

Страниц (1): [1]

> Найдено сообщений: 7
AxqpxA Отправлено: 19 Июля, 2010 - 16:10:44 • Тема: Увеличение картинки • Форум: JavaScript & VBScript

Ответов: 2
Просмотров: 4027
Есть такой java script
CODE (javascript):
скопировать код в буфер обмена
  1.  
  2. function ImageExpander(oThumb, sImgSrc)
  3. {
  4.         this.oThumb = oThumb;
  5.         this.oThumb.expander = this;
  6.         this.oThumb.onclick = function() { this.expander.expand(); }
  7.        
  8.         this.smallWidth = oThumb.offsetWidth;
  9.         this.smallHeight = oThumb.offsetHeight;
  10.  
  11.         this.bExpand = true;
  12.         this.bTicks = false;
  13.        
  14.         if ( !window.aImageExpanders )
  15.         {
  16.                 window.aImageExpanders = new Array();
  17.         }
  18.         window.aImageExpanders.push(this);
  19.  
  20.         this.oImg = new Image();
  21.         this.oImg.expander = this;
  22.         this.oImg.onload = function(){this.expander.onload();}
  23.         this.oImg.src = sImgSrc;
  24. }
  25.  
  26. ImageExpander.prototype.onload = function()
  27. {
  28.         this.oDiv = document.createElement("div");
  29.         document.body.appendChild(this.oDiv);
  30.         this.oDiv.appendChild(this.oImg);
  31.         this.oDiv.style.position = "absolute";
  32.         this.oDiv.expander = this;
  33.         this.oDiv.onclick = function() {this.expander.toggle();};
  34.         this.oImg.title = "Click to reduce.";
  35.         this.bigWidth = this.oImg.width;
  36.         this.bigHeight = this.oImg.height;
  37.        
  38.         if ( this.bExpand )
  39.         {
  40.                 this.expand();
  41.         }
  42.         else
  43.         {
  44.                 this.oDiv.style.visibility = "hidden";
  45.                 this.oImg.style.visibility = "hidden";
  46.         }
  47. }
  48. ImageExpander.prototype.toggle = function()
  49. {
  50.         this.bExpand = !this.bExpand;
  51.         if ( this.bExpand )
  52.         {
  53.                 for ( var i in window.aImageExpanders )
  54.                         if ( window.aImageExpanders[i] !== this )
  55.                                 window.aImageExpanders[i].reduce();
  56.         }
  57. }
  58. ImageExpander.prototype.expand = function()
  59. {
  60.         this.bExpand = true;
  61.  
  62.         for ( var i in window.aImageExpanders )
  63.                 if ( window.aImageExpanders[i] !== this )
  64.                         window.aImageExpanders[i].reduce();
  65.  
  66.         if ( !this.oDiv ) return;
  67.        
  68.         this.oThumb.style.visibility = "hidden";
  69.        
  70.         this.x = this.oThumb.offsetLeft;
  71.         this.y = this.oThumb.offsetTop;
  72.         this.w = this.oThumb.clientWidth;
  73.         this.h = this.oThumb.clientHeight;
  74.        
  75.         this.oDiv.style.left = this.x + "px";
  76.         this.oDiv.style.top = this.y + "px";
  77.         this.oImg.style.width = this.w + "px";
  78.         this.oImg.style.height = this.h + "px";
  79.         this.oDiv.style.visibility = "visible";
  80.         this.oImg.style.visibility = "visible";
  81.        
  82.         if ( !this.bTicks )
  83.         {
  84.                 this.bTicks = true;
  85.                 var pThis = this;
  86.                 window.setTimeout(function(){pThis.tick();},1);        
  87.         }
  88. }
  89. ImageExpander.prototype.reduce = function()
  90. {
  91.  
  92.         this.bExpand = false;
  93. }
  94. ImageExpander.prototype.tick = function()
  95. {
  96.  
  97.         var cw = document.body.clientWidth;
  98.         var ch = document.body.clientHeight;
  99.         var cx = document.body.scrollLeft + cw / 2;
  100.         var cy = document.body.scrollTop + ch / 2;
  101.  
  102.  
  103.         var tw,th,tx,ty;
  104.         if ( this.bExpand )
  105.         {
  106.                 tw = this.bigWidth;
  107.                 th = this.bigHeight;
  108.                 if ( tw > cw )
  109.                 {
  110.                         th *= cw / tw;
  111.                         tw = cw;
  112.                 }      
  113.                 if ( th > ch )
  114.                 {
  115.                         tw *= ch / th;
  116.                         th = ch;
  117.                 }
  118.                 tx = cx - tw + 100;
  119.                 ty = cy - th + 100;
  120.         }
  121.         else
  122.         {
  123.                 tw = this.smallWidth;
  124.                 th = this.smallHeight;
  125.                 tx = this.oThumb.offsetLeft;
  126.                 ty = this.oThumb.offsetTop;
  127.         }      
  128.  
  129.                 var nHit = 0;
  130.         var fMove = function(n,tn)
  131.         {
  132.                 var dn = tn - n;
  133.                 if ( Math.abs(dn) < 3 )
  134.                 {
  135.                         nHit++;
  136.                         return tn;
  137.                 }
  138.                 else
  139.                 {
  140.                         return n + dn / 10;
  141.                 }
  142.         }
  143.         this.x = fMove(this.x, tx);
  144.         this.y = fMove(this.y, ty);
  145.         this.w = fMove(this.w, tw);
  146.         this.h = fMove(this.h, th);
  147.        
  148.         this.oDiv.style.left = this.x + "px";
  149.         this.oDiv.style.top = this.y + "px";
  150.         this.oImg.style.width = this.w + "px";
  151.         this.oImg.style.height = this.h + "px";
  152.  
  153.  
  154.         if ( !this.bExpand && (nHit == 4) )
  155.         {
  156.                 this.oImg.style.visibility = "hidden";
  157.                 this.oDiv.style.visibility = "hidden";
  158.                 this.oThumb.style.visibility = "visible";
  159.  
  160.                 this.bTicks = false;
  161.         }
  162.        
  163.         if ( this.bTicks )
  164.         {
  165.                 var pThis = this;
  166.                 window.setTimeout(function(){pThis.tick();},1);
  167.         }
  168. }
  169.  

Как сделать так, что бы картинка когда увеличивалась, была посередине экрана а не с боку?
---
Я с JS никоьгда не работал, так что для меня это дремучий лес, помогите пожалуйста!
AxqpxA Отправлено: 18 Июля, 2010 - 21:18:06 • Тема: Открытие страницы без обновления (Ajax + PHP) • Форум: Программирование на PHP

Ответов: 1
Просмотров: 279
Добрый вечер! собственно хочу сделать так, что-бы когда нажемаешь на ссылку, выводилась необходимая информация без обновления страницы...
Знаю что это возможно сделать с использованием Ajax, но с этим языком не разу не сталкивался!
Посмотрел в гугле, но ничего не понял! в принципе это не странно...
---
P.s думал где лучше создать тему, решил тут! если не подходящий раздел извините
AxqpxA Отправлено: 15 Июня, 2010 - 20:52:23 • Тема: Вопрос по ооп • Форум: Программирование на PHP

Ответов: 3
Просмотров: 298
Theme Closed
AxqpxA Отправлено: 10 Мая, 2010 - 19:56:49 • Тема: Проблема с курлом • Форум: Программирование на PHP

Ответов: 9
Просмотров: 775
Champion пишет:
m
(Добавление)
это для многострочного поиска

не катит

Цитата:

Notice: Undefined index: 1 in Z:\home\cms.ru\www\additional\translate\index.php on line 65



PHP:
скопировать код в буфер обмена
  1.  
  2. <?
  3. preg_match('/<div class=\"tres\">(.*?)<\/div>/m', $content, $trans_r);
  4. echo $trans_r['1'];
  5. ?>
  6.  
AxqpxA Отправлено: 10 Мая, 2010 - 18:04:51 • Тема: Проблема с курлом • Форум: Программирование на PHP

Ответов: 9
Просмотров: 775
Champion пишет:
На ASP сайт)
Добавь такую строчечку
curl_setopt($translate_r, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3');
Когда такие сайты парсить пытаешься, старайся, чтобы параметры curl запроса свопадали с теми, что шлются, когда ты просматриваешь страницу из браузера: и ueragent, и заголовки, и куки. И POST данные типа __EVENTVALIDATION и __VIEWSTATE.


Спасибо большое! все работает
(Добавление)
еще вопрос!
Есть такая регулярка
PHP:
скопировать код в буфер обмена
  1.  
  2. <?
  3. preg_match('/<div class=\"tres\">(.*?)<\/div>/siu', $parse, $content);
  4. ?>
  5.  

Вполне нормально работает, но если находит пробел, перенос и т.д то ничего не находит
AxqpxA Отправлено: 10 Мая, 2010 - 17:46:54 • Тема: Проблема с курлом • Форум: Программирование на PHP

Ответов: 9
Просмотров: 775
Добрый день!
У меня выходит такая проблема....

Когда я пытаюсь подключится к m.translate.ru у меня выдает "В экземпляре объекта не задана ссылка на объект."

собственно сам код
PHP:
скопировать код в буфер обмена
  1.  
  2. <?
  3. $translate_r = curl_init();
  4. curl_setopt($translate_r, CURLOPT_URL, "http://m.translate.ru/translator/result/?text=%D1%81%D0%BB%D0%BE%D0%B2%D0%BE&dirCode=re");
  5. curl_setopt($translate_r, CURLOPT_HEADER, 0);
  6. $translate_q = curl_exec($translate_r);
  7. curl_close($translate_r);  
  8. echo $translate_q;
  9. ?>
  10.  


на других сайтах все нормально
AxqpxA Отправлено: 04 Апреля, 2010 - 17:18:14 • Тема: Вывод страниц с промежутком • Форум: Напишите за меня, пожалуйста

Ответов: 3
Просмотров: 47
PHP:
скопировать код в буфер обмена
  1.  
  2. <?PHP
  3.  
  4. function pages_navig($start,$conf_navig,$total_comm,$link_page){
  5.  
  6. $ba = ceil($total_comm/$conf_navig);
  7. $ba2 = $ba*$conf_navig-$conf_navig;
  8. $asd = $start-($conf_navig*3);
  9. $asd2 = $start+($conf_navig*4);
  10.  
  11. if ($asd < $total_comm && $asd > 0)
  12. {
  13. echo ' <a href="'.$link.'/0"><span>1</span></a> <span>...</span>';
  14. }
  15.  
  16. for ($i = $asd; $i < $asd2;)
  17. {
  18. if ($i < $total_comm && $i >= 0)
  19. {
  20. $ii = floor(1+$i / $conf_navig);
  21. if ($start == $i)
  22. {
  23. echo ' <span><b>'.$ii.'</b></span>';
  24. }
  25. else
  26. {
  27. echo ' <a href="'.$link.'/'.$i.'"><span>'.$ii.'</span></a>';
  28. }
  29. }
  30. $i = $i+$conf_navig;
  31. }
  32. if($asd2 < $total_comm)
  33. {
  34. echo ' <span>...</span> <a href="'.$link.'/'.$ba2.'"><span>'.$ba.'</span></a>';
  35. }
  36. }
  37.  
  38. ?>
  39.  


$start - Текущая страница
$conf_navig - Колличество выводимых коментов на страницу
$total_comm - Всего коментов
$link_page - Страница

Страниц (1): [1]
Powered by PHP  Powered By MySQL  Powered by Nginx  Valid CSS  RSS

 
Powered by ExBB FM 1.0 RC1. InvisionExBB