Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (function($) {
- $( document ).ready( function() {
- var scrs = [
- [0 , 620 , 'dm1.ru'] ,
- [621 , 1024, 'dm2.ru'] ,
- [1025, 2048, 'dm3.ru'] ,
- [2049, -1, 'dm4.ru']
- ];
- function redirect( nw , rp ) {
- if ( rp ) window.location.replace( nw );
- else window.location.href( nw );
- }
- function replace_domen( new_domen , protocol ) {
- if ( !protocol )
- protocol = window.location.protocol;
- var hostname = window.location.hostname;
- var link = window.location.href;
- var dpos = link.indexOf( hostname );
- if ( ( dpos == -1 ) || ( !hostname.length ) )
- return protocol + '//' + new_domen;
- return protocol + '//' + new_domen + link.substr( dpos + hostname.length );
- }
- function try_width( scrs , params ) {
- if ( !params ) params = {};
- if (params.hide_history===undefined) params.hide_history = true;
- var w = $( document ).width();
- for( var i in scrs ) {
- var item = scrs[i];
- if ( ( (item[0]==-1) || (w >= item[0]) ) &&
- ( (item[1]==-1) || (w <= item[1]) ) ) {
- redirect(
- replace_domen( item[2] , params.protocol ) ,
- params.hide_history
- );
- return true;
- }
- }
- return false;
- }
- try_width( scrs );
- } );
- })( jQuery );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement