code
stringlengths 1
2.08M
| language
stringclasses 1
value |
|---|---|
/* http://keith-wood.name/datepick.html
Simplified Chinese localisation for jQuery Datepicker.
Written by Cloudream (cloudream@gmail.com). */
(function($) {
$.datepick.regional['zh-CN'] = {
monthNames: ['一月','二月','三月','四月','五月','六月',
'七月','八月','九月','十月','十一月','十二月'],
monthNamesShort: ['一','二','三','四','五','六',
'七','八','九','十','十一','十二'],
dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
dayNamesMin: ['日','一','二','三','四','五','六'],
dateFormat: 'yyyy-mm-dd', firstDay: 1,
renderer: $.extend({}, $.datepick.defaultRenderer,
{month: $.datepick.defaultRenderer.month.
replace(/monthHeader/, 'monthHeader:MM yyyy年')}),
prevText: '<上月', prevStatus: '显示上月',
prevJumpText: '<<', prevJumpStatus: '显示上一年',
nextText: '下月>', nextStatus: '显示下月',
nextJumpText: '>>', nextJumpStatus: '显示下一年',
currentText: '今天', currentStatus: '显示本月',
todayText: '今天', todayStatus: '显示本月',
clearText: '清除', clearStatus: '清除已选日期',
closeText: '关闭', closeStatus: '不改变当前选择',
yearStatus: '选择年份', monthStatus: '选择月份',
weekText: '周', weekStatus: '年内周次',
dayStatus: '选择 m月 d日, DD', defaultStatus: '请选择日期',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['zh-CN']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Datepicker Validation extension for jQuery 4.0.3.
Requires Jörn Zaefferer's Validation plugin (http://plugins.jquery.com/project/validate).
Written by Keith Wood (kbwood{at}iinet.com.au).
Dual licensed under the GPL (http://dev.jquery.com/browser/trunk/jquery/GPL-LICENSE.txt) and
MIT (http://dev.jquery.com/browser/trunk/jquery/MIT-LICENSE.txt) licenses.
Please attribute the author if you use it. */
(function($) { // Hide the namespace
/* Add validation methods if validation plugin available. */
if ($.fn.validate) {
$.datepick.selectDateOrig = $.datepick.selectDate;
$.extend($.datepick.regional[''], {
validateDate: 'Please enter a valid date',
validateDateMin: 'Please enter a date on or after {0}',
validateDateMax: 'Please enter a date on or before {0}',
validateDateMinMax: 'Please enter a date between {0} and {1}'
});
$.extend($.datepick._defaults, $.datepick.regional['']);
$.extend($.datepick, {
/* Trigger a validation after updating the input field with the selected date.
@param target (element) the control to examine
@param elem (element) the selected datepicker element */
selectDate: function(target, elem) {
this.selectDateOrig(target, elem);
var inst = $.data(target, $.datepick.dataName);
if (!inst.inline && $.fn.validate) {
var validation = $(target).parents('form').validate();
if (validation) {
validation.element('#' + target.id);
}
}
},
/* Correct error placement for validation errors - after any trigger.
@param error (jQuery) the error message
@param element (jQuery) the field in error */
errorPlacement: function(error, element) {
var inst = $.data(element[0], $.datepick.dataName);
if (inst) {
error[inst.get('isRTL') ? 'insertBefore' : 'insertAfter'](
inst.trigger.length > 0 ? inst.trigger : element);
}
else {
error.insertAfter(element);
}
},
/* Format a validation error message involving dates.
@param source (string) the error message
@param params (Date[]) the dates
@return (string) the formatted message */
errorFormat: function(source, params) {
var format = ($.datepick.curInst ?
$.datepick.curInst.get('dateFormat') :
$.datepick._defaults.dateFormat);
$.each(params, function(index, value) {
source = source.replace(new RegExp('\\{' + index + '\\}', 'g'),
$.datepick.formatDate(format, value) || 'nothing');
});
return source;
}
});
/* Apply a validation test to each date provided.
@param value (string) the current field value
@param element (element) the field control
@return (boolean) true if OK, false if failed validation */
function validateEach(value, element) {
var inst = $.data(element, $.datepick.dataName);
var rangeSelect = inst.get('rangeSelect');
var multiSelect = inst.get('multiSelect');
var dates = (multiSelect ? value.split(inst.get('multiSeparator')) :
(rangeSelect ? value.split(inst.get('rangeSeparator')) : [value]));
var ok = (multiSelect && dates.length <= multiSelect) ||
(!multiSelect && rangeSelect && dates.length == 2) ||
(!multiSelect && !rangeSelect && dates.length == 1);
if (ok) {
try {
var dateFormat = inst.get('dateFormat');
var dp = $(element);
$.each(dates, function(i, v) {
dates[i] = $.datepick.parseDate(dateFormat, v);
ok = ok && (!dates[i] || dp.datepick('isSelectable', dates[i]));
});
}
catch (e) {
ok = false;
}
}
if (ok && rangeSelect) {
ok = (dates[0].getTime() <= dates[1].getTime());
}
return ok;
}
/* Validate basic date format. */
$.validator.addMethod('dpDate', function(value, element) {
return this.optional(element) || validateEach(value, element);
}, function(params) {
return $.datepick._defaults.validateDate;
});
/* Validate format and against a minimum date. */
$.validator.addMethod('dpMinDate', function(value, element, params) {
var inst = $.data(element, $.datepick.dataName);
params[0] = inst.get('minDate');
return this.optional(element) || validateEach(value, element);
}, function(params) {
return $.datepick.errorFormat($.datepick._defaults.validateDateMin, params);
});
/* Validate format and against a maximum date. */
$.validator.addMethod('dpMaxDate', function(value, element, params) {
var inst = $.data(element, $.datepick.dataName);
params[0] = inst.get('maxDate');
return this.optional(element) || validateEach(value, element);
}, function(params) {
return $.datepick.errorFormat($.datepick._defaults.validateDateMax, params);
});
/* Validate format and against minimum/maximum dates. */
$.validator.addMethod('dpMinMaxDate', function(value, element, params) {
var inst = $.data(element, $.datepick.dataName);
params[0] = inst.get('minDate');
params[1] = inst.get('maxDate');
return this.optional(element) || validateEach(value, element);
}, function(params) {
return $.datepick.errorFormat($.datepick._defaults.validateDateMinMax, params);
});
}
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Gujarati (ગુજરાતી) localisation for jQuery Datepicker.
Naymesh Mistry (naymesh@yahoo.com). */
(function($) {
$.datepick.regional['gu'] = {
monthNames: ['જાન્યુઆરી','ફેબ્રુઆરી','માર્ચ','એપ્રિલ','મે','જૂન',
'જુલાઈ','ઑગસ્ટ','સપ્ટેમ્બર','ઑક્ટોબર','નવેમ્બર','ડિસેમ્બર'],
monthNamesShort: ['જાન્યુ','ફેબ્રુ','માર્ચ','એપ્રિલ','મે','જૂન',
'જુલાઈ','ઑગસ્ટ','સપ્ટે','ઑક્ટો','નવે','ડિસે'],
dayNames: ['રવિવાર','સોમવાર','મંગળવાર','બુધવાર','ગુરુવાર','શુક્રવાર','શનિવાર'],
dayNamesShort: ['રવિ','સોમ','મંગળ','બુધ','ગુરુ','શુક્ર','શનિ'],
dayNamesMin: ['ર','સો','મં','બુ','ગુ','શુ','શ'],
dateFormat: 'dd-M-yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<પાછળ', prevStatus: 'પાછલો મહિનો બતાવો',
prevJumpText: '<<', prevJumpStatus: 'પાછળ',
nextText: 'આગળ>', nextStatus: 'આગલો મહિનો બતાવો',
nextJumpText: '>>', nextJumpStatus: 'આગળ',
currentText: 'આજે', currentStatus: 'આજનો દિવસ બતાવો',
todayText: 'આજે', todayStatus: 'આજનો દિવસ',
clearText: 'ભૂંસો', clearStatus: 'હાલ પસંદ કરેલી તારીખ ભૂંસો',
closeText: 'બંધ કરો', closeStatus: 'તારીખ પસંદ કર્યા વગર બંધ કરો',
yearStatus: 'જુદુ વર્ષ બતાવો', monthStatus: 'જુદો મહિનો બતાવો',
weekText: 'અઠવાડિયું', weekStatus: 'અઠવાડિયું',
dayStatus: 'અઠવાડિયાનો પહેલો દિવસ પસંદ કરો', defaultStatus: 'તારીખ પસંદ કરો',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['gu']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Korean localisation for jQuery Datepicker.
Written by DaeKwon Kang (ncrash.dk@gmail.com). */
(function($) {
$.datepick.regional['ko'] = {
monthNames: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)',
'7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'],
monthNamesShort: ['1월(JAN)','2월(FEB)','3월(MAR)','4월(APR)','5월(MAY)','6월(JUN)',
'7월(JUL)','8월(AUG)','9월(SEP)','10월(OCT)','11월(NOV)','12월(DEC)'],
dayNames: ['일','월','화','수','목','금','토'],
dayNamesShort: ['일','월','화','수','목','금','토'],
dayNamesMin: ['일','월','화','수','목','금','토'],
dateFormat: 'yyyy-mm-dd', firstDay: 0,
renderer: $.extend({}, $.datepick.defaultRenderer,
{month: $.datepick.defaultRenderer.month.
replace(/monthHeader/, 'monthHeader:MM yyyy년')}),
prevText: '이전달', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: '다음달', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: '오늘', currentStatus: '',
todayText: '오늘', todayStatus: '',
clearText: '지우기', clearStatus: '',
closeText: '닫기', closeStatus: '',
yearStatus: '', monthStatus: '',
weekText: 'Wk', weekStatus: '',
dayStatus: 'D, M d', defaultStatus: '',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['ko']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Serbian localisation for jQuery Datepicker.
Written by Dejan Dimić. */
(function($) {
$.datepick.regional['sr'] = {
monthNames: ['Јануар','Фебруар','Март','Април','Мај','Јун',
'Јул','Август','Септембар','Октобар','Новембар','Децембар'],
monthNamesShort: ['Јан','Феб','Мар','Апр','Мај','Јун',
'Јул','Авг','Сеп','Окт','Нов','Дец'],
dayNames: ['Недеља','Понедељак','Уторак','Среда','Четвртак','Петак','Субота'],
dayNamesShort: ['Нед','Пон','Уто','Сре','Чет','Пет','Суб'],
dayNamesMin: ['Не','По','Ут','Ср','Че','Пе','Су'],
dateFormat: 'dd/mm/yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<', prevStatus: 'Прикажи претходни месец',
prevJumpText: '<<', prevJumpStatus: 'Прикажи претходну годину',
nextText: '>', nextStatus: 'Прикажи следећи месец',
nextJumpText: '>>', nextJumpStatus: 'Прикажи следећу годину',
currentText: 'Данас', currentStatus: 'Текући месец',
todayText: 'Данас', todayStatus: 'Текући месец',
clearText: 'Обриши', clearStatus: 'Обриши тренутни датум',
closeText: 'Затвори', closeStatus: 'Затвори календар',
yearStatus: 'Прикажи године', monthStatus: 'Прикажи месеце',
weekText: 'Сед', weekStatus: 'Седмица',
dayStatus: '\'Датум\' DD d MM', defaultStatus: 'Одабери датум',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['sr']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Dutch localisation for jQuery Datepicker.
Written by Mathias Bynens <http://mathiasbynens.be/> */
(function($) {
$.datepick.regional['nl'] = {
monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun',
'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
dateFormat: 'dd-mm-yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '←', prevStatus: 'Bekijk de vorige maand',
prevJumpText: '«', nextJumpStatus: 'Bekijk het vorige jaar',
nextText: '→', nextStatus: 'Bekijk de volgende maand',
nextJumpText: '»', nextJumpStatus: 'Bekijk het volgende jaar',
currentText: 'Vandaag', currentStatus: 'Bekijk de huidige maand',
todayText: 'Vandaag', todayStatus: 'Bekijk de huidige maand',
clearText: 'Wissen', clearStatus: 'Wis de huidige datum',
closeText: 'Sluiten', closeStatus: 'Sluit zonder verandering',
yearStatus: 'Bekijk een ander jaar', monthStatus: 'Bekijk een andere maand',
weekText: 'Wk', weekStatus: 'Week van het jaar',
dayStatus: 'dd-mm-yyyy', defaultStatus: 'Kies een datum',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['nl']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Afrikaans localisation for jQuery Datepicker.
Written by Renier Pretorius. */
(function($) {
$.datepick.regional['af'] = {
monthNames: ['Januarie','Februarie','Maart','April','Mei','Junie',
'Julie','Augustus','September','Oktober','November','Desember'],
monthNamesShort: ['Jan', 'Feb', 'Mrt', 'Apr', 'Mei', 'Jun',
'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'],
dayNames: ['Sondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrydag', 'Saterdag'],
dayNamesShort: ['Son', 'Maa', 'Din', 'Woe', 'Don', 'Vry', 'Sat'],
dayNamesMin: ['So','Ma','Di','Wo','Do','Vr','Sa'],
dateFormat: 'dd/mm/yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: 'Vorige', prevStatus: 'Vertoon vorige maand',
prevJumpText: '<<', prevJumpStatus: 'Vertoon vorige jaar',
nextText: 'Volgende', nextStatus: 'Vertoon volgende maand',
nextJumpText: '>>', nextJumpStatus: 'Vertoon volgende jaar',
currentText: 'Vandag', currentStatus: 'Vertoon huidige maand',
todayText: 'Vandag', todayStatus: 'Vertoon huidige maand',
clearText: 'Kanselleer', clearStatus: 'Korigeer die huidige datum',
closeText: 'Selekteer', closeStatus: 'Sluit sonder verandering',
yearStatus: 'Vertoon n ander jaar', monthStatus: 'Vertoon n ander maand',
weekText: 'Wk', weekStatus: 'Week van die jaar',
dayStatus: 'Kies DD, M d', defaultStatus: 'Kies n datum',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['af']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Swiss French localisation for jQuery Datepicker.
Written by Martin Voelkle (martin.voelkle@e-tc.ch). */
(function($) {
$.datepick.regional['fr-CH'] = {
monthNames: ['Janvier','Février','Mars','Avril','Mai','Juin',
'Juillet','Août','Septembre','Octobre','Novembre','Décembre'],
monthNamesShort: ['Jan','Fév','Mar','Avr','Mai','Jun',
'Jul','Aoû','Sep','Oct','Nov','Déc'],
dayNames: ['Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'],
dayNamesShort: ['Dim','Lun','Mar','Mer','Jeu','Ven','Sam'],
dayNamesMin: ['Di','Lu','Ma','Me','Je','Ve','Sa'],
dateFormat: 'dd.mm.yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<Préc', prevStatus: 'Voir le mois précédent',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Suiv>', nextStatus: 'Voir le mois suivant',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'Courant', currentStatus: 'Voir le mois courant',
todayText: 'Aujourd\'hui', todayStatus: 'Voir aujourd\'hui',
clearText: 'Effacer', clearStatus: 'Effacer la date sélectionnée',
closeText: 'Fermer', closeStatus: 'Fermer sans modifier',
yearStatus: 'Voir une autre année', monthStatus: 'Voir un autre mois',
weekText: 'Sm', weekStatus: '',
dayStatus: '\'Choisir\' le DD d MM', defaultStatus: 'Choisir la date',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['fr-CH']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Traditional Chinese localisation for jQuery Datepicker.
Written by Ressol (ressol@gmail.com). */
(function($) {
$.datepick.regional['zh-TW'] = {
monthNames: ['一月','二月','三月','四月','五月','六月',
'七月','八月','九月','十月','十一月','十二月'],
monthNamesShort: ['一','二','三','四','五','六',
'七','八','九','十','十一','十二'],
dayNames: ['星期日','星期一','星期二','星期三','星期四','星期五','星期六'],
dayNamesShort: ['周日','周一','周二','周三','周四','周五','周六'],
dayNamesMin: ['日','一','二','三','四','五','六'],
dateFormat: 'yyyy/mm/dd', firstDay: 1,
renderer: $.extend({}, $.datepick.defaultRenderer,
{month: $.datepick.defaultRenderer.month.
replace(/monthHeader/, 'monthHeader:MM yyyy年')}),
prevText: '<上月', prevStatus: '顯示上月',
prevJumpText: '<<', prevJumpStatus: '顯示上一年',
nextText: '下月>', nextStatus: '顯示下月',
nextJumpText: '>>', nextJumpStatus: '顯示下一年',
currentText: '今天', currentStatus: '顯示本月',
todayText: '今天', todayStatus: '顯示本月',
clearText: '清除', clearStatus: '清除已選日期',
closeText: '關閉', closeStatus: '不改變目前的選擇',
yearStatus: '選擇年份', monthStatus: '選擇月份',
weekText: '周', weekStatus: '年內周次',
dayStatus: '選擇 m月 d日, DD', defaultStatus: '請選擇日期',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['zh-TW']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Indonesian localisation for jQuery Datepicker.
Written by Deden Fathurahman (dedenf@gmail.com). */
(function($) {
$.datepick.regional['id'] = {
monthNames: ['Januari','Februari','Maret','April','Mei','Juni',
'Juli','Agustus','September','Oktober','Nopember','Desember'],
monthNamesShort: ['Jan','Feb','Mar','Apr','Mei','Jun',
'Jul','Agus','Sep','Okt','Nop','Des'],
dayNames: ['Minggu','Senin','Selasa','Rabu','Kamis','Jumat','Sabtu'],
dayNamesShort: ['Min','Sen','Sel','Rab','kam','Jum','Sab'],
dayNamesMin: ['Mg','Sn','Sl','Rb','Km','jm','Sb'],
dateFormat: 'dd/mm/yyyy', firstDay: 0,
renderer: $.datepick.defaultRenderer,
prevText: '<mundur', prevStatus: 'Tampilkan bulan sebelumnya',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'maju>', nextStatus: 'Tampilkan bulan berikutnya',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'hari ini', currentStatus: 'Tampilkan bulan sekarang',
todayText: 'hari ini', todayStatus: 'Tampilkan bulan sekarang',
clearText: 'kosongkan', clearStatus: 'bersihkan tanggal yang sekarang',
closeText: 'Tutup', closeStatus: 'Tutup tanpa mengubah',
yearStatus: 'Tampilkan tahun yang berbeda', monthStatus: 'Tampilkan bulan yang berbeda',
weekText: 'Mg', weekStatus: 'Minggu dalam tahun',
dayStatus: 'pilih le DD, MM d', defaultStatus: 'Pilih Tanggal',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['id']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Bosnian localisation for jQuery Datepicker.
Written by Kenan Konjo. */
(function($) {
$.datepick.regional['bs'] = {
monthNames: ['Januar','Februar','Mart','April','Maj','Juni',
'Juli','August','Septembar','Oktobar','Novembar','Decembar'],
monthNamesShort: ['Jan','Feb','Mar','Apr','Maj','Jun',
'Jul','Aug','Sep','Okt','Nov','Dec'],
dayNames: ['Nedelja','Ponedeljak','Utorak','Srijeda','Četvrtak','Petak','Subota'],
dayNamesShort: ['Ned','Pon','Uto','Sri','Čet','Pet','Sub'],
dayNamesMin: ['Ne','Po','Ut','Sr','Če','Pe','Su'],
dateFormat: 'dd.mm.yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: '>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'Danas', currentStatus: '',
todayText: 'Danas', todayStatus: '',
clearText: 'X', clearStatus: '',
closeText: 'Zatvori', closeStatus: '',
yearStatus: '', monthStatus: '',
weekText: 'Wk', weekStatus: '',
dayStatus: 'DD d MM', defaultStatus: '',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['bs']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Urdu localisation for jQuery Datepicker.
Mansoor Munib -- mansoormunib@gmail.com <http://www.mansoor.co.nr/mansoor.html>
Thanks to Habib Ahmed, ObaidUllah Anwar. */
(function($) {
$.datepick.regional['ur'] = {
monthNames: ['جنوری','فروری','مارچ','اپریل','مئی','جون',
'جولائی','اگست','ستمبر','اکتوبر','نومبر','دسمبر'],
monthNamesShort: ['1','2','3','4','5','6',
'7','8','9','10','11','12'],
dayNames: ['اتوار','پير','منگل','بدھ','جمعرات','جمعہ','ہفتہ'],
dayNamesShort: ['اتوار','پير','منگل','بدھ','جمعرات','جمعہ','ہفتہ'],
dayNamesMin: ['اتوار','پير','منگل','بدھ','جمعرات','جمعہ','ہفتہ'],
dateFormat: 'dd/mm/yyyy', firstDay: 0,
renderer: $.datepick.defaultRenderer,
prevText: '<گذشتہ', prevStatus: 'ماه گذشتہ',
prevJumpText: '<<', prevJumpStatus: 'برس گذشتہ',
nextText: 'آئندہ>', nextStatus: 'ماه آئندہ',
nextJumpText: '>>', nextJumpStatus: 'برس آئندہ',
currentText: 'رواں', currentStatus: 'ماه رواں',
todayText: 'آج', todayStatus: 'آج',
clearText: 'حذف تاريخ', clearStatus: 'کریں حذف تاریخ',
closeText: 'کریں بند', closeStatus: 'کیلئے کرنے بند',
yearStatus: 'برس تبدیلی', monthStatus: 'ماه تبدیلی',
weekText: 'ہفتہ', weekStatus: 'ہفتہ',
dayStatus: 'انتخاب D, M d', defaultStatus: 'کریں منتخب تاريخ',
isRTL: true
};
$.datepick.setDefaults($.datepick.regional['ur']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Ukrainian localisation for jQuery Datepicker.
Written by Maxim Drogobitskiy (maxdao@gmail.com). */
(function($) {
$.datepick.regional['uk'] = {
monthNames: ['Січень','Лютий','Березень','Квітень','Травень','Червень',
'Липень','Серпень','Вересень','Жовтень','Листопад','Грудень'],
monthNamesShort: ['Січ','Лют','Бер','Кві','Тра','Чер',
'Лип','Сер','Вер','Жов','Лис','Гру'],
dayNames: ['неділя','понеділок','вівторок','середа','четвер','п\'ятниця','субота'],
dayNamesShort: ['нед','пнд','вів','срд','чтв','птн','сбт'],
dayNamesMin: ['Нд','Пн','Вт','Ср','Чт','Пт','Сб'],
dateFormat: 'dd/mm/yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: '>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'Сьогодні', currentStatus: '',
todayText: 'Сьогодні', todayStatus: '',
clearText: 'Очистити', clearStatus: '',
closeText: 'Закрити', closeStatus: '',
yearStatus: '', monthStatus: '',
weekText: 'Не', weekStatus: '',
dayStatus: 'D, M d', defaultStatus: '',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['uk']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Catalan localisation for jQuery Datepicker.
Writers: (joan.leon@gmail.com). */
(function($) {
$.datepick.regional['ca'] = {
monthNames: ['Gener','Febrer','Març','Abril','Maig','Juny',
'Juliol','Agost','Setembre','Octubre','Novembre','Desembre'],
monthNamesShort: ['Gen','Feb','Mar','Abr','Mai','Jun',
'Jul','Ago','Set','Oct','Nov','Des'],
dayNames: ['Diumenge','Dilluns','Dimarts','Dimecres','Dijous','Divendres','Dissabte'],
dayNamesShort: ['Dug','Dln','Dmt','Dmc','Djs','Dvn','Dsb'],
dayNamesMin: ['Dg','Dl','Dt','Dc','Dj','Dv','Ds'],
dateFormat: 'dd/mm/yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<Ant', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Seg>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'Avui', currentStatus: '',
todayText: 'Avui', todayStatus: '',
clearText: 'Netejar', clearStatus: '',
closeText: 'Tancar', closeStatus: '',
yearStatus: '', monthStatus: '',
weekText: 'Sm', weekStatus: '',
dayStatus: 'D, M d', defaultStatus: '',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['ca']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Polish localisation for jQuery Datepicker.
Written by Jacek Wysocki (jacek.wysocki@gmail.com). */
(function($) {
$.datepick.regional['pl'] = {
monthNames: ['Styczeń','Luty','Marzec','Kwiecień','Maj','Czerwiec',
'Lipiec','Sierpień','Wrzesień','Październik','Listopad','Grudzień'],
monthNamesShort: ['Sty','Lu','Mar','Kw','Maj','Cze',
'Lip','Sie','Wrz','Pa','Lis','Gru'],
dayNames: ['Niedziela','Poniedzialek','Wtorek','Środa','Czwartek','Piątek','Sobota'],
dayNamesShort: ['Nie','Pn','Wt','Śr','Czw','Pt','So'],
dayNamesMin: ['N','Pn','Wt','Śr','Cz','Pt','So'],
dateFormat: 'yyyy-mm-dd', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<Poprzedni', prevStatus: 'Pokaż poprzedni miesiąc',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Następny>', nextStatus: 'Pokaż następny miesiąc',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'Dziś', currentStatus: 'Pokaż aktualny miesiąc',
todayText: 'Dziś', todayStatus: 'Pokaż aktualny miesiąc',
clearText: 'Wyczyść', clearStatus: 'Wyczyść obecną datę',
closeText: 'Zamknij', closeStatus: 'Zamknij bez zapisywania',
yearStatus: 'Pokaż inny rok', monthStatus: 'Pokaż inny miesiąc',
weekText: 'Tydz', weekStatus: 'Tydzień roku',
dayStatus: '\'Wybierz\' D, M d', defaultStatus: 'Wybierz datę',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['pl']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Japanese localisation for jQuery Datepicker.
Written by Kentaro SATO (kentaro@ranvis.com). */
(function($) {
$.datepick.regional['ja'] = {
monthNames: ['1月','2月','3月','4月','5月','6月',
'7月','8月','9月','10月','11月','12月'],
monthNamesShort: ['1月','2月','3月','4月','5月','6月',
'7月','8月','9月','10月','11月','12月'],
dayNames: ['日曜日','月曜日','火曜日','水曜日','木曜日','金曜日','土曜日'],
dayNamesShort: ['日','月','火','水','木','金','土'],
dayNamesMin: ['日','月','火','水','木','金','土'],
dateFormat: 'yyyy/mm/dd', firstDay: 0,
renderer: $.extend({}, $.datepick.defaultRenderer,
{month: $.datepick.defaultRenderer.month.
replace(/monthHeader/, 'monthHeader:yyyy年 MM')}),
prevText: '<前', prevStatus: '前月を表示します',
prevJumpText: '<<', prevJumpStatus: '前年を表示します',
nextText: '次>', nextStatus: '翌月を表示します',
nextJumpText: '>>', nextJumpStatus: '翌年を表示します',
currentText: '今日', currentStatus: '今月を表示します',
todayText: '今日', todayStatus: '今月を表示します',
clearText: 'クリア', clearStatus: '日付をクリアします',
closeText: '閉じる', closeStatus: '変更せずに閉じます',
yearStatus: '表示する年を変更します', monthStatus: '表示する月を変更します',
weekText: '週', weekStatus: '暦週で第何週目かを表します',
dayStatus: 'Md日(D)', defaultStatus: '日付を選択します',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['ja']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Galician localisation for jQuery Datepicker.
Traducido por Manuel (McNuel@gmx.net). */
(function($) {
$.datepick.regional['gl'] = {
monthNames: ['Xaneiro','Febreiro','Marzo','Abril','Maio','Xuño',
'Xullo','Agosto','Setembro','Outubro','Novembro','Decembro'],
monthNamesShort: ['Xan','Feb','Mar','Abr','Mai','Xuñ',
'Xul','Ago','Set','Out','Nov','Dec'],
dayNames: ['Domingo','Luns','Martes','Mércores','Xoves','Venres','Sábado'],
dayNamesShort: ['Dom','Lun','Mar','Mér','Xov','Ven','Sáb'],
dayNamesMin: ['Do','Lu','Ma','Me','Xo','Ve','Sá'],
dateFormat: 'dd/mm/yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<Ant', prevStatus: 'Amosar mes anterior',
prevJumpText: '<<', prevJumpStatus: 'Amosar ano anterior',
nextText: 'Seg>', nextStatus: 'Amosar mes seguinte',
nextJumpText: '>>', nextJumpStatus: 'Amosar ano seguinte',
currentText: 'Hoxe', currentStatus: 'Amosar mes actual',
todayText: 'Hoxe', todayStatus: 'Amosar mes actual',
clearText: 'Limpar', clearStatus: 'Borrar data actual',
closeText: 'Pechar', closeStatus: 'Pechar sen gardar',
yearStatus: 'Amosar outro ano', monthStatus: 'Amosar outro mes',
weekText: 'Sm', weekStatus: 'Semana do ano',
dayStatus: 'D, M d', defaultStatus: 'Selecciona Data',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['gl']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Bulgarian localisation for jQuery Datepicker.
Written by Stoyan Kyosev (http://svest.org). */
(function($) {
$.datepick.regional['bg'] = {
monthNames: ['Януари','Февруари','Март','Април','Май','Юни',
'Юли','Август','Септември','Октомври','Ноември','Декември'],
monthNamesShort: ['Яну','Фев','Мар','Апр','Май','Юни',
'Юли','Авг','Сеп','Окт','Нов','Дек'],
dayNames: ['Неделя','Понеделник','Вторник','Сряда','Четвъртък','Петък','Събота'],
dayNamesShort: ['Нед','Пон','Вто','Сря','Чет','Пет','Съб'],
dayNamesMin: ['Не','По','Вт','Ср','Че','Пе','Съ'],
dateFormat: 'dd.mm.yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<назад', prevStatus: 'покажи последния месец',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'напред>', nextStatus: 'покажи следващия месец',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'днес', currentStatus: '',
todayText: 'днес', todayStatus: '',
clearText: 'изчисти', clearStatus: 'изчисти актуалната дата',
closeText: 'затвори', closeStatus: 'затвори без промени',
yearStatus: 'покажи друга година', monthStatus: 'покажи друг месец',
weekText: 'Wk', weekStatus: 'седмица от месеца',
dayStatus: 'Избери D, M d', defaultStatus: 'Избери дата',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['bg']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Malaysian localisation for jQuery Datepicker.
Written by Mohd Nawawi Mohamad Jamili (nawawi@ronggeng.net). */
(function($) {
$.datepick.regional['ms'] = {
monthNames: ['Januari','Februari','Mac','April','Mei','Jun',
'Julai','Ogos','September','Oktober','November','Disember'],
monthNamesShort: ['Jan','Feb','Mac','Apr','Mei','Jun',
'Jul','Ogo','Sep','Okt','Nov','Dis'],
dayNames: ['Ahad','Isnin','Selasa','Rabu','Khamis','Jumaat','Sabtu'],
dayNamesShort: ['Aha','Isn','Sel','Rab','Kha','Jum','Sab'],
dayNamesMin: ['Ah','Is','Se','Ra','Kh','Ju','Sa'],
dateFormat: 'dd/mm/yyyy', firstDay: 0,
renderer: $.datepick.defaultRenderer,
prevText: '<Sebelum', prevStatus: 'Tunjukkan bulan lepas',
prevJumpText: '<<', prevJumpStatus: 'Tunjukkan tahun lepas',
nextText: 'Selepas>', nextStatus: 'Tunjukkan bulan depan',
nextJumpText: '>>', nextJumpStatus: 'Tunjukkan tahun depan',
currentText: 'hari ini', currentStatus: 'Tunjukkan bulan terkini',
todayText: 'hari ini', todayStatus: 'Tunjukkan bulan terkini',
clearText: 'Padam', clearStatus: 'Padamkan tarikh terkini',
closeText: 'Tutup', closeStatus: 'Tutup tanpa perubahan',
yearStatus: 'Tunjukkan tahun yang lain', monthStatus: 'Tunjukkan bulan yang lain',
weekText: 'Mg', weekStatus: 'Minggu bagi tahun ini',
dayStatus: 'DD, d MM', defaultStatus: 'Sila pilih tarikh',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['ms']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Dutch/Belgium localisation for jQuery Datepicker.
Written by Mathias Bynens <http://mathiasbynens.be/> */
(function($) {
$.datepick.regional['nl-BE'] = {
monthNames: ['januari', 'februari', 'maart', 'april', 'mei', 'juni',
'juli', 'augustus', 'september', 'oktober', 'november', 'december'],
monthNamesShort: ['jan', 'feb', 'maa', 'apr', 'mei', 'jun',
'jul', 'aug', 'sep', 'okt', 'nov', 'dec'],
dayNames: ['zondag', 'maandag', 'dinsdag', 'woensdag', 'donderdag', 'vrijdag', 'zaterdag'],
dayNamesShort: ['zon', 'maa', 'din', 'woe', 'don', 'vri', 'zat'],
dayNamesMin: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
dateFormat: 'dd/mm/yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '←', prevStatus: 'Bekijk de vorige maand',
prevJumpText: '«', nextJumpStatus: 'Bekijk het vorige jaar',
nextText: '→', nextStatus: 'Bekijk de volgende maand',
nextJumpText: '»', nextJumpStatus: 'Bekijk het volgende jaar',
currentText: 'Vandaag', currentStatus: 'Bekijk de huidige maand',
todayText: 'Vandaag', todayStatus: 'Bekijk de huidige maand',
clearText: 'Wissen', clearStatus: 'Wis de huidige datum',
closeText: 'Sluiten', closeStatus: 'Sluit zonder verandering',
yearStatus: 'Bekijk een ander jaar', monthStatus: 'Bekijk een andere maand',
weekText: 'Wk', weekStatus: 'Week van het jaar',
dayStatus: 'dd/mm/yyyy', defaultStatus: 'Kies een datum',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['nl-BE']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Thai localisation for jQuery Datepicker.
Written by pipo (pipo@sixhead.com). */
(function($) {
$.datepick.regional['th'] = {
monthNames: ['มกราคม','กุมภาพันธ์','มีนาคม','เมษายน','พฤษภาคม','มิถุนายน',
'กรกฎาคม','สิงหาคม','กันยายน','ตุลาคม','พฤศจิกายน','ธันวาคม'],
monthNamesShort: ['ม.ค.','ก.พ.','มี.ค.','เม.ย.','พ.ค.','มิ.ย.',
'ก.ค.','ส.ค.','ก.ย.','ต.ค.','พ.ย.','ธ.ค.'],
dayNames: ['อาทิตย์','จันทร์','อังคาร','พุธ','พฤหัสบดี','ศุกร์','เสาร์'],
dayNamesShort: ['อา.','จ.','อ.','พ.','พฤ.','ศ.','ส.'],
dayNamesMin: ['อา.','จ.','อ.','พ.','พฤ.','ศ.','ส.'],
dateFormat: 'dd/mm/yyyy', firstDay: 0,
renderer: $.datepick.defaultRenderer,
prevText: '« ย้อน', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'ถัดไป »', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'วันนี้', currentStatus: '',
todayText: 'วันนี้', todayStatus: '',
clearText: 'ลบ', clearStatus: '',
closeText: 'ปิด', closeStatus: '',
yearStatus: '', monthStatus: '',
weekText: 'Wk', weekStatus: '',
dayStatus: 'D, M d', defaultStatus: '',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['th']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Turkish localisation for jQuery Datepicker.
Written by Izzet Emre Erkan (kara@karalamalar.net). */
(function($) {
$.datepick.regional['tr'] = {
monthNames: ['Ocak','Şubat','Mart','Nisan','Mayıs','Haziran',
'Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'],
monthNamesShort: ['Oca','Şub','Mar','Nis','May','Haz',
'Tem','Ağu','Eyl','Eki','Kas','Ara'],
dayNames: ['Pazar','Pazartesi','Salı','Çarşamba','Perşembe','Cuma','Cumartesi'],
dayNamesShort: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
dayNamesMin: ['Pz','Pt','Sa','Ça','Pe','Cu','Ct'],
dateFormat: 'dd.mm.yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<geri', prevStatus: 'önceki ayı göster',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'ileri>', nextStatus: 'sonraki ayı göster',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'bugün', currentStatus: '',
todayText: 'bugün', todayStatus: '',
clearText: 'temizle', clearStatus: 'geçerli tarihi temizler',
closeText: 'kapat', closeStatus: 'sadece göstergeyi kapat',
yearStatus: 'başka yıl', monthStatus: 'başka ay',
weekText: 'Hf', weekStatus: 'Ayın haftaları',
dayStatus: 'D, M d seçiniz', defaultStatus: 'Bir tarih seçiniz',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['tr']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Brazilian Portuguese localisation for jQuery Datepicker.
Written by Leonildo Costa Silva (leocsilva@gmail.com). */
(function($) {
$.datepick.regional['pt-BR'] = {
monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho',
'Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun',
'Jul','Ago','Set','Out','Nov','Dez'],
dayNames: ['Domingo','Segunda-feira','Terça-feira','Quarta-feira','Quinta-feira','Sexta-feira','Sábado'],
dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],
dayNamesMin: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb'],
dateFormat: 'dd/mm/yyyy', firstDay: 0,
renderer: $.datepick.defaultRenderer,
prevText: '<Anterior', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Próximo>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'Hoje', currentStatus: '',
todayText: 'Hoje', todayStatus: '',
clearText: 'Limpar', clearStatus: '',
closeText: 'Fechar', closeStatus: '',
yearStatus: '', monthStatus: '',
weekText: 'Sm', weekStatus: '',
dayStatus: 'D, M d', defaultStatus: '',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['pt-BR']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Czech localisation for jQuery Datepicker.
Written by Tomas Muller (tomas@tomas-muller.net). */
(function($) {
$.datepick.regional['cs'] = {
monthNames: ['leden','únor','březen','duben','květen','červen',
'červenec','srpen','září','říjen','listopad','prosinec'],
monthNamesShort: ['led','úno','bře','dub','kvě','čer',
'čvc','srp','zář','říj','lis','pro'],
dayNames: ['neděle', 'pondělí', 'úterý', 'středa', 'čtvrtek', 'pátek', 'sobota'],
dayNamesShort: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so'],
dayNamesMin: ['ne','po','út','st','čt','pá','so'],
dateFormat: 'dd.mm.yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<Dříve', prevStatus: 'Přejít na předchozí měsí',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Později>', nextStatus: 'Přejít na další měsíc',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'Nyní', currentStatus: 'Přejde na aktuální měsíc',
todayText: 'Nyní', todayStatus: 'Přejde na aktuální měsíc',
clearText: 'Vymazat', clearStatus: 'Vymaže zadané datum',
closeText: 'Zavřít', closeStatus: 'Zavře kalendář beze změny',
yearStatus: 'Přejít na jiný rok', monthStatus: 'Přejít na jiný měsíc',
weekText: 'Týd', weekStatus: 'Týden v roce',
dayStatus: '\'Vyber\' DD, M d', defaultStatus: 'Vyberte datum',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['cs']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Slovak localisation for jQuery Datepicker.
Written by Vojtech Rinik (vojto@hmm.sk). */
(function($) {
$.datepick.regional['sk'] = {
monthNames: ['Január','Február','Marec','Apríl','Máj','Jún',
'Júl','August','September','Október','November','December'],
monthNamesShort: ['Jan','Feb','Mar','Apr','Máj','Jún',
'Júl','Aug','Sep','Okt','Nov','Dec'],
dayNames: ['Nedel\'a','Pondelok','Utorok','Streda','Štvrtok','Piatok','Sobota'],
dayNamesShort: ['Ned','Pon','Uto','Str','Štv','Pia','Sob'],
dayNamesMin: ['Ne','Po','Ut','St','Št','Pia','So'],
dateFormat: 'dd.mm.yyyy', firstDay: 0,
renderer: $.datepick.defaultRenderer,
prevText: '<Predchádzajúci', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Nasledujúci>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'Dnes', currentStatus: '',
todayText: 'Dnes', todayStatus: '',
clearText: 'Zmazať', clearStatus: '',
closeText: 'Zavrieť', closeStatus: '',
yearStatus: '', monthStatus: '',
weekText: 'Ty', weekStatus: '',
dayStatus: 'D, M d', defaultStatus: '',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['sk']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Spanish localisation for jQuery Datepicker.
Traducido por Vester (xvester@gmail.com). */
(function($) {
$.datepick.regional['es'] = {
monthNames: ['Enero','Febrero','Marzo','Abril','Mayo','Junio',
'Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'],
monthNamesShort: ['Ene','Feb','Mar','Abr','May','Jun',
'Jul','Ago','Sep','Oct','Nov','Dic'],
dayNames: ['Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'],
dayNamesShort: ['Dom','Lun','Mar','Mié','Juv','Vie','Sáb'],
dayNamesMin: ['Do','Lu','Ma','Mi','Ju','Vi','Sá'],
dateFormat: 'dd/mm/yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: '<Ant', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'Sig>', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'Hoy', currentStatus: '',
todayText: 'Hoy', todayStatus: '',
clearText: 'Limpiar', clearStatus: '',
closeText: 'Cerrar', closeStatus: '',
yearStatus: '', monthStatus: '',
weekText: 'Sm', weekStatus: '',
dayStatus: 'D, M d', defaultStatus: '',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['es']);
})(jQuery);
|
JavaScript
|
/* http://keith-wood.name/datepick.html
Tamil localisation for jQuery Datepicker.
Written by S A Sureshkumar (saskumar@live.com). */
(function($) {
$.datepick.regional['ta'] = {
monthNames: ['தை','மாசி','பங்குனி','சித்திரை','வைகாசி','ஆனி',
'ஆடி','ஆவணி','புரட்டாசி','ஐப்பசி','கார்த்திகை','மார்கழி'],
monthNamesShort: ['தை','மாசி','பங்','சித்','வைகா','ஆனி',
'ஆடி','ஆவ','புர','ஐப்','கார்','மார்'],
dayNames: ['ஞாயிற்றுக்கிழமை','திங்கட்கிழமை','செவ்வாய்க்கிழமை','புதன்கிழமை','வியாழக்கிழமை','வெள்ளிக்கிழமை','சனிக்கிழமை'],
dayNamesShort: ['ஞாயிறு','திங்கள்','செவ்வாய்','புதன்','வியாழன்','வெள்ளி','சனி'],
dayNamesMin: ['ஞா','தி','செ','பு','வி','வெ','ச'],
dateFormat: 'dd/mm/yyyy', firstDay: 1,
renderer: $.datepick.defaultRenderer,
prevText: 'முன்னையது', prevStatus: '',
prevJumpText: '<<', prevJumpStatus: '',
nextText: 'அடுத்தது', nextStatus: '',
nextJumpText: '>>', nextJumpStatus: '',
currentText: 'இன்று', currentStatus: '',
todayText: 'இன்று', todayStatus: '',
clearText: 'அழி', clearStatus: '',
closeText: 'மூடு', closeStatus: '',
yearStatus: '', monthStatus: '',
weekText: 'Wk', weekStatus: '',
dayStatus: 'D, M d', defaultStatus: '',
isRTL: false
};
$.datepick.setDefaults($.datepick.regional['ta']);
})(jQuery);
|
JavaScript
|
/**
* Template JS for Internet Explorer 8 and lower - mainly workaround for missing selectors
*/
(function($)
{
// Standard template setup for IE
$.fn.addTemplateSetup(function()
{
// Clean existing classes
this.find('.first-child').removeClass('first-child');
this.find('.last-child').removeClass('last-child');
this.find('.last-of-type').removeClass('last-of-type');
this.find('.even').removeClass('even');
this.find('.odd').removeClass('odd');
// Missing selectors
this.find(':first-child').addClass('first-child');
this.find(':last-child').addClass('last-child');
// Specific classes
this.find('.head').each(function () { $(this).children('div:last').addClass('last-of-type'); });
this.find('tbody tr:even, .task-dialog > li:even, .planning > li.planning-header > ul > li:even').addClass('even');
this.find('tbody tr:odd, .planning > li:odd').addClass('odd');
this.find('.form fieldset:has(legend)').addClass('fieldset-with-legend').filter(':first-child').addClass('fieldset-with-legend-first-child');
// Disabled buttons
this.find('button:disabled').addClass('disabled');
// IE 7
if ($.browser.version < 8)
{
// Clean existing classes
this.find('.after-h1').removeClass('after-h1');
this.find('.block-content h1:first-child, .block-content .h1:first-child').next().addClass('after-h1');
this.find('.calendar .add-event').prepend('<span class="before"></span>');
}
// Input switches
this.find('input[type=radio].switch:checked + .switch-replace, input[type=checkbox].switch:checked + .switch-replace').addClass('switch-replace-checked');
this.find('input[type=radio].switch:disabled + .switch-replace, input[type=checkbox].switch:disabled + .switch-replace').addClass('switch-replace-disabled');
this.find('input[type=radio].mini-switch:checked + .mini-switch-replace, input[type=checkbox].mini-switch:checked + .mini-switch-replace').addClass('mini-switch-replace-checked');
this.find('input[type=radio].mini-switch:disabled + .mini-switch-replace, input[type=checkbox].mini-switch:disabled + .mini-switch-replace').addClass('mini-switch-replace-disabled');
});
// Document initial setup
$(document).ready(function()
{
// Input switches
$('input[type=radio].switch, input[type=checkbox].switch').click(function() {
if (!this.checked)
{
$(this).next('.switch-replace').addClass('switch-replace-checked');
}
else
{
$(this).next('.switch-replace').removeClass('switch-replace-checked');
}
});
$('input[type=radio].mini-switch, input[type=checkbox].mini-switch').click(function() {
if (!this.checked)
{
$(this).next('.mini-switch-replace').addClass('mini-switch-replace-checked');
}
else
{
$(this).next('.mini-switch-replace').removeClass('mini-switch-replace-checked');
}
});
});
})(jQuery);
|
JavaScript
|
/**
* Template JS for mobile pages
*/
(function($)
{
$(document).ready(function()
{
// Menu
$('#menu > a').click(function(event)
{
event.preventDefault();
$(this).parent().toggleClass('active');
});
// Menus with sub-menus
$('#menu ul li:has(ul)').addClass('with-subs').children('a').click(function(event)
{
// Stop link
event.preventDefault();
// Show sub-menu
var li = $(this).parent();
li.addClass('active').siblings().removeClass('active');
// Scroll
var menu = $('#menu > ul');
menu.stop(true).animate({scrollLeft:li.children('ul:first').offset().left+menu.scrollLeft()});
})
.siblings('ul').prepend('<li class="back"><a href="#">Back</a></li>')
.find('li.back > a').click(function(event)
{
// Stop link
event.preventDefault();
// Scroll
var li = $(this).parent().parent().parent();
var menu = $('#menu > ul');
var scrollVal = (li.parent().parent().attr('id') == 'menu') ? li.parent().offset().left : li.parent().offset().left+menu.scrollLeft();
menu.stop(true).animate({scrollLeft:scrollVal}, {
complete: function()
{
// Close sub-menu
li.removeClass('active');
}
});
});
});
})(jQuery);
|
JavaScript
|
// Create new HTML5 elements ===================================================
// -----------------------------------------------------------------------------
// This script should load before any others. We want the new elements to be
// parsed before pretty much anything happens.
// Plus, IE does not behave otherwise. The cost of being progressive...
// -----------------------------------------------------------------------------
// Credits : http://sickdesigner.com/index.php/2010/html-css/html5-starter-pack-a-sick-freebie/
document.createElement("article");
document.createElement("aside");
document.createElement("audio");
document.createElement("canvas");
document.createElement("command");
document.createElement("datalist");
document.createElement("details");
document.createElement("embed");
document.createElement("figcaption");
document.createElement("figure");
document.createElement("footer");
document.createElement("header");
document.createElement("hgroup");
document.createElement("keygen");
document.createElement("mark");
document.createElement("meter");
document.createElement("nav");
document.createElement("output");
document.createElement("progress");
document.createElement("rp");
document.createElement("rt");
document.createElement("ruby");
document.createElement("section");
document.createElement("source");
document.createElement("summary");
document.createElement("time");
document.createElement("video");
|
JavaScript
|
/**
* Template JS for standard pages
*/
(function($)
{
/**
* List of functions required to enable template effects/hacks
* @var array
*/
var templateSetup = new Array();
/**
* Add a new template function
* @param function func the function to be called on a jQuery object
* @param boolean prioritary set to true to call the function before all others (optional)
* @return void
*/
$.fn.addTemplateSetup = function(func, prioritary)
{
if (prioritary)
{
templateSetup.unshift(func);
}
else
{
templateSetup.push(func);
}
};
/**
* Call every template function over a jQuery object (for instance : $('body').applyTemplateSetup())
* @return void
*/
$.fn.applyTemplateSetup = function()
{
var max = templateSetup.length;
for (var i = 0; i < max; ++i)
{
templateSetup[i].apply(this);
}
return this;
};
// Common (mobile and standard) template setup
$.fn.addTemplateSetup(function()
{
// Collapsible fieldsets
this.find('fieldset legend > a, .fieldset .legend > a').click(function(event)
{
$(this).toggleFieldsetOpen();
event.preventDefault();
});
this.find('fieldset.collapse, .fieldset.collapse').toggleFieldsetOpen().removeClass('collapse');
// Equalize tab content-blocks heights
this.find('.tabs.same-height, .side-tabs.same-height, .mini-tabs.same-height, .controls-tabs.same-height').equalizeTabContentHeight();
// Update tabs
this.find('.js-tabs').updateTabs();
// Input switches
this.find('input[type=radio].switch, input[type=checkbox].switch').hide().after('<span class="switch-replace"></span>').next().click(function() {
$(this).prev().click();
}).prev('.with-tip').next().addClass('with-tip').each(function()
{
$(this).attr('title', $(this).prev().attr('title'));
});
this.find('input[type=radio].mini-switch, input[type=checkbox].mini-switch').hide().after('<span class="mini-switch-replace"></span>').next().click(function() {
$(this).prev().click();
}).prev('.with-tip').next().addClass('with-tip').each(function()
{
$(this).attr('title', $(this).prev().attr('title'));
});
// Tabs links behaviour
this.find('.js-tabs a[href^="#"]').click(function(event)
{
event.preventDefault();
// If hashtag enabled
if ($.fn.updateTabs.enabledHash)
{
// Retrieve hash parts
var element = $(this);
var hash = $.trim(window.location.hash || '');
if (hash.length > 1)
{
// Remove hash from other tabs of the group
var hashParts = hash.substring(1).split('&');
var dummyIndex;
while ((dummyIndex = $.inArray('', hashParts)) > -1)
{
hashParts.splice(dummyIndex, 1);
}
while ((dummyIndex = $.inArray('none', hashParts)) > -1)
{
hashParts.splice(dummyIndex, 1);
}
element.parent().parent().find('a[href^="#"]').each(function(i)
{
var index = $.inArray($(this).attr('href').substring(1), hashParts);
if (index > -1)
{
hashParts.splice(index, 1);
}
});
}
else
{
var hashParts = [];
}
// Add current tab to hash (not if default)
var defaultTab = getDefaultTabIndex(element.parent().parent());
if (element.parent().index() != defaultTab)
{
hashParts.push(element.attr('href').substring(1));
}
// If only one tab, add a empty id to prevent document from jumping to selected content
if (hashParts.length == 1)
{
hashParts.unshift('');
}
// Put hash, will trigger refresh
window.location.hash = (hashParts.length > 0) ? '#'+hashParts.join('&') : '#none';
}
else
{
var li = $(this).closest('li');
li.addClass('current').siblings().removeClass('current');
li.parent().updateTabs();
}
});
});
// Document initial setup
$(document).ready(function()
{
// Template setup
$(document.body).applyTemplateSetup();
// Listener
$(window).bind('hashchange', function()
{
$(document.body).find('.js-tabs').updateTabs();
});
});
/**
* Get tab group default tab
*/
function getDefaultTabIndex(tabGroup)
{
var defaultTab = tabGroup.data('defaultTab');
if (defaultTab === null || defaultTab === '' || defaultTab === undefined)
{
var firstTab = tabGroup.children('.current:first');
defaultTab = (firstTab.length > 0) ? firstTab.index() : 0;
tabGroup.data('defaultTab', defaultTab);
}
return defaultTab;
};
/**
* Update tabs
*/
$.fn.updateTabs = function()
{
// If hashtags enabled
if ($.fn.updateTabs.enabledHash)
{
var hash = $.trim(window.location.hash || '');
var hashParts = (hash.length > 1) ? hash.substring(1).split('&') : [];
}
else
{
var hash = '';
var hashParts = [];
}
// Check all tabs
var hasHash = (hashParts.length > 0);
this.each(function(i)
{
// Check if already inited
var tabGroup = $(this);
var defaultTab = getDefaultTabIndex(tabGroup);
// Look for current tab
var current = false;
if ($.fn.updateTabs.enabledHash)
{
if (hasHash)
{
var links = tabGroup.find('a[href^="#"]');
links.each(function(i)
{
var linkHash = $(this).attr('href').substring(1);
if (linkHash.length > 0)
{
var index = $.inArray(linkHash, hashParts);
if (index > -1)
{
current = $(this).parent();
return false;
}
}
});
}
}
else
{
current = tabGroup.children('.current:first');
}
// If none found : get the default tab
if (!current)
{
current = tabGroup.children(':eq('+defaultTab+')');
}
if (current.length > 0)
{
// Display current tab content block
hash = $.trim(current.children('a').attr('href').substring(1));
if (hash.length > 0)
{
// Highlight current
current.addClass('current');
var tabContainer = $('#'+hash),
tabHidden = tabContainer.is(':hidden');
// Show if hidden
if (tabHidden)
{
tabContainer.show();
}
// Hide others
current.siblings().removeClass('current').children('a').each(function(i)
{
var hash = $.trim($(this).attr('href').substring(1));
if (hash.length > 0)
{
var tabContainer = $('#'+hash);
// Hide if visible
if (tabContainer.is(':visible'))
{
tabContainer.trigger('tabhide').hide();
}
// Or init if first round
else if (!tabContainer.data('tabInited'))
{
tabContainer.trigger('tabhide');
tabContainer.data('tabInited', true);
}
}
});
// Callback
if (tabHidden)
{
tabContainer.trigger('tabshow');
}
// Or init if first round
else if (!tabContainer.data('tabInited'))
{
tabContainer.trigger('tabshow');
tabContainer.data('tabInited', true);
}
}
}
});
return this;
};
/**
* Indicate whereas JS tabs hashtag is enabled
* @var boolean
*/
$.fn.updateTabs.enabledHash = true;
/**
* Reset tab content blocks heights
*/
$.fn.resetTabContentHeight = function()
{
this.find('a[href^="#"]').each(function(i)
{
var hash = $.trim($(this).attr('href').substring(1));
if (hash.length > 0)
{
$('#'+hash).css('height', '');
}
});
return this;
}
/**
* Equalize tab content blocks heights
*/
$.fn.equalizeTabContentHeight = function()
{
var i;
var g;
var maxHeight;
var tabContainers;
var block;
var blockHeight;
var marginAdjustTop;
var marginAdjustBot;
var first;
var last;
var firstMargin;
var lastMargin;
// Process in reverse order to equalize sub-tabs first
for (i = this.length-1; i >= 0; --i)
{
// Look for max height
maxHeight = -1;
tabContainers = [];
this.eq(i).find('a[href^="#"]').each(function(i)
{
var hash = $.trim($(this).attr('href').substring(1));
if (hash.length > 0)
{
block = $('#'+hash);
if (block.length > 0)
{
blockHeight = block.outerHeight()+parseInt(block.css('margin-bottom'));
// First element top-margin affects real height
marginAdjustTop = 0;
first = block.children(':first');
if (first.length > 0)
{
firstMargin = parseInt(first.css('margin-top'));
if (!isNaN(firstMargin) && firstMargin < 0)
{
marginAdjustTop = firstMargin;
}
}
// Same for last element bottom-margin
marginAdjustBot = 0;
last = block.children(':last');
if (last.length > 0)
{
lastMargin = parseInt(last.css('margin-bottom'));
if (!isNaN(lastMargin) && lastMargin < 0)
{
marginAdjustBot = lastMargin;
}
}
if (blockHeight+marginAdjustTop+marginAdjustBot > maxHeight)
{
maxHeight = blockHeight+marginAdjustTop+marginAdjustBot;
}
tabContainers.push([block, marginAdjustTop]);
}
}
});
// Setup height
for (g = 0; g < tabContainers.length; ++g)
{
tabContainers[g][0].height(maxHeight-parseInt(tabContainers[g][0].css('padding-top'))-parseInt(tabContainers[g][0].css('padding-bottom'))-parseInt(tabContainers[g][0].css('margin-bottom'))-tabContainers[g][1]);
// Only the first tab remains visible
if (g > 0)
{
tabContainers[g][0].hide();
}
}
}
return this;
};
/**
* Display the selected tab (apply on tab content-blocks, not tabs, ie: $('#my-tab').showTab(); )
*/
$.fn.showTab = function()
{
this.each(function(i)
{
$('a[href="#'+this.id+'"]').trigger('click');
});
return this;
};
/**
* Add a listener fired when a tab is shown
* @param function callback any function to call when the listener is fired.
* @param boolean runOnce if true, the callback will be run one time only. Default: false - optional
*/
$.fn.onTabShow = function(callback, runOnce)
{
if (runOnce)
{
var runOnceFunc = function()
{
callback.apply(this, arguments);
$(this).unbind('tabshow', runOnceFunc);
}
this.bind('tabshow', runOnceFunc);
}
else
{
this.bind('tabshow', callback);
}
return this;
};
/**
* Add a listener fired when a tab is hidden
* @param function callback any function to call when the listener is fired.
* @param boolean runOnce if true, the callback will be run one time only. Default: false - optional
*/
$.fn.onTabHide = function(callback, runOnce)
{
if (runOnce)
{
var runOnceFunc = function()
{
callback.apply(this, arguments);
$(this).unbind('tabhide', runOnceFunc);
}
this.bind('tabhide', runOnceFunc);
}
else
{
this.bind('tabhide', callback);
}
return this;
};
/**
* Insert a message into a block
* @param string|array message a message, or an array of messages to inserted
* @param object options optional object with following values:
* - type: one of the available message classes : 'info' (default), 'warning', 'error', 'success', 'loading'
* - position: either 'top' (default) or 'bottom'
* - animate: true to show the message with an animation (default), else false
* - noMargin: true to apply the no-margin class to the message (default), else false
*/
$.fn.blockMessage = function(message, options)
{
var settings = $.extend({}, $.fn.blockMessage.defaults, options);
this.each(function(i)
{
// Locate content block
var block = $(this);
if (!block.hasClass('block-content'))
{
block = block.find('.block-content:first');
if (block.length == 0)
{
block = $(this).closest('.block-content');
if (block.length == 0)
{
return;
}
}
}
// Compose message
var messageClass = (settings.type == 'info') ? 'message' : 'message '+settings.type;
if (settings.noMargin)
{
messageClass += ' no-margin';
}
var finalMessage = (typeof message == 'object') ? '<ul class="'+messageClass+'"><li>'+message.join('</li><li>')+'</li></ul>' : '<p class="'+messageClass+'">'+message+'</p>';
// Insert message
if (settings.position == 'top')
{
var children = block.find('h1, .h1, .block-controls, .block-header, .wizard-steps');
if (children.length > 0)
{
var lastHeader = children.last();
var next = lastHeader.next('.message');
while (next.length > 0)
{
lastHeader = next;
next = lastHeader.next('.message');
}
var messageElement = lastHeader.after(finalMessage).next();
}
else
{
var messageElement = block.prepend(finalMessage).children(':first');
}
}
else
{
var children = block.find('.block-footer:last-child');
if (children.length > 0)
{
var messageElement = children.before(finalMessage).prev();
}
else
{
var messageElement = block.append(finalMessage).children(':last');
}
}
if (settings.animate)
{
messageElement.expand();
}
});
return this;
};
// Default config for the blockMessage function
$.fn.blockMessage.defaults = {
type: 'info',
position: 'top',
animate: true,
noMargin: true
};
/**
* Remove all messages from the block
* @param object options optional object with following values:
* - only: string or array of strings of message classes which will be removed
* - except: string or array of strings of message classes which will not be removed (ignored if 'only' is provided)
* - animate: true to remove the message with an animation (default), else false
*/
$.fn.removeBlockMessages = function(options)
{
var settings = $.extend({}, $.fn.removeBlockMessages.defaults, options);
this.each(function(i)
{
// Locate content block
var block = $(this);
if (!block.hasClass('block-content'))
{
block = block.find('.block-content:first');
if (block.length == 0)
{
block = $(this).closest('.block-content');
if (block.length == 0)
{
return;
}
}
}
var messages = block.find('.message');
if (settings.only)
{
if (typeof settings.only == 'string')
{
settings.only = [settings.only];
}
messages = messages.filter('.'+settings.only.join(', .'));
}
else if (settings.except)
{
if (typeof settings.except == 'string')
{
settings.except = [settings.except];
}
messages = messages.not('.'+settings.except.join(', .'));
}
if (settings.animate)
{
messages.foldAndRemove();
}
else
{
messages.remove();
}
});
return this;
};
// Default config for the blockMessage function
$.fn.removeBlockMessages.defaults = {
only: false, // string or array of strings of message classes which will be removed
except: false, // except: string or array of strings of message classes which will not be removed (ignored if only is provided)
animate: true // animate: true to remove the message with an animation (default), else false
};
/**
* Fold an element
* @param string|int duration a string (fast, normal or slow) or a number of millisecond. Default: 'normal'. - optional
* @param function callback any function to call at the end of the effect. Default: none. - optional
*/
$.fn.fold = function(duration, callback)
{
this.each(function(i)
{
var element = $(this);
var marginTop = parseInt(element.css('margin-top'));
var marginBottom = parseInt(element.css('margin-bottom'));
var anim = {
'height': 0,
'paddingTop': 0,
'paddingBottom': 0
};
// IE8 and lower do not understand border-xx-width
// http://forum.jquery.com/topic/ie-invalid-argument
if (!$.browser.msie || $.browser.version > 8)
{
// Border width is not set to 0 because it does not allow fluid movement
anim.borderTopWidth = '1px';
anim.borderBottomWidth = '1px';
}
// Detection of elements sticking to their predecessor
var prev = element.prev();
if (prev.length === 0 && parseInt(element.css('margin-bottom'))+marginTop !== 0)
{
anim.marginTop = Math.min(0, marginTop);
anim.marginBottom = Math.min(0, marginBottom);
}
// Effect
element.stop(true).css({
'overflow': 'hidden'
}).animate(anim, {
'duration': duration,
'complete': function()
{
// Reset properties
$(this).css({
'display': 'none',
'overflow': '',
'height': '',
'paddingTop': '',
'paddingBottom': '',
'borderTopWidth': '',
'borderBottomWidth': '',
'marginTop': '',
'marginBottom': ''
});
// Callback function
if (callback)
{
callback.apply(this);
}
}
});
});
return this;
};
/*
* Expand an element
* @param string|int duration a string (fast, normal or slow) or a number of millisecond. Default: 'normal'. - optional
* @param function callback any function to call at the end of the effect. Default: none. - optional
*/
$.fn.expand = function(duration, callback)
{
this.each(function(i)
{
// Init
var element = $(this);
element.css('display', 'block');
// Reset and get values
element.stop(true).css({
'overflow': '',
'height': '',
'paddingTop': '',
'paddingBottom': '',
'borderTopWidth': '',
'borderBottomWidth': '',
'marginTop': '',
'marginBottom': ''
});
var height = element.height();
var paddingTop = parseInt(element.css('padding-top'));
var paddingBottom = parseInt(element.css('padding-bottom'));
var marginTop = parseInt(element.css('margin-top'));
var marginBottom = parseInt(element.css('margin-bottom'));
// Initial and target values
var css = {
'overflow': 'hidden',
'height': 0,
'paddingTop': 0,
'paddingBottom': 0
};
var anim = {
'height': height,
'paddingTop': paddingTop,
'paddingBottom': paddingBottom
};
// IE8 and lower do not understand border-xx-width
// http://forum.jquery.com/topic/ie-invalid-argument
if (!$.browser.msie || $.browser.version > 8)
{
var borderTopWidth = parseInt(element.css('border-top-width'));
var borderBottomWidth = parseInt(element.css('border-bottom-width'));
// Border width is not set to 0 because it does not allow fluid movement
css.borderTopWidth = '1px';
css.borderBottomWidth = '1px';
anim.borderTopWidth = borderTopWidth;
anim.borderBottomWidth = borderBottomWidth;
}
// Detection of elements sticking to their predecessor
var prev = element.prev();
if (prev.length === 0 && parseInt(element.css('margin-bottom'))+marginTop !== 0)
{
css.marginTop = Math.min(0, marginTop);
css.marginBottom = Math.min(0, marginBottom);
anim.marginTop = marginTop;
anim.marginBottom = marginBottom;
}
// Effect
element.stop(true).css(css).animate(anim, {
'duration': duration,
'complete': function()
{
// Reset properties
$(this).css({
'display': '',
'overflow': '',
'height': '',
'paddingTop': '',
'paddingBottom': '',
'borderTopWidth': '',
'borderBottomWidth': '',
'marginTop': '',
'marginBottom': ''
});
// Callback function
if (callback)
{
callback.apply(this);
}
// Required for IE7 - don't ask me why...
if ($.browser.msie && $.browser.version < 8)
{
$(this).css('zoom', 1);
}
}
});
});
return this;
};
/**
* Remove an element with folding effect
* @param string|int duration a string (fast, normal or slow) or a number of millisecond. Default: 'normal'. - optional
* @param function callback any function to call at the end of the effect. Default: none. - optional
*/
$.fn.foldAndRemove = function(duration, callback)
{
$(this).fold(duration, function()
{
// Callback function
if (callback)
{
callback.apply(this);
}
$(this).remove();
});
return this;
}
/**
* Remove an element with fading then folding effect
* @param string|int duration a string (fast, normal or slow) or a number of millisecond. Default: 'normal'. - optional
* @param function callback any function to call at the end of the effect. Default: none. - optional
*/
$.fn.fadeAndRemove = function(duration, callback)
{
this.animate({'opacity': 0}, {
'duration': duration,
'complete': function()
{
// No folding required if the element has position: absolute (not in the elements flow)
if ($(this).css('position') == 'absolute')
{
// Callback function
if (callback)
{
callback.apply(this);
}
$(this).remove();
}
else
{
$(this).slideUp(duration, function()
{
// Callback function
if (callback)
{
callback.apply(this);
}
$(this).remove();
});
}
}
});
return this;
};
/**
* Open/close fieldsets
*/
$.fn.toggleFieldsetOpen = function()
{
this.each(function()
{
/*
* Tip: if you want to add animation or do anything that should not occur at startup closing,
* check if the element has the class 'collapse':
* if (!$(this).hasClass('collapse')) { // Anything that sould no occur at startup }
*/
// Change
$(this).closest('fieldset, .fieldset').toggleClass('collapsed');
});
return this;
};
/**
* Add a semi-transparent layer in front of an element
*/
$.fn.addEffectLayer = function(options)
{
var settings = $.extend({}, $.fn.addEffectLayer.defaults, options);
this.each(function(i)
{
var element = $(this);
// Add layer
var refElement = getNodeRefElement(this);
var layer = $('<div class="loading-mask"><span>'+settings.message+'</span></div>').insertAfter(refElement);
// Position
var elementOffset = element.position();
layer.css({
top: elementOffset.top+'px',
left: elementOffset.left+'px'
}).width(element.outerWidth()).height(element.outerHeight());
// Effect
var span = layer.children('span');
var marginTop = parseInt(span.css('margin-top'));
span.css({'opacity':0, 'marginTop':(marginTop-40)+'px'});
layer.css({'opacity':0}).animate({'opacity':1}, {
'complete': function()
{
span.animate({'opacity': 1, 'marginTop': marginTop+'px'});
}
});
});
return this;
};
/**
* Retrieve the reference element after which the layer will be inserted
* @param HTMLelement node the node on which the effect is applied
* @return HTMLelement the reference node
*/
function getNodeRefElement(node)
{
var element = $(node);
// Special case
if (node.nodeName.toLowerCase() == 'document' || node.nodeName.toLowerCase() == 'body')
{
var refElement = $(document.body).children(':last').get(0);
}
else
{
// Look for the reference element, the one after which the layer will be inserted
var refElement = node;
var offsetParent = element.offsetParent().get(0);
// List of elements in which we can add a div
var absPos = ['absolute', 'relative'];
while (refElement && refElement !== offsetParent && !$.inArray($(refElement.parentNode).css('position'), absPos))
{
refElement = refElement.parentNode;
}
}
return refElement;
}
// Default params for the loading effect layer
$.fn.addEffectLayer.defaults = {
message: 'Please wait...'
};
/**
* jQuery load() method wrapper : add a visual effect on the load() target
* Parameters are the same as load()
*/
$.fn.loadWithEffect = function()
{
// Add effect layer
this.addEffectLayer({
message: $.fn.loadWithEffect.defaults.message
});
// Rewrite callback function
var target = this;
var callback = false;
var args = $.makeArray(arguments);
var index = args.length;
if (args[2] && typeof args[2] == 'function')
{
callback = args[2];
index = 2;
}
else if (args[1] && typeof args[1] == 'function')
{
callback = args[1];
index = 1;
}
// Custom callback
args[index] = function(responseText, textStatus, XMLHttpRequest)
{
// Get the effect layer
var refElement = getNodeRefElement(this);
var layer = $(refElement).next('.loading-mask');
var span = layer.children('span');
// If success
if (textStatus == 'success' || textStatus == 'notmodified')
{
// Initial callback
if (callback)
{
callback.apply(this, arguments);
}
// Remove effect layer
layer.stop(true);
span.stop(true);
var currentMarginTop = parseInt(span.css('margin-top'));
var marginTop = parseInt(span.css('margin-top', '').css('margin-top'));
span.css({'marginTop':currentMarginTop+'px'}).animate({'opacity':0, 'marginTop':(marginTop-40)+'px'}, {
'complete': function()
{
layer.fadeAndRemove();
}
});
}
else
{
span.addClass('error').html($.fn.loadWithEffect.defaults.errorMessage+'<br><a href="#">'+$.fn.loadWithEffect.defaults.retry+'</a> / <a href="#">'+$.fn.loadWithEffect.defaults.cancel+'</a>');
span.children('a:first').click(function(event)
{
event.preventDefault();
// Relaunch request
$.fn.load.apply(target, args);
// Reset
span.removeClass('error').html($.fn.loadWithEffect.defaults.message).css('margin-left', '');
});
span.children('a:last').click(function(event)
{
event.preventDefault();
// Remove effect layer
layer.stop(true);
span.stop(true);
var currentMarginTop = parseInt(span.css('margin-top'));
var marginTop = parseInt(span.css('margin-top', '').css('margin-top'));
span.css({'marginTop':currentMarginTop+'px'}).animate({'opacity':0, 'marginTop':(marginTop-40)+'px'}, {
'complete': function()
{
layer.fadeAndRemove();
}
});
});
// Centering
span.css('margin-left', -Math.round(span.outerWidth()/2));
}
};
// Redirect to jQuery load
$.fn.load.apply(target, args);
return this;
};
// Default texts for the loading effect layer
$.fn.loadWithEffect.defaults = {
message: 'Loading...',
errorMessage: 'Error while loading',
retry: 'Retry',
cancel: 'Cancel'
};
/**
* Enable any button with workaround for IE lack of :disabled selector
*/
$.fn.enableBt = function()
{
$(this).attr('disabled', false);
if ($.browser.msie && $.browser.version < 9)
{
$(this).removeClass('disabled');
}
}
/**
* Disable any button with workaround for IE lack of :disabled selector
*/
$.fn.disableBt = function()
{
$(this).attr('disabled', true);
if ($.browser.msie && $.browser.version < 9)
{
$(this).addClass('disabled');
}
}
})(jQuery);
|
JavaScript
|
/*!
* jQuery hashchange event - v1.3 - 7/21/2010
* http://benalman.com/projects/jquery-hashchange-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
// Script: jQuery hashchange event
//
// *Version: 1.3, Last updated: 7/21/2010*
//
// Project Home - http://benalman.com/projects/jquery-hashchange-plugin/
// GitHub - http://github.com/cowboy/jquery-hashchange/
// Source - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.js
// (Minified) - http://github.com/cowboy/jquery-hashchange/raw/master/jquery.ba-hashchange.min.js (0.8kb gzipped)
//
// About: License
//
// Copyright (c) 2010 "Cowboy" Ben Alman,
// Dual licensed under the MIT and GPL licenses.
// http://benalman.com/about/license/
//
// About: Examples
//
// These working examples, complete with fully commented code, illustrate a few
// ways in which this plugin can be used.
//
// hashchange event - http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/
// document.domain - http://benalman.com/code/projects/jquery-hashchange/examples/document_domain/
//
// About: Support and Testing
//
// Information about what version or versions of jQuery this plugin has been
// tested with, what browsers it has been tested in, and where the unit tests
// reside (so you can test it yourself).
//
// jQuery Versions - 1.2.6, 1.3.2, 1.4.1, 1.4.2
// Browsers Tested - Internet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5,
// Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5.
// Unit Tests - http://benalman.com/code/projects/jquery-hashchange/unit/
//
// About: Known issues
//
// While this jQuery hashchange event implementation is quite stable and
// robust, there are a few unfortunate browser bugs surrounding expected
// hashchange event-based behaviors, independent of any JavaScript
// window.onhashchange abstraction. See the following examples for more
// information:
//
// Chrome: Back Button - http://benalman.com/code/projects/jquery-hashchange/examples/bug-chrome-back-button/
// Firefox: Remote XMLHttpRequest - http://benalman.com/code/projects/jquery-hashchange/examples/bug-firefox-remote-xhr/
// WebKit: Back Button in an Iframe - http://benalman.com/code/projects/jquery-hashchange/examples/bug-webkit-hash-iframe/
// Safari: Back Button from a different domain - http://benalman.com/code/projects/jquery-hashchange/examples/bug-safari-back-from-diff-domain/
//
// Also note that should a browser natively support the window.onhashchange
// event, but not report that it does, the fallback polling loop will be used.
//
// About: Release History
//
// 1.3 - (7/21/2010) Reorganized IE6/7 Iframe code to make it more
// "removable" for mobile-only development. Added IE6/7 document.title
// support. Attempted to make Iframe as hidden as possible by using
// techniques from http://www.paciellogroup.com/blog/?p=604. Added
// support for the "shortcut" format $(window).hashchange( fn ) and
// $(window).hashchange() like jQuery provides for built-in events.
// Renamed jQuery.hashchangeDelay to <jQuery.fn.hashchange.delay> and
// lowered its default value to 50. Added <jQuery.fn.hashchange.domain>
// and <jQuery.fn.hashchange.src> properties plus document-domain.html
// file to address access denied issues when setting document.domain in
// IE6/7.
// 1.2 - (2/11/2010) Fixed a bug where coming back to a page using this plugin
// from a page on another domain would cause an error in Safari 4. Also,
// IE6/7 Iframe is now inserted after the body (this actually works),
// which prevents the page from scrolling when the event is first bound.
// Event can also now be bound before DOM ready, but it won't be usable
// before then in IE6/7.
// 1.1 - (1/21/2010) Incorporated document.documentMode test to fix IE8 bug
// where browser version is incorrectly reported as 8.0, despite
// inclusion of the X-UA-Compatible IE=EmulateIE7 meta tag.
// 1.0 - (1/9/2010) Initial Release. Broke out the jQuery BBQ event.special
// window.onhashchange functionality into a separate plugin for users
// who want just the basic event & back button support, without all the
// extra awesomeness that BBQ provides. This plugin will be included as
// part of jQuery BBQ, but also be available separately.
(function($,window,undefined){
'$:nomunge'; // Used by YUI compressor.
// Reused string.
var str_hashchange = 'hashchange',
// Method / object references.
doc = document,
fake_onhashchange,
special = $.event.special,
// Does the browser support window.onhashchange? Note that IE8 running in
// IE7 compatibility mode reports true for 'onhashchange' in window, even
// though the event isn't supported, so also test document.documentMode.
doc_mode = doc.documentMode,
supports_onhashchange = 'on' + str_hashchange in window && ( doc_mode === undefined || doc_mode > 7 );
// Get location.hash (or what you'd expect location.hash to be) sans any
// leading #. Thanks for making this necessary, Firefox!
function get_fragment( url ) {
url = url || location.href;
return '#' + url.replace( /^[^#]*#?(.*)$/, '$1' );
};
// Method: jQuery.fn.hashchange
//
// Bind a handler to the window.onhashchange event or trigger all bound
// window.onhashchange event handlers. This behavior is consistent with
// jQuery's built-in event handlers.
//
// Usage:
//
// > jQuery(window).hashchange( [ handler ] );
//
// Arguments:
//
// handler - (Function) Optional handler to be bound to the hashchange
// event. This is a "shortcut" for the more verbose form:
// jQuery(window).bind( 'hashchange', handler ). If handler is omitted,
// all bound window.onhashchange event handlers will be triggered. This
// is a shortcut for the more verbose
// jQuery(window).trigger( 'hashchange' ). These forms are described in
// the <hashchange event> section.
//
// Returns:
//
// (jQuery) The initial jQuery collection of elements.
// Allow the "shortcut" format $(elem).hashchange( fn ) for binding and
// $(elem).hashchange() for triggering, like jQuery does for built-in events.
$.fn[ str_hashchange ] = function( fn ) {
return fn ? this.bind( str_hashchange, fn ) : this.trigger( str_hashchange );
};
// Property: jQuery.fn.hashchange.delay
//
// The numeric interval (in milliseconds) at which the <hashchange event>
// polling loop executes. Defaults to 50.
// Property: jQuery.fn.hashchange.domain
//
// If you're setting document.domain in your JavaScript, and you want hash
// history to work in IE6/7, not only must this property be set, but you must
// also set document.domain BEFORE jQuery is loaded into the page. This
// property is only applicable if you are supporting IE6/7 (or IE8 operating
// in "IE7 compatibility" mode).
//
// In addition, the <jQuery.fn.hashchange.src> property must be set to the
// path of the included "document-domain.html" file, which can be renamed or
// modified if necessary (note that the document.domain specified must be the
// same in both your main JavaScript as well as in this file).
//
// Usage:
//
// jQuery.fn.hashchange.domain = document.domain;
// Property: jQuery.fn.hashchange.src
//
// If, for some reason, you need to specify an Iframe src file (for example,
// when setting document.domain as in <jQuery.fn.hashchange.domain>), you can
// do so using this property. Note that when using this property, history
// won't be recorded in IE6/7 until the Iframe src file loads. This property
// is only applicable if you are supporting IE6/7 (or IE8 operating in "IE7
// compatibility" mode).
//
// Usage:
//
// jQuery.fn.hashchange.src = 'path/to/file.html';
$.fn[ str_hashchange ].delay = 50;
/*
$.fn[ str_hashchange ].domain = null;
$.fn[ str_hashchange ].src = null;
*/
// Event: hashchange event
//
// Fired when location.hash changes. In browsers that support it, the native
// HTML5 window.onhashchange event is used, otherwise a polling loop is
// initialized, running every <jQuery.fn.hashchange.delay> milliseconds to
// see if the hash has changed. In IE6/7 (and IE8 operating in "IE7
// compatibility" mode), a hidden Iframe is created to allow the back button
// and hash-based history to work.
//
// Usage as described in <jQuery.fn.hashchange>:
//
// > // Bind an event handler.
// > jQuery(window).hashchange( function(e) {
// > var hash = location.hash;
// > ...
// > });
// >
// > // Manually trigger the event handler.
// > jQuery(window).hashchange();
//
// A more verbose usage that allows for event namespacing:
//
// > // Bind an event handler.
// > jQuery(window).bind( 'hashchange', function(e) {
// > var hash = location.hash;
// > ...
// > });
// >
// > // Manually trigger the event handler.
// > jQuery(window).trigger( 'hashchange' );
//
// Additional Notes:
//
// * The polling loop and Iframe are not created until at least one handler
// is actually bound to the 'hashchange' event.
// * If you need the bound handler(s) to execute immediately, in cases where
// a location.hash exists on page load, via bookmark or page refresh for
// example, use jQuery(window).hashchange() or the more verbose
// jQuery(window).trigger( 'hashchange' ).
// * The event can be bound before DOM ready, but since it won't be usable
// before then in IE6/7 (due to the necessary Iframe), recommended usage is
// to bind it inside a DOM ready handler.
// Override existing $.event.special.hashchange methods (allowing this plugin
// to be defined after jQuery BBQ in BBQ's source code).
special[ str_hashchange ] = $.extend( special[ str_hashchange ], {
// Called only when the first 'hashchange' event is bound to window.
setup: function() {
// If window.onhashchange is supported natively, there's nothing to do..
if ( supports_onhashchange ) { return false; }
// Otherwise, we need to create our own. And we don't want to call this
// until the user binds to the event, just in case they never do, since it
// will create a polling loop and possibly even a hidden Iframe.
$( fake_onhashchange.start );
},
// Called only when the last 'hashchange' event is unbound from window.
teardown: function() {
// If window.onhashchange is supported natively, there's nothing to do..
if ( supports_onhashchange ) { return false; }
// Otherwise, we need to stop ours (if possible).
$( fake_onhashchange.stop );
}
});
// fake_onhashchange does all the work of triggering the window.onhashchange
// event for browsers that don't natively support it, including creating a
// polling loop to watch for hash changes and in IE 6/7 creating a hidden
// Iframe to enable back and forward.
fake_onhashchange = (function(){
var self = {},
timeout_id,
// Remember the initial hash so it doesn't get triggered immediately.
last_hash = get_fragment(),
fn_retval = function(val){ return val; },
history_set = fn_retval,
history_get = fn_retval;
// Start the polling loop.
self.start = function() {
timeout_id || poll();
};
// Stop the polling loop.
self.stop = function() {
timeout_id && clearTimeout( timeout_id );
timeout_id = undefined;
};
// This polling loop checks every $.fn.hashchange.delay milliseconds to see
// if location.hash has changed, and triggers the 'hashchange' event on
// window when necessary.
function poll() {
var hash = get_fragment(),
history_hash = history_get( last_hash );
if ( hash !== last_hash ) {
history_set( last_hash = hash, history_hash );
$(window).trigger( str_hashchange );
} else if ( history_hash !== last_hash ) {
location.href = location.href.replace( /#.*/, '' ) + history_hash;
}
timeout_id = setTimeout( poll, $.fn[ str_hashchange ].delay );
};
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
// vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7/8 vvvvvvvvvvvvvvvvvvv
// vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
$.browser.msie && !supports_onhashchange && (function(){
// Not only do IE6/7 need the "magical" Iframe treatment, but so does IE8
// when running in "IE7 compatibility" mode.
var iframe,
iframe_src;
// When the event is bound and polling starts in IE 6/7, create a hidden
// Iframe for history handling.
self.start = function(){
if ( !iframe ) {
iframe_src = $.fn[ str_hashchange ].src;
iframe_src = iframe_src && iframe_src + get_fragment();
// Create hidden Iframe. Attempt to make Iframe as hidden as possible
// by using techniques from http://www.paciellogroup.com/blog/?p=604.
iframe = $('<iframe tabindex="-1" title="empty"/>').hide()
// When Iframe has completely loaded, initialize the history and
// start polling.
.one( 'load', function(){
iframe_src || history_set( get_fragment() );
poll();
})
// Load Iframe src if specified, otherwise nothing.
.attr( 'src', iframe_src || 'javascript:0' )
// Append Iframe after the end of the body to prevent unnecessary
// initial page scrolling (yes, this works).
.insertAfter( 'body' )[0].contentWindow;
// Whenever `document.title` changes, update the Iframe's title to
// prettify the back/next history menu entries. Since IE sometimes
// errors with "Unspecified error" the very first time this is set
// (yes, very useful) wrap this with a try/catch block.
doc.onpropertychange = function(){
try {
if ( event.propertyName === 'title' ) {
iframe.document.title = doc.title;
}
} catch(e) {}
};
}
};
// Override the "stop" method since an IE6/7 Iframe was created. Even
// if there are no longer any bound event handlers, the polling loop
// is still necessary for back/next to work at all!
self.stop = fn_retval;
// Get history by looking at the hidden Iframe's location.hash.
history_get = function() {
return get_fragment( iframe.location.href );
};
// Set a new history item by opening and then closing the Iframe
// document, *then* setting its location.hash. If document.domain has
// been set, update that as well.
history_set = function( hash, history_hash ) {
var iframe_doc = iframe.document,
domain = $.fn[ str_hashchange ].domain;
if ( hash !== history_hash ) {
// Update Iframe with any initial `document.title` that might be set.
iframe_doc.title = doc.title;
// Opening the Iframe's document after it has been closed is what
// actually adds a history entry.
iframe_doc.open();
// Set document.domain for the Iframe document as well, if necessary.
domain && iframe_doc.write( '<script>document.domain="' + domain + '"</script>' );
iframe_doc.close();
// Update the Iframe's hash, for great justice.
iframe.location.hash = hash;
}
};
})();
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
// ^^^^^^^^^^^^^^^^^^^ REMOVE IF NOT SUPPORTING IE6/7/8 ^^^^^^^^^^^^^^^^^^^
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
return self;
})();
})(jQuery,this);
|
JavaScript
|
/**
* Template plugin for searchField
*/
(function($)
{
/**
* Timeout for ajax requests
* @var int
*/
var ajaxTimeout;
/**
* Timeout for search block close
* @var int
*/
var closeTimeout;
/**
* Last request timer
* @var int
*/
var lastRequest;
/**
* Setup the search field
* @param object options an object with any of the options defined below in the function's defaults
*/
$.fn.advancedSearchField = function(options)
{
var settings = $.extend({}, $.fn.advancedSearchField.defaults, options);
// Setup
this.before('<input type="hidden" name="search-last" id="search-last" value="">').focus(function() {
// Stop closing
if (closeTimeout)
{
clearTimeout(closeTimeout);
}
// Add event listener
$(this).bind('keyup', updateSearch);
updateSearch();
}).blur(function() {
// Remove event listener
$(this).unbind('keyup', updateSearch);
// Timeout for result hiding - needed for search block interactions
closeTimeout = setTimeout(closeSearch, 500);
}).after('<div id="search-result" class="result-block"><span class="arrow"><span></span></span><div id="server-search">'+settings.messageLoading+'</div><p id="search-info" class="result-info">-</p></div>').next().hide();
/**
* Hide search result block
* @return void
*/
function closeSearch()
{
// Hide elements
$('#s').hideTip();
$('#search-result').fadeOut();
};
/**
* Update the search field results block
* @return void
*/
function updateSearch()
{
// Elements
var result = $('#search-result');
// Current search
var s = $.trim($('#s').val());
// Parsing
if (s.length == 0)
{
// Tip
$('#s').showTip({
content: settings.tipFocus
});
result.fadeOut();
}
else if (s.length < settings.minSearchLength)
{
// Tip
$('#s').showTip({
content: settings.tipTooShort
});
result.fadeOut();
}
else
{
var last = $('#search-last');
var lastS = last.val();
var info = $('#search-info');
// Hide tip
$('#s').hideTip();
// Show search results block
result.fadeIn();
// Detect changes
if (lastS != s)
{
// Store search
$('#search-last').val(s);
// Stop previous request timeout
if (ajaxTimeout)
{
clearTimeout(ajaxTimeout);
}
// Empty block
result.children().not('.arrow, #server-search, #search-info').remove();
// If search within nav
if (settings.enableNavSearch)
{
result.children('.arrow:first').after('<h2>'+settings.titleTemplateResult+'</h2>'+searchInNav(s)+'<hr>');
// If hiding too long matches list
if ($.fn.accessibleList && (settings.moreButtonAfter > 0 || settings.matchesPerPage > 0))
{
result.children('ul:first').accessibleList({
'moreAfter': settings.moreButtonAfter,
'pageSize': settings.matchesPerPage,
'after': function()
{
// Restore focus
$('#s').focus();
}
});
}
}
// Message
$('#search-info').addClass('loading').text(settings.messageLoading);
// Ajax call
var date = new Date();
if (!lastRequest || lastRequest < date.getTime()-noUpdateDelay)
{
var delay = settings.firstRequestDelay;
}
else
{
var delay = settings.nextRequestDelay;
}
ajaxTimeout = setTimeout(sendRequest, delay);
}
}
};
/**
* Search within the main nav
* @param string s the search string
* @return void
*/
function searchInNav(s)
{
// Split keywords
var keywords = s.toLowerCase().split(/\s+/);
var nbKeywords = keywords.length;
// Search links
var links = $('nav a');
var matches = [];
links.each(function(i)
{
var text = $(this).text().toLowerCase();
var textMatch = true;
for (var i = 0; i < nbKeywords; ++i)
{
if (text.indexOf(keywords[i]) == -1)
{
textMatch = false;
break;
}
}
if (textMatch)
{
// All keywords found
matches.push(this);
}
});
// Build results list
var nbMatches = matches.length;
if (nbMatches > 0)
{
var output = '<p class="results-count"><strong>'+nbMatches+'</strong> match'+((nbMatches > 1) ? 'es' : '')+'</p>';
output += '<ul class="small-files-list icon-html">';
for (var m = 0; m < nbMatches; ++m)
{
// Text with highlighted keywords
var link = $(matches[m]);
var text = link.text();
var path = [text];
for (var i = 0; i < nbKeywords; ++i)
{
text = text.replace(new RegExp('('+keywords[i]+')', 'gi'), '<strong>$1</strong>');
}
// Path
var parent = link;
while ((parent = parent.parent().parent().prev('a')) && parent.length > 0)
{
path.push(parent.text());
}
output += '<li><a href="'+matches[m].href+'">'+text+'<br><small>'+path.reverse().join(' > ')+'</small></a></li>';
}
return output+'</ul>';
}
else
{
return '<p class="results-count">'+settings.messageNoMatches+'</p>';
}
};
/**
* Send search request to server
*/
function sendRequest()
{
// Search url
var url = $('#s').parents('form:first').attr('action');
if (!url || url == '')
{
// Page url without hash
url = document.location.href.match(/^([^#]+)/)[1];
}
var date = new Date();
var timer = date.getTime();
$('#server-search').load(url, {
's': $('#search-last').val(),
'timer': timer
}, function(responseText, textStatus, XMLHttpRequest)
{
if (textStatus == 'success' || textStatus == 'notmodified')
{
$('#search-info').removeClass('loading').html(settings.messageSearchDone);
}
else
{
$('#server-search').html('<p class="error-message">'+settings.messageErrorFull+'</p>');
$('#search-info').removeClass('loading').html(settings.messageError);
}
});
};
return this;
};
// Function's default configuration
$.fn.advancedSearchField.defaults = {
/**
* Minimum search string length
* @var int
*/
minSearchLength: 2,
/**
* Max number of visible matches in each list above 'more' button (0 for no masking)
* @var int
*/
moreButtonAfter: 3,
/**
* Number of visible matches per page (0 for no pagination)
* @var int
*/
matchesPerPage: 5,
/**
* Delay before first request in ms (avoid multiple request while user types)
* @var int
*/
firstRequestDelay: 250,
/**
* Minimum delay between search requests in ms (reduces server load)
* @var int
*/
nextRequestDelay: 750,
/**
* Minimum delay upon which the plugin considers the user has stopped typing long enough
* to start the next request with firstRequestDelay delay, thus responding faster
* @var int
*/
noUpdateDelay: 3000,
/**
* Enable search within navigation
* @var boolean
*/
enableNavSearch: true,
/**
* Message when user focuses the search field
* @var string
*/
tipFocus: 'Enter your search',
/**
* Message is search is too short
* @var string
*/
tipTooShort: 'Enter at least 2 chars',
/**
* Message while loading
* @var string
*/
messageLoading: 'Loading results...',
/**
* Message when no matches found
* @var string
*/
messageNoMatches: 'No matches',
/**
* Message when the search request is done
* @var string
*/
messageSearchDone: 'Not found? <a href="#">Try advanced search »</a>',
/**
* Full message if an error occurs while loading results
* @var string
*/
messageErrorFull: 'Error while loading results, please try again',
/**
* Status message if an error occurs while loading results
* @var string
*/
messageError: 'Error while loading',
/**
* Title of the result section showing template nav items
* @var string
*/
titleTemplateResult: 'Admin pages'
};
})(jQuery);
|
JavaScript
|
/**
* Add tip to any element
*/
(function($)
{
/**
* Adds tip on selected elements
* @param object options an object with any of the following options
* - content: Content of the tip (may be HTML) or false for auto detect (default: false)
* - onHover: Show tip only on hover (default: true)
* - reverseHover: Hide tip on hover in, show on hover out (default: false)
* - stickIfCurrent: Enable permanent tip on elements with the class 'current' (default: false)
* - currentClass: Name of the 'current' class (default: 'current')
* - offset: Offset of the tip from the element (default: 4)
* - position: Position of the tip relative to the element (default: 'top')
* - animationOffset: Offset for the animation (pixels) (default: 4)
* - delay: Delay before tip shows up on hover (milliseconds) (default: 0)
*/
$.fn.tip = function(options)
{
var settings = $.extend({}, $.fn.tip.defaults, options);
// Mode
if (settings.onHover)
{
// Detect current elements
if (settings.stickIfCurrent)
{
this.filter('.'+settings.currentClass).each(function(i)
{
$(this).createTip(settings);
});
}
// Effect
if (settings.reverseHover)
{
$(this).createTip(settings);
this.hover(function()
{
if (!settings.stickIfCurrent || !$(this).hasClass(settings.currentClass))
{
$(this).hideTip();
}
}, function()
{
$(this).showTip(settings);
});
}
else
{
this.hover(function()
{
$(this).showTip(settings);
}, function()
{
if (!settings.stickIfCurrent || !$(this).hasClass(settings.currentClass))
{
$(this).hideTip();
}
});
}
}
else
{
this.createTip(settings);
}
return this;
};
$.fn.tip.defaults = {
/**
* Content of the tip (may be HTML) or false for auto detect
* @var string|boolean
*/
content: false,
/**
* Show tip only on hover
* @var boolean
*/
onHover: true,
/**
* Hide tip on hover in, show on hover out
* @var boolean
*/
reverseHover: false,
/**
* Enable permanent tip on elements with the class 'current'
* @var boolean
*/
stickIfCurrent: false,
/**
* Name of the 'current' class
* @var boolean
*/
currentClass: 'current',
/**
* Offset of the tip from the element (pixels)
* @var int
*/
offset: 4,
/**
* Position of the tip relative to the element
* @var string
*/
position: 'top',
/**
* Offset for the animation (pixels)
* @var int
*/
animationOffset: 4,
/**
* Delay before tip shows up on hover (milliseconds)
* @var int
*/
delay: 0
};
/**
* Add tip (if not exist) and show it with effect
* @param object options same as the tip() method
*/
$.fn.showTip = function(options)
{
var settings = $.extend({}, $.fn.tip.defaults, options);
this.each(function(i)
{
var element = $(this);
var oldIE = ($.browser.msie && $.browser.version < 9);
// If tip does not already exist (if current), create it
var tip = element.data('tip');
if (!tip)
{
element.createTip(settings, oldIE ? false : true);
tip = element.data('tip');
}
else if (settings.content !== element.data('settings').content)
{
element.updateTipContent(options.content);
}
// Animation
if (!oldIE) // IE6-8 filters do not allow correct animation (the arrow is truncated)
{
var position = getTipPosition(element, tip, settings, false);
tip.stop(true).delay(settings.delay).animate({
opacity: 1,
top: position.top,
left: position.left
}, 'fast');
}
});
return this;
};
/**
* Hide then remove tip
*/
$.fn.hideTip = function()
{
this.each(function(i)
{
var element = $(this);
var tip = element.data('tip');
if (tip)
{
var settings = element.data('settings');
if ($.browser.msie && $.browser.version < 9)
{
// IE8 and lower filters do not allow correct animation (the arrow is truncated)
tip.children('.arrow').remove();
this.title = tip.html();
element.data('tip', false);
tip.remove();
}
else
{
// Hiding is not relative to the parent element, to prevent weird behaviour if parent is moved or removed
var position = getFinalPosition(tip, settings);
var offset = tip.offset();
switch (position)
{
case 'right':
offset.left += settings.animationOffset+settings.offset;
break;
case 'bottom':
offset.top += settings.animationOffset+settings.offset;
break;
case 'left':
offset.left -= settings.animationOffset+settings.offset;
break;
default:
offset.top -= settings.animationOffset+settings.offset;
break;
}
tip.animate({
opacity: 0,
top: offset.top,
left: offset.left
}, {
complete: function()
{
// Restore node
var tip = $(this);
var node = tip.data('node');
if (node)
{
tip.children('.arrow').remove();
node.attr('title', tip.html());
node.data('tip', false);
}
// Remove tip
tip.remove();
}
});
}
}
});
return this;
};
/**
* Create tip bubble
* @param object settings the options object given to tip()
* @param boolean hide indicate whether to hide the tip after creating it or not (default : false)
*/
$.fn.createTip = function(settings, hide)
{
this.each(function(i)
{
var element = $(this);
var tips = getTipDiv();
// Insertion
tips.append('<div></div>');
var tip = tips.children(':last-child');
// Position class
if (settings.position == 'right' || element.hasClass('tip-right') || element.parent().hasClass('children-tip-right'))
{
tip.addClass('tip-right');
}
else if (settings.position == 'bottom' || element.hasClass('tip-bottom') || element.parent().hasClass('children-tip-bottom'))
{
tip.addClass('tip-bottom');
}
else if (settings.position == 'left' || element.hasClass('tip-left') || element.parent().hasClass('children-tip-left'))
{
tip.addClass('tip-left');
}
// Cross references
tip.data('node', element);
element.data('tip', tip);
element.data('settings', settings);
// Content
element.updateTipContent(settings.content, hide);
// Effect
if (hide)
{
tip.css({opacity:0});
}
});
return this;
};
/**
* Update tip content
* @param mixed content any content (text or HTML) for the tip, of false for automatic detection
* @param boolean hide optional, compatibility with createTip()
*/
$.fn.updateTipContent = function(content, hide)
{
this.each(function(i)
{
var element = $(this);
var tip = element.data('tip');
var settings = element.data('settings');
// If auto tip content
if (!content)
{
if (this.title && this.title.length > 0)
{
var finalContent = this.title;
this.title = '';
}
else
{
var subTitle = element.find('[title]:first');
if (subTitle.length > 0)
{
var finalContent = subTitle.attr('title');
subTitle.attr('title', '');
}
else
{
var finalContent = element.text();
}
}
}
else
{
var finalContent = content;
}
// If empty
if (!finalContent || $.trim(finalContent).length == 0)
{
finalContent = '<em>No tip</em>';
}
// Insert
tip.html(finalContent+'<span class="arrow"><span></span></span>');
// Position
tip.stop(true, true);
var position = getTipPosition(element, tip, settings, hide);
tip.offset(position);
});
return this;
};
/**
* Call this function to refresh tips when using the stickIfCurrent option
* and the 'current' element has changed
*/
$.fn.refreshTip = function()
{
this.each(function(i)
{
var settings = $(this).data('settings');
if (settings && settings.stickIfCurrent)
{
var element = $(this);
if (element.hasClass(settings.currentClass))
{
element.showTip(settings);
}
else
{
element.hideTip(settings);
}
}
});
return this;
};
/**
* Detect final position for the tip
* @param jQuery tip the tip element
* @param Object settings the tip options
* @return string the final position
*/
function getFinalPosition(tip, settings)
{
var position = settings.position;
if (tip.hasClass('tip-right'))
{
position = 'right';
}
else if (tip.hasClass('tip-bottom'))
{
position = 'bottom';
}
else if (tip.hasClass('tip-left'))
{
position = 'left';
}
return position;
}
/**
* Get tip position, relative to the element
* @param jQuery element the element on which the the tip show
* @param jQuery tip the tip element
* @param Object settings the tip options
* @param boolean animStart tells wether the tip should be positioned at the start of the animation or not
* @return Object an object with two values : 'top' and 'left'
*/
function getTipPosition(element, tip, settings, animStart)
{
var offset = element.offset();
var position = getFinalPosition(tip, settings);
switch (position)
{
case 'right':
return {
top: Math.round(offset.top+(element.outerHeight()/2)-(tip.outerHeight()/2)),
left: Math.round(offset.left+element.outerWidth()+(animStart ? settings.animationOffset+settings.offset : settings.offset))
};
break;
case 'bottom':
return {
top: Math.round(offset.top+element.outerHeight()+(animStart ? settings.animationOffset+settings.offset : settings.offset)),
left: Math.round(offset.left+(element.outerWidth()/2)-(tip.outerWidth()/2))
};
break;
case 'left':
return {
top: Math.round(offset.top+(element.outerHeight()/2)-(tip.outerHeight()/2)),
left: Math.round(offset.left-tip.outerWidth()-(animStart ? settings.animationOffset+settings.offset : settings.offset))
};
break;
default:
return {
top: Math.round(offset.top-tip.outerHeight()-(animStart ? settings.animationOffset+settings.offset : settings.offset)),
left: Math.round(offset.left+(element.outerWidth()/2)-(tip.outerWidth()/2))
};
break;
}
}
// If template common functions loaded
if ($.fn.addTemplateSetup)
{
$.fn.addTemplateSetup(function()
{
this.find('.with-tip, .with-children-tip > *').tip();
});
}
else
{
// Default behaviour
$(document).ready(function()
{
$('.with-tip, .with-children-tip > *').tip();
});
}
/**
* Return the tips div, or create it if it does not exist
*/
function getTipDiv()
{
var tips = $('#tips');
if (tips.length == 0)
{
$(document.body).append('<div id="tips"></div>');
tips = $('#tips');
}
return tips;
}
// Handle viewport resizing
$(window).resize(function()
{
getTipDiv().children().each(function(i)
{
// Init
var tip = $(this);
var element = tip.data('node');
var settings = element.data('settings');
var isCurrent = settings.stickIfCurrent && element.hasClass(settings.currentClass);
// Position
var animate = (settings.onHover && !isCurrent);
tip.stop(true, true);
var position = getTipPosition(element, tip, settings, animate);
tip.offset(position);
});
});
})(jQuery);
|
JavaScript
|
/**
* Enables the context menu for elements bound to the 'contextMenu' event
*/
(function($)
{
/*
* Enable context menu
*/
document.oncontextmenu = function(event)
{
var e = window.event || event;
var target = $(e.target || e.srcElement);
var list = [];
target.trigger('contextMenu', [list]);
// If some menu elements added
if (list.length > 0)
{
// Mouse position
var posx = 0;
var posy = 0;
if (e.pageX || e.pageY)
{
posx = e.pageX;
posy = e.pageY;
}
else if (e.clientX || e.clientY)
{
posx = e.clientX+document.body.scrollLeft+document.documentElement.scrollLeft;
posy = e.clientY+document.body.scrollTop+document.documentElement.scrollTop;
}
$('#contextMenu').html(buildMenuLevel(list)).css({
top: posy+'px',
left: posx+'px'
}).show().openDropDownMenu();
// Listener
$(document).bind('click', closeContextMenu);
// Prevent browser menu
return false;
}
};
/*
* Simple functions for closing menu
*/
function closeContextMenu()
{
$('#contextMenu').empty().hide();
removeBinding();
};
function removeBinding()
{
$(document).unbind('click', closeContextMenu);
};
// Insert menu element
$(document).ready(function()
{
$(document.body).append('<div id="contextMenu" class="menu"></div>');
});
/**
* Builds a level of the menu (recursive function)
* @param array list the menu elements list
*/
function buildMenuLevel(list)
{
var html = '<ul>';
var defaults = {
text: 'Link',
alt: '',
link: '',
subs: [],
icon: ''
};
for (var element in list)
{
// If separation
if (typeof(list[element]) != 'object')
{
html += '<li class="sep"></li>';
}
else
{
var el = $.extend({}, defaults, list[element]);
var alt = (el.alt.length > 0) ? ' title="'+el.alt+'"' : '';
var icon = (el.icon.length > 0) ? ' class="icon_'+el.icon+'"' : '';
if (el.link.length > 0)
{
var opener = 'a href="'+el.link+'"';
var closer = 'a';
}
else
{
var opener = 'span';
var closer = 'span';
}
// Opening
html += '<li'+icon+'><'+opener+alt+'>'+el.text+'</'+closer+'>';
// If sub menus
if (typeof(el.subs) == 'object' && el.subs.length > 0)
{
html += buildMenuLevel(el.subs);
}
// Close
html += '</li>';
}
}
return html+'</ul>';
};
})(jQuery);
|
JavaScript
|
/**
* Template JS for standard pages
*/
(function($)
{
// Standard template setup
$.fn.addTemplateSetup(function()
{
// Mini menu
this.find('.mini-menu').css({opacity:0}).parent().hover(function()
{
$(this).children('.mini-menu').stop(true).animate({opacity:1});
}, function()
{
$(this).children('.mini-menu').css('display', 'block').stop(true).animate({opacity:0}, {'complete': function() { $(this).css('display', ''); }});
});
// CSS Menu improvement
this.find('.menu, .menu li:has(ul)').hover(function()
{
$(this).openDropDownMenu();
}, function()
{
// Remove in case of future window resizing
$(this).children('ul').removeClass('reverted');
});
// Scroll top button
$('a[href="#top"]').click(function(event)
{
event.preventDefault();
$('html, body').animate({scrollTop:0});
});
});
// Close buttons
$('.close-bt').live('click', function()
{
$(this).parent().fadeAndRemove();
});
// Document initial setup
$(document).ready(function()
{
// Notifications blocks
var notifications = $('<ul id="notifications"></ul>').appendTo(document.body);
var notificationsTop = parseInt(notifications.css('top'));
// If it is a standard page
if (!$(document.body).hasClass('special-page'))
{
// Main nav - click style
$('nav > ul > li').click(function(event) {
// If not already active and has sub-menu
if (!$(this).hasClass('current') && $(this).find('ul li').length > 0)
{
$(this).addClass('current').siblings().removeClass('current');
$('nav > ul > li').refreshTip();
event.preventDefault();
}
}).tip({
stickIfCurrent: true,
offset: -3
});
// Main nav - hover style
/*$('nav > ul > li').hover(function() {
$(this).addClass('current').siblings().removeClass('current');
$('nav > ul > li').refreshTip();
}, function() {}).tip({
stickIfCurrent: true,
offset: -3
});*/
// Advanced search field
if ($.fn.advancedSearchField)
{
$('#s').advancedSearchField();
}
// Status bar buttons : drop-downs fade In/Out
function convertDropLists()
{
$(this).find('.result-block .small-files-list').accessibleList({moreAfter:false});
// Run only once
$(this).unbind('mouseenter', convertDropLists);
}
$('#status-infos li:has(.result-block)').hover(function()
{
$(this).find('.result-block').stop(true).css('display', 'none').fadeIn('normal', function()
{
$(this).css('opacity', '');
});
}, function()
{
$(this).find('.result-block').stop(true).css('display', 'block').fadeOut('normal', function()
{
$(this).css('opacity', '');
});
}).bind('mouseenter', convertDropLists);
// Fixed control bar
var controlBar = $('#control-bar');
if (controlBar.length > 0)
{
var cbPlaceHolder = controlBar.after('<div id="cb-place-holder" style="height:'+controlBar.outerHeight()+'px"></div>').next();
// Effect
controlBar.hover(function()
{
if ($(this).hasClass('fixed'))
{
$(this).stop(true).fadeTo('fast', 1);
}
}, function()
{
if ($(this).hasClass('fixed'))
{
$(this).stop(true).fadeTo('slow', 0.5);
}
});
// Listener
$(window).scroll(function()
{
// Check top position
var controlBarPos = controlBar.hasClass('fixed') ? cbPlaceHolder.offset().top : controlBar.offset().top;
if ($(window).scrollTop() > controlBarPos)
{
if (!controlBar.hasClass('fixed'))
{
cbPlaceHolder.height(controlBar.outerHeight()).show();
controlBar.addClass('fixed').stop(true).fadeTo('slow', 0.5);
// Notifications
$('#notifications').animate({'top': controlBar.outerHeight()+notificationsTop});
}
}
else
{
if (controlBar.hasClass('fixed'))
{
cbPlaceHolder.hide();
controlBar.removeClass('fixed').stop(true).fadeTo('fast', 1, function()
{
// Required for IE
$(this).css('filter', '');
});
// Notifications
$('#notifications').animate({'top': notificationsTop});
}
}
}).trigger('scroll');
}
}
});
/**
* Internal function to open drop-down menus, required for context menu
*/
$.fn.openDropDownMenu = function()
{
var ul = this.children('ul');
// Position check
if (ul.offset().left+ul.outerWidth()-$(window).scrollLeft() > $(window).width())
{
ul.addClass('reverted');
}
// Effect - IE < 9 uses filter for opacity, cutting out sub-menus
if (!$.browser.msie || $.browser.version > 8)
{
ul.stop(true).css({opacity:0}).animate({opacity:1});
}
};
})(jQuery);
/**
* Display a notification. If the page is not yet ready, delay the notification until it is ready.
* @var string message a text or html message to display
* @var object options an object with any options for the message - optional
* - closeButton: true to add a close button to the message (default: true)
* - autoClose: true to close message after (closeDelay) ms (default: true)
* - closeDelay: delay before message close (default: 8000)
*/
var notify = function(message, options)
{
var block = jQuery('#notifications');
// If ready
if (block.length > 0)
{
var settings = jQuery.extend({}, notify.defaults, options);
// Append message
var closeButton = settings.closeButton ? '<span class="close-bt"></span>' : '';
var element = jQuery('#notifications').append('<li>'+message+closeButton+'</li>').children(':last-child');
// Effect
element.expand();
// If closing
if (settings.autoClose)
{
// Timer
var timeoutId = setTimeout(function() { element.fadeAndRemove(); }, settings.closeDelay);
// Prevent closing when hover
element.hover(function()
{
clearTimeout(timeoutId);
}, function()
{
timeoutId = setTimeout(function() { element.fadeAndRemove(); }, settings.closeDelay);
});
}
}
else
{
// Not ready, delay action
setTimeout(function() { notify(message, options); }, 40);
}
};
// Defaults values for the notify method
notify.defaults = {
closeButton: true, // Add a close button to the message
autoClose: true, // Message will close after (closeDelay) ms
closeDelay: 8000 // Delay before message closes
};
|
JavaScript
|
function formataData(data){
dia = data.getDate();
mes = data.getMonth()+1;
mes = new String(mes);
if(mes.length < 2) mes = "0"+mes;
ano = data.getFullYear();
return dia+"/"+mes+"/"+ano;
}
function abrirModalSimples(conteudo, titulo){
$.modal({
content: conteudo,
title: titulo,
maxWidth: 500,
buttons: {
'Fechar': function(win) {win.closeModal();}
}
});
}
function abrirModalConfirmacao(url){
$.modal({
content: 'Deseja Realmente Realizar Essa Operação?',
title: 'Confirmação',
maxWidth: 500,
buttons: {
'Sim': function() {window.location.href = url},
'Não': function(win) {win.closeModal();}
}
});
}
function abrirModalCarregando(conteudo){
return $.modal({
content: '<img src="include/images/ajax-loader.gif"/> '+conteudo,
title: 'Carregango',
maxWidth: 500,
closeButton : false
});
}
function getEndereco() {
if($.trim($("#cepEnd").val()) != ""){
var winModal = abrirModalCarregando('Carregando Endereço...');
$.getScript("http://cep.republicavirtual.com.br/web_cep.php?formato=javascript&cep="+$("#cepEnd").val(), function(){
if(resultadoCEP["resultado"] > 0){
// troca o valor dos elementos
$("#logradouroEnd").val(unescape(resultadoCEP["tipo_logradouro"])+" "+unescape(resultadoCEP["logradouro"]));
$("#bairroEnd").val(unescape(resultadoCEP["bairro"]));
$("#cidadeEnd").val(unescape(resultadoCEP["cidade"]));
$("#estadoEnd").val(unescape(resultadoCEP["uf"]));
}else{
abrirModalSimples('Endereço não encontrado!!!','');
winModal.closeModal();
}
winModal.closeModal();
});
}
}
function limitarCampo(campo, limite, campoContador){
$("#"+campo).keyup(function(){
var tamanho = $(this).val().length;
if(tamanho > limite)
tamanho -= 1;
var count = limite - tamanho;
if(count <= 0)
count = 0;
$("#"+campoContador).text(count);
if(tamanho >= limite){
$(this).val($(this).val().substring(0, limite));
}
})
}
|
JavaScript
|
/**
* Functions required for the template documentation
*/
$('a[href^="content/"]').live('click', function(event)
{
event.preventDefault();
var href = $(this).attr('href');
// Load content
$('#content').load(href, '', function(responseText, textStatus, XMLHttpRequest)
{
$(this).applyTemplateSetup().buildTableOfContent();
});
window.location.hash = '#'+href;
// Get nav link
var a = $('#menu a[href="'+href+'"]');
if (a.length > 0)
{
// Mark as current
$('#menu a').removeClass('current');
a.addClass('current');
// Update breadcrumb
var breadcrumb = $('#breadcrumb').empty();
while (a.length > 0)
{
if (a.get(0).nodeName.toUpperCase() == 'A')
{
var target = a;
}
else
{
var target = a.parent().find('a:first');
}
breadcrumb.prepend('<li><a href="'+target.attr('href')+'">'+a.html()+'</a></li>');
// Check if opened
var li = a.parent();
if (li.hasClass('closed'))
{
li.removeClass('closed');
}
a = li.parent().parent().children('a, span');
}
}
});
// Function for building table of content
$.fn.buildTableOfContent = function()
{
var h2 = this.find('h2');
if (h2.length > 0)
{
var h1 = this.find('h1:first');
if (h1.length == 0)
{
h1 = this.prepend('<h1>Help</h1>').children(':first');
}
var menu = h1.wrap('<div class="h1 with-menu"></div>')
.after('<div class="menu"><img src="images/menu-open-arrow.png" width="16" height="16"><ul></ul></div>')
.next().children('ul');
h2.each(function(i)
{
this.id = 'step'+i;
menu.append('<li class="icon_down"><a href="#step'+i+'">'+$(this).html()+'</a></li>');
});
menu.find('a').click(function(event)
{
event.preventDefault();
$('html, body').animate({scrollTop: $($(this).attr('href')).offset().top });
});
}
return this;
};
// Initial page
$(document).ready(function()
{
var hash = $.trim(window.location.hash || '');
if (hash.length < 2)
{
$('#home a').click();
}
else
{
hash = hash.substring(1);
var a = $('a[href="'+hash+'"]');
if (a.length > 0)
{
a.click();
}
else
{
$('#home a').click();
}
}
// Enable back/next buttons
$(window).bind('hashchange', function()
{
var hash = $.trim(window.location.hash || '');
if (hash.length > 1)
{
hash = hash.substring(1);
var a = $('a[href="'+hash+'"]');
if (a.length > 0 && !a.hasClass('current'))
{
a.click();
}
}
});
});
|
JavaScript
|
/**
* Modal window extension
*/
(function($)
{
/**
* Opens a new modal window
* @param object options an object with any of the following options
* @return object the jQuery object of the new window
*/
$.modal = function(options)
{
var settings = $.extend({}, $.modal.defaults, options),
root = getModalDiv(),
// Vars for resizeFunc and moveFunc
winX = 0,
winY = 0,
contentWidth = 0,
contentHeight = 0,
mouseX = 0,
mouseY = 0,
resized;
// Get contents
var content = '';
var contentObj;
if (settings.content)
{
if (typeof(settings.content) == 'string')
{
content = settings.content;
}
else
{
contentObj = settings.content.clone(true).show();
}
}
else
{
// No content
content = '';
}
// Title
var titleClass = settings.title ? '' : ' no-title';
var title = settings.title ? '<h1>'+settings.title+'</h1>' : '';
// Content size
var sizeParts = new Array();
sizeParts.push('min-width:'+settings.minWidth+'px;');
sizeParts.push('min-height:'+settings.minHeight+'px;');
if (settings.width)
{
sizeParts.push('width:'+settings.width+'px; ');
}
if (settings.height)
{
sizeParts.push('height:'+settings.height+'px; ');
}
if (settings.maxWidth)
{
sizeParts.push('max-width:'+settings.maxWidth+'px; ');
}
if (settings.maxHeight)
{
sizeParts.push('max-height:'+settings.maxHeight+'px; ');
}
var contentStyle = (sizeParts.length > 0) ? ' style="'+sizeParts.join(' ')+'"' : '';
// Borders
var borderOpen = settings.border ? '"><div class="block-content'+titleClass : titleClass;
var borderClose = settings.border ? '></div' : '';
// Scrolling
var scrollClass = settings.scrolling ? ' modal-scroll' : '';
// Insert window
var win = $('<div class="modal-window block-border'+borderOpen+'">'+title+'<div class="modal-content'+scrollClass+'"'+contentStyle+'>'+content+'</div></div'+borderClose+'>').appendTo(root);
var contentDiv = win.find('.modal-content');
if (contentObj)
{
contentObj.appendTo(contentDiv);
}
// If resizable
if (settings.resizable && settings.border)
{
// Custom function (to use correct var scope)
var resizeFunc = function(event)
{
// Mouse offset
var offsetX = event.pageX-mouseX,
offsetY = event.pageY-mouseY,
// New size
newWidth = Math.max(settings.minWidth, contentWidth+(resized.width*offsetX)),
newHeight = Math.max(settings.minHeight, contentHeight+(resized.height*offsetY)),
// Position correction
correctX = 0,
correctY = 0;
// If max sizes are defined
if (settings.maxWidth && newWidth > settings.maxWidth)
{
correctX = newWidth-settings.maxWidth;
newWidth = settings.maxWidth;
}
if (settings.maxHeight && newHeight > settings.maxHeight)
{
correctY = newHeight-settings.maxHeight;
newHeight = settings.maxHeight;
}
contentDiv.css({
width: newWidth+'px',
height: newHeight+'px'
});
win.css({
left: (winX+(resized.left*(offsetX+correctX)))+'px',
top: (winY+(resized.top*(offsetY+correctY)))+'px'
});
};
// Create resize handlers
$('<div class="modal-resize-tl"></div>').appendTo(win).data('modal-resize', {
top: 1, left: 1,
height: -1, width: -1
}).add(
$('<div class="modal-resize-t"></div>').appendTo(win).data('modal-resize', {
top: 1, left: 0,
height: -1, width: 0
})
).add(
$('<div class="modal-resize-tr"></div>').appendTo(win).data('modal-resize', {
top: 1, left: 0,
height: -1, width: 1
})
).add(
$('<div class="modal-resize-r"></div>').appendTo(win).data('modal-resize', {
top: 0, left: 0,
height: 0, width: 1
})
).add(
$('<div class="modal-resize-br"></div>').appendTo(win).data('modal-resize', {
top: 0, left: 0,
height: 1, width: 1
})
).add(
$('<div class="modal-resize-b"></div>').appendTo(win).data('modal-resize', {
top: 0, left: 0,
height: 1, width: 0
})
).add(
$('<div class="modal-resize-bl"></div>').appendTo(win).data('modal-resize', {
top: 0, left: 1,
height: 1, width: -1
})
).add(
$('<div class="modal-resize-l"></div>').appendTo(win).data('modal-resize', {
top: 0, left: 1,
height: 0, width: -1
})
).mousedown(function(event)
{
// Detect positions
contentWidth = contentDiv.width();
contentHeight = contentDiv.height();
var position = win.position();
winX = position.left;
winY = position.top;
mouseX = event.pageX;
mouseY = event.pageY;
resized = $(this).data('modal-resize');
// Prevent text selection
document.onselectstart = function () { return false; };
$(document).bind('mousemove', resizeFunc);
})
root.mouseup(function()
{
$(document).unbind('mousemove', resizeFunc);
// Restore text selection
document.onselectstart = null;
});
}
// Put in front
win.mousedown(function()
{
$(this).putModalOnFront();
});
// If movable
if (settings.draggable && title)
{
// Custom functions (to use correct var scope)
var moveFunc = function(event)
{
// Window and document sizes
var width = win.outerWidth(),
height = win.outerHeight();
// New position
win.css({
left: Math.max(0, Math.min(winX+(event.pageX-mouseX), $(root).width()-width))+'px',
top: Math.max(0, Math.min(winY+(event.pageY-mouseY), $(root).height()-height))+'px'
});
};
// Listeners
win.find('h1:first').mousedown(function(event)
{
// Detect positions
var position = win.position();
winX = position.left;
winY = position.top;
mouseX = event.pageX;
mouseY = event.pageY;
// Prevent text selection
document.onselectstart = function () { return false; };
$(document).bind('mousemove', moveFunc);
})
root.mouseup(function()
{
$(document).unbind('mousemove', moveFunc);
// Restore text selection
document.onselectstart = null;
});
}
// Close button
if (settings.closeButton)
{
$('<ul class="action-tabs right"><li><a href="#" title="Fechar"><img src="include/images/icons/fugue/cross-circle.png" width="16" height="16"></a></li></ul>')
.prependTo(win)
.find('a').click(function(event)
{
event.preventDefault();
$(this).closest('.modal-window').closeModal();
});
}
// Bottom buttons
var buttonsFooter = false;
$.each(settings.buttons, function(key, value)
{
// Button zone
if (!buttonsFooter)
{
buttonsFooter = $('<div class="block-footer align-'+settings.buttonsAlign+'"></div>').insertAfter(contentDiv);
}
else
{
// Spacing
buttonsFooter.append(' ');
}
$('<button type="button">'+key+'</button>').appendTo(buttonsFooter).click(function(event)
{
value.call(this, $(this).closest('.modal-window'), event);
});
});
// Close function
if (settings.onClose)
{
win.bind('closeModal', settings.onClose);
}
// Apply template setup
win.applyTemplateSetup();
// Effect
if (!root.is(':visible'))
{
win.hide();
root.fadeIn('normal', function()
{
win.show().centerModal();
});
}
else
{
win.centerModal();
}
// Store as current
$.modal.current = win;
$.modal.all = root.children('.modal-window');
// Callback
if (settings.onOpen)
{
settings.onOpen.call(win.get(0));
}
// If content url
if (settings.url)
{
win.loadModalContent(settings.url, settings);
}
return win;
};
/**
* Shortcut to the current window
* @var jQuery|boolean
*/
$.modal.current = false;
/**
* jQuery selection of all opened modal windows
* @var jQuery
*/
$.modal.all = $();
/**
* Wraps the selected elements content in a new modal window
* @param object options same as $.modal()
* @return jQuery the new windows
*/
$.fn.modal = function(options)
{
var modals = $();
this.each(function()
{
modals.add($.modal($.extend({}, $.modal.defaults, {content: $(this).clone(true).show()})));
});
return modals;
};
/**
* Use this method to retrieve the content div in the modal window
*/
$.fn.getModalContentBlock = function()
{
return this.find('.modal-content');
}
/**
* Use this method to retrieve the modal window from any element within it
*/
$.fn.getModalWindow = function()
{
return this.closest('.modal-window');
}
/**
* Set window content
* @param string|jQuery content the content to put: HTML or a jQuery object
* @param boolean resize use true to resize window to fit content (height only)
*/
$.fn.setModalContent = function(content, resize)
{
this.each(function()
{
var contentBlock = $(this).getModalContentBlock();
// Set content
if (typeof(content) == 'string')
{
contentBlock.html(content);
}
else
{
content.clone(true).show().appendTo(contentBlock);
}
contentBlock.applyTemplateSetup();
// Resizing
if (resize)
{
contentBlock.setModalContentSize(true, false);
}
});
return this;
}
/**
* Set window content-block size
* @param int|boolean width the width to set, true to keep current or false for fluid width
* @param int|boolean height the height to set, true to keep current or false for fluid height
*/
$.fn.setModalContentSize = function(width, height)
{
this.each(function()
{
var contentBlock = $(this).getModalContentBlock();
// Resizing
if (width !== true)
{
contentBlock.css('width', width ? width+'px' : '');
}
if (height !== true)
{
contentBlock.css('height', height ? height+'px' : '');
}
});
return this;
}
/**
* Load AJAX content
* @param string url the content url
* @param object options an object with any of the following options:
* - string loadingMessage any message to display while loading (may contain HTML), or leave empty to keep current content
* - string|object data a map or string that is sent to the server with the request (same as jQuery.load())
* - function complete a callback function that is executed when the request completes. (same as jQuery.load())
* - boolean resize use true to resize window on loading message and when content is loaded. To define separately, use options below:
* - boolean resizeOnMessage use true to resize window on loading message
* - boolean resizeOnLoad use true to resize window when content is loaded
*/
$.fn.loadModalContent = function(url, options)
{
var settings = $.extend({
loadingMessage: '',
data: {},
complete: function(responseText, textStatus, XMLHttpRequest) {},
resize: true,
resizeOnMessage: false,
resizeOnLoad: false
}, options)
this.each(function()
{
var win = $(this),
contentBlock = win.getModalContentBlock();
// If loading message
if (settings.loadingMessage)
{
win.setModalContent('<div class="modal-loading">'+settings.loadingMessage+'</div>', (settings.resize || settings.resizeOnMessage));
}
contentBlock.load(url, settings.data, function(responseText, textStatus, XMLHttpRequest)
{
// Template functions
contentBlock.applyTemplateSetup();
if (settings.resize || settings.resizeOnLoad)
{
contentBlock.setModalContentSize(true, false);
}
// Callback
settings.complete.call(this, responseText, textStatus, XMLHttpRequest);
});
});
return this;
}
/**
* Set modal title
* @param string newTitle the new title (may contain HTML), or an empty string to remove the title
*/
$.fn.setModalTitle = function(newTitle)
{
this.each(function()
{
var win = $(this),
title = $(this).find('h1'),
contentBlock = win.hasClass('block-content') ? win : win.children('.block-content:first');
if (newTitle.length > 0)
{
if (title.length == 0)
{
contentBlock.removeClass('no-title');
title = $('<h1>'+newTitle+'</h1>').prependTo(contentBlock);
}
title.html(newTitle);
}
else if (title.length > 0)
{
title.remove();
contentBlock.addClass('no-title');
}
});
return this;
}
/**
* Center the window
* @param boolean animate true to animate the window movement
*/
$.fn.centerModal = function(animate)
{
var root = getModalDiv(),
rootW = root.width()/2,
rootH = root.height()/2;
this.each(function()
{
var win = $(this),
winW = Math.round(win.outerWidth()/2),
winH = Math.round(win.outerHeight()/2);
win[animate ? 'animate' : 'css']({
left: (rootW-winW)+'px',
top: (rootH-winH)+'px'
});
});
return this;
};
/**
* Put modal on front
*/
$.fn.putModalOnFront = function()
{
if ($.modal.all.length > 1)
{
var root = getModalDiv();
this.each(function()
{
if ($(this).next('.modal-window').length > 0)
{
$(this).detach().appendTo(root);
}
});
}
return this;
};
/**
* Closes the window
*/
$.fn.closeModal = function()
{
this.each(function()
{
var event = $.Event('closeModal'),
win = $(this);
// Events on close
win.trigger(event);
if (!event.isDefaultPrevented())
{
win.remove();
// Modal root element
var root = getModalDiv();
$.modal.all = root.children('.modal-window');
if ($.modal.all.length == 0)
{
$.modal.current = false;
root.fadeOut('normal');
}
else
{
// Refresh current
$.modal.current = $.modal.all.last();
}
}
});
return this;
};
/**
* New modal window options
*/
$.modal.defaults = {
/**
* Content of the window: HTML or jQuery object
* @var string|jQuery
*/
content: false,
/**
* Url for loading content
* @var string|boolean
*/
url: false,
/**
* Title of the window, or false for none
* @var string|boolean
*/
title: false,
/**
* Add glass-like border to the window (required to enable resizing)
* @var boolean
*/
border: true,
/**
* Enable window moving (only work if title is defined)
* @var boolean
*/
draggable: true,
/**
* Enable window resizing (only work if border is true)
* @var boolean
*/
resizable: true,
/**
* If true, enable content vertical scrollbar if content is higher than 'height' (or 'maxHeight' if 'height' is undefined)
* @var boolean
*/
scrolling: true,
/**
* Wether or not to display the close window button
* @var boolean
*/
closeButton: true,
/**
* Map of bottom buttons, with text as key and function on click as value
* Ex: {'Close' : function(win) { win.closeModal(); } }
* @var object
*/
buttons: {},
/**
* Alignement of buttons ('left', 'center' or 'right')
* @var string
*/
buttonsAlign: 'right',
/**
* Function called when opening window
* @var function
*/
onOpen: false,
/**
* Function called when closing window. It may return false or call event.preventDefault() to prevent closing
* @var function
*/
onClose: false,
/**
* Minimum content height
* @var int
*/
minHeight: 40,
/**
* Minimum content width
* @var int
*/
minWidth: 200,
/**
* Maximum content width, or false for no limit
* @var int|boolean
*/
maxHeight: false,
/**
* Maximum content height, or false for no limit
* @var int|boolean
*/
maxWidth: false,
/**
* Initial content height, or false for fluid size
* @var int|boolean
*/
height: false,
/**
* Initial content width, or false for fluid size
* @var int|boolean
*/
width: 450,
/**
* If AJAX load only - loading message, or false for none (can be HTML)
* @var string|boolean
*/
loadingMessage: 'Loading...',
/**
* If AJAX load only - data a map or string that is sent to the server with the request (same as jQuery.load())
* @var string|object
*/
data: {},
/**
* If AJAX load only - a callback function that is executed when the request completes. (same as jQuery.load())
* @var function
*/
complete: function(responseText, textStatus, XMLHttpRequest) {},
/**
* If AJAX load only - true to resize window on loading message and when content is loaded. To define separately, use options below.
* @var boolean
*/
resize: true,
/**
* If AJAX load only - use true to resize window on loading message
* @var boolean
*/
resizeOnMessage: false,
/**
* If AJAX load only - use true to resize window when content is loaded
* @var boolean
*/
resizeOnLoad: false
};
/**
* Return the modal windows root div
*/
function getModalDiv()
{
var modal = $('#modal');
if (modal.length == 0)
{
$(document.body).append('<div id="modal"></div>');
modal = $('#modal').hide();
}
return modal;
};
})(jQuery);
|
JavaScript
|
/**
* Older browsers detection
*/
(function($)
{
// Change these values to fit your needs
if (
($.browser.msie && parseFloat($.browser.version) < 7) || // IE 6 and lower
($.browser.mozilla && parseFloat($.browser.version) < 1.9) || // Firefox 2 and lower
($.browser.opera && parseFloat($.browser.version) < 9) || // Opera 8 and lower
($.browser.webkit && parseInt($.browser.version) < 400) // Older Chrome and Safari
) {
// If no cookie has been set
if (getCookie('forceAccess') !== 'yes')
{
// If coming back from the old browsers page
if (window.location.search.indexOf('forceAccess=yes') > -1)
{
// Mark for future tests
setCookie('forceAccess', 'yes');
}
else
{
document.location.href = 'old-browsers.html?redirect='+escape(document.location.href);
}
}
}
/**
* Get cookie params
* @return object an object with every params in the cookie
*/
function getCookieParams()
{
var parts = document.cookie.split(/; */g);
var params = {};
for (var i = 0; i < parts.length; ++i)
{
var part = parts[i];
if (part)
{
var equal = part.indexOf('=');
if (equal > -1)
{
var param = part.substr(0, equal);
var value = unescape(part.substring(equal+1));
params[param] = value;
}
}
}
return params;
}
/**
* Get a cookie value
* @param string name the cookie name
* @return string the value, or null if not defined
*/
function getCookie(name)
{
var params = getCookieParams();
return params[name] || null;
}
/**
* Write a cookie value
* @param string name the cookie name
* @param string value the value
* @param int days number of days for cookie life
* @return void
*/
function setCookie(name, value, days)
{
var params = getCookieParams();
params[name] = value;
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
params.expires = date.toGMTString();
}
var cookie = [];
for (var thevar in params)
{
cookie.push(thevar+'='+escape(params[thevar]));
}
document.cookie = cookie.join('; ');
}
})(jQuery);
|
JavaScript
|
/**
* Lists generic controls
*/
(function($)
{
// List styles setup
$.fn.addTemplateSetup(function()
{
// Closed elements
this.find('.close').toggleBranchOpen().removeClass('close');
// :first-of-type is buggy with jQuery under IE
this.find('dl.accordion dt:first-child + dd').siblings('dd').hide();
// Tasks dialog
if (!$.browser.msie || $.browser.version > 8) // IE is buggy on this animation
{
this.find('.task-dialog').parent().hover(function()
{
$(this).find('.task-dialog > li.auto-hide').expand();
}, function()
{
$(this).find('.task-dialog > li.auto-hide').fold();
});
}
// Arbo elements controls
this.find('.arbo .toggle, .collapsible-list li:has(ul) > :first-child, .collapsible-list li:has(ul) > :first-child + span').click(function(event)
{
// Toggle style
$(this).toggleBranchOpen();
// Prevent link action
if (this.nodeName.toLowerCase() == 'a')
{
event.preventDefault();
}
});
// Accordions effect
this.find('dl.accordion dt').click(function()
{
$(this).next('dd').slideDown().siblings('dd').slideUp().prev('dt');
// Effect need for rounded corners
$(this).addClass('opened').siblings('dt').removeClass('opened');
});
}, true);
/**
* Open/close branch
*/
$.fn.toggleBranchOpen = function()
{
this.each(function()
{
/*
* Tip: if you want to add animation or do anything that should not occur at startup closing,
* check if the element has the class 'close':
* if (!$(this).hasClass('close')) { // Anything that sould no occur at startup }
*/
// Change
$(this).closest('li').toggleClass('closed');
});
return this;
};
})(jQuery);
|
JavaScript
|
// Create new HTML5 elements ===================================================
// -----------------------------------------------------------------------------
// This script should load before any others. We want the new elements to be
// parsed before pretty much anything happens.
// Plus, IE does not behave otherwise. The cost of being progressive...
// -----------------------------------------------------------------------------
// Credits : http://sickdesigner.com/index.php/2010/html-css/html5-starter-pack-a-sick-freebie/
document.createElement("article");
document.createElement("aside");
document.createElement("audio");
document.createElement("canvas");
document.createElement("command");
document.createElement("datalist");
document.createElement("details");
document.createElement("embed");
document.createElement("figcaption");
document.createElement("figure");
document.createElement("footer");
document.createElement("header");
document.createElement("hgroup");
document.createElement("keygen");
document.createElement("mark");
document.createElement("meter");
document.createElement("nav");
document.createElement("output");
document.createElement("progress");
document.createElement("rp");
document.createElement("rt");
document.createElement("ruby");
document.createElement("section");
document.createElement("source");
document.createElement("summary");
document.createElement("time");
document.createElement("video");
|
JavaScript
|
/**
* Template JS for standard pages
*/
(function($)
{
/**
* List of functions required to enable template effects/hacks
* @var array
*/
var templateSetup = new Array();
/**
* Add a new template function
* @param function func the function to be called on a jQuery object
* @param boolean prioritary set to true to call the function before all others (optional)
* @return void
*/
$.fn.addTemplateSetup = function(func, prioritary)
{
if (prioritary)
{
templateSetup.unshift(func);
}
else
{
templateSetup.push(func);
}
};
/**
* Call every template function over a jQuery object (for instance : $('body').applyTemplateSetup())
* @return void
*/
$.fn.applyTemplateSetup = function()
{
var max = templateSetup.length;
for (var i = 0; i < max; ++i)
{
templateSetup[i].apply(this);
}
return this;
};
// Common (mobile and standard) template setup
$.fn.addTemplateSetup(function()
{
// Collapsible fieldsets
this.find('fieldset legend > a, .fieldset .legend > a').click(function(event)
{
$(this).toggleFieldsetOpen();
event.preventDefault();
});
this.find('fieldset.collapse, .fieldset.collapse').toggleFieldsetOpen().removeClass('collapse');
// Equalize tab content-blocks heights
this.find('.tabs.same-height, .side-tabs.same-height, .mini-tabs.same-height, .controls-tabs.same-height').equalizeTabContentHeight();
// Update tabs
this.find('.js-tabs').updateTabs();
// Input switches
this.find('input[type=radio].switch, input[type=checkbox].switch').hide().after('<span class="switch-replace"></span>').next().click(function() {
$(this).prev().click();
}).prev('.with-tip').next().addClass('with-tip').each(function()
{
$(this).attr('title', $(this).prev().attr('title'));
});
this.find('input[type=radio].mini-switch, input[type=checkbox].mini-switch').hide().after('<span class="mini-switch-replace"></span>').next().click(function() {
$(this).prev().click();
}).prev('.with-tip').next().addClass('with-tip').each(function()
{
$(this).attr('title', $(this).prev().attr('title'));
});
// Tabs links behaviour
this.find('.js-tabs a[href^="#"]').click(function(event)
{
event.preventDefault();
// If hashtag enabled
if ($.fn.updateTabs.enabledHash)
{
// Retrieve hash parts
var element = $(this);
var hash = $.trim(window.location.hash || '');
if (hash.length > 1)
{
// Remove hash from other tabs of the group
var hashParts = hash.substring(1).split('&');
var dummyIndex;
while ((dummyIndex = $.inArray('', hashParts)) > -1)
{
hashParts.splice(dummyIndex, 1);
}
while ((dummyIndex = $.inArray('none', hashParts)) > -1)
{
hashParts.splice(dummyIndex, 1);
}
element.parent().parent().find('a[href^="#"]').each(function(i)
{
var index = $.inArray($(this).attr('href').substring(1), hashParts);
if (index > -1)
{
hashParts.splice(index, 1);
}
});
}
else
{
var hashParts = [];
}
// Add current tab to hash (not if default)
var defaultTab = getDefaultTabIndex(element.parent().parent());
if (element.parent().index() != defaultTab)
{
hashParts.push(element.attr('href').substring(1));
}
// If only one tab, add a empty id to prevent document from jumping to selected content
if (hashParts.length == 1)
{
hashParts.unshift('');
}
// Put hash, will trigger refresh
window.location.hash = (hashParts.length > 0) ? '#'+hashParts.join('&') : '#none';
}
else
{
var li = $(this).closest('li');
li.addClass('current').siblings().removeClass('current');
li.parent().updateTabs();
}
});
});
// Document initial setup
$(document).ready(function()
{
// Template setup
$(document.body).applyTemplateSetup();
// Listener
$(window).bind('hashchange', function()
{
$(document.body).find('.js-tabs').updateTabs();
});
});
/**
* Get tab group default tab
*/
function getDefaultTabIndex(tabGroup)
{
var defaultTab = tabGroup.data('defaultTab');
if (defaultTab === null || defaultTab === '' || defaultTab === undefined)
{
var firstTab = tabGroup.children('.current:first');
defaultTab = (firstTab.length > 0) ? firstTab.index() : 0;
tabGroup.data('defaultTab', defaultTab);
}
return defaultTab;
};
/**
* Update tabs
*/
$.fn.updateTabs = function()
{
// If hashtags enabled
if ($.fn.updateTabs.enabledHash)
{
var hash = $.trim(window.location.hash || '');
var hashParts = (hash.length > 1) ? hash.substring(1).split('&') : [];
}
else
{
var hash = '';
var hashParts = [];
}
// Check all tabs
var hasHash = (hashParts.length > 0);
this.each(function(i)
{
// Check if already inited
var tabGroup = $(this);
var defaultTab = getDefaultTabIndex(tabGroup);
// Look for current tab
var current = false;
if ($.fn.updateTabs.enabledHash)
{
if (hasHash)
{
var links = tabGroup.find('a[href^="#"]');
links.each(function(i)
{
var linkHash = $(this).attr('href').substring(1);
if (linkHash.length > 0)
{
var index = $.inArray(linkHash, hashParts);
if (index > -1)
{
current = $(this).parent();
return false;
}
}
});
}
}
else
{
current = tabGroup.children('.current:first');
}
// If none found : get the default tab
if (!current)
{
current = tabGroup.children(':eq('+defaultTab+')');
}
if (current.length > 0)
{
// Display current tab content block
hash = $.trim(current.children('a').attr('href').substring(1));
if (hash.length > 0)
{
// Highlight current
current.addClass('current');
var tabContainer = $('#'+hash),
tabHidden = tabContainer.is(':hidden');
// Show if hidden
if (tabHidden)
{
tabContainer.show();
}
// Hide others
current.siblings().removeClass('current').children('a').each(function(i)
{
var hash = $.trim($(this).attr('href').substring(1));
if (hash.length > 0)
{
var tabContainer = $('#'+hash);
// Hide if visible
if (tabContainer.is(':visible'))
{
tabContainer.trigger('tabhide').hide();
}
// Or init if first round
else if (!tabContainer.data('tabInited'))
{
tabContainer.trigger('tabhide');
tabContainer.data('tabInited', true);
}
}
});
// Callback
if (tabHidden)
{
tabContainer.trigger('tabshow');
}
// Or init if first round
else if (!tabContainer.data('tabInited'))
{
tabContainer.trigger('tabshow');
tabContainer.data('tabInited', true);
}
}
}
});
return this;
};
/**
* Indicate whereas JS tabs hashtag is enabled
* @var boolean
*/
$.fn.updateTabs.enabledHash = true;
/**
* Reset tab content blocks heights
*/
$.fn.resetTabContentHeight = function()
{
this.find('a[href^="#"]').each(function(i)
{
var hash = $.trim($(this).attr('href').substring(1));
if (hash.length > 0)
{
$('#'+hash).css('height', '');
}
});
return this;
}
/**
* Equalize tab content blocks heights
*/
$.fn.equalizeTabContentHeight = function()
{
var i;
var g;
var maxHeight;
var tabContainers;
var block;
var blockHeight;
var marginAdjustTop;
var marginAdjustBot;
var first;
var last;
var firstMargin;
var lastMargin;
// Process in reverse order to equalize sub-tabs first
for (i = this.length-1; i >= 0; --i)
{
// Look for max height
maxHeight = -1;
tabContainers = [];
this.eq(i).find('a[href^="#"]').each(function(i)
{
var hash = $.trim($(this).attr('href').substring(1));
if (hash.length > 0)
{
block = $('#'+hash);
if (block.length > 0)
{
blockHeight = block.outerHeight()+parseInt(block.css('margin-bottom'));
// First element top-margin affects real height
marginAdjustTop = 0;
first = block.children(':first');
if (first.length > 0)
{
firstMargin = parseInt(first.css('margin-top'));
if (!isNaN(firstMargin) && firstMargin < 0)
{
marginAdjustTop = firstMargin;
}
}
// Same for last element bottom-margin
marginAdjustBot = 0;
last = block.children(':last');
if (last.length > 0)
{
lastMargin = parseInt(last.css('margin-bottom'));
if (!isNaN(lastMargin) && lastMargin < 0)
{
marginAdjustBot = lastMargin;
}
}
if (blockHeight+marginAdjustTop+marginAdjustBot > maxHeight)
{
maxHeight = blockHeight+marginAdjustTop+marginAdjustBot;
}
tabContainers.push([block, marginAdjustTop]);
}
}
});
// Setup height
for (g = 0; g < tabContainers.length; ++g)
{
tabContainers[g][0].height(maxHeight-parseInt(tabContainers[g][0].css('padding-top'))-parseInt(tabContainers[g][0].css('padding-bottom'))-parseInt(tabContainers[g][0].css('margin-bottom'))-tabContainers[g][1]);
// Only the first tab remains visible
if (g > 0)
{
tabContainers[g][0].hide();
}
}
}
return this;
};
/**
* Display the selected tab (apply on tab content-blocks, not tabs, ie: $('#my-tab').showTab(); )
*/
$.fn.showTab = function()
{
this.each(function(i)
{
$('a[href="#'+this.id+'"]').trigger('click');
});
return this;
};
/**
* Add a listener fired when a tab is shown
* @param function callback any function to call when the listener is fired.
* @param boolean runOnce if true, the callback will be run one time only. Default: false - optional
*/
$.fn.onTabShow = function(callback, runOnce)
{
if (runOnce)
{
var runOnceFunc = function()
{
callback.apply(this, arguments);
$(this).unbind('tabshow', runOnceFunc);
}
this.bind('tabshow', runOnceFunc);
}
else
{
this.bind('tabshow', callback);
}
return this;
};
/**
* Add a listener fired when a tab is hidden
* @param function callback any function to call when the listener is fired.
* @param boolean runOnce if true, the callback will be run one time only. Default: false - optional
*/
$.fn.onTabHide = function(callback, runOnce)
{
if (runOnce)
{
var runOnceFunc = function()
{
callback.apply(this, arguments);
$(this).unbind('tabhide', runOnceFunc);
}
this.bind('tabhide', runOnceFunc);
}
else
{
this.bind('tabhide', callback);
}
return this;
};
/**
* Insert a message into a block
* @param string|array message a message, or an array of messages to inserted
* @param object options optional object with following values:
* - type: one of the available message classes : 'info' (default), 'warning', 'error', 'success', 'loading'
* - position: either 'top' (default) or 'bottom'
* - animate: true to show the message with an animation (default), else false
* - noMargin: true to apply the no-margin class to the message (default), else false
*/
$.fn.blockMessage = function(message, options)
{
var settings = $.extend({}, $.fn.blockMessage.defaults, options);
this.each(function(i)
{
// Locate content block
var block = $(this);
if (!block.hasClass('block-content'))
{
block = block.find('.block-content:first');
if (block.length == 0)
{
block = $(this).closest('.block-content');
if (block.length == 0)
{
return;
}
}
}
// Compose message
var messageClass = (settings.type == 'info') ? 'message' : 'message '+settings.type;
if (settings.noMargin)
{
messageClass += ' no-margin';
}
var finalMessage = (typeof message == 'object') ? '<ul class="'+messageClass+'"><li>'+message.join('</li><li>')+'</li></ul>' : '<p class="'+messageClass+'">'+message+'</p>';
// Insert message
if (settings.position == 'top')
{
var children = block.find('h1, .h1, .block-controls, .block-header, .wizard-steps');
if (children.length > 0)
{
var lastHeader = children.last();
var next = lastHeader.next('.message');
while (next.length > 0)
{
lastHeader = next;
next = lastHeader.next('.message');
}
var messageElement = lastHeader.after(finalMessage).next();
}
else
{
var messageElement = block.prepend(finalMessage).children(':first');
}
}
else
{
var children = block.find('.block-footer:last-child');
if (children.length > 0)
{
var messageElement = children.before(finalMessage).prev();
}
else
{
var messageElement = block.append(finalMessage).children(':last');
}
}
if (settings.animate)
{
messageElement.expand();
}
});
return this;
};
// Default config for the blockMessage function
$.fn.blockMessage.defaults = {
type: 'info',
position: 'top',
animate: true,
noMargin: true
};
/**
* Remove all messages from the block
* @param object options optional object with following values:
* - only: string or array of strings of message classes which will be removed
* - except: string or array of strings of message classes which will not be removed (ignored if 'only' is provided)
* - animate: true to remove the message with an animation (default), else false
*/
$.fn.removeBlockMessages = function(options)
{
var settings = $.extend({}, $.fn.removeBlockMessages.defaults, options);
this.each(function(i)
{
// Locate content block
var block = $(this);
if (!block.hasClass('block-content'))
{
block = block.find('.block-content:first');
if (block.length == 0)
{
block = $(this).closest('.block-content');
if (block.length == 0)
{
return;
}
}
}
var messages = block.find('.message');
if (settings.only)
{
if (typeof settings.only == 'string')
{
settings.only = [settings.only];
}
messages = messages.filter('.'+settings.only.join(', .'));
}
else if (settings.except)
{
if (typeof settings.except == 'string')
{
settings.except = [settings.except];
}
messages = messages.not('.'+settings.except.join(', .'));
}
if (settings.animate)
{
messages.foldAndRemove();
}
else
{
messages.remove();
}
});
return this;
};
// Default config for the blockMessage function
$.fn.removeBlockMessages.defaults = {
only: false, // string or array of strings of message classes which will be removed
except: false, // except: string or array of strings of message classes which will not be removed (ignored if only is provided)
animate: true // animate: true to remove the message with an animation (default), else false
};
/**
* Fold an element
* @param string|int duration a string (fast, normal or slow) or a number of millisecond. Default: 'normal'. - optional
* @param function callback any function to call at the end of the effect. Default: none. - optional
*/
$.fn.fold = function(duration, callback)
{
this.each(function(i)
{
var element = $(this);
var marginTop = parseInt(element.css('margin-top'));
var marginBottom = parseInt(element.css('margin-bottom'));
var anim = {
'height': 0,
'paddingTop': 0,
'paddingBottom': 0
};
// IE8 and lower do not understand border-xx-width
// http://forum.jquery.com/topic/ie-invalid-argument
if (!$.browser.msie || $.browser.version > 8)
{
// Border width is not set to 0 because it does not allow fluid movement
anim.borderTopWidth = '1px';
anim.borderBottomWidth = '1px';
}
// Detection of elements sticking to their predecessor
var prev = element.prev();
if (prev.length === 0 && parseInt(element.css('margin-bottom'))+marginTop !== 0)
{
anim.marginTop = Math.min(0, marginTop);
anim.marginBottom = Math.min(0, marginBottom);
}
// Effect
element.stop(true).css({
'overflow': 'hidden'
}).animate(anim, {
'duration': duration,
'complete': function()
{
// Reset properties
$(this).css({
'display': 'none',
'overflow': '',
'height': '',
'paddingTop': '',
'paddingBottom': '',
'borderTopWidth': '',
'borderBottomWidth': '',
'marginTop': '',
'marginBottom': ''
});
// Callback function
if (callback)
{
callback.apply(this);
}
}
});
});
return this;
};
/*
* Expand an element
* @param string|int duration a string (fast, normal or slow) or a number of millisecond. Default: 'normal'. - optional
* @param function callback any function to call at the end of the effect. Default: none. - optional
*/
$.fn.expand = function(duration, callback)
{
this.each(function(i)
{
// Init
var element = $(this);
element.css('display', 'block');
// Reset and get values
element.stop(true).css({
'overflow': '',
'height': '',
'paddingTop': '',
'paddingBottom': '',
'borderTopWidth': '',
'borderBottomWidth': '',
'marginTop': '',
'marginBottom': ''
});
var height = element.height();
var paddingTop = parseInt(element.css('padding-top'));
var paddingBottom = parseInt(element.css('padding-bottom'));
var marginTop = parseInt(element.css('margin-top'));
var marginBottom = parseInt(element.css('margin-bottom'));
// Initial and target values
var css = {
'overflow': 'hidden',
'height': 0,
'paddingTop': 0,
'paddingBottom': 0
};
var anim = {
'height': height,
'paddingTop': paddingTop,
'paddingBottom': paddingBottom
};
// IE8 and lower do not understand border-xx-width
// http://forum.jquery.com/topic/ie-invalid-argument
if (!$.browser.msie || $.browser.version > 8)
{
var borderTopWidth = parseInt(element.css('border-top-width'));
var borderBottomWidth = parseInt(element.css('border-bottom-width'));
// Border width is not set to 0 because it does not allow fluid movement
css.borderTopWidth = '1px';
css.borderBottomWidth = '1px';
anim.borderTopWidth = borderTopWidth;
anim.borderBottomWidth = borderBottomWidth;
}
// Detection of elements sticking to their predecessor
var prev = element.prev();
if (prev.length === 0 && parseInt(element.css('margin-bottom'))+marginTop !== 0)
{
css.marginTop = Math.min(0, marginTop);
css.marginBottom = Math.min(0, marginBottom);
anim.marginTop = marginTop;
anim.marginBottom = marginBottom;
}
// Effect
element.stop(true).css(css).animate(anim, {
'duration': duration,
'complete': function()
{
// Reset properties
$(this).css({
'display': '',
'overflow': '',
'height': '',
'paddingTop': '',
'paddingBottom': '',
'borderTopWidth': '',
'borderBottomWidth': '',
'marginTop': '',
'marginBottom': ''
});
// Callback function
if (callback)
{
callback.apply(this);
}
// Required for IE7 - don't ask me why...
if ($.browser.msie && $.browser.version < 8)
{
$(this).css('zoom', 1);
}
}
});
});
return this;
};
/**
* Remove an element with folding effect
* @param string|int duration a string (fast, normal or slow) or a number of millisecond. Default: 'normal'. - optional
* @param function callback any function to call at the end of the effect. Default: none. - optional
*/
$.fn.foldAndRemove = function(duration, callback)
{
$(this).fold(duration, function()
{
// Callback function
if (callback)
{
callback.apply(this);
}
$(this).remove();
});
return this;
}
/**
* Remove an element with fading then folding effect
* @param string|int duration a string (fast, normal or slow) or a number of millisecond. Default: 'normal'. - optional
* @param function callback any function to call at the end of the effect. Default: none. - optional
*/
$.fn.fadeAndRemove = function(duration, callback)
{
this.animate({'opacity': 0}, {
'duration': duration,
'complete': function()
{
// No folding required if the element has position: absolute (not in the elements flow)
if ($(this).css('position') == 'absolute')
{
// Callback function
if (callback)
{
callback.apply(this);
}
$(this).remove();
}
else
{
$(this).slideUp(duration, function()
{
// Callback function
if (callback)
{
callback.apply(this);
}
$(this).remove();
});
}
}
});
return this;
};
/**
* Open/close fieldsets
*/
$.fn.toggleFieldsetOpen = function()
{
this.each(function()
{
/*
* Tip: if you want to add animation or do anything that should not occur at startup closing,
* check if the element has the class 'collapse':
* if (!$(this).hasClass('collapse')) { // Anything that sould no occur at startup }
*/
// Change
$(this).closest('fieldset, .fieldset').toggleClass('collapsed');
});
return this;
};
/**
* Add a semi-transparent layer in front of an element
*/
$.fn.addEffectLayer = function(options)
{
var settings = $.extend({}, $.fn.addEffectLayer.defaults, options);
this.each(function(i)
{
var element = $(this);
// Add layer
var refElement = getNodeRefElement(this);
var layer = $('<div class="loading-mask"><span>'+settings.message+'</span></div>').insertAfter(refElement);
// Position
var elementOffset = element.position();
layer.css({
top: elementOffset.top+'px',
left: elementOffset.left+'px'
}).width(element.outerWidth()).height(element.outerHeight());
// Effect
var span = layer.children('span');
var marginTop = parseInt(span.css('margin-top'));
span.css({'opacity':0, 'marginTop':(marginTop-40)+'px'});
layer.css({'opacity':0}).animate({'opacity':1}, {
'complete': function()
{
span.animate({'opacity': 1, 'marginTop': marginTop+'px'});
}
});
});
return this;
};
/**
* Retrieve the reference element after which the layer will be inserted
* @param HTMLelement node the node on which the effect is applied
* @return HTMLelement the reference node
*/
function getNodeRefElement(node)
{
var element = $(node);
// Special case
if (node.nodeName.toLowerCase() == 'document' || node.nodeName.toLowerCase() == 'body')
{
var refElement = $(document.body).children(':last').get(0);
}
else
{
// Look for the reference element, the one after which the layer will be inserted
var refElement = node;
var offsetParent = element.offsetParent().get(0);
// List of elements in which we can add a div
var absPos = ['absolute', 'relative'];
while (refElement && refElement !== offsetParent && !$.inArray($(refElement.parentNode).css('position'), absPos))
{
refElement = refElement.parentNode;
}
}
return refElement;
}
// Default params for the loading effect layer
$.fn.addEffectLayer.defaults = {
message: 'Please wait...'
};
/**
* jQuery load() method wrapper : add a visual effect on the load() target
* Parameters are the same as load()
*/
$.fn.loadWithEffect = function()
{
// Add effect layer
this.addEffectLayer({
message: $.fn.loadWithEffect.defaults.message
});
// Rewrite callback function
var target = this;
var callback = false;
var args = $.makeArray(arguments);
var index = args.length;
if (args[2] && typeof args[2] == 'function')
{
callback = args[2];
index = 2;
}
else if (args[1] && typeof args[1] == 'function')
{
callback = args[1];
index = 1;
}
// Custom callback
args[index] = function(responseText, textStatus, XMLHttpRequest)
{
// Get the effect layer
var refElement = getNodeRefElement(this);
var layer = $(refElement).next('.loading-mask');
var span = layer.children('span');
// If success
if (textStatus == 'success' || textStatus == 'notmodified')
{
// Initial callback
if (callback)
{
callback.apply(this, arguments);
}
// Remove effect layer
layer.stop(true);
span.stop(true);
var currentMarginTop = parseInt(span.css('margin-top'));
var marginTop = parseInt(span.css('margin-top', '').css('margin-top'));
span.css({'marginTop':currentMarginTop+'px'}).animate({'opacity':0, 'marginTop':(marginTop-40)+'px'}, {
'complete': function()
{
layer.fadeAndRemove();
}
});
}
else
{
span.addClass('error').html($.fn.loadWithEffect.defaults.errorMessage+'<br><a href="#">'+$.fn.loadWithEffect.defaults.retry+'</a> / <a href="#">'+$.fn.loadWithEffect.defaults.cancel+'</a>');
span.children('a:first').click(function(event)
{
event.preventDefault();
// Relaunch request
$.fn.load.apply(target, args);
// Reset
span.removeClass('error').html($.fn.loadWithEffect.defaults.message).css('margin-left', '');
});
span.children('a:last').click(function(event)
{
event.preventDefault();
// Remove effect layer
layer.stop(true);
span.stop(true);
var currentMarginTop = parseInt(span.css('margin-top'));
var marginTop = parseInt(span.css('margin-top', '').css('margin-top'));
span.css({'marginTop':currentMarginTop+'px'}).animate({'opacity':0, 'marginTop':(marginTop-40)+'px'}, {
'complete': function()
{
layer.fadeAndRemove();
}
});
});
// Centering
span.css('margin-left', -Math.round(span.outerWidth()/2));
}
};
// Redirect to jQuery load
$.fn.load.apply(target, args);
return this;
};
// Default texts for the loading effect layer
$.fn.loadWithEffect.defaults = {
message: 'Loading...',
errorMessage: 'Error while loading',
retry: 'Retry',
cancel: 'Cancel'
};
/**
* Enable any button with workaround for IE lack of :disabled selector
*/
$.fn.enableBt = function()
{
$(this).attr('disabled', false);
if ($.browser.msie && $.browser.version < 9)
{
$(this).removeClass('disabled');
}
}
/**
* Disable any button with workaround for IE lack of :disabled selector
*/
$.fn.disableBt = function()
{
$(this).attr('disabled', true);
if ($.browser.msie && $.browser.version < 9)
{
$(this).addClass('disabled');
}
}
})(jQuery);
|
JavaScript
|
/**
* Template JS for standard pages
*/
(function($)
{
// Standard template setup
$.fn.addTemplateSetup(function()
{
// Mini menu
this.find('.mini-menu').css({opacity:0}).parent().hover(function()
{
$(this).children('.mini-menu').stop(true).animate({opacity:1});
}, function()
{
$(this).children('.mini-menu').css('display', 'block').stop(true).animate({opacity:0}, {'complete': function() { $(this).css('display', ''); }});
});
// CSS Menu improvement
this.find('.menu, .menu li:has(ul)').hover(function()
{
$(this).openDropDownMenu();
}, function()
{
// Remove in case of future window resizing
$(this).children('ul').removeClass('reverted');
});
// Scroll top button
$('a[href="#top"]').click(function(event)
{
event.preventDefault();
$('html, body').animate({scrollTop:0});
});
});
// Close buttons
$('.close-bt').live('click', function()
{
$(this).parent().fadeAndRemove();
});
// Document initial setup
$(document).ready(function()
{
// Notifications blocks
var notifications = $('<ul id="notifications"></ul>').appendTo(document.body);
var notificationsTop = parseInt(notifications.css('top'));
// If it is a standard page
if (!$(document.body).hasClass('special-page'))
{
// Main nav - click style
$('nav > ul > li').click(function(event) {
// If not already active and has sub-menu
if (!$(this).hasClass('current') && $(this).find('ul li').length > 0)
{
$(this).addClass('current').siblings().removeClass('current');
$('nav > ul > li').refreshTip();
event.preventDefault();
}
}).tip({
stickIfCurrent: true,
offset: -3
});
// Main nav - hover style
/*$('nav > ul > li').hover(function() {
$(this).addClass('current').siblings().removeClass('current');
$('nav > ul > li').refreshTip();
}, function() {}).tip({
stickIfCurrent: true,
offset: -3
});*/
// Advanced search field
if ($.fn.advancedSearchField)
{
$('#s').advancedSearchField();
}
// Status bar buttons : drop-downs fade In/Out
function convertDropLists()
{
$(this).find('.result-block .small-files-list').accessibleList({moreAfter:false});
// Run only once
$(this).unbind('mouseenter', convertDropLists);
}
$('#status-infos li:has(.result-block)').hover(function()
{
$(this).find('.result-block').stop(true).css('display', 'none').fadeIn('normal', function()
{
$(this).css('opacity', '');
});
}, function()
{
$(this).find('.result-block').stop(true).css('display', 'block').fadeOut('normal', function()
{
$(this).css('opacity', '');
});
}).bind('mouseenter', convertDropLists);
// Fixed control bar
var controlBar = $('#control-bar');
if (controlBar.length > 0)
{
var cbPlaceHolder = controlBar.after('<div id="cb-place-holder" style="height:'+controlBar.outerHeight()+'px"></div>').next();
// Effect
controlBar.hover(function()
{
if ($(this).hasClass('fixed'))
{
$(this).stop(true).fadeTo('fast', 1);
}
}, function()
{
if ($(this).hasClass('fixed'))
{
$(this).stop(true).fadeTo('slow', 0.5);
}
});
// Listener
$(window).scroll(function()
{
// Check top position
var controlBarPos = controlBar.hasClass('fixed') ? cbPlaceHolder.offset().top : controlBar.offset().top;
if ($(window).scrollTop() > controlBarPos)
{
if (!controlBar.hasClass('fixed'))
{
cbPlaceHolder.height(controlBar.outerHeight()).show();
controlBar.addClass('fixed').stop(true).fadeTo('slow', 0.5);
// Notifications
$('#notifications').animate({'top': controlBar.outerHeight()+notificationsTop});
}
}
else
{
if (controlBar.hasClass('fixed'))
{
cbPlaceHolder.hide();
controlBar.removeClass('fixed').stop(true).fadeTo('fast', 1, function()
{
// Required for IE
$(this).css('filter', '');
});
// Notifications
$('#notifications').animate({'top': notificationsTop});
}
}
}).trigger('scroll');
}
}
});
/**
* Internal function to open drop-down menus, required for context menu
*/
$.fn.openDropDownMenu = function()
{
var ul = this.children('ul');
// Position check
if (ul.offset().left+ul.outerWidth()-$(window).scrollLeft() > $(window).width())
{
ul.addClass('reverted');
}
// Effect - IE < 9 uses filter for opacity, cutting out sub-menus
if (!$.browser.msie || $.browser.version > 8)
{
ul.stop(true).css({opacity:0}).animate({opacity:1});
}
};
})(jQuery);
/**
* Display a notification. If the page is not yet ready, delay the notification until it is ready.
* @var string message a text or html message to display
* @var object options an object with any options for the message - optional
* - closeButton: true to add a close button to the message (default: true)
* - autoClose: true to close message after (closeDelay) ms (default: true)
* - closeDelay: delay before message close (default: 8000)
*/
var notify = function(message, options)
{
var block = jQuery('#notifications');
// If ready
if (block.length > 0)
{
var settings = jQuery.extend({}, notify.defaults, options);
// Append message
var closeButton = settings.closeButton ? '<span class="close-bt"></span>' : '';
var element = jQuery('#notifications').append('<li>'+message+closeButton+'</li>').children(':last-child');
// Effect
element.expand();
// If closing
if (settings.autoClose)
{
// Timer
var timeoutId = setTimeout(function() { element.fadeAndRemove(); }, settings.closeDelay);
// Prevent closing when hover
element.hover(function()
{
clearTimeout(timeoutId);
}, function()
{
timeoutId = setTimeout(function() { element.fadeAndRemove(); }, settings.closeDelay);
});
}
}
else
{
// Not ready, delay action
setTimeout(function() { notify(message, options); }, 40);
}
};
// Defaults values for the notify method
notify.defaults = {
closeButton: true, // Add a close button to the message
autoClose: true, // Message will close after (closeDelay) ms
closeDelay: 8000 // Delay before message closes
};
|
JavaScript
|
function abrirModalSimples(conteudo, titulo){
return $.modal({
content: conteudo,
title: titulo,
maxWidth: 500,
maxHeight: 500,
buttons: {
'Fechar': function(win) {win.closeModal();}
}
});
}
function abrirModalConfirmacao(url){
return $.modal({
content: 'Deseja Realmente Realizar Essa Operação?',
title: 'Confirmação',
maxWidth: 500,
maxHeight: 500,
buttons: {
'Sim': function() {window.location.href = url},
'Não': function(win) {win.closeModal();}
}
});
}
function abrirModalCarregando(conteudo){
return $.modal({
content: '<img src="include/images/ajax-loader.gif"/> '+conteudo,
title: 'Carregando',
maxWidth: 500,
maxHeight: 500,
closeButton : false
});
}
function loadClass(type,table,view){
var janelaModal = $.modal({
title: 'Visualização',
content: '<img src="include/images/ajax-loader.gif"/> Carregando...',
maxWidth: 800,
minWidth: 700,
maxHeight: 500,
minHeight: 450,
buttons: {
'Fechar': function(win) {
win.closeModal();
}
}
});
$.post('GeneratorAction.loadClass',
{
type:type,
table:table,
view:view
},
function(response, status, xhr){
var content = '<div id="loadClass" style="font-size:13px">';
if (status == "error") {
var msg = "Erro: ";
content += msg + xhr.status + " " + xhr.statusText;
}else{
content += response;
}
content += '</div>';
janelaModal.setModalContent(content,true);
}
);
}
|
JavaScript
|
/**
* Modal window extension
*/
(function($)
{
/**
* Opens a new modal window
* @param object options an object with any of the following options
* @return object the jQuery object of the new window
*/
$.modal = function(options)
{
var settings = $.extend({}, $.modal.defaults, options),
root = getModalDiv(),
// Vars for resizeFunc and moveFunc
winX = 0,
winY = 0,
contentWidth = 0,
contentHeight = 0,
mouseX = 0,
mouseY = 0,
resized;
// Get contents
var content = '';
var contentObj;
if (settings.content)
{
if (typeof(settings.content) == 'string')
{
content = settings.content;
}
else
{
contentObj = settings.content.clone(true).show();
}
}
else
{
// No content
content = '';
}
// Title
var titleClass = settings.title ? '' : ' no-title';
var title = settings.title ? '<h1>'+settings.title+'</h1>' : '';
// Content size
var sizeParts = new Array();
sizeParts.push('min-width:'+settings.minWidth+'px;');
sizeParts.push('min-height:'+settings.minHeight+'px;');
if (settings.width)
{
sizeParts.push('width:'+settings.width+'px; ');
}
if (settings.height)
{
sizeParts.push('height:'+settings.height+'px; ');
}
if (settings.maxWidth)
{
sizeParts.push('max-width:'+settings.maxWidth+'px; ');
}
if (settings.maxHeight)
{
sizeParts.push('max-height:'+settings.maxHeight+'px; ');
}
var contentStyle = (sizeParts.length > 0) ? ' style="'+sizeParts.join(' ')+'"' : '';
// Borders
var borderOpen = settings.border ? '"><div class="block-content'+titleClass : titleClass;
var borderClose = settings.border ? '></div' : '';
// Scrolling
var scrollClass = settings.scrolling ? ' modal-scroll' : '';
// Insert window
var win = $('<div class="modal-window block-border'+borderOpen+'">'+title+'<div class="modal-content'+scrollClass+'"'+contentStyle+'>'+content+'</div></div'+borderClose+'>').appendTo(root);
var contentDiv = win.find('.modal-content');
if (contentObj)
{
contentObj.appendTo(contentDiv);
}
// If resizable
if (settings.resizable && settings.border)
{
// Custom function (to use correct var scope)
var resizeFunc = function(event)
{
// Mouse offset
var offsetX = event.pageX-mouseX,
offsetY = event.pageY-mouseY,
// New size
newWidth = Math.max(settings.minWidth, contentWidth+(resized.width*offsetX)),
newHeight = Math.max(settings.minHeight, contentHeight+(resized.height*offsetY)),
// Position correction
correctX = 0,
correctY = 0;
// If max sizes are defined
if (settings.maxWidth && newWidth > settings.maxWidth)
{
correctX = newWidth-settings.maxWidth;
newWidth = settings.maxWidth;
}
if (settings.maxHeight && newHeight > settings.maxHeight)
{
correctY = newHeight-settings.maxHeight;
newHeight = settings.maxHeight;
}
contentDiv.css({
width: newWidth+'px',
height: newHeight+'px'
});
win.css({
left: (winX+(resized.left*(offsetX+correctX)))+'px',
top: (winY+(resized.top*(offsetY+correctY)))+'px'
});
};
// Create resize handlers
$('<div class="modal-resize-tl"></div>').appendTo(win).data('modal-resize', {
top: 1, left: 1,
height: -1, width: -1
}).add(
$('<div class="modal-resize-t"></div>').appendTo(win).data('modal-resize', {
top: 1, left: 0,
height: -1, width: 0
})
).add(
$('<div class="modal-resize-tr"></div>').appendTo(win).data('modal-resize', {
top: 1, left: 0,
height: -1, width: 1
})
).add(
$('<div class="modal-resize-r"></div>').appendTo(win).data('modal-resize', {
top: 0, left: 0,
height: 0, width: 1
})
).add(
$('<div class="modal-resize-br"></div>').appendTo(win).data('modal-resize', {
top: 0, left: 0,
height: 1, width: 1
})
).add(
$('<div class="modal-resize-b"></div>').appendTo(win).data('modal-resize', {
top: 0, left: 0,
height: 1, width: 0
})
).add(
$('<div class="modal-resize-bl"></div>').appendTo(win).data('modal-resize', {
top: 0, left: 1,
height: 1, width: -1
})
).add(
$('<div class="modal-resize-l"></div>').appendTo(win).data('modal-resize', {
top: 0, left: 1,
height: 0, width: -1
})
).mousedown(function(event)
{
// Detect positions
contentWidth = contentDiv.width();
contentHeight = contentDiv.height();
var position = win.position();
winX = position.left;
winY = position.top;
mouseX = event.pageX;
mouseY = event.pageY;
resized = $(this).data('modal-resize');
// Prevent text selection
document.onselectstart = function () { return false; };
$(document).bind('mousemove', resizeFunc);
})
root.mouseup(function()
{
$(document).unbind('mousemove', resizeFunc);
// Restore text selection
document.onselectstart = null;
});
}
// Put in front
win.mousedown(function()
{
$(this).putModalOnFront();
});
// If movable
if (settings.draggable && title)
{
// Custom functions (to use correct var scope)
var moveFunc = function(event)
{
// Window and document sizes
var width = win.outerWidth(),
height = win.outerHeight();
// New position
win.css({
left: Math.max(0, Math.min(winX+(event.pageX-mouseX), $(root).width()-width))+'px',
top: Math.max(0, Math.min(winY+(event.pageY-mouseY), $(root).height()-height))+'px'
});
};
// Listeners
win.find('h1:first').mousedown(function(event)
{
// Detect positions
var position = win.position();
winX = position.left;
winY = position.top;
mouseX = event.pageX;
mouseY = event.pageY;
// Prevent text selection
document.onselectstart = function () { return false; };
$(document).bind('mousemove', moveFunc);
})
root.mouseup(function()
{
$(document).unbind('mousemove', moveFunc);
// Restore text selection
document.onselectstart = null;
});
}
// Close button
if (settings.closeButton)
{
$('<ul class="action-tabs right"><li><a href="#" title="Fechar"><img src="include/images/icons/fugue/cross-circle.png" width="16" height="16"></a></li></ul>')
.prependTo(win)
.find('a').click(function(event)
{
event.preventDefault();
$(this).closest('.modal-window').closeModal();
});
}
// Bottom buttons
var buttonsFooter = false;
$.each(settings.buttons, function(key, value)
{
// Button zone
if (!buttonsFooter)
{
buttonsFooter = $('<div class="block-footer align-'+settings.buttonsAlign+'"></div>').insertAfter(contentDiv);
}
else
{
// Spacing
buttonsFooter.append(' ');
}
$('<button type="button">'+key+'</button>').appendTo(buttonsFooter).click(function(event)
{
value.call(this, $(this).closest('.modal-window'), event);
});
});
// Close function
if (settings.onClose)
{
win.bind('closeModal', settings.onClose);
}
// Apply template setup
win.applyTemplateSetup();
// Effect
if (!root.is(':visible'))
{
win.hide();
root.fadeIn('normal', function()
{
win.show().centerModal();
});
}
else
{
win.centerModal();
}
// Store as current
$.modal.current = win;
$.modal.all = root.children('.modal-window');
// Callback
if (settings.onOpen)
{
settings.onOpen.call(win.get(0));
}
// If content url
if (settings.url)
{
win.loadModalContent(settings.url, settings);
}
return win;
};
/**
* Shortcut to the current window
* @var jQuery|boolean
*/
$.modal.current = false;
/**
* jQuery selection of all opened modal windows
* @var jQuery
*/
$.modal.all = $();
/**
* Wraps the selected elements content in a new modal window
* @param object options same as $.modal()
* @return jQuery the new windows
*/
$.fn.modal = function(options)
{
var modals = $();
this.each(function()
{
modals.add($.modal($.extend({}, $.modal.defaults, {content: $(this).clone(true).show()})));
});
return modals;
};
/**
* Use this method to retrieve the content div in the modal window
*/
$.fn.getModalContentBlock = function()
{
return this.find('.modal-content');
}
/**
* Use this method to retrieve the modal window from any element within it
*/
$.fn.getModalWindow = function()
{
return this.closest('.modal-window');
}
/**
* Set window content
* @param string|jQuery content the content to put: HTML or a jQuery object
* @param boolean resize use true to resize window to fit content (height only)
*/
$.fn.setModalContent = function(content, resize)
{
this.each(function()
{
var contentBlock = $(this).getModalContentBlock();
// Set content
if (typeof(content) == 'string')
{
contentBlock.html(content);
}
else
{
content.clone(true).show().appendTo(contentBlock);
}
contentBlock.applyTemplateSetup();
// Resizing
if (resize)
{
contentBlock.setModalContentSize(true, false);
}
});
return this;
}
/**
* Set window content-block size
* @param int|boolean width the width to set, true to keep current or false for fluid width
* @param int|boolean height the height to set, true to keep current or false for fluid height
*/
$.fn.setModalContentSize = function(width, height)
{
this.each(function()
{
var contentBlock = $(this).getModalContentBlock();
// Resizing
if (width !== true)
{
contentBlock.css('width', width ? width+'px' : '');
}
if (height !== true)
{
contentBlock.css('height', height ? height+'px' : '');
}
});
return this;
}
/**
* Load AJAX content
* @param string url the content url
* @param object options an object with any of the following options:
* - string loadingMessage any message to display while loading (may contain HTML), or leave empty to keep current content
* - string|object data a map or string that is sent to the server with the request (same as jQuery.load())
* - function complete a callback function that is executed when the request completes. (same as jQuery.load())
* - boolean resize use true to resize window on loading message and when content is loaded. To define separately, use options below:
* - boolean resizeOnMessage use true to resize window on loading message
* - boolean resizeOnLoad use true to resize window when content is loaded
*/
$.fn.loadModalContent = function(url, options)
{
var settings = $.extend({
loadingMessage: '',
data: {},
complete: function(responseText, textStatus, XMLHttpRequest) {},
resize: true,
resizeOnMessage: false,
resizeOnLoad: false
}, options)
this.each(function()
{
var win = $(this),
contentBlock = win.getModalContentBlock();
// If loading message
if (settings.loadingMessage)
{
win.setModalContent('<div class="modal-loading">'+settings.loadingMessage+'</div>', (settings.resize || settings.resizeOnMessage));
}
contentBlock.load(url, settings.data, function(responseText, textStatus, XMLHttpRequest)
{
// Template functions
contentBlock.applyTemplateSetup();
if (settings.resize || settings.resizeOnLoad)
{
contentBlock.setModalContentSize(true, false);
}
// Callback
settings.complete.call(this, responseText, textStatus, XMLHttpRequest);
});
});
return this;
}
/**
* Set modal title
* @param string newTitle the new title (may contain HTML), or an empty string to remove the title
*/
$.fn.setModalTitle = function(newTitle)
{
this.each(function()
{
var win = $(this),
title = $(this).find('h1'),
contentBlock = win.hasClass('block-content') ? win : win.children('.block-content:first');
if (newTitle.length > 0)
{
if (title.length == 0)
{
contentBlock.removeClass('no-title');
title = $('<h1>'+newTitle+'</h1>').prependTo(contentBlock);
}
title.html(newTitle);
}
else if (title.length > 0)
{
title.remove();
contentBlock.addClass('no-title');
}
});
return this;
}
/**
* Center the window
* @param boolean animate true to animate the window movement
*/
$.fn.centerModal = function(animate)
{
var root = getModalDiv(),
rootW = root.width()/2,
rootH = root.height()/2;
this.each(function()
{
var win = $(this),
winW = Math.round(win.outerWidth()/2),
winH = Math.round(win.outerHeight()/2);
win[animate ? 'animate' : 'css']({
left: (rootW-winW)+'px',
top: (rootH-winH)+'px'
});
});
return this;
};
/**
* Put modal on front
*/
$.fn.putModalOnFront = function()
{
if ($.modal.all.length > 1)
{
var root = getModalDiv();
this.each(function()
{
if ($(this).next('.modal-window').length > 0)
{
$(this).detach().appendTo(root);
}
});
}
return this;
};
/**
* Closes the window
*/
$.fn.closeModal = function()
{
this.each(function()
{
var event = $.Event('closeModal'),
win = $(this);
// Events on close
win.trigger(event);
if (!event.isDefaultPrevented())
{
win.remove();
// Modal root element
var root = getModalDiv();
$.modal.all = root.children('.modal-window');
if ($.modal.all.length == 0)
{
$.modal.current = false;
root.fadeOut('normal');
}
else
{
// Refresh current
$.modal.current = $.modal.all.last();
}
}
});
return this;
};
/**
* New modal window options
*/
$.modal.defaults = {
/**
* Content of the window: HTML or jQuery object
* @var string|jQuery
*/
content: false,
/**
* Url for loading content
* @var string|boolean
*/
url: false,
/**
* Title of the window, or false for none
* @var string|boolean
*/
title: false,
/**
* Add glass-like border to the window (required to enable resizing)
* @var boolean
*/
border: true,
/**
* Enable window moving (only work if title is defined)
* @var boolean
*/
draggable: true,
/**
* Enable window resizing (only work if border is true)
* @var boolean
*/
resizable: true,
/**
* If true, enable content vertical scrollbar if content is higher than 'height' (or 'maxHeight' if 'height' is undefined)
* @var boolean
*/
scrolling: true,
/**
* Wether or not to display the close window button
* @var boolean
*/
closeButton: true,
/**
* Map of bottom buttons, with text as key and function on click as value
* Ex: {'Close' : function(win) { win.closeModal(); } }
* @var object
*/
buttons: {},
/**
* Alignement of buttons ('left', 'center' or 'right')
* @var string
*/
buttonsAlign: 'right',
/**
* Function called when opening window
* @var function
*/
onOpen: false,
/**
* Function called when closing window. It may return false or call event.preventDefault() to prevent closing
* @var function
*/
onClose: false,
/**
* Minimum content height
* @var int
*/
minHeight: 40,
/**
* Minimum content width
* @var int
*/
minWidth: 200,
/**
* Maximum content width, or false for no limit
* @var int|boolean
*/
maxHeight: false,
/**
* Maximum content height, or false for no limit
* @var int|boolean
*/
maxWidth: false,
/**
* Initial content height, or false for fluid size
* @var int|boolean
*/
height: false,
/**
* Initial content width, or false for fluid size
* @var int|boolean
*/
width: 450,
/**
* If AJAX load only - loading message, or false for none (can be HTML)
* @var string|boolean
*/
loadingMessage: 'Loading...',
/**
* If AJAX load only - data a map or string that is sent to the server with the request (same as jQuery.load())
* @var string|object
*/
data: {},
/**
* If AJAX load only - a callback function that is executed when the request completes. (same as jQuery.load())
* @var function
*/
complete: function(responseText, textStatus, XMLHttpRequest) {},
/**
* If AJAX load only - true to resize window on loading message and when content is loaded. To define separately, use options below.
* @var boolean
*/
resize: true,
/**
* If AJAX load only - use true to resize window on loading message
* @var boolean
*/
resizeOnMessage: false,
/**
* If AJAX load only - use true to resize window when content is loaded
* @var boolean
*/
resizeOnLoad: false
};
/**
* Return the modal windows root div
*/
function getModalDiv()
{
var modal = $('#modal');
if (modal.length == 0)
{
$(document.body).append('<div id="modal"></div>');
modal = $('#modal').hide();
}
return modal;
};
})(jQuery);
|
JavaScript
|
/*!
* jQuery Form Plugin
* version: 2.73 (03-MAY-2011)
* @requires jQuery v1.3.2 or later
*
* Examples and documentation at: http://malsup.com/jquery/form/
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*/
;(function($) {
/*
Usage Note:
-----------
Do not use both ajaxSubmit and ajaxForm on the same form. These
functions are intended to be exclusive. Use ajaxSubmit if you want
to bind your own submit handler to the form. For example,
$(document).ready(function() {
$('#myForm').bind('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit({
target: '#output'
});
});
});
Use ajaxForm when you want the plugin to manage all the event binding
for you. For example,
$(document).ready(function() {
$('#myForm').ajaxForm({
target: '#output'
});
});
When using ajaxForm, the ajaxSubmit function will be invoked for you
at the appropriate time.
*/
/**
* ajaxSubmit() provides a mechanism for immediately submitting
* an HTML form using AJAX.
*/
$.fn.ajaxSubmit = function(options) {
// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
if (!this.length) {
log('ajaxSubmit: skipping submit process - no element selected');
return this;
}
if (typeof options == 'function') {
options = { success: options };
}
var action = this.attr('action');
var url = (typeof action === 'string') ? $.trim(action) : '';
if (url) {
// clean url (don't include hash vaue)
url = (url.match(/^([^#]+)/)||[])[1];
}
url = url || window.location.href || '';
options = $.extend(true, {
url: url,
success: $.ajaxSettings.success,
type: this[0].getAttribute('method') || 'GET', // IE7 massage (see issue 57)
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
}, options);
// hook for manipulating the form data before it is extracted;
// convenient for use with rich editors like tinyMCE or FCKEditor
var veto = {};
this.trigger('form-pre-serialize', [this, options, veto]);
if (veto.veto) {
log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
return this;
}
// provide opportunity to alter form data before it is serialized
if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
log('ajaxSubmit: submit aborted via beforeSerialize callback');
return this;
}
var n,v,a = this.formToArray(options.semantic);
if (options.data) {
options.extraData = options.data;
for (n in options.data) {
if(options.data[n] instanceof Array) {
for (var k in options.data[n]) {
a.push( { name: n, value: options.data[n][k] } );
}
}
else {
v = options.data[n];
v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
a.push( { name: n, value: v } );
}
}
}
// give pre-submit callback an opportunity to abort the submit
if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
log('ajaxSubmit: submit aborted via beforeSubmit callback');
return this;
}
// fire vetoable 'validate' event
this.trigger('form-submit-validate', [a, this, options, veto]);
if (veto.veto) {
log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
return this;
}
var q = $.param(a);
if (options.type.toUpperCase() == 'GET') {
options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
options.data = null; // data is null for 'get'
}
else {
options.data = q; // data is the query string for 'post'
}
var $form = this, callbacks = [];
if (options.resetForm) {
callbacks.push(function() { $form.resetForm(); });
}
if (options.clearForm) {
callbacks.push(function() { $form.clearForm(); });
}
// perform a load on the target only if dataType is not provided
if (!options.dataType && options.target) {
var oldSuccess = options.success || function(){};
callbacks.push(function(data) {
var fn = options.replaceTarget ? 'replaceWith' : 'html';
$(options.target)[fn](data).each(oldSuccess, arguments);
});
}
else if (options.success) {
callbacks.push(options.success);
}
options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
var context = options.context || options; // jQuery 1.4+ supports scope context
for (var i=0, max=callbacks.length; i < max; i++) {
callbacks[i].apply(context, [data, status, xhr || $form, $form]);
}
};
// are there files to upload?
var fileInputs = $('input:file', this).length > 0;
var mp = 'multipart/form-data';
var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
// options.iframe allows user to force iframe mode
// 06-NOV-09: now defaulting to iframe mode if file input is detected
if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
// hack to fix Safari hang (thanks to Tim Molendijk for this)
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
if (options.closeKeepAlive) {
$.get(options.closeKeepAlive, fileUpload);
}
else {
fileUpload();
}
}
else {
$.ajax(options);
}
// fire 'notify' event
this.trigger('form-submit-notify', [this, options]);
return this;
// private function for handling file uploads (hat tip to YAHOO!)
function fileUpload() {
var form = $form[0];
if ($(':input[name=submit],:input[id=submit]', form).length) {
// if there is an input with a name or id of 'submit' then we won't be
// able to invoke the submit fn on the form (at least not x-browser)
alert('Error: Form elements must not have name or id of "submit".');
return;
}
var s = $.extend(true, {}, $.ajaxSettings, options);
s.context = s.context || s;
var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
var $io = $('<iframe id="' + id + '" name="' + id + '" src="'+ s.iframeSrc +'" />');
var io = $io[0];
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
var xhr = { // mock object
aborted: 0,
responseText: null,
responseXML: null,
status: 0,
statusText: 'n/a',
getAllResponseHeaders: function() {},
getResponseHeader: function() {},
setRequestHeader: function() {},
abort: function(status) {
var e = (status === 'timeout' ? 'timeout' : 'aborted');
log('aborting upload... ' + e);
this.aborted = 1;
$io.attr('src', s.iframeSrc); // abort op in progress
xhr.error = e;
s.error && s.error.call(s.context, xhr, e, e);
g && $.event.trigger("ajaxError", [xhr, s, e]);
s.complete && s.complete.call(s.context, xhr, e);
}
};
var g = s.global;
// trigger ajax global events so that activity/block indicators work like normal
if (g && ! $.active++) {
$.event.trigger("ajaxStart");
}
if (g) {
$.event.trigger("ajaxSend", [xhr, s]);
}
if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
if (s.global) {
$.active--;
}
return;
}
if (xhr.aborted) {
return;
}
var timedOut = 0, timeoutHandle;
// add submitting element to data if we know it
var sub = form.clk;
if (sub) {
var n = sub.name;
if (n && !sub.disabled) {
s.extraData = s.extraData || {};
s.extraData[n] = sub.value;
if (sub.type == "image") {
s.extraData[n+'.x'] = form.clk_x;
s.extraData[n+'.y'] = form.clk_y;
}
}
}
// take a breath so that pending repaints get some cpu time before the upload starts
function doSubmit() {
// make sure form attrs are set
var t = $form.attr('target'), a = $form.attr('action');
// update form attrs in IE friendly way
form.setAttribute('target',id);
if (form.getAttribute('method') != 'POST') {
form.setAttribute('method', 'POST');
}
if (form.getAttribute('action') != s.url) {
form.setAttribute('action', s.url);
}
// ie borks in some cases when setting encoding
if (! s.skipEncodingOverride) {
$form.attr({
encoding: 'multipart/form-data',
enctype: 'multipart/form-data'
});
}
// support timout
if (s.timeout) {
timeoutHandle = setTimeout(function() { timedOut = true; cb(true); }, s.timeout);
}
// add "extra" data to form if provided in options
var extraInputs = [];
try {
if (s.extraData) {
for (var n in s.extraData) {
extraInputs.push(
$('<input type="hidden" name="'+n+'" value="'+s.extraData[n]+'" />')
.appendTo(form)[0]);
}
}
// add iframe to doc and submit the form
$io.appendTo('body');
io.attachEvent ? io.attachEvent('onload', cb) : io.addEventListener('load', cb, false);
form.submit();
}
finally {
// reset attrs and remove "extra" input elements
form.setAttribute('action',a);
if(t) {
form.setAttribute('target', t);
} else {
$form.removeAttr('target');
}
$(extraInputs).remove();
}
}
if (s.forceSync) {
doSubmit();
}
else {
setTimeout(doSubmit, 10); // this lets dom updates render
}
var data, doc, domCheckCount = 50, callbackProcessed;
function cb(e) {
if (xhr.aborted || callbackProcessed) {
return;
}
if (e === true && xhr) {
xhr.abort('timeout');
return;
}
var doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
if (!doc || doc.location.href == s.iframeSrc) {
// response not received yet
if (!timedOut)
return;
}
io.detachEvent ? io.detachEvent('onload', cb) : io.removeEventListener('load', cb, false);
var ok = true;
try {
if (timedOut) {
throw 'timeout';
}
var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
log('isXml='+isXml);
if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
if (--domCheckCount) {
// in some browsers (Opera) the iframe DOM is not always traversable when
// the onload callback fires, so we loop a bit to accommodate
log('requeing onLoad callback, DOM not available');
setTimeout(cb, 250);
return;
}
// let this fall through because server response could be an empty document
//log('Could not access iframe DOM after mutiple tries.');
//throw 'DOMException: not available';
}
//log('response detected');
xhr.responseText = doc.body ? doc.body.innerHTML : doc.documentElement ? doc.documentElement.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
if (isXml)
s.dataType = 'xml';
xhr.getResponseHeader = function(header){
var headers = {'content-type': s.dataType};
return headers[header];
};
var scr = /(json|script|text)/.test(s.dataType);
if (scr || s.textarea) {
// see if user embedded response in textarea
var ta = doc.getElementsByTagName('textarea')[0];
if (ta) {
xhr.responseText = ta.value;
}
else if (scr) {
// account for browsers injecting pre around json response
var pre = doc.getElementsByTagName('pre')[0];
var b = doc.getElementsByTagName('body')[0];
if (pre) {
xhr.responseText = pre.textContent;
}
else if (b) {
xhr.responseText = b.innerHTML;
}
}
}
else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
xhr.responseXML = toXml(xhr.responseText);
}
data = httpData(xhr, s.dataType, s);
}
catch(e){
log('error caught:',e);
ok = false;
xhr.error = e;
s.error && s.error.call(s.context, xhr, 'error', e);
g && $.event.trigger("ajaxError", [xhr, s, e]);
}
if (xhr.aborted) {
log('upload aborted');
ok = false;
}
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (ok) {
s.success && s.success.call(s.context, data, 'success', xhr);
g && $.event.trigger("ajaxSuccess", [xhr, s]);
}
g && $.event.trigger("ajaxComplete", [xhr, s]);
if (g && ! --$.active) {
$.event.trigger("ajaxStop");
}
s.complete && s.complete.call(s.context, xhr, ok ? 'success' : 'error');
callbackProcessed = true;
if (s.timeout)
clearTimeout(timeoutHandle);
// clean up
setTimeout(function() {
$io.removeData('form-plugin-onload');
$io.remove();
xhr.responseXML = null;
}, 100);
}
var toXml = $.parseXML || function(s, doc) { // use parseXML if available (jQuery 1.5+)
if (window.ActiveXObject) {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML(s);
}
else {
doc = (new DOMParser()).parseFromString(s, 'text/xml');
}
return (doc && doc.documentElement && doc.documentElement.nodeName != 'parsererror') ? doc : null;
};
var parseJSON = $.parseJSON || function(s) {
return window['eval']('(' + s + ')');
};
var httpData = function( xhr, type, s ) { // mostly lifted from jq1.4.4
var ct = xhr.getResponseHeader('content-type') || '',
xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
data = xml ? xhr.responseXML : xhr.responseText;
if (xml && data.documentElement.nodeName === 'parsererror') {
$.error && $.error('parsererror');
}
if (s && s.dataFilter) {
data = s.dataFilter(data, type);
}
if (typeof data === 'string') {
if (type === 'json' || !type && ct.indexOf('json') >= 0) {
data = parseJSON(data);
} else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
$.globalEval(data);
}
}
return data;
};
}
};
/**
* ajaxForm() provides a mechanism for fully automating form submission.
*
* The advantages of using this method instead of ajaxSubmit() are:
*
* 1: This method will include coordinates for <input type="image" /> elements (if the element
* is used to submit the form).
* 2. This method will include the submit element's name/value data (for the element that was
* used to submit the form).
* 3. This method binds the submit() method to the form for you.
*
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
* passes the options argument along after properly binding events for submit elements and
* the form itself.
*/
$.fn.ajaxForm = function(options) {
// in jQuery 1.3+ we can fix mistakes with the ready state
if (this.length === 0) {
var o = { s: this.selector, c: this.context };
if (!$.isReady && o.s) {
log('DOM not ready, queuing ajaxForm');
$(function() {
$(o.s,o.c).ajaxForm(options);
});
return this;
}
// is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
return this;
}
return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
e.preventDefault();
$(this).ajaxSubmit(options);
}
}).bind('click.form-plugin', function(e) {
var target = e.target;
var $el = $(target);
if (!($el.is(":submit,input:image"))) {
// is this a child element of the submit el? (ex: a span within a button)
var t = $el.closest(':submit');
if (t.length == 0) {
return;
}
target = t[0];
}
var form = this;
form.clk = target;
if (target.type == 'image') {
if (e.offsetX != undefined) {
form.clk_x = e.offsetX;
form.clk_y = e.offsetY;
} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
var offset = $el.offset();
form.clk_x = e.pageX - offset.left;
form.clk_y = e.pageY - offset.top;
} else {
form.clk_x = e.pageX - target.offsetLeft;
form.clk_y = e.pageY - target.offsetTop;
}
}
// clear form vars
setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
});
};
// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$.fn.ajaxFormUnbind = function() {
return this.unbind('submit.form-plugin click.form-plugin');
};
/**
* formToArray() gathers form element data into an array of objects that can
* be passed to any of the following ajax functions: $.get, $.post, or load.
* Each object in the array has both a 'name' and 'value' property. An example of
* an array for a simple login form might be:
*
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
*
* It is this array that is passed to pre-submit callback functions provided to the
* ajaxSubmit() and ajaxForm() methods.
*/
$.fn.formToArray = function(semantic) {
var a = [];
if (this.length === 0) {
return a;
}
var form = this[0];
var els = semantic ? form.getElementsByTagName('*') : form.elements;
if (!els) {
return a;
}
var i,j,n,v,el,max,jmax;
for(i=0, max=els.length; i < max; i++) {
el = els[i];
n = el.name;
if (!n) {
continue;
}
if (semantic && form.clk && el.type == "image") {
// handle image inputs on the fly when semantic == true
if(!el.disabled && form.clk == el) {
a.push({name: n, value: $(el).val()});
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
}
continue;
}
v = $.fieldValue(el, true);
if (v && v.constructor == Array) {
for(j=0, jmax=v.length; j < jmax; j++) {
a.push({name: n, value: v[j]});
}
}
else if (v !== null && typeof v != 'undefined') {
a.push({name: n, value: v});
}
}
if (!semantic && form.clk) {
// input type=='image' are not found in elements array! handle it here
var $input = $(form.clk), input = $input[0];
n = input.name;
if (n && !input.disabled && input.type == 'image') {
a.push({name: n, value: $input.val()});
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
}
}
return a;
};
/**
* Serializes form data into a 'submittable' string. This method will return a string
* in the format: name1=value1&name2=value2
*/
$.fn.formSerialize = function(semantic) {
//hand off to jQuery.param for proper encoding
return $.param(this.formToArray(semantic));
};
/**
* Serializes all field elements in the jQuery object into a query string.
* This method will return a string in the format: name1=value1&name2=value2
*/
$.fn.fieldSerialize = function(successful) {
var a = [];
this.each(function() {
var n = this.name;
if (!n) {
return;
}
var v = $.fieldValue(this, successful);
if (v && v.constructor == Array) {
for (var i=0,max=v.length; i < max; i++) {
a.push({name: n, value: v[i]});
}
}
else if (v !== null && typeof v != 'undefined') {
a.push({name: this.name, value: v});
}
});
//hand off to jQuery.param for proper encoding
return $.param(a);
};
/**
* Returns the value(s) of the element in the matched set. For example, consider the following form:
*
* <form><fieldset>
* <input name="A" type="text" />
* <input name="A" type="text" />
* <input name="B" type="checkbox" value="B1" />
* <input name="B" type="checkbox" value="B2"/>
* <input name="C" type="radio" value="C1" />
* <input name="C" type="radio" value="C2" />
* </fieldset></form>
*
* var v = $(':text').fieldValue();
* // if no values are entered into the text inputs
* v == ['','']
* // if values entered into the text inputs are 'foo' and 'bar'
* v == ['foo','bar']
*
* var v = $(':checkbox').fieldValue();
* // if neither checkbox is checked
* v === undefined
* // if both checkboxes are checked
* v == ['B1', 'B2']
*
* var v = $(':radio').fieldValue();
* // if neither radio is checked
* v === undefined
* // if first radio is checked
* v == ['C1']
*
* The successful argument controls whether or not the field element must be 'successful'
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
* The default value of the successful argument is true. If this value is false the value(s)
* for each element is returned.
*
* Note: This method *always* returns an array. If no valid value can be determined the
* array will be empty, otherwise it will contain one or more values.
*/
$.fn.fieldValue = function(successful) {
for (var val=[], i=0, max=this.length; i < max; i++) {
var el = this[i];
var v = $.fieldValue(el, successful);
if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
continue;
}
v.constructor == Array ? $.merge(val, v) : val.push(v);
}
return val;
};
/**
* Returns the value of the field element.
*/
$.fieldValue = function(el, successful) {
var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
if (successful === undefined) {
successful = true;
}
if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
(t == 'checkbox' || t == 'radio') && !el.checked ||
(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
tag == 'select' && el.selectedIndex == -1)) {
return null;
}
if (tag == 'select') {
var index = el.selectedIndex;
if (index < 0) {
return null;
}
var a = [], ops = el.options;
var one = (t == 'select-one');
var max = (one ? index+1 : ops.length);
for(var i=(one ? index : 0); i < max; i++) {
var op = ops[i];
if (op.selected) {
var v = op.value;
if (!v) { // extra pain for IE...
v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
}
if (one) {
return v;
}
a.push(v);
}
}
return a;
}
return $(el).val();
};
/**
* Clears the form data. Takes the following actions on the form's input fields:
* - input text fields will have their 'value' property set to the empty string
* - select elements will have their 'selectedIndex' property set to -1
* - checkbox and radio inputs will have their 'checked' property set to false
* - inputs of type submit, button, reset, and hidden will *not* be effected
* - button elements will *not* be effected
*/
$.fn.clearForm = function() {
return this.each(function() {
$('input,select,textarea', this).clearFields();
});
};
/**
* Clears the selected form elements.
*/
$.fn.clearFields = $.fn.clearInputs = function() {
return this.each(function() {
var t = this.type, tag = this.tagName.toLowerCase();
if (t == 'text' || t == 'password' || tag == 'textarea') {
this.value = '';
}
else if (t == 'checkbox' || t == 'radio') {
this.checked = false;
}
else if (tag == 'select') {
this.selectedIndex = -1;
}
});
};
/**
* Resets the form data. Causes all form elements to be reset to their original value.
*/
$.fn.resetForm = function() {
return this.each(function() {
// guard against an input with the name of 'reset'
// note that IE reports the reset function as an 'object'
if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
this.reset();
}
});
};
/**
* Enables or disables any matching elements.
*/
$.fn.enable = function(b) {
if (b === undefined) {
b = true;
}
return this.each(function() {
this.disabled = !b;
});
};
/**
* Checks/unchecks any matching checkboxes or radio buttons and
* selects/deselects and matching option elements.
*/
$.fn.selected = function(select) {
if (select === undefined) {
select = true;
}
return this.each(function() {
var t = this.type;
if (t == 'checkbox' || t == 'radio') {
this.checked = select;
}
else if (this.tagName.toLowerCase() == 'option') {
var $sel = $(this).parent('select');
if (select && $sel[0] && $sel[0].type == 'select-one') {
// deselect all other options
$sel.find('option').selected(false);
}
this.selected = select;
}
});
};
// helper fn for console logging
// set $.fn.ajaxSubmit.debug to true to enable debug logging
function log() {
if ($.fn.ajaxSubmit.debug) {
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
if (window.console && window.console.log) {
window.console.log(msg);
}
else if (window.opera && window.opera.postError) {
window.opera.postError(msg);
}
}
};
})(jQuery);
|
JavaScript
|
/**
* Older browsers detection
*/
(function($)
{
// Change these values to fit your needs
if (
($.browser.msie && parseFloat($.browser.version) < 7) || // IE 6 and lower
($.browser.mozilla && parseFloat($.browser.version) < 1.9) || // Firefox 2 and lower
($.browser.opera && parseFloat($.browser.version) < 9) || // Opera 8 and lower
($.browser.webkit && parseInt($.browser.version) < 400) // Older Chrome and Safari
) {
// If no cookie has been set
if (getCookie('forceAccess') !== 'yes')
{
// If coming back from the old browsers page
if (window.location.search.indexOf('forceAccess=yes') > -1)
{
// Mark for future tests
setCookie('forceAccess', 'yes');
}
else
{
document.location.href = 'old-browsers.html?redirect='+escape(document.location.href);
}
}
}
/**
* Get cookie params
* @return object an object with every params in the cookie
*/
function getCookieParams()
{
var parts = document.cookie.split(/; */g);
var params = {};
for (var i = 0; i < parts.length; ++i)
{
var part = parts[i];
if (part)
{
var equal = part.indexOf('=');
if (equal > -1)
{
var param = part.substr(0, equal);
var value = unescape(part.substring(equal+1));
params[param] = value;
}
}
}
return params;
}
/**
* Get a cookie value
* @param string name the cookie name
* @return string the value, or null if not defined
*/
function getCookie(name)
{
var params = getCookieParams();
return params[name] || null;
}
/**
* Write a cookie value
* @param string name the cookie name
* @param string value the value
* @param int days number of days for cookie life
* @return void
*/
function setCookie(name, value, days)
{
var params = getCookieParams();
params[name] = value;
if (days)
{
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
params.expires = date.toGMTString();
}
var cookie = [];
for (var thevar in params)
{
cookie.push(thevar+'='+escape(params[thevar]));
}
document.cookie = cookie.join('; ');
}
})(jQuery);
|
JavaScript
|
/**
* Lists generic controls
*/
(function($)
{
// List styles setup
$.fn.addTemplateSetup(function()
{
// Closed elements
this.find('.close').toggleBranchOpen().removeClass('close');
// :first-of-type is buggy with jQuery under IE
this.find('dl.accordion dt:first-child + dd').siblings('dd').hide();
// Tasks dialog
if (!$.browser.msie || $.browser.version > 8) // IE is buggy on this animation
{
this.find('.task-dialog').parent().hover(function()
{
$(this).find('.task-dialog > li.auto-hide').expand();
}, function()
{
$(this).find('.task-dialog > li.auto-hide').fold();
});
}
// Arbo elements controls
this.find('.arbo .toggle, .collapsible-list li:has(ul) > :first-child, .collapsible-list li:has(ul) > :first-child + span').click(function(event)
{
// Toggle style
$(this).toggleBranchOpen();
// Prevent link action
if (this.nodeName.toLowerCase() == 'a')
{
event.preventDefault();
}
});
// Accordions effect
this.find('dl.accordion dt').click(function()
{
$(this).next('dd').slideDown().siblings('dd').slideUp().prev('dt');
// Effect need for rounded corners
$(this).addClass('opened').siblings('dt').removeClass('opened');
});
}, true);
/**
* Open/close branch
*/
$.fn.toggleBranchOpen = function()
{
this.each(function()
{
/*
* Tip: if you want to add animation or do anything that should not occur at startup closing,
* check if the element has the class 'close':
* if (!$(this).hasClass('close')) { // Anything that sould no occur at startup }
*/
// Change
$(this).closest('li').toggleClass('closed');
});
return this;
};
})(jQuery);
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
/*
prop = {
header, // String
property, // String
events, //
type, // checkbox, select, input.type, button
extra // depend on type
}
*/
function List(config) {
this.config = config;
this.props = config.props;
this.main = config.main;
this.selectedLine = -2;
this.lines = [];
if (!config.getItems) {
config.getItems = function() {
return config.items;
}
}
if (!config.getItemProp) {
config.getItemProp = function(id, prop) {
return config.getItem(id)[prop];
}
}
if (!config.setItemProp) {
config.setItemProp = function(id, prop, value) {
config.getItem(id)[prop] = value;
}
}
if (!config.getItem) {
config.getItem = function(id) {
return config.getItems()[id];
}
}
if (!config.move) {
config.move = function(a, b) {
if (a != b && a >= 0 && b >= 0 && a < this.count() && b < this.count()) {
var list = config.getItems();
var tmp = list[a];
// remove a
list.splice(a, 1);
// insert b
list.splice(b, 0, tmp);
}
}
};
if (!config.insert) {
config.insert = function(id, newItem) {
config.getItems().splice(id, 0, newItem);
}
}
if (!config.remove) {
config.remove = function(a) {
config.move(a, config.count() - 1);
config.getItems().pop();
}
}
if (!config.validate) {
config.validate = function() {return true;};
}
if (!config.count) {
config.count = function() {
return config.getItems().length;
}
}
if (!config.patch) {
config.patch = function(id, newVal) {
for (var name in newVal) {
config.setItemProp(id, name, newVal[name]);
}
}
}
if (!config.defaultValue) {
config.defaultValue = {};
}
config.main.addClass('list');
}
List.ids = {
noline: -1,
};
List.types = {};
List.prototype = {
init: function() {
with (this) {
if (this.inited) {
return;
}
this.inited = true;
this.headergroup = $('<div class="headers"></div>');
for (var i = 0; i < props.length; ++i) {
var header = $('<div class="header"></div>').
attr('property', props[i].property).html(props[i].header);
headergroup.append(header);
}
this.scrolls = $('<div>').addClass('listscroll');
this.contents = $('<div class="listitems"></div>').appendTo(scrolls);
scrolls.scroll(function() {
headergroup.css('left', -(scrolls.scrollLeft()) + 'px');
});
contents.click(function(e) {
if (e.target == contents[0]) {
selectLine(List.ids.noline);
}
});
$(main).append(headergroup).append(scrolls);
var height = this.main.height() - this.headergroup.outerHeight();
this.scrolls.height(height);
load();
selectLine(List.ids.noline);
}
},
editNewLine: function() {
this.startEdit(this.lines[this.lines.length - 1]);
},
updatePropDisplay : function(line, prop) {
var name = prop.property;
obj = $('[property=' + name + ']', line);
var ctrl = obj[0].listdata;
var id = Number(line.attr('row'));
if (id == this.config.count()) {
var value = this.config.defaultValue[name];
if (value) {
ctrl.value = value;
}
obj.trigger('createNew');
} else {
ctrl.value = this.config.getItemProp(id, name);
obj.trigger('update');
}
},
updateLine: function(line) {
for (var i = 0; i < this.props.length; ++i) {
this.updatePropDisplay(line, this.props[i]);
}
if (Number(line.attr('row')) < this.config.count()) {
line.trigger('update');
} else {
line.addClass('newline');
}
},
createLine: function() {
with (this) {
var line = $('<div></div>').addClass('itemline');
var inner = $('<div>');
line.append(inner);
// create input boxes
for (var i = 0; i < props.length; ++i) {
var prop = props[i];
var ctrl = $('<div></div>').attr('property', prop.property)
.addClass('listvalue').attr('tabindex', -1);
var valueobj = new List.types[prop.type](ctrl, prop);
var data = {list: this, line: line, prop: prop};
for (var e in prop.events) {
ctrl.bind(e, data, prop.events[e]);
}
ctrl.bind('change', function(e) {
validate(line);
return true;
});
ctrl.bind('keyup', function(e) {
if (e.keyCode == 27) {
cancelEdit(line);
}
});
ctrl.trigger('create');
inner.append(ctrl);
}
// Event listeners
line.click(function(e) {
startEdit(line);
});
line.focusin(function(e) {
startEdit(line);
});
line.focusout(function(e) {
finishEdit(line);
});
for (var e in this.config.lineEvents) {
line.bind(e, {list: this, line: line}, this.config.lineEvents[e]);
}
var list = this;
line.bind('updating', function() {
$(list).trigger('updating');
});
line.bind('updated', function() {
$(list).trigger('updated');
});
this.bindId(line, this.lines.length);
this.lines.push(line);
line.appendTo(this.contents);
return line;
}
},
refresh: function(lines) {
var all = false;
if (lines === undefined) {
all = true;
lines = [];
}
for (var i = this.lines.length; i <= this.config.count(); ++i) {
var line = this.createLine();
lines.push(i);
}
while (this.lines.length > this.config.count() + 1) {
this.lines.pop().remove();
}
$('.newline', this.contents).removeClass('newline');
this.lines[this.lines.length - 1].addClass('newline');
if (all) {
for (var i = 0; i < this.lines.length; ++i) {
this.updateLine(this.lines[i]);
}
} else {
for (var i = 0; i < lines.length; ++i) {
this.updateLine(this.lines[lines[i]]);
}
}
},
load: function() {
this.contents.empty();
this.lines = [];
this.refresh();
},
bindId: function(line, id) {
line.attr('row', id);
},
getLineNewValue: function(line) {
var ret = {};
for (var i = 0; i < this.props.length; ++i) {
this.getPropValue(line, ret, this.props[i]);
}
return ret;
},
getPropValue: function(line, item, prop) {
var name = prop.property;
obj = $('[property=' + name + ']', line);
var ctrl = obj[0].listdata;
var value = ctrl.value;
if (value !== undefined) {
item[name] = value;
}
return value;
},
startEdit: function(line) {
if (line.hasClass('editing')) {
return;
}
line.addClass('editing');
this.showLine(line);
this.selectLine(line);
var list = this;
setTimeout(function() {
if (!line[0].contains(document.activeElement)) {
$('.valinput', line).first().focus();
}
list.validate(line);
}, 50);
},
finishEdit: function(line) {
var list = this;
function doFinishEdit() {
with(list) {
if (line[0].contains(document.activeElement)) {
return;
}
var valid = isValid(line);
if (valid) {
var id = Number(line.attr('row'));
var newval = getLineNewValue(line);
if (line.hasClass('newline')) {
$(list).trigger('updating');
if(!config.insert(id, newval)) {
line.removeClass('newline');
list.selectLine(line);
$(list).trigger('add', id);
addNewLine();
}
} else {
line.trigger('updating');
config.patch(id, newval);
}
line.trigger('updated');
}
cancelEdit(line);
}
};
setTimeout(doFinishEdit, 50);
},
cancelEdit: function(line) {
line.removeClass('editing');
line.removeClass('error');
var id = Number(line.attr('row'));
if (id == this.config.count() && this.selectedLine == id) {
this.selectedLine = List.ids.noline;
}
this.updateLine(line);
},
addNewLine: function() {
with(this) {
var line = $('.newline', contents);
if (!line.length) {
line = createLine().addClass('newline');
}
return line;
}
},
isValid: function(line) {
var id = Number(line.attr('row'));
var obj = this.getLineNewValue(line);
return valid = this.config.validate(id, obj);
},
validate: function(line) {
if (this.isValid(line)) {
line.removeClass('error');
} else {
line.addClass('error');
}
},
move: function(a, b, keepSelect) {
var len = this.config.count();
if (a == b || a < 0 || b < 0 || a >= len || b >= len) {
return;
}
this.config.move(a, b);
for (var i = Math.min(a, b); i <= Math.max(a, b); ++i) {
this.updateLine(this.getLine(i));
}
if (keepSelect) {
if (this.selectedLine == a) {
this.selectLine(b);
} else if (this.selectedLine == b) {
this.selectLine(a);
}
}
},
getLine: function(id) {
if (id < 0 || id >= this.lines.length) {
return null;
}
return this.lines[id];
},
remove: function(id) {
id = Number(id);
if (id < 0 || id >= this.config.count()) {
return;
}
$(this).trigger('updating');
var len = this.lines.length;
this.getLine(id).trigger('removing');
if (this.config.remove(id)) {
return;
}
this.getLine(len - 1).remove();
this.lines.pop();
for (var i = id; i < len - 1; ++i) {
this.updateLine(this.getLine(i));
}
if (id >= len - 2) {
this.selectLine(id);
} else {
this.selectLine(List.ids.noline);
}
$(this).trigger('updated');
},
selectLine: function(id) {
var line = id;
if (typeof id == "number") {
line = this.getLine(id);
} else {
id = Number(line.attr('row'));
}
// Can't select the new line.
if (line && line.hasClass('newline')) {
line = null;
id = List.ids.noline;
}
if (this.selectedLine == id) {
return;
}
var oldline = this.getLine(this.selectedLine);
if (oldline) {
this.cancelEdit(oldline);
oldline.removeClass('selected');
oldline.trigger('deselect');
this.selectedLine = List.ids.noline;
}
this.selectedLine = id;
if (line != null) {
line.addClass('selected');
line.trigger('select');
this.showLine(line);
}
$(this).trigger('select');
},
showLine: function(line) {
var showtop = this.scrolls.scrollTop();
var showbottom = showtop + this.scrolls.height();
var top = line.offset().top - this.contents.offset().top;
// Include the scroll bar
var bottom = top + line.height() + 20;
if (top < showtop) {
// show at top
this.scrolls.scrollTop(top);
} else if (bottom > showbottom) {
// show at bottom
this.scrolls.scrollTop(Math.max(0, bottom - this.scrolls.height()));
}
}
};
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
var baseDir = '/setting/';
var rules = [];
var scripts = [];
var issues = [];
var dirty = false;
function setScriptAutoComplete(e) {
var last = /[^\s]*$/;
var obj = $('input', e.target);
$(obj).bind("keydown", function(event) {
if (event.keyCode === $.ui.keyCode.TAB &&
$(this).data("autocomplete").menu.active) {
event.preventDefault();
}
})
.autocomplete({
minLength: 0,
source: function(request, response) {
// delegate back to autocomplete, but extract the last term
response($.ui.autocomplete.filter(
scriptItems, last.exec(request.term)[0]));
},
focus: function() {
// prevent value inserted on focus
return false;
},
select: function(event, ui) {
this.value = this.value.replace(last, ui.item.value);
return false;
}
});
}
var ruleProps = [ {
header: "Identifier",
property: "identifier",
type: "input"
}, {
header: "Name",
property: "title",
type: "input"
}, {
header: "Mode",
property: "type",
type: "select",
option: "static",
options: [
{value: "wild", text: "WildChar"},
{value: "regex", text: "RegEx"},
{value: "clsid", text: "CLSID"}
]
}, {
header: "Pattern",
property: "value",
type: "input"
}, {
header: "Keyword",
property: "keyword",
type: "input"
}, {
header: "testURL",
property: "testUrl",
type: "input"
}, {
header: "UserAgent",
property: "userAgent",
type: "select",
option: "static",
options: [
{value: "", text: "Chrome"},
{value: "ie9", text: "MSIE9"},
{value: "ie8", text: "MSIE8"},
{value: "ie7", text: "MSIE7"},
{value: "ff7win", text: "Firefox 7 Windows"},
{value: "ff7mac", text: "Firefox 7 Mac"},
{value: "ip5", text: "iPhone"},
{value: "ipad5", text: "iPad"}
]
}, {
header: "Helper Script",
property: "script",
type: "input",
events: {
create: setScriptAutoComplete
}
}];
var currentScript = -1;
function showScript(id) {
var url = baseDir + scripts[id].url;
currentScript = id;
$(scriptEditor).val('');
$.ajax(url, {
success: function(value) {
origScript = value;
$(scriptEditor).val(value);
}
});
$('#scriptDialog').dialog('open');
}
function saveToFile(file, value) {
$.ajax(baseDir + 'upload.php', {
type: "POST",
data: {
file: file,
data: value
}
});
}
var origScript;
function saveScript(id) {
var value = $('#scriptEditor').val();
if (value == origScript) {
return;
}
var file = scripts[id].url;
scriptList.updateLine(scriptList.getLine(id));
saveToFile(file, value);
dirty = true;
}
var scriptProps = [{
property: "identifier",
header: "Identifier",
type: "input"
}, {
property: "url",
header: "URL",
type: "input"
}, {
property: "context",
header: "Context",
type: "select",
option: "static",
options: [
{value: "page", text: "Page"},
{value: "extension", text: "Extension"}
]
}, {
property: "show",
header: "Show",
type: "button",
events: {
create: function(e) {
$('button', this).text('Show');
},
command: function(e) {
showScript(Number(e.data.line.attr('row')), true);
}
}
}];
var issueProps = [{
header: "Identifier",
property: "identifier",
type: "input"
}, {
header: "Mode",
property: "type",
type: "select",
option: "static",
options: [
{value: "wild", text: "WildChar"},
{value: "regex", text: "RegEx"},
{value: "clsid", text: "CLSID"}
]
}, {
header: "Pattern",
property: "value",
type: "input"
}, {
header: "Description",
property: "description",
type: "input"
}, {
header: "IssueId",
property: "issueId",
type: "input"
}, {
header: "url",
property: "url",
type: "input"
}];
// The JSON formatter is from http://joncom.be/code/javascript-json-formatter/
function FormatJSON(oData, sIndent) {
function RealTypeOf(v) {
if (typeof(v) == "object") {
if (v === null) return "null";
if (v.constructor == Array) return "array";
if (v.constructor == Date) return "date";
if (v.constructor == RegExp) return "regex";
return "object";
}
return typeof(v);
}
if (arguments.length < 2) {
var sIndent = "";
}
var sIndentStyle = " ";
var sDataType = RealTypeOf(oData);
// open object
if (sDataType == "array") {
if (oData.length == 0) {
return "[]";
}
var sHTML = "[";
} else {
var iCount = 0;
$.each(oData, function() {
iCount++;
return;
});
if (iCount == 0) { // object is empty
return "{}";
}
var sHTML = "{";
}
// loop through items
var iCount = 0;
$.each(oData, function(sKey, vValue) {
if (iCount > 0) {
sHTML += ",";
}
if (sDataType == "array") {
sHTML += ("\n" + sIndent + sIndentStyle);
} else {
sHTML += ("\n" + sIndent + sIndentStyle + "\"" + sKey + "\"" + ": ");
}
// display relevant data type
switch (RealTypeOf(vValue)) {
case "array":
case "object":
sHTML += FormatJSON(vValue, (sIndent + sIndentStyle));
break;
case "boolean":
case "number":
sHTML += vValue.toString();
break;
case "null":
sHTML += "null";
break;
case "string":
sHTML += ("\"" + vValue + "\"");
break;
default:
sHTML += JSON.stringify(vValue);
}
// loop
iCount++;
});
// close object
if (sDataType == "array") {
sHTML += ("\n" + sIndent + "]");
} else {
sHTML += ("\n" + sIndent + "}");
}
// return
return sHTML;
}
function loadRules(value) {
rules = [];
for (var i in value) {
rules.push(value[i]);
}
ruleList.refresh();
freezeIdentifier(ruleList);
}
function loadIssues(value) {
issues = [];
for (var i in value) {
issues.push(value[i]);
}
issueList.refresh();
freezeIdentifier(issueList);
}
function loadScripts(value) {
scripts = [];
for (var i in value) {
scripts.push(value[i]);
}
scriptList.refresh();
freezeIdentifier(scriptList);
updateScriptItems();
}
function serialize(list) {
var obj = {};
for (var i = 0; i < list.length; ++i) {
obj[list[i].identifier] = list[i];
}
return FormatJSON(obj);
}
function save() {
saveToFile('setting.json', serialize(rules));
saveToFile('scripts.json', serialize(scripts));
saveToFile('issues.json', serialize(issues));
dirty= false;
freezeIdentifier(ruleList);
freezeIdentifier(scriptList);
}
function reload() {
$.ajax(baseDir + 'setting.json', {
success: loadRules
});
$.ajax(baseDir + 'scripts.json', {
success: loadScripts
});
$.ajax(baseDir + 'issues.json', {
success: loadIssues
});
dirty = false;
}
function freezeIdentifier(list) {
$('.itemline:not(.newline) div[property=identifier]', list.contents)
.addClass('readonly');
}
var scriptList, ruleList, issueList;
var scriptItems = [];
function updateScriptItems() {
scriptItems = [];
for (var i = 0; i < scripts.length; ++i) {
scriptItems.push(scripts[i].identifier);
}
}
$(document).ready(function() {
window.onbeforeunload=function() {
if (dirty) {
return 'Page not saved. Continue?';
}
}
$('#addRule').click(function() {
ruleList.editNewLine();
}).button();
$('#deleteRule').click(function() {
ruleList.remove(ruleList.selectedLine);
}).button();
$('#addScript').click(function() {
scriptList.editNewLine();
}).button();
$('#deleteScript').click(function() {
scriptList.remove(scriptList.selectedLine);
}).button();
$('#addIssue').click(function() {
issueList.editNewLine();
}).button();
$('#deleteIssue').click(function() {
issueList.remove(issueList.selectedLine);
}).button();
$('.doSave').each(function() {
$(this).click(save).button();
});
$('#tabs').tabs();
$('#scriptDialog').dialog({
modal: true,
autoOpen: false,
height: 500,
width: 700,
buttons: {
"Save": function() {
saveScript(currentScript);
$(this).dialog('close');
},
"Cancel": function() {
$(this).dialog('close');
}
}
});
$.ajaxSetup({
cache: false
});
scriptList = new List({
props: scriptProps,
main: $('#scriptTable'),
getItems: function() {return scripts;}
});
$(scriptList).bind('updated', function() {
dirty = true;
updateScriptItems();
});
scriptList.init();
ruleList = new List({
props: ruleProps,
main: $('#ruleTable'),
getItems: function() {return rules;}
});
ruleList.init();
$(ruleList).bind('updated', function() {
dirty = true;
});
issueList = new List({
props: issueProps,
main: $('#issueTable'),
getItems: function() {return issues;}
});
issueList.init();
$(issueList).bind('updated', function() {
dirty = true;
});
reload();
});
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
List.types.input = function(p, prop) {
p[0].listdata = this;
this.p = p;
var input = this.input = $('<input></input>').addClass('valinput');
this.label = $('<span></span>').addClass('valdisp');
this.label.click(function(e) {
setTimeout(function(){
input.focus();
}, 10);
});
this.input.focus(function(e) {
input.select();
});
this.input.keypress(function(e) {
p.trigger('change');
});
this.input.keyup(function(e) {
p.trigger('change');
});
this.input.change(function(e) {
p.trigger('change');
});
p.append(this.input).append(this.label);
};
List.types.input.prototype.__defineSetter__('value', function(val) {
this.input.val(val);
this.label.text(val);
});
List.types.input.prototype.__defineGetter__('value', function() {
return this.input.val();
});
List.types.select = function(p, prop) {
p[0].listdata = this;
this.p = p;
var input = this.input = $('<select></select>').addClass('valinput');
this.label = $('<span></span>').addClass('valdisp');
if (prop.option == 'static') {
this.loadOptions(prop.options);
}
var select = this;
this.input.change(function(e) {
if (p.hasClass('readonly')) {
select.value = select.lastval;
} else {
p.trigger('change');
}
});
this.label.click(function(e) {
setTimeout(function(){
input.focus();
}, 10);
});
p.append(this.input).append(this.label);
};
List.types.select.prototype.loadOptions = function(options) {
this.options = options;
this.mapping = {};
this.input.html("");
for (var i = 0; i < options.length; ++i) {
this.mapping[options[i].value] = options[i].text;
var o = $('<option></option>').val(options[i].value).text(options[i].text)
this.input.append(o);
}
}
List.types.select.prototype.__defineGetter__('value', function() {
return this.input.val();
});
List.types.select.prototype.__defineSetter__('value', function(val) {
this.lastval = val;
this.input.val(val);
this.label.text(this.mapping[val]);
});
List.types.checkbox = function(p, prop) {
p[0].listdata = this;
this.p = p;
var input = this.input = $('<input type="checkbox">').addClass('valcheck');
var box = this;
this.input.change(function(e) {
if (p.hasClass('readonly')) {
box.value = box.lastval;
} else {
p.trigger('change');
}
});
p.append(this.input);
};
List.types.checkbox.prototype.__defineGetter__('value', function() {
return this.input[0].checked;
});
List.types.checkbox.prototype.__defineSetter__('value', function(val) {
this.lastval = val;
this.input[0].checked = val;
});
List.types.button = function(p, prop) {
p[0].listdata = this;
this.p = p;
var input = this.input = $('<button>');
if (prop.caption) {
input.text(prop.caption);
}
input.click(function(e) {
p.trigger('command');
return false;
});
p.append(this.input);
};
List.types.button.prototype.__defineGetter__('value', function() {
return undefined;
});
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
var tabStatus = {};
var version;
var firstRun = false;
var firstUpgrade = false;
var blackList = [
/^https?:\/\/[^\/]*\.taobao\.com\/.*/i,
/^https?:\/\/[^\/]*\.alipay\.com\/.*/i
];
var MAX_LOG = 400;
(function getVersion() {
$.ajax('manifest.json', {
success: function(v) {
v = JSON.parse(v);
version = v.version;
trackVersion(version);
}
});
})();
function startListener() {
chrome.extension.onConnect.addListener(function(port) {
if (!port.sender.tab) {
console.error('Not connect from tab');
return;
}
initPort(port);
});
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
if (!sender.tab) {
console.error('Request from non-tab');
} else if (request.command == 'Configuration') {
var config = setting.getPageConfig(request.href);
sendResponse(config);
if (request.top) {
resetTabStatus(sender.tab.id);
var dummy = {href: request.href, clsid: 'NULL', urldetect: true};
if (!config.pageRule &&
setting.getFirstMatchedRule(
dummy, setting.defaultRules)) {
detectControl(dummy, sender.tab.id, 0);
}
}
} else if (request.command == 'GetNotification') {
getNotification(request, sender, sendResponse);
} else if (request.command == 'DismissNotification') {
chrome.tabs.sendRequest(
sender.tab.id, {command: 'DismissNotificationPage'});
sendResponse({});
} else if (request.command == 'BlockSite') {
setting.blocked.push({type: 'wild', value: request.site});
setting.update();
sendResponse({});
}
}
);
}
var blocked = {};
function notifyUser(request, tabId) {
var s = tabStatus[tabId];
if (s.notify && (s.urldetect || s.count > s.actived)) {
console.log('Notify the user on tab ', tabId);
chrome.tabs.sendRequest(tabId, {command: 'NotifyUser', tabid: tabId}, null);
}
}
var greenIcon = chrome.extension.getURL('icon16.png');
var grayIcon = chrome.extension.getURL('icon16-gray.png');
var errorIcon = chrome.extension.getURL('icon16-error.png');
var responseCommands = {};
function resetTabStatus(tabId) {
tabStatus[tabId] = {
count: 0,
actived: 0,
error: 0,
urldetect: 0,
notify: true,
issueId: null,
logs: {'0': []},
objs: {'0': []},
frames: 1,
tracking: false
};
}
function initPort(port) {
var tabId = port.sender.tab.id;
if (!(tabId in tabStatus)) {
resetTabStatus(tabId);
}
var status = tabStatus[tabId];
var frameId = tabStatus[tabId].frames++;
status.logs[frameId] = [];
status.objs[frameId] = [];
port.onMessage.addListener(function(request) {
var resp = responseCommands[request.command];
if (resp) {
delete request.command;
resp(request, tabId, frameId);
} else {
console.error('Unknown command ' + request.command);
}
});
port.onDisconnect.addListener(function() {
for (var i = 0; i < status.objs[frameId].length; ++i) {
countTabObject(status, status.objs[frameId][i], -1);
}
showTabStatus(tabId);
if (status.tracking) {
if (status.count == 0) {
// Open the log page.
window.open('log.html?tabid=' + tabId);
status.tracking = false;
}
} else {
// Clean up after 1 min.
window.setTimeout(function() {
status.logs[frameId] = [];
status.objs[frameId] = [];
}, 60 * 1000);
}
});
}
chrome.tabs.onRemoved.addListener(function(tabId, removeInfo) {
if (tabStatus[tabId]) {
tabStatus[tabId].removed = true;
var TIMEOUT = 1000 * 60 * 5;
// clean up after 5 mins.
window.setTimeout(function() {
delete tabStatus[tabId];
}, TIMEOUT);
}
});
function countTabObject(status, info, delta) {
for (var i = 0; i < blackList.length; ++i) {
if (info.href.match(blackList[i])) {
return;
}
}
if (setting.getFirstMatchedRule(info, setting.blocked)) {
status.notify = false;
}
if (info.urldetect) {
status.urldetect += delta;
// That's not a object.
return;
}
if (info.actived) {
status.actived += delta;
if (delta > 0) {
trackUse(info.rule);
}
} else if (delta > 0) {
trackNotUse(info.href);
}
status.count += delta;
var issue = setting.getMatchedIssue(info);
if (issue) {
status.error += delta;
status.issueId = issue.identifier;
if (delta > 0) {
trackIssue(issue);
}
}
}
function showTabStatus(tabId) {
if (tabStatus[tabId].removed) {
return;
}
var status = tabStatus[tabId];
var title = '';
var iconPath = greenIcon;
if (!status.count && !status.urldetect) {
chrome.pageAction.hide(tabId);
return;
} else {
chrome.pageAction.show(tabId);
}
if (status.urldetect) {
// Matched some rule.
iconPath = grayIcon;
title = $$('status_urldetect');
} else if (status.count == 0) {
// Do nothing..
} else if (status.error != 0) {
// Error
iconPath = errorIcon;
title = $$('status_error');
} else if (status.count != status.actived) {
// Disabled..
iconPath = grayIcon;
title = $$('status_disabled');
} else {
// OK
iconPath = greenIcon;
title = $$('status_ok');
}
chrome.pageAction.setIcon({
tabId: tabId,
path: iconPath
});
chrome.pageAction.setTitle({
tabId: tabId,
title: title
});
chrome.pageAction.setPopup({
tabId: tabId,
popup: 'popup.html?tabid=' + tabId
});
}
function detectControl(request, tabId, frameId) {
var status = tabStatus[tabId];
if (frameId != 0 && status.objs[0].length) {
// Remove the item to identify the page.
countTabObject(status, status.objs[0][0], -1);
status.objs[0] = [];
}
status.objs[frameId].push(request);
countTabObject(status, request, 1);
showTabStatus(tabId);
notifyUser(request, tabId);
}
responseCommands.DetectControl = detectControl;
responseCommands.Log = function(request, tabId, frameId) {
var logs = tabStatus[tabId].logs[frameId];
if (logs.length < MAX_LOG) {
logs.push(request.message);
} else if (logs.length == MAX_LOG) {
logs.push('More logs clipped');
}
};
function generateLogFile(tabId) {
var status = tabStatus[tabId];
if (!status) {
return 'No log for tab ' + tabId;
}
var ret = '---------- Start of log --------------\n';
ret += 'UserAgent: ' + navigator.userAgent + '\n';
ret += 'Extension version: ' + version + '\n';
ret += '\n';
var frameCount = 0;
for (var i = 0; i < status.frames; ++i) {
if (status.objs[i].length == 0 && status.logs[i].length == 0) {
continue;
}
if (frameCount) {
ret += '\n\n';
}
++frameCount;
ret += '------------ Frame ' + (i + 1) + ' ------------------\n';
ret += 'Objects:\n';
for (var j = 0; j < status.objs[i].length; ++j) {
ret += JSON.stringify(status.objs[i][j]) + '\n';
}
ret += '\n';
ret += 'Log:\n';
for (var j = 0; j < status.logs[i].length; ++j) {
ret += status.logs[i][j] + '\n';
}
}
ret += '\n---------------- End of log ---------------\n';
ret += stringHash(ret);
if (frameCount == 0) {
return 'No log for tab ' + tabId;
}
return ret;
}
function getNotification(request, sender, sendResponse) {
var tabid = sender.tab.id;
chrome.tabs.get(tabid, function(tab) {
var config = {};
config.tabId = tab.id;
config.site = tab.url.replace(/[^:]*:\/\/([^\/]*).*/, '$1');
config.sitePattern = tab.url.replace(/([^:]*:\/\/[^\/]*).*/, '$1/*');
if (tabStatus[tabid].urldetect) {
config.message = $$('status_urldetect');
} else {
config.message = $$('status_disabled');
}
config.closeMsg = $$('bar_close');
config.enableMsg = $$('bar_enable');
config.blockMsg = $$('bar_block', config.site);
sendResponse(config);
});
}
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
// Permission for experimental not given.
var handler = chrome.webRequest;
function onBeforeSendHeaders(details) {
var rule = setting.getFirstMatchedRule(
{href: details.url}, setting.cache.userAgent);
if (!rule || !(rule.userAgent in agents)) {
return {};
}
for (var i = 0; i < details.requestHeaders.length; ++i) {
if (details.requestHeaders[i].name == 'User-Agent') {
details.requestHeaders[i].value = agents[rule.userAgent];
break;
}
}
return {requestHeaders: details.requestHeaders};
}
function registerRequestListener() {
if (!handler) {
return;
}
var filters = {
urls: ['<all_urls>'],
types: ['main_frame', 'sub_frame', 'xmlhttprequest']
};
try {
handler.onBeforeSendHeaders.addListener(
onBeforeSendHeaders, filters, ['requestHeaders', 'blocking']);
} catch (e) {
console.log('Your browser doesn\'t support webRequest');
}
}
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
/*
Rule: {
identifier: an unique identifier
title: description
type: Can be "wild", "regex", "clsid"
value: pattern, correspond to type
userAgent: the useragent value. See var "agents" for options.
script: script to inject. Separated by spaces
}
Order: {
status: enabled / disabled / custom
position: default / custom
identifier: identifier of rule
}
Issue: {
type: Can be "wild", "regex", "clsid"
value: pattern, correspond to type
description: The description of this issue
issueId: Issue ID on issue tracking page
url: optional, support page for issue tracking.
Use code.google.com if omitted.
}
ServerSide:
ActiveXConfig: {
version: version
rules: object of user-defined rules, propertied by identifiers
defaultRules: ojbect of default rules
scripts: mapping of workaround scripts, by identifiers.
order: the order of rules
cache: to accerlerate processing
issues: The bugs/unsuppoted sites that we have accepted.
misc:{
lastUpdate: last timestamp of updating
logEnabled: log
tracking: Allow GaS tracking.
verbose: verbose level of logging
}
}
PageSide:
ActiveXConfig: {
pageSide: Flag of pageSide.
pageScript: Helper script to execute on context of page
extScript: Helper script to execute on context of extension
pageRule: If page is matched.
clsidRules: If page is not matched or disabled. valid CLSID rules
logEnabled: log
verbose: verbose level of logging
}
*/
function ActiveXConfig(input)
{
var settings;
if (input === undefined) {
var defaultSetting = {
version: 3,
rules: {},
defaultRules: {},
scriptContents: {},
scripts: {},
order: [],
notify: [],
issues: [],
blocked: [],
misc: {
lastUpdate: 0,
logEnabled: false,
tracking: true,
verbose: 3
}
};
input = defaultSetting;
}
settings = ActiveXConfig.convertVersion(input);
settings.removeInvalidItems();
settings.update();
return settings;
}
var settingKey = 'setting';
clsidPattern = /[^0-9A-F][0-9A-F]{8}-([0-9A-F]{4}-){3}[0-9A-F]{12}[^0-9A-F]/;
var agents = {
ie9: 'Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)',
ie8: 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0)',
ie7: 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; WOW64;)',
ff7win: 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1)' +
' Gecko/20100101 Firefox/7.0.1',
ip5: 'Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X)' +
' AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1' +
' Mobile/9A334 Safari/7534.48.3',
ipad5: 'Mozilla/5.0 (iPad; CPU OS 5_0 like Mac OS X) AppleWebKit/534.46' +
'(KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3'
};
function getUserAgent(key) {
// This script is always run under sandbox, so useragent should be always
// correct.
if (!key || !(key in agents)) {
return '';
}
var current = navigator.userAgent;
var wow64 = current.indexOf('WOW64') >= 0;
var value = agents[key];
if (!wow64) {
value = value.replace(' WOW64;', '');
}
return value;
}
ActiveXConfig.convertVersion = function(setting) {
if (setting.version == 3) {
if (!setting.blocked) {
setting.blocked = [];
}
setting.__proto__ = ActiveXConfig.prototype;
return setting;
} else if (setting.version == 2) {
function parsePattern(pattern) {
pattern = pattern.trim();
var title = pattern.match(/###(.*)/);
if (title) {
return {
pattern: pattern.match(/(.*)###/)[1].trim(),
title: title[1].trim()
};
} else {
return {
pattern: pattern,
title: 'Rule'
};
}
}
var ret = new ActiveXConfig();
if (setting.logEnabled) {
ret.misc.logEnabled = true;
}
var urls = setting.url_plain.split('\n');
for (var i = 0; i < urls.length; ++i) {
var rule = ret.createRule();
var pattern = parsePattern(urls[i]);
rule.title = pattern.title;
var url = pattern.pattern;
if (url.substr(0, 2) == 'r/') {
rule.type = 'regex';
rule.value = url.substr(2);
} else {
rule.type = 'wild';
rule.value = url;
}
ret.addCustomRule(rule, 'convert');
}
var clsids = setting.trust_clsids.split('\n');
for (var i = 0; i < clsids.length; ++i) {
var rule = ret.createRule();
rule.type = 'clsid';
var pattern = parsePattern(clsids[i]);
rule.title = pattern.title;
rule.value = pattern.pattern;
ret.addCustomRule(rule, 'convert');
}
firstUpgrade = true;
return ret;
}
};
ActiveXConfig.prototype = {
// Only used for user-scripts
shouldEnable: function(object) {
if (this.pageRule) {
return this.pageRule;
}
var clsidRule = this.getFirstMatchedRule(object, this.clsidRules);
if (clsidRule) {
return clsidRule;
} else {
return null;
}
},
createRule: function() {
return {
title: 'Rule',
type: 'wild',
value: '',
userAgent: '',
scriptItems: ''
};
},
removeInvalidItems: function() {
if (this.pageSide) {
return;
}
function checkIdentifierMatches(item, prop) {
if (typeof item[prop] != 'object') {
console.log('reset ', prop);
item[prop] = {};
}
for (var i in item[prop]) {
var ok = true;
if (typeof item[prop][i] != 'object') {
ok = false;
}
if (ok && item[prop][i].identifier != i) {
ok = false;
}
if (!ok) {
console.log('remove corrupted item ', i, ' in ', prop);
delete item[prop][i];
}
}
}
checkIdentifierMatches(this, 'rules');
checkIdentifierMatches(this, 'defaultRules');
checkIdentifierMatches(this, 'scripts');
checkIdentifierMatches(this, 'issues');
var newOrder = [];
for (var i = 0; i < this.order.length; ++i) {
if (this.getItem(this.order[i])) {
newOrder.push(this.order[i]);
} else {
console.log('remove order item ', this.order[i]);
}
}
this.order = newOrder;
},
addCustomRule: function(newItem, auto) {
if (!this.validateRule(newItem)) {
return;
}
var identifier = this.createIdentifier();
newItem.identifier = identifier;
this.rules[identifier] = newItem;
this.order.push({
status: 'custom',
position: 'custom',
identifier: identifier
});
this.update();
trackAddCustomRule(newItem, auto);
},
updateDefaultRules: function(newRules) {
var deleteAll = false, ruleToDelete = {};
if (typeof this.defaultRules != 'object') {
// There might be some errors!
// Clear all defaultRules
console.log('Corrupted default rules, reload all');
deleteAll = true;
this.defaultRules = {};
} else {
for (var i in this.defaultRules) {
if (!(i in newRules)) {
console.log('Remove rule ' + i);
ruleToDelete[i] = true;
delete this.defaultRules[i];
}
}
}
var newOrder = [];
for (var i = 0; i < this.order.length; ++i) {
if (this.order[i].position == 'custom' ||
(!deleteAll && !ruleToDelete[this.order[i].identifier])) {
newOrder.push(this.order[i]);
}
}
this.order = newOrder;
var position = 0;
for (var i in newRules) {
if (!(i in this.defaultRules)) {
this.addDefaultRule(newRules[i], position);
position++;
}
this.defaultRules[i] = newRules[i];
}
},
loadDefaultConfig: function() {
var setting = this;
$.ajax({
url: '/settings/setting.json',
dataType: 'json',
success: function(nv, status, xhr) {
console.log('Update default rules');
setting.updateDefaultRules(nv);
setting.update();
}
});
$.ajax({
url: '/settings/scripts.json',
dataType: 'json',
success: function(nv, status, xhr) {
console.log('Update scripts');
setting.scripts = nv;
setting.loadAllScripts();
setting.update();
}
});
$.ajax({
url: '/settings/issues.json',
dataType: 'json',
success: function(nv, status, xhr) {
setting.issues = nv;
setting.update();
}
});
},
getPageConfig: function(href) {
var ret = {};
ret.pageSide = true;
ret.version = this.version;
ret.verbose = this.misc.verbose;
ret.logEnabled = this.misc.logEnabled;
ret.pageRule = this.getFirstMatchedRule({href: href});
if (!ret.pageRule) {
ret.clsidRules = this.cache.clsidRules;
} else {
var script = this.getScripts(ret.pageRule.script);
ret.pageScript = script.page;
ret.extScript = script.extension;
}
return ret;
},
getFirstMatchedRule: function(object, rules) {
var useCache = false;
if (!rules) {
rules = this.cache.validRules;
useCache = true;
}
if (Array.isArray(rules)) {
for (var i = 0; i < rules.length; ++i) {
if (this.isRuleMatched(rules[i], object, useCache ? i : -1)) {
return rules[i];
}
}
} else {
for (var i in rules) {
if (this.isRuleMatched(rules[i], object)) {
return rules[i];
}
}
}
return null;
},
getMatchedIssue: function(filter) {
return this.getFirstMatchedRule(filter, this.issues);
},
activeRule: function(rule) {
for (var i = 0; i < this.order.length; ++i) {
if (this.order[i].identifier == rule.identifier) {
if (this.order[i].status == 'disabled') {
this.order[i].status = 'enabled';
trackAutoEnable(rule.identifier);
}
break;
}
}
this.update();
},
validateRule: function(rule) {
var ret = true;
try {
if (rule.type == 'wild') {
ret &= this.convertUrlWildCharToRegex(rule.value) != null;
} else if (rule.type == 'regex') {
ret &= rule.value != '';
var r = new RegExp(rule.value, 'i');
} else if (rule.type == 'clsid') {
var v = rule.value.toUpperCase();
if (!clsidPattern.test(v) || v.length > 55)
ret = false;
}
} catch (e) {
ret = false;
}
return ret;
},
isRuleMatched: function(rule, object, id) {
if (rule.type == 'wild' || rule.type == 'regex') {
var regex;
if (id >= 0) {
regex = this.cache.regex[id];
} else if (rule.type == 'wild') {
regex = this.convertUrlWildCharToRegex(rule.value);
} else if (rule.type == 'regex') {
regex = new RegExp('^' + rule.value + '$', 'i');
}
if (object.href && regex.test(object.href)) {
return true;
}
} else if (rule.type == 'clsid') {
if (object.clsid) {
var v1 = clsidPattern.exec(rule.value.toUpperCase());
var v2 = clsidPattern.exec(object.clsid.toUpperCase());
if (v1 && v2 && v1[0] == v2[0]) {
return true;
}
}
}
return false;
},
getScripts: function(script) {
var ret = {
page: '',
extension: ''
};
if (!script) {
return ret;
}
var items = script.split(' ');
for (var i = 0; i < items.length; ++i) {
if (!items[i] || !this.scripts[items[i]]) {
continue;
}
var name = items[i];
var val = '// ';
val += items[i] + '\n';
val += this.scriptsContents[name];
val += '\n\n';
ret[this.scripts[name].context] += val;
}
return ret;
},
convertUrlWildCharToRegex: function(wild) {
try {
function escapeRegex(str, star) {
if (!star) star = '*';
var escapeChars = /([\.\\\/\?\{\}\+\[\]])/g;
return str.replace(escapeChars, '\\$1').replace('*', star);
}
wild = wild.toLowerCase();
if (wild == '<all_urls>') {
wild = '*://*/*';
}
var pattern = /^(.*?):\/\/(\*?[^\/\*]*)\/(.*)$/i;
// pattern: [all, scheme, host, page]
var parts = pattern.exec(wild);
if (parts == null) {
return null;
}
var scheme = parts[1];
var host = parts[2];
var page = parts[3];
var regex = '^' + escapeRegex(scheme, '[^:]*') + ':\\/\\/';
regex += escapeRegex(host, '[^\\/]*') + '/';
regex += escapeRegex(page, '.*');
return new RegExp(regex, 'i');
} catch (e) {
return null;
}
},
update: function() {
if (this.pageSide) {
return;
}
this.updateCache();
if (this.cache.listener) {
this.cache.listener.trigger('update');
}
this.save();
},
// Please remember to call update() after all works are done.
addDefaultRule: function(rule, position) {
console.log('Add new default rule: ', rule);
var custom = null;
if (rule.type == 'clsid') {
for (var i in this.rules) {
var info = {href: 'not-a-URL-/', clsid: rule.value};
if (this.isRuleMatched(this.rules[i], info, -1)) {
custom = this.rules[i];
break;
}
}
} else if (rule.keyword && rule.testUrl) {
// Try to find matching custom rule
for (var i in this.rules) {
if (this.isRuleMatched(this.rules[i], {href: rule.testUrl}, -1)) {
if (this.rules[i].value.toLowerCase().indexOf(rule.keyword) != -1) {
custom = this.rules[i];
break;
}
}
}
}
var newStatus = 'disabled';
if (custom) {
console.log('Convert custom rule', custom, ' to default', rule);
// Found a custom rule which is similiar to this default rule.
newStatus = 'enabled';
// Remove old one
delete this.rules[custom.identifier];
for (var i = 0; i < this.order.length; ++i) {
if (this.order[i].identifier == custom.identifier) {
this.order.splice(i, 1);
break;
}
}
}
this.order.splice(position, 0, {
position: 'default',
status: newStatus,
identifier: rule.identifier
});
this.defaultRules[rule.identifier] = rule;
},
updateCache: function() {
if (this.pageSide) {
return;
}
this.cache = {
validRules: [],
regex: [],
clsidRules: [],
userAgentRules: [],
listener: (this.cache || {}).listener
};
for (var i = 0; i < this.order.length; ++i) {
if (['custom', 'enabled'].indexOf(this.order[i].status) >= 0) {
var rule = this.getItem(this.order[i]);
var cacheId = this.cache.validRules.push(rule) - 1;
if (rule.type == 'clsid') {
this.cache.clsidRules.push(rule);
} else if (rule.type == 'wild') {
this.cache.regex[cacheId] =
this.convertUrlWildCharToRegex(rule.value);
} else if (rule.type == 'regex') {
this.cache.regex[cacheId] = new RegExp('^' + rule.value + '$', 'i');
}
if (rule.userAgent != '') {
this.cache.userAgentRules.push(rule);
}
}
}
},
save: function() {
if (location.protocol == 'chrome-extension:') {
// Don't include cache in localStorage.
var cache = this.cache;
delete this.cache;
var scripts = this.scriptsContents;
delete this.scriptsContents;
localStorage[settingKey] = JSON.stringify(this);
this.cache = cache;
this.scriptsContents = scripts;
}
},
createIdentifier: function() {
var base = 'custom_' + Date.now() + '_' + this.order.length + '_';
var ret;
do {
ret = base + Math.round(Math.random() * 65536);
} while (this.getItem(ret));
return ret;
},
getItem: function(item) {
var identifier = item;
if (typeof identifier != 'string') {
identifier = item.identifier;
}
if (identifier in this.rules) {
return this.rules[identifier];
} else {
return this.defaultRules[identifier];
}
},
loadAllScripts: function() {
this.scriptsContents = {};
setting = this;
for (var i in this.scripts) {
var item = this.scripts[i];
$.ajax({
url: '/settings/' + item.url,
datatype: 'text',
context: item,
success: function(nv, status, xhr) {
setting.scriptsContents[this.identifier] = nv;
}
});
}
}
};
function loadLocalSetting() {
var setting = undefined;
if (localStorage[settingKey]) {
try {
setting = JSON.parse(localStorage[settingKey]);
} catch (e) {
setting = undefined;
}
}
if (!setting) {
firstRun = true;
}
return new ActiveXConfig(setting);
}
function clearSetting() {
localStorage.removeItem(settingKey);
setting = loadLocalSetting();
}
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
var FLASH_CLSID = '{d27cdb6e-ae6d-11cf-96b8-444553540000}';
var typeId = 'application/x-itst-activex';
var updating = false;
function executeScript(script) {
var scriptobj = document.createElement('script');
scriptobj.innerHTML = script;
var element = document.head || document.body ||
document.documentElement || document;
element.insertBefore(scriptobj, element.firstChild);
element.removeChild(scriptobj);
}
function checkParents(obj) {
var parent = obj;
var level = 0;
while (parent && parent.nodeType == 1) {
if (getComputedStyle(parent).display == 'none') {
var desp = obj.id + ' at level ' + level;
if (scriptConfig.none2block) {
parent.style.display = 'block';
parent.style.height = '0px';
parent.style.width = '0px';
log('Remove display:none for ' + desp);
} else {
log('Warning: Detected display:none for ' + desp);
}
}
parent = parent.parentNode;
++level;
}
}
function getLinkDest(url) {
if (typeof url != 'string') {
return url;
}
url = url.trim();
if (/^https?:\/\/.*/.exec(url)) {
return url;
}
if (url[0] == '/') {
if (url[1] == '/') {
return location.protocol + url;
} else {
return location.origin + url;
}
}
return location.href.replace(/\/[^\/]*$/, '/' + url);
}
var hostElement = null;
function enableobj(obj) {
updating = true;
// We can't use classid directly because it confuses the browser.
obj.setAttribute('clsid', getClsid(obj));
obj.removeAttribute('classid');
checkParents(obj);
var newObj = obj.cloneNode(true);
newObj.type = typeId;
// Remove all script nodes. They're executed.
var scripts = newObj.getElementsByTagName('script');
for (var i = 0; i < scripts.length; ++i) {
scripts[i].parentNode.removeChild(scripts[i]);
}
// Set codebase to full path.
var codebase = newObj.getAttribute('codebase');
if (codebase && codebase != '') {
newObj.setAttribute('codebase', getLinkDest(codebase));
}
newObj.activex_process = true;
obj.parentNode.insertBefore(newObj, obj);
obj.parentNode.removeChild(obj);
obj = newObj;
if (obj.id) {
var command = '';
if (obj.form && scriptConfig.formid) {
var form = obj.form.name;
command += 'document.all.' + form + '.' + obj.id;
command += ' = document.all.' + obj.id + ';\n';
log('Set form[obj.id]: form: ' + form + ', object: ' + obj.id);
}
// Allow access by document.obj.id
if (obj.id && scriptConfig.documentid) {
command += 'delete document.' + obj.id + ';\n';
command += 'document.' + obj.id + '=' + obj.id + ';\n';
}
if (command) {
executeScript(command);
}
}
log('Enabled object, id: ' + obj.id + ' clsid: ' + getClsid(obj));
updating = false;
return obj;
}
function getClsid(obj) {
if (obj.hasAttribute('clsid'))
return obj.getAttribute('clsid');
var clsid = obj.getAttribute('classid');
var compos = clsid.indexOf(':');
if (clsid.substring(0, compos).toLowerCase() != 'clsid')
return;
clsid = clsid.substring(compos + 1);
return '{' + clsid + '}';
}
function notify(data) {
connect();
data.command = 'DetectControl';
port.postMessage(data);
}
function process(obj) {
if (obj.activex_process)
return;
if (onBeforeLoading.caller == enableobj ||
onBeforeLoading.caller == process ||
onBeforeLoading.caller == checkParents) {
log('Nested onBeforeLoading ' + obj.id);
return;
}
if (obj.type == typeId) {
if (!config || !config.pageRule) {
// hack??? Deactive this object.
log('Deactive unexpected object ' + obj.outerHTML);
return true;
}
log('Found objects created by client scripts');
notify({
href: location.href,
clsid: clsid,
actived: true,
rule: config.pageRule.identifier
});
obj.activex_process = true;
return;
}
if ((obj.type != '' && obj.type != 'application/x-oleobject') ||
!obj.hasAttribute('classid'))
return;
if (getClsid(obj).toLowerCase() == FLASH_CLSID) {
return;
}
if (config == null) {
// Delay the process of this object.
// Hope config will be load soon.
log('Pending object ', obj.id);
pendingObjects.push(obj);
return;
}
obj.activex_process = true;
connect();
var clsid = getClsid(obj);
var rule = config.shouldEnable({href: location.href, clsid: clsid});
if (rule) {
obj = enableobj(obj);
notify({
href: location.href,
clsid: clsid,
actived: true,
rule: rule.identifier
});
} else {
notify({href: location.href, clsid: clsid, actived: false});
}
}
function replaceSubElements(obj) {
var s = obj.querySelectorAll('object[classid]');
if (obj.tagName == 'OBJECT' && obj.hasAttribute('classid')) {
s.push(obj);
}
for (var i = 0; i < s.length; ++i) {
process(s[i]);
}
}
function onBeforeLoading(event) {
var obj = event.target;
if (obj.nodeName == 'OBJECT') {
log('BeforeLoading ' + obj.id);
if (process(obj)) {
event.preventDefault();
}
}
}
function onError(event) {
var message = 'Error: ';
message += event.message;
message += ' at ';
message += event.filename;
message += ':';
message += event.lineno;
log(message);
return false;
}
function setUserAgent() {
if (!config.pageRule) {
return;
}
var agent = getUserAgent(config.pageRule.userAgent);
if (agent && agent != '') {
log('Set userAgent: ' + config.pageRule.userAgent);
var js = '(function(agent) {';
js += 'delete navigator.userAgent;';
js += 'navigator.userAgent = agent;';
js += 'delete navigator.appVersion;';
js += "navigator.appVersion = agent.substr(agent.indexOf('/') + 1);";
js += "if (agent.indexOf('MSIE') >= 0) {";
js += 'delete navigator.appName;';
js += 'navigator.appName = "Microsoft Internet Explorer";}})("';
js += agent;
js += '")';
executeScript(js);
}
}
function onSubtreeModified(e) {
if (updating) {
return;
}
if (e.nodeType == e.TEXT_NODE) {
return;
}
replaceSubElements(e.srcElement);
}
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
var controlLogFName = '__npactivex_log';
var controlLogEvent = '__npactivex_log_event__';
var config = null;
var port = null;
var logs = [];
var scriptConfig = {
none2block: false,
formid: false,
documentid: false
};
function onControlLog(event) {
var message = event.data;
log(message);
}
window.addEventListener(controlLogEvent, onControlLog, false);
function connect() {
if (port) {
return;
}
port = chrome.extension.connect();
for (var i = 0; i < logs.length; ++i) {
port.postMessage({command: 'Log', message: logs[i]});
}
if (port && config) {
logs = undefined;
}
}
function log(message) {
var time = (new Date()).toLocaleTimeString();
message = time + ' ' + message;
if (config && config.logEnabled) {
console.log(message);
}
if (port) {
port.postMessage({command: 'Log', message: message});
}
if (!config || !port) {
logs.push(message);
}
}
log('PageURL: ' + location.href);
var pendingObjects = [];
function init(response) {
config = new ActiveXConfig(response);
if (config.logEnabled) {
for (var i = 0; i < logs.length; ++i) {
console.log(logs[i]);
}
}
eval(config.extScript);
executeScript(config.pageScript);
setUserAgent();
log('Page rule:' + JSON.stringify(config.pageRule));
for (var i = 0; i < pendingObjects.length; ++i) {
pendingObjects[i].activex_process = false;
process(pendingObjects[i]);
cacheConfig();
}
delete pendingObjects;
}
function cacheConfig() {
sessionStorage.activex_config_cache = JSON.stringify(config);
}
function loadConfig(response) {
if (config) {
config = new ActiveXConfig(response);
var cache = sessionStorage.activex_config_cache;
if (cache) {
cacheConfig();
}
} else {
init(response);
}
if (config.pageRule) {
cacheConfig();
}
}
function loadSessionConfig() {
var cache = sessionStorage.activex_config_cache;
if (cache) {
log('Loading config from session cache');
init(JSON.parse(cache));
}
}
loadSessionConfig();
var notifyBar = null;
var pageDOMLoaded = false;
var needNotifyBar = false;
function showNotifyBar(request) {
if (notifyBar) {
return;
}
if (!pageDOMLoaded) {
needNotifyBar = true;
return;
}
notifyBar = {};
log('Create notification bar');
var barurl = chrome.extension.getURL('notifybar.html');
if (document.body.tagName == 'BODY') {
var iframe = document.createElement('iframe');
iframe.frameBorder = 0;
iframe.src = barurl;
iframe.height = '35px';
iframe.width = '100%';
iframe.style.top = '0px';
iframe.style.left = '0px';
iframe.style.zIndex = '2000';
iframe.style.position = 'fixed';
notifyBar.iframe = iframe;
document.body.insertBefore(iframe, document.body.firstChild);
var placeHolder = document.createElement('div');
placeHolder.style.height = iframe.height;
placeHolder.style.zIndex = '1999';
placeHolder.style.borderWidth = '0px';
placeHolder.style.borderStyle = 'solid';
placeHolder.style.borderBottomWidth = '1px';
document.body.insertBefore(placeHolder, document.body.firstChild);
notifyBar.placeHolder = placeHolder;
} else if (document.body.tagName == 'FRAMESET') {
// We can't do this..
return;
}
}
function dismissNotifyBar() {
if (!notifyBar || !notifyBar.iframe) {
return;
}
notifyBar.iframe.parentNode.removeChild(notifyBar.iframe);
notifyBar.placeHolder.parentNode.removeChild(notifyBar.placeHolder);
}
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
if (self == top && request.command == 'NotifyUser') {
showNotifyBar(request);
sendResponse({});
} else if (self == top && request.command == 'DismissNotificationPage') {
dismissNotifyBar();
sendResponse({});
}
});
chrome.extension.sendRequest(
{command: 'Configuration', href: location.href, top: self == top},
loadConfig);
window.addEventListener('beforeload', onBeforeLoading, true);
document.addEventListener('DOMSubtreeModified', onSubtreeModified, true);
|
JavaScript
|
if (chrome.extension.getBackgroundPage().firstRun) {
document.getElementById('hint').style.display = '';
chrome.extension.getBackgroundPage().firstRun = false;
}
$(document).ready(function() {
$('#share').load('share.html');
});
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
/*
prop = {
header, // String
property, // String
events, //
type, // checkbox, select, input.type, button
extra // depend on type
}
*/
function List(config) {
this.config = config;
this.props = config.props;
this.main = config.main;
this.selectedLine = -2;
this.lines = [];
if (!config.getItems) {
config.getItems = function() {
return config.items;
}
}
if (!config.getItemProp) {
config.getItemProp = function(id, prop) {
return config.getItem(id)[prop];
}
}
if (!config.setItemProp) {
config.setItemProp = function(id, prop, value) {
config.getItem(id)[prop] = value;
}
}
if (!config.getItem) {
config.getItem = function(id) {
return config.getItems()[id];
}
}
if (!config.move) {
config.move = function(a, b) {
if (a != b && a >= 0 && b >= 0 && a < this.count() && b < this.count()) {
var list = config.getItems();
var tmp = list[a];
// remove a
list.splice(a, 1);
// insert b
list.splice(b, 0, tmp);
}
}
}
if (!config.insert) {
config.insert = function(id, newItem) {
config.getItems().splice(id, 0, newItem);
}
}
if (!config.remove) {
config.remove = function(a) {
config.move(a, config.count() - 1);
config.getItems().pop();
}
}
if (!config.validate) {
config.validate = function() {return true;};
}
if (!config.count) {
config.count = function() {
return config.getItems().length;
}
}
if (!config.patch) {
config.patch = function(id, newVal) {
for (var name in newVal) {
config.setItemProp(id, name, newVal[name]);
}
}
}
if (!config.defaultValue) {
config.defaultValue = {};
}
config.main.addClass('list');
}
List.ids = {
noline: -1
};
List.types = {};
List.prototype = {
init: function() {
with (this) {
if (this.inited) {
return;
}
this.inited = true;
this.headergroup = $('<div class="headers"></div>');
for (var i = 0; i < props.length; ++i) {
var header = $('<div class="header"></div>').
attr('property', props[i].property).html(props[i].header);
headergroup.append(header);
}
this.scrolls = $('<div>').addClass('listscroll');
this.contents = $('<div class="listitems"></div>').appendTo(scrolls);
scrolls.scroll(function() {
headergroup.css('left', -(scrolls.scrollLeft()) + 'px');
});
contents.click(function(e) {
if (e.target == contents[0]) {
selectLine(List.ids.noline);
}
});
$(main).append(headergroup).append(scrolls);
var height = this.main.height() - this.headergroup.outerHeight();
this.scrolls.height(height);
load();
selectLine(List.ids.noline);
}
},
editNewLine: function() {
this.startEdit(this.lines[this.lines.length - 1]);
},
updatePropDisplay: function(line, prop) {
var name = prop.property;
obj = $('[property=' + name + ']', line);
var ctrl = obj[0].listdata;
var id = Number(line.attr('row'));
if (id == this.config.count()) {
var value = this.config.defaultValue[name];
if (value) {
ctrl.value = value;
}
obj.trigger('createNew');
} else {
ctrl.value = this.config.getItemProp(id, name);
obj.trigger('update');
}
},
updateLine: function(line) {
for (var i = 0; i < this.props.length; ++i) {
this.updatePropDisplay(line, this.props[i]);
}
if (Number(line.attr('row')) < this.config.count()) {
line.trigger('update');
} else {
line.addClass('newline');
}
},
createLine: function() {
with (this) {
var line = $('<div></div>').addClass('itemline');
var inner = $('<div>');
line.append(inner);
// create input boxes
for (var i = 0; i < props.length; ++i) {
var prop = props[i];
var ctrl = $('<div></div>').attr('property', prop.property)
.addClass('listvalue').attr('tabindex', -1);
var valueobj = new List.types[prop.type](ctrl, prop);
var data = {list: this, line: line, prop: prop};
for (var e in prop.events) {
ctrl.bind(e, data, prop.events[e]);
}
ctrl.bind('change', function(e) {
validate(line);
return true;
});
ctrl.bind('keyup', function(e) {
if (e.keyCode == 27) {
cancelEdit(line);
}
});
ctrl.trigger('create');
inner.append(ctrl);
}
// Event listeners
line.click(function(e) {
startEdit(line);
});
line.focusin(function(e) {
startEdit(line);
});
line.focusout(function(e) {
finishEdit(line);
});
for (var e in this.config.lineEvents) {
line.bind(e, {list: this, line: line}, this.config.lineEvents[e]);
}
var list = this;
line.bind('updating', function() {
$(list).trigger('updating');
});
line.bind('updated', function() {
$(list).trigger('updated');
});
this.bindId(line, this.lines.length);
this.lines.push(line);
line.appendTo(this.contents);
return line;
}
},
refresh: function(lines) {
var all = false;
if (lines === undefined) {
all = true;
lines = [];
}
for (var i = this.lines.length; i <= this.config.count(); ++i) {
var line = this.createLine();
lines.push(i);
}
while (this.lines.length > this.config.count() + 1) {
this.lines.pop().remove();
}
$('.newline', this.contents).removeClass('newline');
this.lines[this.lines.length - 1].addClass('newline');
if (all) {
for (var i = 0; i < this.lines.length; ++i) {
this.updateLine(this.lines[i]);
}
} else {
for (var i = 0; i < lines.length; ++i) {
this.updateLine(this.lines[lines[i]]);
}
}
},
load: function() {
this.contents.empty();
this.lines = [];
this.refresh();
},
bindId: function(line, id) {
line.attr('row', id);
},
getLineNewValue: function(line) {
var ret = {};
for (var i = 0; i < this.props.length; ++i) {
this.getPropValue(line, ret, this.props[i]);
}
return ret;
},
getPropValue: function(line, item, prop) {
var name = prop.property;
obj = $('[property=' + name + ']', line);
var ctrl = obj[0].listdata;
var value = ctrl.value;
if (value !== undefined) {
item[name] = value;
}
return value;
},
startEdit: function(line) {
if (line.hasClass('editing')) {
return;
}
line.addClass('editing');
this.showLine(line);
this.selectLine(line);
var list = this;
setTimeout(function() {
if (!line[0].contains(document.activeElement)) {
$('.valinput', line).first().focus();
}
list.validate(line);
}, 50);
},
finishEdit: function(line) {
var list = this;
function doFinishEdit() {
with (list) {
if (line[0].contains(document.activeElement)) {
return;
}
var valid = isValid(line);
if (valid) {
var id = Number(line.attr('row'));
var newval = getLineNewValue(line);
if (line.hasClass('newline')) {
$(list).trigger('updating');
if (!config.insert(id, newval)) {
line.removeClass('newline');
list.selectLine(line);
$(list).trigger('add', id);
addNewLine();
}
} else {
line.trigger('updating');
config.patch(id, newval);
}
line.trigger('updated');
}
cancelEdit(line);
}
};
setTimeout(doFinishEdit, 50);
},
cancelEdit: function(line) {
line.removeClass('editing');
line.removeClass('error');
var id = Number(line.attr('row'));
if (id == this.config.count() && this.selectedLine == id) {
this.selectedLine = List.ids.noline;
}
this.updateLine(line);
},
addNewLine: function() {
with (this) {
var line = $('.newline', contents);
if (!line.length) {
line = createLine().addClass('newline');
}
return line;
}
},
isValid: function(line) {
var id = Number(line.attr('row'));
var obj = this.getLineNewValue(line);
return valid = this.config.validate(id, obj);
},
validate: function(line) {
if (this.isValid(line)) {
line.removeClass('error');
} else {
line.addClass('error');
}
},
move: function(a, b, keepSelect) {
var len = this.config.count();
if (a == b || a < 0 || b < 0 || a >= len || b >= len) {
return;
}
this.config.move(a, b);
for (var i = Math.min(a, b); i <= Math.max(a, b); ++i) {
this.updateLine(this.getLine(i));
}
if (keepSelect) {
if (this.selectedLine == a) {
this.selectLine(b);
} else if (this.selectedLine == b) {
this.selectLine(a);
}
}
},
getLine: function(id) {
if (id < 0 || id >= this.lines.length) {
return null;
}
return this.lines[id];
},
remove: function(id) {
id = Number(id);
if (id < 0 || id >= this.config.count()) {
return;
}
$(this).trigger('updating');
var len = this.lines.length;
this.getLine(id).trigger('removing');
if (this.config.remove(id)) {
return;
}
this.getLine(len - 1).remove();
this.lines.pop();
for (var i = id; i < len - 1; ++i) {
this.updateLine(this.getLine(i));
}
if (id >= len - 2) {
this.selectLine(id);
} else {
this.selectLine(List.ids.noline);
}
$(this).trigger('updated');
},
selectLine: function(id) {
var line = id;
if (typeof id == 'number') {
line = this.getLine(id);
} else {
id = Number(line.attr('row'));
}
// Can't select the new line.
if (line && line.hasClass('newline')) {
line = null;
id = List.ids.noline;
}
if (this.selectedLine == id) {
return;
}
var oldline = this.getLine(this.selectedLine);
if (oldline) {
this.cancelEdit(oldline);
oldline.removeClass('selected');
oldline.trigger('deselect');
this.selectedLine = List.ids.noline;
}
this.selectedLine = id;
if (line != null) {
line.addClass('selected');
line.trigger('select');
this.showLine(line);
}
$(this).trigger('select');
},
showLine: function(line) {
var showtop = this.scrolls.scrollTop();
var showbottom = showtop + this.scrolls.height();
var top = line.offset().top - this.contents.offset().top;
// Include the scroll bar
var bottom = top + line.height() + 20;
if (top < showtop) {
// show at top
this.scrolls.scrollTop(top);
} else if (bottom > showbottom) {
// show at bottom
this.scrolls.scrollTop(Math.max(0, bottom - this.scrolls.height()));
}
}
};
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
replaceSubElements(document);
pageDOMLoaded = true;
if (needNotifyBar) {
showNotifyBar();
}
|
JavaScript
|
scriptConfig.formid = true;
|
JavaScript
|
document.addEventListener('DOMContentLoaded', function() {
if (window.doLogin && window.statcus && window.psw) {
function makeHidden(obj) {
obj.style.display = 'block';
obj.style.height = '0px';
obj.style.width = '0px';
}
window.doLogin = function(orig) {
return function() {
if (statcus.style.display == 'none') {
makeHidden(statcus);
}
if (psw.style.display == 'none') {
makeHidden(psw);
}
orig();
};
}(doLogin);
}
}, false);
|
JavaScript
|
(function () {
function patch() {
if (window.ShowPayPage && window.InitControls) {
InitControls = function(orig) {
return function() {
if (CreditCardYear.object === undefined) {
CreditCardYear.object = {};
}
if (CreditCardMonth.object === undefined) {
CreditCardMonth.object = {};
}
if (CreditCardCVV2.object === undefined) {
CreditCardCVV2.object = {};
}
orig();
}
} (InitControls);
ShowPayPage = function(orig) {
return function(par) {
orig(par);
InitControls();
}
} (ShowPayPage);
DoSubmit = function(orig) {
return function(par) {
if (!CardPayNo.Option) {
CardPayNo.Option = function() {};
}
orig(par);
}
} (DoSubmit);
}
if (window.OpenWnd) {
var inputs = document.querySelectorAll('div > input[type=hidden]');
for (var i = 0; i < inputs.length; ++i) {
window[inputs[i].name] = inputs[i];
}
}
function patchLoginSwitch(fncName) {
if (!(window[fncName])) {
return;
}
window[fncName] = function(orig) {
return function(par) {
orig(par);
MobileNo_Ctrl.PasswdCtrl = false;
EMail_Ctrl.PasswdCtrl = false;
NetBankUser_Ctrl.PasswdCtrl = false;
DebitCardNo_Ctrl.PasswdCtrl = false;
CreditCardNo_Ctrl.PasswdCtrl = false;
IdNo_Ctrl.PasswdCtrl = false;
BookNo_Ctrl.PasswdCtrl = false;
}
} (window[fncName]);
}
patchLoginSwitch('changeCreditCardLoginType');
patchLoginSwitch('changeEALoginType');
patchLoginSwitch('showLoginEntry');
CallbackCheckClient = function() {};
}
if (document.readyState == 'complete') {
patch();
} else {
window.addEventListener('load', patch, false);
}
})();
|
JavaScript
|
(function() {
Document.prototype.getElementById = function(orig) {
return function(id) {
var a = this.getElementsByName(id);
if (a.length > 0) {
return a[0];
}
return orig.call(this, id);
}
} (Document.prototype.getElementById);
})();
|
JavaScript
|
document.addEventListener('DOMContentLoaded', function() {
if (window.PocoUpload) {
document.all.PocoUpload.Document = document;
}
}, false);
|
JavaScript
|
//********************************************
//*** \u4ee5\u4e0b\u51fd\u6570\u7528\u6765\u5904\u7406\u91d1\u989d\u5343\u5206\u4f4d\u663e\u793a\u53ca\u4eba\u6c11\u5e01\u5927\u5199
//********************************************
var pubarray1 = new Array("\u96f6","\u58f9","\u8d30","\u53c1","\u8086","\u4f0d","\u9646","\u67d2","\u634c","\u7396","");
var pubarray2 = new Array("","\u62fe","\u4f70","\u4edf");
var pubarray3 = new Array("\u5143","\u4e07","\u4ebf","\u5146","","");
var pubarray4 = new Array("\u89d2","\u5206");
var char_len = pubarray1[0].length;
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u6839\u636e\u8d27\u5e01\u7801\u683c\u5f0f\u5316\u8f85\u5e01\u4f4d\u6570\uff0c\u4e0d\u8db3\u4f4d\u7684\u88650
*
* Parameter str -- \u9700\u5904\u7406\u7684\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32;
* curCode -- \u8d27\u5e01\u7801;
*
* Return \u5b57\u7b26\u4e32 -- \u683c\u5f0f\u5316\u540e\u7684\u5b57\u7b26\u4e32
*
* \u4f8b\u5b50\uff1aformatDecimalPart("12345678","001");
* \u8fd4\u56de\u5b57\u7b26\u4e32\uff1a12345678.00
*
*/
function formatDecimalPart(str,curCode)
{
var curDec;
for(var j = 0; j < curCodeArr.length; j++)
{
if (curCodeArr[j][0] == curCode)
{
curDec = curCodeArr[j][3];
break;
}
}
if (str.indexOf(".") == -1)
{
var tmp = "";
if (curDec == 0)
return str;
for(var i = 0; i < curDec; i++)
{
tmp += "0";
}
return str + "." + tmp;
}
else
{
var strArr = str.split(".");
var decimalPart = strArr[1];
while(decimalPart.length < curDec)
{
decimalPart += "0";
}
return strArr[0] + "." + decimalPart;
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5c06\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32\u7528","\u8fdb\u884c\u5206\u9694,\u5e76\u4e14\u52a0\u4e0a\u5c0f\u6570\u4f4d(\u5904\u7406\u5343\u5206\u4f4d,\u5206\u5e01\u79cd)
*
* Parameter str -- \u9700\u5904\u7406\u7684\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32;
* curCode -- \u8d27\u5e01\u7801;
*
* Return \u5b57\u7b26\u4e32 -- \u683c\u5f0f\u5316\u540e\u7684\u5b57\u7b26\u4e32
*
* \u4f8b\u5b50\uff1achangePartition("12345678");
* \u8fd4\u56de\u5b57\u7b26\u4e32\uff1a12,345,678.00
*
*/
function changePartition(str,curCode)
{
var minus = "";
if(str.substring(0,1) == "-")
{
str = str.substring(1);
minus = "-";
}
str = formatDecimalPart(str,curCode);
var twopart = str.split(".");
var decimal_part = twopart[1];
//format integer part
var integer_part="0";
var intlen=twopart[0].length;
if(intlen>0)
{
var i=0;
integer_part="";
while(intlen>3)
{
integer_part=","+twopart[0].substring(intlen-3,intlen)+integer_part;
i=i+1;
intlen=intlen-3;
}
integer_part=twopart[0].substring(0,intlen)+integer_part;
}
if (!decimal_part)
return minus + integer_part;
else
return minus + integer_part + "." + decimal_part
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5c06\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32\u5904\u7406\u6210\u5927\u5199\u7684\u4eba\u6c11\u5e01
*
* Parameter str -- \u9700\u5904\u7406\u7684\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32;
*
* Return \u5b57\u7b26\u4e32 -- \u683c\u5f0f\u5316\u540e\u7684\u5b57\u7b26\u4e32
*
* \u4f8b\u5b50\uff1achangeUppercase("12345678.90")
* \u8fd4\u56de\u5b57\u7b26\u4e32\uff1a\u58f9\u4edf\u8d30\u4f70\u53c1\u62fe\u8086\u4e07\u4f0d\u4edf\u9646\u4f70\u67d2\u62fe\u634c\u5143\u7396\u89d2
*
*/
function changeUppercase(str)
{
if(str=="" || eval(str)==0)
return "\u96f6";
if(str.substring(0,1) == "-")
{
if(eval(str.substring(1)) < 0.01)
return "\u91d1\u989d\u6709\u8bef!!";
else
str = str.substring(1);
}
var integer_part="";
var decimal_part="\u6574";
var tmpstr="";
var twopart=str.split(".");
//\u5904\u7406\u6574\u578b\u90e8\u5206\uff08\u5c0f\u6570\u70b9\u524d\u7684\u6574\u6570\u4f4d\uff09
var intlen=twopart[0].length;
if (intlen > 0 && eval(twopart[0]) != 0)
{
var gp=0;
var intarray=new Array();
while(intlen > 4)
{
intarray[gp]=twopart[0].substring(intlen-4,intlen);
gp=gp+1;
intlen=intlen-4;
}
intarray[gp]=twopart[0].substring(0,intlen);
for(var i=gp;i>=0;i--)
{
integer_part=integer_part+every4(intarray[i])+pubarray3[i];
}
integer_part=replace(integer_part,"\u4ebf\u4e07","\u4ebf\u96f6");
integer_part=replace(integer_part,"\u5146\u4ebf","\u5146\u96f6");
while(true)
{
if (integer_part.indexOf("\u96f6\u96f6")==-1)
break;
integer_part=replace(integer_part,"\u96f6\u96f6","\u96f6");
}
integer_part=replace(integer_part,"\u96f6\u5143","\u5143");
/*\u6b64\u5904\u6ce8\u91ca\u662f\u4e3a\u4e86\u89e3\u51b3100000\uff0c\u663e\u793a\u4e3a\u62fe\u4e07\u800c\u4e0d\u662f\u58f9\u62fe\u4e07\u7684\u95ee\u9898\uff0c\u6b64\u6bb5\u7a0b\u5e8f\u628a\u58f9\u62fe\u4e07\u622a\u6210\u4e86\u62fe\u4e07
tmpstr=intarray[gp];
if (tmpstr.length==2 && tmpstr.charAt(0)=="1")
{
intlen=integer_part.length;
integer_part=integer_part.substring(char_len,intlen);
}
*/
}
//\u5904\u7406\u5c0f\u6570\u90e8\u5206\uff08\u5c0f\u6570\u70b9\u540e\u7684\u6570\u503c\uff09
tmpstr="";
if(twopart.length==2 && twopart[1]!="")
{
if(eval(twopart[1])!=0)
{
decimal_part="";
intlen= (twopart[1].length>2) ? 2 : twopart[1].length;
for(var i=0;i<intlen;i++)
{
tmpstr=twopart[1].charAt(i);
decimal_part=decimal_part+pubarray1[eval(tmpstr)]+pubarray4[i];
}
decimal_part=replace(decimal_part,"\u96f6\u89d2","\u96f6");
decimal_part=replace(decimal_part,"\u96f6\u5206","");
if(integer_part=="" && twopart[1].charAt(0)==0)
{
intlen=decimal_part.length;
decimal_part=decimal_part.substring(char_len,intlen);
}
}
}
tmpstr=integer_part+decimal_part;
return tmpstr;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5bf9\u4f4d\u6570\u5c0f\u4e8e\u7b49\u4e8e4\u7684\u6574\u6570\u503c\u5b57\u7b26\u4e32\u8fdb\u884c\u4e2d\u6587\u8d27\u5e01\u7b26\u53f7\u5904\u7406
*
* Parameter str -- \u9700\u5904\u7406\u7684\u5e26\u6709\u6570\u5b57\u7684\u5b57\u7b26\u4e32;
*
* Return \u5b57\u7b26\u4e32 -- \u683c\u5f0f\u5316\u540e\u7684\u5b57\u7b26\u4e32
*
* \u4f8b\u5b50\uff1aevery4("1234")
* \u8fd4\u56de\u5b57\u7b26\u4e32\uff1a\u58f9\u4edf\u8d30\u4f70\u53c1\u62fe\u8086
*
*/
function every4(str)
{
var weishu=str.length-1;
var retstr="";
var shuzi;
for (var i=0;i<str.length;i++)
{
shuzi=str.charAt(i);
if(shuzi=="0")
retstr=retstr+pubarray1[eval(shuzi)];
else
retstr=retstr+pubarray1[eval(shuzi)]+pubarray2[weishu];
weishu=weishu-1;
}
while(true)
{
if (retstr.indexOf("\u96f6\u96f6")==-1)
break;
retstr=replace(retstr,"\u96f6\u96f6","\u96f6");
}
if(shuzi=="0")
{
weishu=retstr.length-char_len;
retstr=retstr.substring(0,weishu);
}
return retstr;
}
|
JavaScript
|
//************************************/
//******* \u5b9a\u4e49\u6240\u6709JS\u63d0\u793a\u8bed *******/
//************************************/
/** CurCode\u8d27\u5e01\u5217\u8868 begin */
var CURCODE_CNY = "\u4eba\u6c11\u5e01\u5143";
var CURCODE_GBP = "\u82f1\u9551";
var CURCODE_HKD = "\u6e2f\u5e01";
var CURCODE_USD = "\u7f8e\u5143";
var CURCODE_CHF = "\u745e\u58eb\u6cd5\u90ce";
var CURCODE_DEM = "\u5fb7\u56fd\u9a6c\u514b";
var CURCODE_FRF = "\u6cd5\u56fd\u6cd5\u90ce";
var CURCODE_SGD = "\u65b0\u52a0\u5761\u5143";
var CURCODE_NLG = "\u8377\u5170\u76fe";
var CURCODE_SEK = "\u745e\u5178\u514b\u90ce";
var CURCODE_DKK = "\u4e39\u9ea6\u514b\u90ce";
var CURCODE_NOK = "\u632a\u5a01\u514b\u90ce";
var CURCODE_ATS = "\u5965\u5730\u5229\u5148\u4ee4";
var CURCODE_BEF = "\u6bd4\u5229\u65f6\u6cd5\u90ce";
var CURCODE_ITL = "\u610f\u5927\u5229\u91cc\u62c9";
var CURCODE_JPY = "\u65e5\u5143";
var CURCODE_CAD = "\u52a0\u62ff\u5927\u5143";
var CURCODE_AUD = "\u6fb3\u5927\u5229\u4e9a\u5143";
var CURCODE_EUR = "\u6b27\u5143";
var CURCODE_IDR = "\u5370\u5c3c\u76fe";
var CURCODE_MOP = "\u6fb3\u95e8\u5143";
var CURCODE_PHP = "\u83f2\u5f8b\u5bbe\u6bd4\u7d22";
var CURCODE_THB = "\u6cf0\u56fd\u94e2";
var CURCODE_NZD = "\u65b0\u897f\u5170\u5143";
var CURCODE_KRW = "\u97e9\u5143";
var CURCODE_XSF = "\u8bb0\u8d26\u745e\u58eb\u6cd5\u90ce";
//edit by zhangfeng
var CURCODE_VND = "\u8d8a\u5357\u76fe";
var CURCODE_IDR = "\u5370\u5c3c\u76fe";
//edit by liangd
var CURCODE_AED = "\u963f\u8054\u914b\u8fea\u62c9\u59c6";
var CURCODE_ARP = "\u963f\u6839\u5ef7\u6bd4\u7d22";
var CURCODE_BRL = "\u96f7\u4e9a\u5c14";
var CURCODE_EGP = "\u57c3\u53ca\u78c5";
var CURCODE_INR = "\u5370\u5ea6\u5362\u6bd4";
var CURCODE_JOD = "\u7ea6\u65e6\u7b2c\u7eb3\u5c14";
var CURCODE_MNT = "\u8499\u53e4\u56fe\u683c\u91cc\u514b";
var CURCODE_MYR = "\u9a6c\u6765\u897f\u4e9a\u6797\u5409\u7279";
var CURCODE_NGN = "\u5c3c\u65e5\u5229\u4e9a\u5948\u62c9";
var CURCODE_ROL = "\u7f57\u9a6c\u5c3c\u4e9a\u5217\u4f0a";
var CURCODE_TRL = "\u571f\u8033\u5176\u91cc\u62c9";
var CURCODE_UAH = "\u4e4c\u514b\u5170\u683c\u91cc\u592b\u7eb3";
var CURCODE_ZAR = "\u5357\u975e\u5170\u7279";
//edit by cuiyk
var CURCODE_RUR = "\u5362\u5e03";
var CURCODE_HUF = "\u798f\u6797";
var CURCODE_KZT = "\u54c8\u8428\u514b\u65af\u5766\u575a\u6208";
var CURCODE_ZMK = "\u8d5e\u6bd4\u4e9a\u514b\u74e6\u67e5";
var CURCODE_XPT = "\u767d\u91d1";
var CURCODE_BND = "\u6587\u83b1\u5e01";
var CURCODE_BWP = "\u535a\u8328\u74e6\u7eb3\u666e\u62c9";
//added by hhf.2009.9.10 modify by cuiyk 2009.11.10
var CURCODE_XAU="\u9ec4\u91d1(\u76ce\u53f8)";
var CURCODE_GLD="\u9ec4\u91d1(\u514b)";
/** CurCode\u8d27\u5e01\u5217\u8868 end */
/** FormCheck\u8868\u5355\u68c0\u67e5 begin */
var COMMA_MSG = "\uff0c";
var ENTER_MSG = "\n";
var NOT_NULL = "\u4e0d\u80fd\u4e3a\u7a7a\uff0c\u8bf7\u4fee\u6539\uff01";
var ILLEGAL_REGEX = "\u4e0d\u7b26\u5408\u8f93\u5165\u683c\u5f0f\uff0c\u8bf7\u4fee\u6539\uff01";
var ILLEGAL_CHAR = "\u6570\u636e\u542b\u4e86\u975e\u6cd5\u5b57\u7b26\uff1a[]^$\\~@#%&<>{}:'\"\uff0c\u8bf7\u4fee\u6539\uff01";
var HAVE_CHINESE = "\u6570\u636e\u542b\u4e86\u4e2d\u6587\u6216\u5176\u4ed6\u975e\u6807\u51c6\u5b57\u7b26\uff0c\u8bf7\u4fee\u6539\uff01";
var NOT_ONLY_CHINESE = "\u6570\u636e\u542b\u4e86\u4e2d\u6587\u4ee5\u5916\u7684\u5176\u4ed6\u5b57\u7b26\uff0c\u8bf7\u4fee\u6539\uff01";
var NOT_NUMBER = "\u6570\u636e\u5305\u542b\u4e86\u963f\u62c9\u4f2f\u6570\u5b57\u4ee5\u5916\u7684\u5b57\u7b26\uff0c\u8bf7\u4fee\u6539\uff01";
var NOT_PHONE_NUMBER = "\u6570\u636e\u5305\u542b\u4e86\u7535\u8bdd\u53f7\u7801\u4ee5\u5916\u7684\u5176\u4ed6\u5b57\u7b26\uff0c\u8bf7\u4fee\u6539\uff01";
var LENGTH_MSG = "\u7684\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e";
var LENGTH_EQUAL_MSG = "\u7684\u957f\u5ea6\u5fc5\u987b\u4e3a";
var LENGTH_MSG1 = "\u4e2a\u82f1\u6587\u5b57\u7b26\uff08\u4e00\u4e2a\u6c49\u5b57\u5360\u75282\u4e2a\u5b57\u7b26\uff09";
var MODIFY_MSG = "\u8bf7\u4fee\u6539\uff01";
var LENGHT_PERIOD_MSG = "\u7684\u957f\u5ea6\u5fc5\u987b\u4e3a\uff1a";
var MINUS_MSG = "-";
var MONEY_MSG1 = "\u6570\u636e\u4e3a\u975e\u6cd5\u91d1\u989d\uff0c\u8bf7\u4fee\u6539\uff01";
var MONEY_MSG2 = "\u6570\u636e\u4e0d\u80fd\u4e3a\u8d1f\uff0c\u8bf7\u4fee\u6539\uff01";
var MONEY_MSG3 = "\u6570\u636e\u6574\u6570\u90e8\u5206\u8d85\u957f\uff0c\u8bf7\u4fee\u6539\uff01";
var MONEY_MSG4 = "\u6570\u636e\u8f85\u5e01\u90e8\u5206\u8d85\u957f\uff0c\u8bf7\u4fee\u6539\uff01";
var MONEY_MSG = "\u5e94\u5927\u4e8e";
var MONEY_MSG0 = "\u5e94\u5c0f\u4e8e\u7b49\u4e8e";
var EXCHANGERATE_MSG1 = "\u6570\u636e\u975e\u6cd5\uff0c\u8bf7\u4fee\u6539\uff01";
var EXCHANGERATE_MSG2 = "\u6570\u636e\u4e0d\u80fd\u4e3a\u8d1f\uff0c\u8bf7\u4fee\u6539\uff01";
var EXCHANGERATE_MSG3 = "\u6570\u636e\u6574\u6570\u90e8\u5206\u8d85\u957f\uff0c\u8bf7\u4fee\u6539\uff01";
var EXCHANGERATE_MSG4 = "\u6570\u636e\u8f85\u5e01\u90e8\u5206\u8d85\u957f\uff0c\u8bf7\u4fee\u6539\uff01";
var ILLEGAL_DATE = "\u6570\u636e\u4e3a\u975e\u6cd5\u65e5\u671f\uff0c\u8bf7\u4fee\u6539\uff01";
var DATE_LATER_MSG = "\u4e0d\u5e94\u65e9\u4e8e";
var DATE_NOTLATER_MSG = "\u4e0d\u80fd\u665a\u4e8e"
var ILLEGAL_DATE_PERIOD = "\u8f93\u5165\u65e5\u671f\u8303\u56f4\u8d85\u8fc7";
var ENTRIES = "\u4e2a";
var MONTH = "\u6708";
var DAY = "\u5929";
/** FormCheck\u8868\u5355\u68c0\u67e5 end */
/** ListCheck\u8868\u5355\u68c0\u67e5 begin */
var ALL_AUTH = "\u6b64\u64cd\u4f5c\u5c06\u6e05\u9664\u60a8\u6240\u505a\u7684\u5176\u4ed6\u9009\u62e9\uff0c\u662f\u5426\u7ee7\u7eed\uff1f";
var CHOICE_MSG = "\u8bf7\u60a8\u81f3\u5c11\u9009\u62e9\u67d0\u4e00";
var ALL_COUNT = "\u672c\u6b21\u5171\u5904\u7406\u4e1a\u52a1\uff1a";
var ALL_MONEY = "\u7b14\uff0c\u603b\u91d1\u989d\uff1a";
var SPACE_MSG = " ";
var DOT_MSG = ".";
var EXCMARK_MSG = "\uff01";
/** ListCheck\u8868\u5355\u68c0\u67e5 end */
/** \u65e5\u5386\u4f7f\u7528 begin */
var calLanguage="zhCN";
var calMonthArr = new Array("1\u6708","2\u6708","3\u6708","4\u6708","5\u6708","6\u6708","7\u6708","8\u6708","9\u6708","10\u6708","11\u6708","12\u6708");
var calDayArr = new Array("\u65e5","\u4e00","\u4e8c","\u4e09","\u56db","\u4e94","\u516d");
var calYear = "\u5e74";
var calMonth = "\u6708";
/** \u65e5\u5386\u4f7f\u7528 end */
/** \u6536\u6b3e\u4eba\u5f00\u6237\u884c\u4e0b\u62c9\u83dc\u5355\u4f7f\u7528 begin */
var PLEASE_CHOICE="\u8bf7\u9009\u62e9";
/** \u6536\u6b3e\u4eba\u5f00\u6237\u884c\u4e0b\u62c9\u83dc\u5355\u4f7f\u7528 end */
//author liuy
var START_DATE="\u8d77\u59cb\u65e5\u671f";
var END_DATE="\u7ed3\u675f\u65e5\u671f";
/*******************************/
/*** \u81ea\u52a9\u6ce8\u518c\u4f7f\u7528 ***/
/*******************************/
var USER_NAME_IS_EMPTY = "\u8bf7\u8f93\u5165\u7528\u6237\u540d\uff01";
var USER_NAME_IS_INCORRECT = "\u7528\u6237\u540d\u4e0d\u6b63\u786e\uff0c\u7528\u6237\u540d\u75316-20\u4f4d\u957f\u5ea6\u7684\u6570\u5b57\u548c\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\uff0c\u4e0d\u533a\u5206\u5927\u5c0f\u5199\uff0c\u4e0d\u5141\u8bb8\u6709\u7a7a\u683c\uff0c\u81f3\u5c11\u5305\u542b1\u4f4d\u82f1\u6587\u5b57\u6bcd\uff01";
var PASSWORD_IS_EMPTY = "\u8bf7\u8f93\u5165\u5bc6\u7801\uff01";
var PASSWORD_IS_INCORRECT = "\u5bc6\u7801\u4e0d\u6b63\u786e\uff0c\u5bc6\u7801\u75318-20\u4f4d\u957f\u5ea6\u7684\u6570\u5b57\u548c\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\uff0c\u533a\u5206\u5927\u5c0f\u5199\uff0c\u81f3\u5c11\u5305\u542b1\u4f4d\u82f1\u6587\u5b57\u6bcd\u548c1\u4f4d\u6570\u5b57\uff01";
var NEW_PASSWORD_IS_EMPTY = "\u8bf7\u8f93\u5165\u65b0\u5bc6\u7801\uff01";
var NEW_PASSWORD_IS_INCORRECT = "\u65b0\u5bc6\u7801\u4e0d\u6b63\u786e\uff0c\u5bc6\u7801\u75318-20\u4f4d\u957f\u5ea6\u7684\u6570\u5b57\u548c\u82f1\u6587\u5b57\u6bcd\u7ec4\u6210\uff0c\u533a\u5206\u5927\u5c0f\u5199\uff0c\u81f3\u5c11\u5305\u542b1\u4f4d\u82f1\u6587\u5b57\u6bcd\u548c1\u4f4d\u6570\u5b57\uff01";
var CONFIRM_PASSWORD_IS_EMPTY = "\u8bf7\u8f93\u5165\u786e\u8ba4\u5bc6\u7801\uff01";
var CONFIRM_PASSWORD_IS_INCORRECT = "\u786e\u8ba4\u5bc6\u7801\u4e0e\u5bc6\u7801\u4e0d\u5339\u914d\uff01";
var OLD_PASSWORD_IS_EMPTY = "\u8bf7\u8f93\u5165\u539f\u59cb\u5bc6\u7801\uff01";
var BIRTHDAY_IS_INCORRECT = "\u51fa\u751f\u65e5\u671f\u4e0d\u6b63\u786e\uff01\u65e5\u671f\u7684\u6b63\u786e\u683c\u5f0f\u4e3aYYYY/MM/DD\uff0c\u4e14\u5fc5\u987b\u4e3a\u5408\u6cd5\u7684\u65e5\u671f\uff01";
var BIRTHDAY_MORE_THAN_TODAY = "\u51fa\u751f\u65e5\u671f\u4e0d\u80fd\u5927\u4e8e\u4eca\u5929\uff01";
var PHONE_IS_EMPTY = "\u8bf7\u8f93\u5165\u5e38\u7528\u7535\u8bdd\u53f7\u7801\uff01";
var PHONE_IS_INCORRECT = "\u5e38\u7528\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u53ea\u80fd\u5305\u542b\u6570\u5b57\uff0c\u5b57\u6bcd\u4ee5\u53ca-\uff0c\u4e14\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e15\uff01";
var PHONE2_IS_INCORRECT = "\u5907\u7528\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u53ea\u80fd\u5305\u542b\u6570\u5b57\uff0c\u5b57\u6bcd\u4ee5\u53ca-\uff0c\u4e14\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e15\uff01";
var MOBILE_IS_INCORRECT = "\u79fb\u52a8\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u5fc5\u987b\u662f11\u4f4d\u6570\u5b57\uff01";
var EMAIL_IS_EMPTY = "\u8bf7\u8f93\u5165\u7535\u5b50\u4fe1\u7bb1\uff01";
var EMAIL_IS_INCORRECT = "\u7535\u5b50\u4fe1\u7bb1\u4e0d\u6b63\u786e\uff01";
var EMAIL1_IS_EMPTY = "\u8bf7\u8f93\u5165\u5e38\u7528\u7684\u7535\u5b50\u4fe1\u7bb1\uff01";
var EMAIL1_IS_INCORRECT = "\u5e38\u7528\u7684\u7535\u5b50\u4fe1\u7bb1\u4e0d\u6b63\u786e\uff01";
var EMAIL2_IS_INCORRECT = "\u5907\u7528\u7684\u7535\u5b50\u4fe1\u7bb1\u4e0d\u6b63\u786e\uff01";
var ZIPCODE_IS_EMPTY = "\u8bf7\u8f93\u5165\u90ae\u653f\u7f16\u7801\uff01";
var ZIPCODE_IS_INCORRECT = "\u90ae\u653f\u7f16\u7801\u5fc5\u987b\u662f6\u4f4d\u6570\u5b57\uff01";
var ADDRESS_IS_EMPTY = "\u8bf7\u8f93\u5165\u90ae\u653f\u5730\u5740\uff01";
var ADDRESS_IS_INCORRECT = "\u90ae\u653f\u5730\u5740\u4e0d\u6b63\u786e\uff0c\u5730\u5740\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e60\uff01";
var ACCOUNT_EDIT_INPUT_NICKNAME = "\u8bf7\u8f93\u5165\u8d26\u6237\u522b\u540d\uff01";
var WELCOME_IS_EMPTY = "\u8bf7\u8f93\u5165\u6b22\u8fce\u4fe1\u606f\uff01";
var COLOR_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u6700\u559c\u6b22\u7684\u989c\u8272\uff01";
var MOVIE_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u6700\u559c\u6b22\u7684\u7535\u5f71\uff01";
var PET_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u6700\u559c\u6b22\u7684\u5ba0\u7269\uff01";
var GENDER_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u6027\u522b\uff01";
var QUESTIONONE_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u9884\u7559\u95ee\u9898\u4e00\uff01";
var QUESTIONTWO_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u9884\u7559\u95ee\u9898\u4e8c\uff01";
var QUESTIONTHREE_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u9884\u7559\u95ee\u9898\u4e09\uff01";
var ANSWERONE_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u95ee\u9898\u4e00\u7b54\u6848\uff01";
var ANSWERTWO_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u9884\u7559\u95ee\u9898\u4e8c\u7b54\u6848\uff01";
var ANSWERTHREE_IS_EMPTY = "\u8bf7\u8f93\u5165\u60a8\u7684\u9884\u7559\u95ee\u9898\u4e09\u7b54\u6848\uff01";
//***************User identity related constants********************/
var IDENTITY_TYPE_IS_EMPTY = "\u8bf7\u9009\u62e9\u8bc1\u4ef6\u7c7b\u578b";
var IDENTITY_NO_IS_EMPTY = "\u8bf7\u8f93\u5165\u5408\u6cd5\u7684\u8bc1\u4ef6\u53f7\u7801\u3002";
var IDENTITY_NO_IS_INCORRECT = "\u8eab\u4efd\u8bc1\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u6b63\u786e\u7684\u8eab\u4efd\u8bc1\u53f7\u7801\u5fc5\u987b\u6ee1\u8db3\u4ee5\u4e0b\u89c4\u5219\uff1a" +
"\r\n1\u3001\u957f\u5ea6\u5fc5\u987b\u4e3a15\u621618\u3002" +
"\r\n2\u3001\u8eab\u4efd\u8bc1\u4e2d\u7684\u51fa\u751f\u65e5\u671f\u5fc5\u987b\u662f\u5408\u6cd5\u7684\u65e5\u671f\u3002" +
"\r\n3\u300115\u4f4d\u7684\u8eab\u4efd\u8bc1\u5fc5\u987b\u662f\u6570\u5b57\u3002" +
"\r\n4\u300118\u4f4d\u7684\u8eab\u4efd\u8bc1\u524d17\u4f4d\u5fc5\u987b\u662f\u6570\u5b57\uff0c\u6700\u540e\u4e00\u4f4d\u662f\u6570\u5b57\u6216\u5b57\u6bcd\u2018x\u2019\u3001\u2018X\u2019";
//***************User identity related constants end********************/
/*************** psnApplay \u5728\u7ebf\u9884\u7ea6\u7533\u8bf7\u5f00\u6237 lyj 20110321 begin **************************/
var IDENTITYDATE_IS_EMPTY = "\u8bf7\u8f93\u5165\u8bc1\u4ef6\u5230\u671f\u65e5\u671f\uff01";
var IDENTITYDATE_IS_INCORRECT = "\u8bc1\u4ef6\u5230\u671f\u65e5\u671f\u4e0d\u6b63\u786e\uff01\u65e5\u671f\u7684\u6b63\u786e\u683c\u5f0f\u4e3aYYYY/MM/DD\uff0c\u4e14\u5fc5\u987b\u4e3a\u5408\u6cd5\u7684\u65e5\u671f\uff01";
var IDENTITYDATE_LESS_THAN_TODAY = "\u8bc1\u4ef6\u5230\u671f\u65e5\u671f\u4e0d\u80fd\u5c0f\u4e8e\u4eca\u5929\uff01";
var BIRTHDAY_IS_EMPTY = "\u8bf7\u8f93\u5165\u51fa\u751f\u65e5\u671f";
var A_MOBILE_IS_EMPTY = "\u8bf7\u8f93\u5165\u624b\u673a\u53f7\u7801\uff01";
var A_MOBILE_IS_INCORRECT = "\u79fb\u52a8\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u5fc5\u987b\u662f11\u4f4d\u6570\u5b57\uff01";
var A_COUNTRY_IS_EMPTY = "\u8bf7\u8f93\u5165\u56fd\u5bb6\uff01";
var A_PROVINCE_IS_EMPTY = "\u8bf7\u8f93\u5165\u7701/\u76f4\u8f96\u5e02/\u81ea\u6cbb\u533a\uff01";
var A_PROVINCE_IS_INCORRECT = "\u7701/\u76f4\u8f96\u5e02/\u81ea\u6cbb\u533a\u4e0d\u6b63\u786e\uff0c\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e"+"\r\n\u7b49\u4e8e20\u4e2a\u82f1\u6587\u5b57\u7b26\uff08\u4e00\u4e2a\u6c49\u5b57\u53602\u4e2a\u5b57\u7b26\uff09\uff0c\u8bf7\u4fee\u6539\uff01";
var A_CITY_IS_EMPTY = "\u8bf7\u8f93\u5165\u57ce\u5e02\uff01";
var A_CITY_IS_INCORRECT = "\u57ce\u5e02\u4e0d\u6b63\u786e\uff0c\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e20\u4e2a\u82f1\u6587\u5b57\u7b26\uff08\u4e00\u4e2a\u6c49\u5b57\u53602\u4e2a\u5b57\u7b26\uff09\uff0c\u8bf7\u4fee\u6539\uff01";
var A_ADDRESS_IS_EMPTY = "\u8bf7\u8f93\u5165\u5730\u5740\uff01";
var A_ADDRESS_IS_INCORRECT = "\u5730\u5740\u4e0d\u6b63\u786e\uff0c\u5730\u5740\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u7b49\u4e8e120\u4e2a\u82f1\u6587\u5b57\u7b26\uff08\u4e00\u4e2a\u6c49\u5b57\u53602\u4e2a\u5b57\u7b26\uff09\uff0c\u8bf7\u4fee\u6539\uff01";
var A_EMAIL1_IS_INCORRECT = "\u7535\u5b50\u4fe1\u7bb1\u4e0d\u6b63\u786e\uff01";
var A_PHONE_IS_INCORRECT = "\u529e\u516c\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u53ea\u80fd\u5305\u542b\u6570\u5b57\uff0c()\u4ee5\u53ca-\uff0c"+"\r\n\u4e14\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u6216\u7b49\u4e8e14\uff01\u5982\uff1a"+"\r\n\n010-12345678\uff0c(0731)12345678\u3002";
var A_PHONE2_IS_INCORRECT = "\u5bb6\u5ead\u7535\u8bdd\u53f7\u7801\u4e0d\u6b63\u786e\uff0c\u5176\u53ea\u80fd\u5305\u542b\u6570\u5b57\uff0c()\u4ee5\u53ca-\uff0c"+"\r\n\u4e14\u957f\u5ea6\u5fc5\u987b\u5c0f\u4e8e\u6216\u7b49\u4e8e14\uff01\u5982\uff1a"+"\r\n\n010-12345678\uff0c(0731)12345678\u3002";
/*************** psnApplay \u5728\u7ebf\u9884\u7ea6\u7533\u8bf7\u5f00\u6237 lyj 20110321 end **************************/
//***************banking account related constants********************/
var ACCOUNT_IS_EMPTY = "\u8bf7\u8f93\u5165\u94f6\u884c\u8d26\u53f7\u3002";
var ACCOUNT_MUST_BE_NUMBER = "\u94f6\u884c\u8d26\u53f7\u5fc5\u987b\u662f\u6570\u5b57\u3002";
var DEBIT_CARD_IS_INVALID = "\u501f\u8bb0\u5361\u7684\u5361\u53f7\u5fc5\u987b\u662f19\u4f4d\u3002";
var QCC_IS_INVALID = "\u51c6\u8d37\u8bb0\u5361\u7684\u5361\u53f7\u5fc5\u987b\u662f16\u4f4d\u3002";
var BOC_CREDIT_CARD_IS_INVALID = "\u4fe1\u7528\u5361\u7684\u5361\u53f7\u5fc5\u987b\u662f16\u4f4d\u3002";
var ENROLLMENT_ACCOUNT_INVALID = "\u53ea\u6709\u501f\u8bb0\u5361\u624d\u80fd\u4f5c\u4e3a\u6ce8\u518c\u5361";
//***************banking account related constants end********************/
var PASSWORD_NOT_EQUAL_CONFIRM_PASSWORD = "\u5bc6\u7801\u4e0e\u786e\u8ba4\u5bc6\u7801\u4e0d\u4e00\u81f4\u3002";
var EFS_PASSWORD_LEN_INVALID = "\u5bc6\u7801\u7684\u957f\u5ea6\u5fc5\u987b\u5927\u4e8e\u7b49\u4e8e8\u3002";
var USER_NAME_LEN_INVALID = "\u7528\u6237\u540d\u7684\u957f\u5ea6\u5fc5\u987b\u5927\u4e8e\u7b49\u4e8e6\u3002";
var PHONE_PASSWORD_INVALID = "\u7535\u8bdd\u94f6\u884c\u5bc6\u7801\u4e0d\u6b63\u786e\u3002";
var CHECKING_CODE_IS_EMTPY = "\u8bf7\u8f93\u5165\u9a8c\u8bc1\u7801\u3002";
var DATE_INVALID = "\u60a8\u8f93\u5165\u7684\u65e5\u671f\u4e0d\u6b63\u786e\u3002";
var EXPIRING_DATE_INVALID = "\u4f60\u8f93\u5165\u7684\u5931\u6548\u65e5\u671f\u4e0d\u6b63\u786e\u3002";
var E_TOKEN_INVALID = "\u52a8\u6001\u53e3\u4ee4\u4e0d\u6b63\u786e\uff0c\u8bf7\u8f93\u51656\u4f4d\u6570\u5b57\u7684\u52a8\u6001\u53e3\u4ee4\u3002";
/*******************************/
/*** \u81ea\u52a9\u6ce8\u518c\u4f7f\u7528 end */
/*******************************/
/*******************************/
/*** \u5b9a\u671f\u5b58\u6b3e **/
/********************************/
var SELECT_CURRENCY = "\u8bf7\u9009\u62e9";
var TRANSFER_ACCOUNT_INVALID = "\u8d26\u6237\u4fe1\u606f\u4e0d\u53ef\u7528\uff0c\u8bf7\u9009\u62e9\u53e6\u4e00\u4e2a\u8d26\u6237\u6216\u8005\u5237\u65b0\u8d26\u6237\u4fe1\u606f";
var TRANSFER_FROM_ACCOUNT = "\u8bf7\u9009\u62e9\u8f6c\u51fa\u8d26\u6237\uff01";
var TRANSFER_TO_ACCOUNT = "\u8bf7\u9009\u62e9\u8f6c\u5165\u8d26\u6237\uff01";
var TRANSFER_AMOUNT = "\u8bf7\u586b\u5199\u8f6c\u8d26\u91d1\u989d\uff01";
var TRANSFER_CURRENCY = "\u8bf7\u8f93\u5165\u5e01\u79cd\u6027\u8d28!";
var TRANSFER_CASHREMIT = "\u8bf7\u9009\u62e9\u949e\u6c47\u6807\u5fd7!";
var TRANSFER_CDTERM = "\u8bf7\u9009\u62e9\u5b58\u671f!";
var TRANSFER_FREQUENCY = "\u8bf7\u9009\u62e9\u5468\u671f!";
var TRANSFER_ENDDATE = "\u8bf7\u9009\u62e9\u7ed3\u675f\u65e5\u671f!";
var SYSDATE = "\u7cfb\u7edf\u5f53\u524d\u65e5\u671f";
var SCHEDULEDATE = "\u9884\u7ea6\u6267\u884c\u65e5\u671f";
var STARTDATE_INVALID = "\u8d77\u59cb\u65e5\u671f\u5fc5\u987b\u662f\u7cfb\u7edf\u5f53\u524d\u65e5\u671f\u672a\u6765\u4e00\u4e2a\u6708\u7684\u4efb\u610f\u4e00\u5929!";
var ENDDATE_INVALID = "\u7ed3\u675f\u65e5\u671f\u5fc5\u987b\u662f\u7cfb\u7edf\u5f53\u524d\u65e5\u671f\u672a\u6765\u516d\u4e2a\u6708\u7684\u4efb\u610f\u4e00\u5929!";
var SCHEDULEDATE_INVALID = "\u9884\u7ea6\u6267\u884c\u65e5\u671f\u5fc5\u987b\u662f\u7cfb\u7edf\u5f53\u524d\u65e5\u671f\u672a\u6765\u4e09\u4e2a\u6708\u5185\u7684\u4efb\u610f\u4e00\u5929!";
var ENDDATE_BEFORE_STARTDATE = "\u7ed3\u675f\u65e5\u671f\u4e0d\u80fd\u5c0f\u4e8e\u8d77\u59cb\u65e5\u671f!";
var FORMAT_ERROR="{0}\u683c\u5f0f\u4e0d\u6b63\u786e\uff0c";
/*******************************/
/*** \u5b89\u5168\u63a7\u4ef6 **/
/********************************/
var SAFECONTROL_INSTALL = "\u8bf7\u9996\u5148\u4e0b\u8f7d\u5e76\u5b89\u88c5\u5b89\u5168\u63a7\u4ef6\u540e\u518d\u767b\u5f55\u7f51\u4e0a\u94f6\u884c\uff0c\u5b89\u88c5\u63a7\u4ef6\u65f6\u8bf7\u5173\u95ed\u6240\u6709\u7684\u6d4f\u89c8\u5668\u7a97\u53e3\u3002";
var SAFECONTROL_VERSION = "\u5b89\u5168\u63a7\u4ef6\u5df2\u7ecf\u5347\u7ea7\uff0c\u8bf7\u9996\u5148\u4e0b\u8f7d\u5e76\u5b89\u88c5\u65b0\u7248\u672c\u5b89\u5168\u63a7\u4ef6\u540e\u518d\u767b\u5f55\u7f51\u4e0a\u94f6\u884c\u3002\u5b89\u88c5\u65b0\u5b89\u5168\u63a7\u4ef6\u524d\u8bf7\u5148\u5230\u63a7\u5236\u9762\u677f\u4e2d\u5378\u8f7d\u65e7\u5b89\u5168\u63a7\u4ef6\uff0c\u5b89\u88c5\u65f6\u5173\u95ed\u6240\u6709\u7684\u6d4f\u89c8\u5668\u7a97\u53e3\u3002";
//edit by yangda
var CURCODE_KHR = "\u67ec\u57d4\u5be8\u745e\u5c14";
/*
* \u5404\u5e01\u79cd\u91d1\u989d\u683c\u5f0f\u6570\u7ec4
*
* curCodeArr[0] -- \u8868\u793a\u8d27\u5e01\u4ee3\u7801
* curCodeArr[1] -- \u8868\u793a\u5e01\u79cd\u540d\u79f0
* curCodeArr[2] -- \u8868\u793a\u6574\u6570\u4f4d\u6570
* curCodeArr[3] -- \u8868\u793a\u8f85\u5e01\u4f4d\u6570
*
*/
var curCodeArr = new Array(
new Array("001",CURCODE_CNY,13,2),
new Array("012",CURCODE_GBP,13,2),
new Array("013",CURCODE_HKD,13,2),
new Array("014",CURCODE_USD,13,2),
new Array("015",CURCODE_CHF,13,2),
new Array("016",CURCODE_DEM,13,2),
new Array("017",CURCODE_FRF,13,2),
new Array("018",CURCODE_SGD,13,2),
new Array("020",CURCODE_NLG,13,2),
new Array("021",CURCODE_SEK,13,2),
new Array("022",CURCODE_DKK,13,2),
new Array("023",CURCODE_NOK,13,2),
new Array("024",CURCODE_ATS,13,2),
new Array("025",CURCODE_BEF,13,0),
new Array("026",CURCODE_ITL,13,0),
new Array("027",CURCODE_JPY,13,0),
new Array("028",CURCODE_CAD,13,2),
new Array("029",CURCODE_AUD,13,2),
new Array("038",CURCODE_EUR,13,2),
new Array("056",CURCODE_IDR,13,2),
new Array("064",CURCODE_VND,13,0),
new Array("081",CURCODE_MOP,13,2),
new Array("082",CURCODE_PHP,13,2),
new Array("084",CURCODE_THB,13,2),
new Array("087",CURCODE_NZD,13,2),
new Array("088",CURCODE_KRW,13,0),
new Array("095",CURCODE_XSF,13,2),
new Array("072",CURCODE_RUR,13,2),
new Array("070",CURCODE_ZAR,13,2),
new Array("065",CURCODE_HUF,13,2),
new Array("101",CURCODE_KZT,13,2),
new Array("080",CURCODE_ZMK,13,2),
new Array("032",CURCODE_MYR,13,2),
//add by cuiyk \u767d\u91d1 \u6587\u83b1\u5e01 \u91cc\u4e9a\u5c14 \u535a\u8328\u74e6\u7eb3\u666e\u62c9
new Array("843",CURCODE_XPT,13,2),
new Array("131",CURCODE_BND,13,2),
new Array("134",CURCODE_BRL,13,2),
new Array("039",CURCODE_BWP,13,2),
//added by hhf.\u4e3a\u9ec4\u91d1\u724c\u4ef7\u5c40\u90e8\u5237\u65b0
new Array("034",CURCODE_XAU,13,2),
new Array("035",CURCODE_GLD,13,0),
//add by zph Riel
new Array("166",CURCODE_KHR,13,2)
);
|
JavaScript
|
(function(proto) {
proto.__defineGetter__("classid", function() {
var clsid = this.getAttribute("clsid");
if (clsid == null) {
return "";
}
return "CLSID:" + clsid.substring(1, clsid.length - 1);
})
proto.__defineSetter__("classid", function(value) {
var e = document.createEvent('TextEvent');
e.initTextEvent(
'__npactivex_log_event__', false, false, window,
'edit clsid ' + value);
window.dispatchEvent(e);
var oldstyle = this.style.display;
this.style.display = "none";
var pos = value.indexOf(":");
this.setAttribute("clsid", "{" + value.substring(pos + 1) + "}");
this.setAttribute("type", "application/x-itst-activex");
this.style.display = oldstyle;
})
})(HTMLObjectElement.prototype)
|
JavaScript
|
navigator.cpuClass='x86';
|
JavaScript
|
//**************************************
//*** \u4ee5\u4e0b\u51fd\u6570\u662f\u8868\u5355\u68c0\u67e5\u76f8\u5173\u7684\u51fd\u6570
//*** \u6ce8\u610f:\u5f15\u7528\u6b64js\u6587\u4ef6\u65f6,\u5fc5\u987b\u5f15\u7528common.js
//**************************************
//**************************************
//*** \u4ee5\u4e0b\u51fd\u6570\u662fFORM\u8868\u5355\u68c0\u67e5\u51fd\u6570
//**************************************
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5c06\u8868\u5355\u5143\u7d20\u7f6e\u4e3aDISABLED(\u5305\u62ec\u6240\u6709\u8868\u5355\u5143\u7d20),\u5e76\u5c06\u8be5\u5143\u7d20\u80cc\u666f\u8272\u81f4\u7070
*
* Parameter inputName -- \u6b32DISABLED\u7684\u8868\u5355\u5143\u7d20\u7684\u540d\u79f0;
* flag -- \u662f\u5426disabled,true:disabled = true;false:disabled = false;
*
* \u4f8b\u5b50\uff1a setDisabled("form1.text1",true);
* setDisabled("form1.text1|radio1|select1",true);
*/
function setDisabled(inputName,flag)
{
var inputObj;
var bgStr;
if (flag)
bgStr = "#e7e7e7";
else
bgStr = "#ffffff";
if(inputName.indexOf("|") == -1)
{
inputObj = eval(CONST_STRDOC + inputName);
if (!inputObj.length)
{
if (inputObj.type != "radio" && inputObj.type != "checkbox")
inputObj.style.background = bgStr;
inputObj.disabled = flag;
}
else if (inputObj.type == "select-one" || inputObj.type == "select-multiple")
{
inputObj.style.background = bgStr;
inputObj.disabled = flag;
}
else
{
for(var i = 0; i < inputObj.length; i++)
{
inputObj[i].disabled = flag;
}
}
return;
}
var tmp = inputName.split(".");
var formName = tmp[0];
var objName = tmp[1].split("|");
for (var i = 0; i < objName.length; i++)
{
inputObj = eval(CONST_STRDOC + formName + "." + objName[i]);
if (!inputObj.length)
{
if (inputObj.type != "radio" && inputObj.type != "checkbox")
inputObj.style.background = bgStr;
inputObj.disabled = flag;
}
else if (inputObj.type == "select-one" || inputObj.type == "select-multiple")
{
inputObj.style.background = bgStr;
inputObj.disabled = flag;
}
else
{
for(var j = 0; j < inputObj.length; j++)
{
inputObj[j].disabled = flag;
}
}
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5c06\u8868\u5355\u5143\u7d20\u7f6e\u4e3aREADONLY(\u4ec5\u6587\u672c\u57df\u6216\u8005textarea),\u5e76\u5c06\u8be5\u5143\u7d20\u80cc\u666f\u8272\u81f4\u7070
*
* Parameter inputName -- \u6b32DISABLED\u7684\u8868\u5355\u5143\u7d20\u7684\u540d\u79f0;
* flag -- \u662f\u5426disabled,true:disabled = true;false:disabled = false;
*
* \u4f8b\u5b50\uff1a setDisabled("form1.text1",true);
* setDisabled("form1.text1|text2",true);
*/
function setReadOnly(inputName,flag)
{
var inputObj;
var bgStr;
if (flag)
bgStr = "#e7e7e7";
else
bgStr = "#ffffff";
if(inputName.indexOf("|") == -1)
{
inputObj = eval(CONST_STRDOC + inputName);
inputObj.style.background = bgStr;
inputObj.readOnly = flag;
}
var tmp = inputName.split(".");
var formName = tmp[0];
var objName = tmp[1].split("|");
for (var i = 0; i < objName.length; i++)
{
inputObj = eval(CONST_STRDOC + formName + "." + objName[i]);
inputObj.style.background = bgStr;
inputObj.readOnly = flag;
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u8868\u5355\u8f93\u5165\u57df\u662f\u5426\u4e3a\u7a7a\uff0c\u4e0d\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter objName -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
*
* Return false --\u4e0d\u4e3a\u7a7a
* true -- \u4e3a\u7a7a
*
* \u4f8b\u5b50\uff1aisEmpty('form1.userName');
*/
function isEmpty(objName)
{
var inputObj = eval(CONST_STRDOC + objName);
if (inputObj.value.trim() == null || inputObj.value.trim().length == 0)
return true;
else
return false;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u7a7a,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f
* \u4f8b\uff1acheck_empty('form1.userName','\u7528\u6237\u59d3\u540d');
* \u4f8b\uff1acheck_empty('form1.userName|userAge|userAddress','\u7528\u6237\u59d3\u540d|\u7528\u6237\u5e74\u9f84|\u7528\u6237\u5730\u5740');
* \u8868\u5355\u6837\u4f8b\uff1a
* <form name='form1' action=''>
* \u7528\u6237\u59d3\u540d\uff1a<input type='text' value='' name='userName'>
* \u7528\u6237\u5e74\u9f84\uff1a<input type='text' value='' name='userAge'>
* \u7528\u6237\u5730\u5740\uff1a<input type='text' value='' name='userAddress'>
* </form>
*/
function check_empty(inputname,msg)
{
if(inputname.indexOf("|") == -1)
{
if(isEmpty(inputname))
{
alert(msg + ENTER_MSG + NOT_NULL);
return false;
}
return true;
}
var split_inputname = inputname.split(".");
var split_inputs = split_inputname[1].split("|");
var split_msg = msg.split("|");
var errmsg="";
for (var i = 0; i < split_inputs.length; i++)
{
if(isEmpty(split_inputname[0]+"."+split_inputs[i]))
errmsg = errmsg + split_msg[i] + " ";
}
if(errmsg.length != 0)
{
alert(errmsg + ENTER_MSG + NOT_NULL);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u5b57\u7b26(\u4e25\u683c\u975e\u6cd5\u5b57\u7b26\u96c6)[]',^$\~:;!@?#%&<>''""
* \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a(\u5141\u8bb8\u4e2d\u6587\u6807\u70b9)
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheck_name('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_name('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function check_name(inputname,msg)
{
// var const_arychar=new Array("[","]","^","$","\\","~","@","#","%","&","<",">");
var const_arychar=new Array("[","]","^","$","\\","~","@","#","%","&","<",">","{","}",":","'","\"");
// var const_arychar=new Array("[","]","'",",","^","$","\\","~",":",";","!","@","?","#","%","&","<",">","'","'","\"","\"" );
var inputobj,inputvalue;
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
inputvalue=inputobj.value;
if(inputvalue.length==0)
return true;
for (var i=0;i<const_arychar.length;i++)
{
if(inputvalue.indexOf(const_arychar[i])!=-1)
{//find
alert(msg + ENTER_MSG + ILLEGAL_CHAR);
return false;
}
}
return true;
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue=inputobj.value;
if(inputvalue.length==0)
continue;
for (var j=0;j<const_arychar.length;j++)
{
if(inputvalue.indexOf(const_arychar[j])!=-1)
{//find
errmsg=errmsg+split_msg[i]+" ";
break;
}
}
}
if(errmsg!="")
{
alert(errmsg + ENTER_MSG + ILLEGAL_CHAR);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u5b57\u7b26(\u5c0f\u989d\u53ca\u63a7\u5236\u5b57\u7b26\u975e\u6cd5\u5b57\u7b26\u96c6){}[]%'" \u0000-\u001F
* \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a(\u5141\u8bb8\u4e2d\u6587\u6807\u70b9)
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheck_name('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_name('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
* Add By Hongxf
*/
function check_name3(inputname,msg)
{
var pattern;
pattern = "^[^{}\\[\\]\\%\\'\\\"\\u0000-\\u001F]*$";
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
inputvalue=inputobj.value;
if(inputvalue.length==0)
return true;
return regex_match(inputname,msg,pattern);
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue=inputobj.value;
if(inputvalue.length==0){
continue;
}else if(!regex_match(split_inputname[0]+"."+split_inputs[i],split_msg[i],pattern)){
return false;
}
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u5b57\u7b26(\u9700\u6c42\u53d8\u66f4\u540e\u7684\u5c0f\u989d\u53ca\u63a7\u5236\u5b57\u7b26\u975e\u6cd5\u5b57\u7b26\u96c6){}[]%'" \u0000-\u001F \u65b0\u589e\u9650\u5236: `~$^_|\:
* \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a(\u5141\u8bb8\u4e2d\u6587\u6807\u70b9)
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheck_name('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_name('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
* Add By Hongxf
*/
function check_payee_name_xe(inputname,msg)
{
var pattern;
pattern = "^[^{}\\[\\]%'\"`~$^_|\\\\:\\u0000-\\u001F\\u0080-\\u00FF]{1,76}$";
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
inputvalue=inputobj.value;
if(inputvalue.length==0)
return true;
return regex_match(inputname,msg,pattern);
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue=inputobj.value;
if(inputvalue.length==0){
continue;
}else if(!regex_match(split_inputname[0]+"."+split_inputs[i],split_msg[i],pattern)){
return false;
}
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u5b57\u7b26(\u5c0f\u989d\u53ca\u63a7\u5236\u5b57\u7b26\u975e\u6cd5\u5b57\u7b26\u96c6){}[]%'" \u0000-\u001F \u65b0\u589e\u9650\u5236: `~$^_|\:oOiI
* \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a(\u5141\u8bb8\u4e2d\u6587\u6807\u70b9)
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheck_name('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_name('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
* Add By Hongxf
*/
function check_payee_name_xeoi(inputname,msg)
{
var pattern;
pattern = "^[^oOiI{}\\[\\]%'\"`~$^_|\\\\:\\u0000-\\u001F\\u0080-\\u00FF]{1,35}$";
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
inputvalue=inputobj.value;
if(inputvalue.length==0)
return true;
return regex_match(inputname,msg,pattern);
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue=inputobj.value;
if(inputvalue.length==0){
continue;
}else if(!regex_match(split_inputname[0]+"."+split_inputs[i],split_msg[i],pattern)){
return false;
}
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u5ba2\u6237\u7533\u8bf7\u53f7\u683c\u5f0f(1-10,4,90-100)
* \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
* \u6c47\u5212\u5373\u65f6\u901a\u67e5\u8be2\u5ba2\u6237\u7533\u8bf7\u53f7\u9700\u8981\u4f7f\u7528\u82f1\u6587\u9017\u53f7,\u6545\u5141\u8bb8\u82f1\u6587\u9017\u53f7
* \u7981\u6b62\u4e2d\u6587\u6807\u70b9
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
allowEng -- \u662f\u5426\u53ef\u4ee5\u542b\u6709\u82f1\u6587(0:\u53ef\u4ee5,1:\u4e0d\u53ef\u4ee5)
*
* Return false --\u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheck_name2('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_name2('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
* modified by liuy
*/
function check_name2(inputname,msg,allowEng)
{
var pattern;
if(allowEng=="0"){
pattern = "^[A-Za-z0-9]{1,16}(-[A-Za-z0-9]{1,16})?(,[A-Za-z0-9]{1,16}(-[A-Za-z0-9]{1,16})?)*$";
}else if(allowEng=="1"){
pattern = "^[0-9]{1,16}(-[0-9]{1,16})?(,[0-9]{1,16}(-[0-9]{1,16})?)*$";
}
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
inputvalue=inputobj.value;
if(inputvalue.length==0)
return true;
return regex_match(inputname,msg,pattern);
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue=inputobj.value;
if(inputvalue.length==0){
continue;
}else if(!regex_match(split_inputname[0]+"."+split_inputs[i],split_msg[i],pattern)){
return false;
}
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u662f\u5426\u5b57\u7b26\u4e32\u4e2d\u6709\u4e2d\u6587,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u5305\u542b\u4e2d\u6587
* true -- \u4e0d\u5305\u542b
*
* \u4f8b\uff1acheck_chinese('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_chinese('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function check_chinese(inputname,msg)
{
var inputobj,inputvalue;
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
inputvalue=inputobj.value;
if(inputvalue.length==0)
return true;
for (var i=0;i<inputvalue.length;i++)
{
if(inputvalue.charCodeAt(i)>255)
{//find
alert(msg + ENTER_MSG + HAVE_CHINESE);
return false;
}
}
return true;
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue=inputobj.value;
if(inputvalue.length==0)
continue;
for (var j=0;j<inputvalue.length;j++)
{
if(inputvalue.charCodeAt(j)>255)
{//find
errmsg=errmsg+split_msg[i]+" ";
break;
}
}
}
if(errmsg!="")
{
alert(errmsg + ENTER_MSG + HAVE_CHINESE);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u6570\u5b57,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u5305\u542b\u975e\u6570\u5b57
* true -- \u4e0d\u5305\u542b
*
* \u4f8b\uff1acheck_number('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_number('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function check_number(inputname,msg)
{
var inputobj,inputvalue;
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
inputvalue=inputobj.value;
if(inputvalue.length==0)
return true;
for (var i=0;i<inputvalue.length;i++)
{
if(inputvalue.charCodeAt(i)>57 || inputvalue.charCodeAt(i)<48)
{//find
alert(msg + ENTER_MSG + NOT_NUMBER);
return false;
}
}
return true;
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue=inputobj.value;
if(inputvalue.length==0)
continue;
for (var j=0;j<inputvalue.length;j++)
{
if(inputvalue.charCodeAt(j)>57 || inputvalue.charCodeAt(j)<48)
{//find
errmsg=errmsg+split_msg[i]+" ";
break;
}
}
}
if(errmsg!="")
{
alert(errmsg + ENTER_MSG + NOT_NUMBER);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u662f\u5426\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
* pattern -- \u6b63\u5219\u8868\u8fbe\u5f0f
*
* Return false --\u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1aregex_match('Form1.Input1','\u5b57\u6bb51','A-Z');
* \u4f8b\uff1aregex_match('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53','A-Z');
*
*/
function regex_match(inputname,msg,pattern)
{
return regex_match_msg(inputname,msg,pattern,ILLEGAL_REGEX);
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u662f\u5426\u5339\u914d\u6b63\u5219\u8868\u8fbe\u5f0f,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
* pattern -- \u6b63\u5219\u8868\u8fbe\u5f0f
warn -- \u9519\u8bef\u63d0\u793a
*
* Return false --\u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1aregex_match_msg('Form1.Input1','\u5b57\u6bb51','A-Z','\u5fc5\u987b\u4e3a\u5b57\u6bcd');
* \u4f8b\uff1aregex_match_msg('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53','A-Z','\u5fc5\u987b\u4e3a\u5b57\u6bcd');
*
*/
function regex_match_msg(inputname,msg,pattern,warn)
{
var inputobj,inputvalue;
var regex = new RegExp(pattern);
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
inputvalue=inputobj.value;
if (regex.test(inputvalue))
return true;
alert(msg + ENTER_MSG + warn);
return false;
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue=inputobj.value;
// if(inputvalue.length==0)
// continue;
if (!regex.test(inputvalue))
{
errmsg=errmsg+split_msg[i]+" ";
break;
}
}
if(errmsg=="")
return true;
alert(errmsg + ENTER_MSG + warn);
return false;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u957f\u5ea6\u662f\u5426\u7b49\u4e8e\u56fa\u5b9a\u957f\u5ea6,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* inputlength -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u6307\u5b9a\u56fa\u5b9a\u957f\u5ea6;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u4e0d\u7b49\u4e8e
* true -- \u7b49\u4e8e
*
* \u4f8b\uff1acheck_length('Form1.Input1','8','\u5b57\u6bb51');
* \u4f8b\uff1acheck_length('Form1.Input1|Input2|Input3','6|8|10','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function check_length(inputname,inputlength,msg)
{
var inputobj;
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
if((inputobj.value.length!=0) && (inputobj.value.length!=inputlength))
{
alert(msg + LENGTH_EQUAL_MSG + inputlength + COMMA_MSG + ENTER_MSG + MODIFY_MSG);
return false;
}
return true;
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_inputlength=inputlength.split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
if((inputobj.value.length!=0) && (inputobj.value.length!=split_inputlength[i]))
errmsg=errmsg+split_msg[i] + LENGTH_EQUAL_MSG + split_inputlength[i] + COMMA_MSG + ENTER_MSG;
}
if(errmsg.length!=0)
{
alert(errmsg + MODIFY_MSG);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u957f\u5ea6\u662f\u5426\u5c0f\u4e8e\u6216\u7b49\u4e8e\u6307\u5b9a\u957f\u5ea6,\u63a7\u5236\u4e2d\u6587\u5b57\u7b26,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* inputlength -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u6307\u5b9a\u56fa\u5b9a\u957f\u5ea6;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u5927\u4e8e\u6307\u5b9a\u957f\u5ea6
* true -- \u5c0f\u4e8e\u6216\u7b49\u4e8e\u6307\u5b9a\u957f\u5ea6
*
* \u4f8b\uff1acheck_length_zhCN('Form1.Input1','8','\u5b57\u6bb51');
* \u4f8b\uff1acheck_length_zhCN('Form1.Input1|Input2|Input3','6|8|10','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function check_length_zhCN(inputname,inputlength,msg)
{
var inputobj;
var inputValue;
var inputLength = 0;
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
if(inputobj.value.length != 0)
{
inputValue = inputobj.value;
for(var i = 0; i < inputobj.value.length;i++)
{
if(inputValue.charCodeAt(i)>127)
inputLength++;
inputLength++;
}
if (inputLength>inputlength)
{
alert(msg + LENGTH_MSG + inputlength + LENGTH_MSG1 + COMMA_MSG + ENTER_MSG + MODIFY_MSG);
return false;
}
}
return true;
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_inputlength=inputlength.split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
if(inputobj.value.length != 0)
{
inputValue = inputobj.value;
for(var j = 0; j < inputobj.value.length;j++)
{
if(inputValue.charCodeAt(j)>127)
inputLength++;
inputLength++;
}
if (inputLength > split_inputlength[i])
errmsg=errmsg+split_msg[i] + LENGTH_MSG + split_inputlength[i] + LENGTH_MSG1 + COMMA_MSG + ENTER_MSG;
inputLength = 0;
}
}
if(errmsg.length!=0)
{
alert(errmsg + MODIFY_MSG);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u957f\u5ea6\u662f\u5426\u5728\u6307\u5b9a\u957f\u5ea6\u4e4b\u95f4,\u63a7\u5236\u4e2d\u6587\u5b57\u7b26,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* inputlength1 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u6307\u5b9a\u56fa\u5b9a\u957f\u5ea6\u4e0b\u9650;
* inputlength2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u6307\u5b9a\u56fa\u5b9a\u957f\u5ea6\u4e0a\u9650;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u8d85\u51fa\u6307\u5b9a\u957f\u5ea6\u8303\u56f4
* true -- \u672a\u8d85\u51fa\u6307\u5b9a\u957f\u5ea6\u8303\u56f4
*
* \u4f8b\uff1acheck_length_period('Form1.Input1','2','8','\u5b57\u6bb51');
* \u4f8b\uff1acheck_length_period('Form1.Input1|Input2|Input3','2|2|2','6|8|10','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function check_length_period(inputname,inputlength1,inputlength2,msg)
{
var inputobj;
var inputValue;
var inputLength = 0;
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
if(inputobj.value.length != 0)
{
inputValue = inputobj.value;
for(var i = 0; i < inputobj.value.length;i++)
{
if(inputValue.charCodeAt(i)>127)
inputLength++;
inputLength++;
}
if (inputLength > inputlength2 || inputLength < inputlength1)
{
alert(msg + LENGHT_PERIOD_MSG + inputlength1 + MINUS_MSG + inputlength2 + COMMA_MSG + ENTER_MSG + MODIFY_MSG);
return false;
}
}
return true;
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_inputlength1=inputlength1.split("|");
var split_inputlength2=inputlength2.split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
if(inputobj.value.length != 0)
{
inputValue = inputobj.value;
for(var j = 0; j < inputobj.value.length;j++)
{
if(inputValue.charCodeAt(j)>127)
inputLength++;
inputLength++;
}
if (inputLength > split_inputlength2[i] || inputLength < split_inputlength1[i])
errmsg=errmsg+split_msg[i] + LENGHT_PERIOD_MSG + split_inputlength1[i] + MINUS_MSG + split_inputlength2[i] + COMMA_MSG + ENTER_MSG;
inputLength = 0;
}
}
if(errmsg.length!=0)
{
alert(errmsg + MODIFY_MSG);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u91d1\u989d,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname1,inputname2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg1,msg2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
* xflag -- 0:\u5355\u3001\u591a\u6587\u672c\u6846\u68c0\u67e5\u91d1\u989d\u662f\u5426\u5408\u6cd5\uff0c\u5355\u65f6inputname2\u548cmsg2\u7528 ''\u6216""\u8868\u793a;
* 1:\u4e24\u6587\u672c\u6846\u68c0\u67e5\u91d1\u989d\u662f\u5426\u5408\u6cd5\uff0c\u91d1\u989d\u4e0b\u9650\u662f\u5426\u5927\u4e8e\u91d1\u989d\u4e0a\u9650;
* 2:\u4e24\u6587\u672c\u6846\u68c0\u67e5\u91d1\u989d\u662f\u5426\u5408\u6cd5\uff0c\u91d1\u989d\u4e0a\u9650\u662f\u5426\u5c0f\u4e8e\u7b49\u4e8e\u91d1\u989d\u4e0b\u9650;
* curCode -- \u8d27\u5e01\u4ee3\u7801,\u4eba\u6c11\u5e01\u4e3a001
* minusFlag -- \u91d1\u989d\u662f\u5426\u53ef\u4ee5\u4e3a\u8d1f,true:\u53ef\u4ee5\u4e3a\u8d1f,false:\u4e0d\u80fd\u4e3a\u8d1f;
*
* Return false -- \u91d1\u989d\u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheck_money(0,'Form1.Input1','','\u5b57\u6bb51','','001','false');
* \u4f8b\uff1acheck_money(0,'Form1.Input1|Input2|Input3','','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53','','001','false');
* \u4f8b\uff1acheck_money(1,'Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','001','false');
* \u4f8b\uff1acheck_money(2,'Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','001','false');
*
*/
function check_money(xflag,inputname1,inputname2,msg1,msg2,curCode,minusFlag)
{
var curName, curLlen, curDec;
for(var j = 0; j < curCodeArr.length; j++)
{
if (curCodeArr[j][0] == curCode)
{
curName = curCodeArr[j][1];
curLlen = curCodeArr[j][2];
curDec = curCodeArr[j][3];
break;
}
}
if(xflag == 0)
{
var inputobj;
if(inputname1.indexOf("|")==-1)
{
inputobj = eval(CONST_STRDOC + inputname1);
switch(moneyCheck(inputobj.value,curLlen,curDec,minusFlag,"true"))
{
case "b":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1);
return false;
case "c":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2);
return false;
case "d":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3);
return false;
case "e":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4);
return false;
}
return true;
}
var split_inputname=inputname1.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg1.split("|");
var minusArr = minusFlag.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
switch(moneyCheck(inputobj.value,curLlen,curDec,minusArr[i],"true"))
{
case "b":
alert(split_msg[i] + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1);
return false;
case "c":
alert(split_msg[i] + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2);
return false;
case "d":
alert(split_msg[i] + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3);
return false;
case "e":
alert(split_msg[i] + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4);
return false;
}
}
return true;
}
//xflag=1
if(xflag==1)
{
var inputobj1=eval(CONST_STRDOC+inputname1);
var inputobj2=eval(CONST_STRDOC+inputname2);
var inputvalue1 = moneyCheck(inputobj1.value,curLlen,curDec,minusFlag,"true");
var inputvalue2 = moneyCheck(inputobj2.value,curLlen,curDec,minusFlag,"true");
var errmsg="";
switch(inputvalue1)
{
case "b":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1);
return false;
case "c":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2);
return false;
case "d":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3);
return false;
case "e":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4);
return false;
}
switch(inputvalue2)
{
case "b":
alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1);
return false;
case "c":
alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2);
return false;
case "d":
alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3);
return false;
case "e":
alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4);
return false;
}
if(inputvalue1 == 0 || inputvalue2 == 0)
return true;
if(inputvalue1 > inputvalue2 )
{
alert(msg2 + MONEY_MSG + msg1 + COMMA_MSG + MODIFY_MSG);
return false;
}
return true;
}
//xflag=2
if(xflag==2)
{
var inputobj1=eval(CONST_STRDOC+inputname1);
var inputobj2=eval(CONST_STRDOC+inputname2);
var inputvalue1 = moneyCheck(inputobj1.value,curLlen,curDec,minusFlag,"true");
var inputvalue2 = moneyCheck(inputobj2.value,curLlen,curDec,minusFlag,"true");
var errmsg="";
switch(inputvalue1)
{
case "b":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1);
return false;
case "c":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2);
return false;
case "d":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3);
return false;
case "e":
alert(msg1 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4);
return false;
}
switch(inputvalue2)
{
case "b":
alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG1);
return false;
case "c":
alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG2);
return false;
case "d":
alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG3);
return false;
case "e":
alert(msg2 + "("+ curName + ")" + ":" + ENTER_MSG + MONEY_MSG4);
return false;
}
if(inputvalue1 == 0 || inputvalue2 == 0)
return true;
if(inputvalue1 > inputvalue2 )
{
alert(msg1 + MONEY_MSG0 + msg2 + COMMA_MSG + MODIFY_MSG);
return false;
}
return true;
}
return false;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u975e\u6cd5\u6c47\u7387,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
* curCode -- \u8d27\u5e01\u4ee3\u7801,\u4eba\u6c11\u5e01\u4e3a001
* emptyFlag -- \u57df\u662f\u5426\u53ef\u4ee5\u4e3a\u7a7a,true:\u53ef\u4ee5\u4e3a\u7a7a,false:\u4e0d\u80fd\u4e3a\u7a7a;
*
* Return false --\u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheck_exchangerate("Form1.Input1","\u5b57\u6bb51","027","false");
* \u4f8b\uff1acheck_exchangerate("Form1.Input1|Input2|Input3","2|2|2","6|8|10","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53");
*
*/
function check_exchangerate(inputname,msg,curCode,emptyFlag)
{
if(inputname.indexOf("|") == -1)
{
var inputobj;
inputobj = eval(CONST_STRDOC + inputname);
/** \u4e3a\u5916\u6c47\u529f\u80fd\u7279\u6b8a\u5904\u7406\uff0c\u5982\u679c\u9875\u9762\u4e0a\u6709\u540c\u540d\u7684input\u57df\uff0c\u5219\u53d6\u7b2c\u4e00\u4e2a\u975edisabled\u7684\u4e3a\u5224\u65ad\u4f9d\u636e */
if (inputobj.length != null)
{
for(var i = 0; i < inputobj.length; i++)
{
if (!inputobj[i].disabled)
{
inputobj = inputobj[i];
break;
}
}
}
var curLen = 3;
var curDec = 4;
if (curCode == "027")
{
curLen = 3;
curDec = 2;
}
switch(moneyCheck(inputobj.value,curLen,curDec,"false","false"))
{
case "a":
if (emptyFlag == "false")
alert(msg + ENTER_MSG + NOT_NULL);
return false;
case "b":
alert(msg + ":" + ENTER_MSG + EXCHANGERATE_MSG1);
return false;
case "c":
alert(msg + ":" + ENTER_MSG + EXCHANGERATE_MSG2);
return false;
case "d":
alert(msg + ":" + ENTER_MSG + EXCHANGERATE_MSG3);
return false;
case "e":
alert(msg + ":" + ENTER_MSG + EXCHANGERATE_MSG4);
return false;
}
return true;
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
var curCodeArr=curCode.split("|");
var emptyFlagArr = emptyFlag.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
var curLen = 3;
var curDec = 4;
if (curCodeArr[i] == "027")
{
curLen = 3;
curDec = 2;
}
switch(moneyCheck(inputobj.value,curLen,curDec,"false","false"))
{
case "a":
if (emptyFlagArr[i] == "false")
alert(split_msg[i] + ENTER_MSG + NOT_NULL);
return false;
case "b":
alert(split_msg[i] + ":" + ENTER_MSG + EXCHANGERATE_MSG1);
return false;
case "c":
alert(split_msg[i] + ":" + ENTER_MSG + EXCHANGERATE_MSG2);
return false;
case "d":
alert(split_msg[i] + ":" + ENTER_MSG + EXCHANGERATE_MSG3);
return false;
case "e":
alert(split_msg[i] + ":" + ENTER_MSG + EXCHANGERATE_MSG4);
return false;
}
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u624b\u673a\u53f7,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f
* true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f
*
* \u4f8b\uff1acheck_mobile("Form1.Input1","\u5b57\u6bb51");
* \u4f8b\uff1acheck_mobile("Form1.Input1|Input2|Input3","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53");
*
*/
function check_mobile(inputname,msg)
{
return regex_match(inputname,msg,"^([0-9]{11})?$");
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u8eab\u4efd\u8bc1\u53f7,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f
* true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f
*
* \u4f8b\uff1acheck_identify("Form1.Input1","\u5b57\u6bb51");
* \u4f8b\uff1acheck_identify("Form1.Input1|Input2|Input3","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53");
*
*/
function check_identify(inputname,msg)
{
return regex_match(inputname,msg,"^(\\d{15}|\\d{17}[0-9Xx])?$");
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5EMAIL,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f
* true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f
*
* \u4f8b\uff1acheck_email("Form1.Input1","\u5b57\u6bb51");
* \u4f8b\uff1acheck_email("Form1.Input1|Input2|Input3","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53");
*
*/
function check_email(inputname,msg)
{
return regex_match(inputname,msg,"^(\\S+@\\S+)?$");
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5E-token,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f
* true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f
*
* \u4f8b\uff1acheck_etoken("Form1.Input1","\u5b57\u6bb51");
* \u4f8b\uff1acheck_etoken("Form1.Input1|Input2|Input3","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53");
*
*/
function check_etoken(inputname,msg)
{
return regex_match(inputname,msg,"^[0-9A-Za-z+=/]{6,12}$");
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u6d77\u5916\u4e2a\u4eba\u8f6c\u8d26\u6458\u8981,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f
* true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f
*
* \u4f8b\uff1acheck_englishForBoc2000("Form1.Input1","\u5b57\u6bb51");
* \u4f8b\uff1acheck_englishForBoc2000("Form1.Input1|Input2|Input3","\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53");
*
*/
function check_englishForBoc2000(inputname,msg)
{
return regex_match(inputname,msg,"^[ A-Za-z0-9-().,'//s/?/+//]*$");
}
/**
* \u51fd\u6570\u529f\u80fd\uff1a\u5b9e\u73b0check_date\u51fd\u6570\u7684\u91cd\u8f7d,\u672c\u51fd\u6570\u6839\u636echeck_date(arg1,arg2.....)\u4e2d\u53c2\u6570\u7684\u4e2a\u6570,\u5206\u522b\u8c03\u7528\u4e0d\u540c\u7684\u51fd\u6570,\u5206\u522b\u5b9e\u73b0\u4ee5\u4e0b\u529f\u80fd:
*
* 1. \u4ec5\u68c0\u67e5\u4e00\u4e2a\u65e5\u671f\u8f93\u5165\u57df\u662f\u5426\u5408\u6cd5:function checkDateSingle(inputname1,msg1)
* 2. \u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u8f93\u5165\u57df(\u8d77\u59cb/\u622a\u6b62\u65e5\u671f)\u662f\u5426\u5408\u6cd5,\u4e14\u622a\u6b62\u665a\u4e8e\u8d77\u59cb:function checkDateTwo(inputname1,inputname2,msg1,msg2)
* 3. \u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u8f93\u5165\u57df\u662f\u5426\u5408\u6cd5\u3001\u622a\u6b62\u662f\u5426\u665a\u4e8e\u8d77\u59cb\u3001\u65e5\u671f\u8de8\u5ea6\u4e3a\u82e5\u5e72\u6708\uff1a
* 4. \u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5\u3001\u622a\u6b62\u662f\u5426\u665a\u4e8e\u8d77\u59cb\u3001\u540c\u65f6\u9650\u5236\u622a\u6b62\u65e5\u671f\u548c\u8d77\u59cb\u65e5\u671f\u7684\u8303\u56f4\u662f\u5426\u5728\u67d0\u4e2a\u65e5\u671f\uff08limitDate\uff09\u4e4b\u5185\uff0c\u8de8\u5ea6\u4e3aperiod:
* function checkDateTwoLimit(inputname1,inputname2,msg1,msg2,limitDate,period)
* 5. \u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5\u3001\u622a\u6b62\u662f\u5426\u665a\u4e8e\u8d77\u59cb\u3001\u65e5\u671f\u8de8\u5ea6\u4e3a\u82e5\u5e72\u6708\u3001\u4e14\u53ef\u67e5\u8be2\u8303\u56f4\u662f\u5426\u5728\u67d0\u4e2a\u65e5\u671f\uff08limitDate\uff09\u4e4b\u5185\uff0c\u8de8\u5ea6\u4e3aperiod,\u67e5\u8be2\u8303\u56f4\u4e3ayPeriod
* function checkDatePeriodLimit(inputname1,inputname2,msg1,msg2,limitDate,period,yPeriod)
*
*
* Parameter \u53c2\u6570\u542b\u4e49\u89c1\u5404\u51fd\u6570\u6ce8\u91ca
*
* Return false -- \u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1a1. check_date('Form1.Input1','\u5b57\u6bb51');
* check_date('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
* 2. check_date('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52');
*
* 3. check_date('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52',3);
*
* 4. check_date('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','2007/07/27',6);
*
* 5. check_date('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','2007/07/27',6,-12);
*/
function check_date()
{
switch (arguments.length)
{
/** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a2,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */
case 2:
return checkDateSingle(arguments[0],arguments[1]);
break;
/** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a4,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */
case 4:
return checkDateTwo(arguments[0],arguments[1],arguments[2],arguments[3]);
break;
/** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a5,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */
case 5:
return checkDateTwoPeriod(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4]);
break;
/** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a6,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */
case 6:
return checkDateTwoLimit(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]);
break;
/** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a7,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */
case 7:
return checkDatePeriodLimit(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5],arguments[6]);
break;
default:
return false;
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5date,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname1 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg1 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false -- \u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheckDateSingle('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheckDateSingle('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function checkDateSingle(inputname1,msg1)
{
var inputobj;
var inputvalue;
if(inputname1.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname1);
inputvalue = isdate(inputobj.value);
if(typeof(inputvalue) == "number" && inputvalue < 0)
{
alert(msg1 + ENTER_MSG + ILLEGAL_DATE);
return false;
}
return true;
}
var split_inputname=inputname1.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg1.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue = isdate(inputobj.value);
if(typeof(inputvalue) == "number" && inputvalue < 0)
errmsg=errmsg+split_msg[i]+" ";
}
if(errmsg!="")
{
alert(errmsg + ENTER_MSG + ILLEGAL_DATE);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5date,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a,\u4e3b\u8981\u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5\uff0c\u5224\u65ad\u622a\u6b62\u65e5\u671f>\u5f00\u59cb\u65e5\u671f
*
* Parameter inputname1,inputname2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg1,msg2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false -- \u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheckDateTwo('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52');
*
*/
function checkDateTwo(inputname1,inputname2,msg1,msg2)
{
var inputobj1=eval(CONST_STRDOC+inputname1);
var inputobj2=eval(CONST_STRDOC+inputname2);
var inputvalue1=isdate(inputobj1.value);
var inputvalue2=isdate(inputobj2.value);
var errmsg="";
if(typeof(inputvalue1) == "number" && inputvalue1 < 0)
errmsg=errmsg+msg1+" ";
if(typeof(inputvalue2) == "number" && inputvalue2 < 0)
errmsg=errmsg+msg2+" ";
if(errmsg!="")
{
alert(errmsg + ENTER_MSG + ILLEGAL_DATE);
return false;
}
if(typeof(inputvalue1) == "number" && inputvalue1 == 0 && typeof(inputvalue2) == "number" && inputvalue2 == 0)
return true;
if(inputvalue2 < inputvalue1)
{
alert(msg2 + DATE_LATER_MSG + msg1 + COMMA_MSG + MODIFY_MSG);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5date,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a,\u4e3b\u8981\u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5,\u540c\u65f6\u9650\u5236\u622a\u6b62\u65e5\u671f\u548c\u8d77\u59cb\u65e5\u671f\u7684\u8303\u56f4
*
* Parameter inputname1,inputname2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg1,msg2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
* period -- \u8d77\u59cb\u65e5\u671f/\u622a\u6b62\u65e5\u671f\u7684\u8de8\u5ea6,\u4ee5\u6708\u4e3a\u5355\u4f4d,\u5982:period=3,\u8868\u793a3\u4e2a\u6708
*
* Return false -- \u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheckDateTwoPeriod('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52',3);
*
*/
function checkDateTwoPeriod(inputname1,inputname2,msg1,msg2,period)
{
var inputobj1=eval(CONST_STRDOC+inputname1);
var inputobj2=eval(CONST_STRDOC+inputname2);
var inputvalue1=isdate(inputobj1.value);
var inputvalue2=isdate(inputobj2.value);
var errmsg="";
if(typeof(inputvalue1) == "number" && inputvalue1 < 0)
errmsg=errmsg+msg1+" ";
if(typeof(inputvalue2) == "number" && inputvalue2 < 0)
errmsg=errmsg+msg2+" ";
if(errmsg!="")
{
alert(errmsg + ENTER_MSG + ILLEGAL_DATE);
return false;
}
if(typeof(inputvalue1) == "number" && inputvalue1 == 0 && typeof(inputvalue2) == "number" && inputvalue2 == 0)
return true;
if(inputvalue2 < inputvalue1)
{
alert(msg2 + DATE_LATER_MSG + msg1 + COMMA_MSG + MODIFY_MSG);
return false;
}
if (addDate("m",inputvalue1,period) < inputvalue2)
{
alert(ILLEGAL_DATE_PERIOD + period + ENTRIES + MONTH + COMMA_MSG + MODIFY_MSG);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5date,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a,\u4e3b\u8981\u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5,\u540c\u65f6\u9650\u5236\u622a\u6b62\u65e5\u671f\u548c\u8d77\u59cb\u65e5\u671f\u7684\u8303\u56f4
*
* Parameter inputname1,inputname2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg1,msg2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
* limitDate -- \u622a\u6b62\u65e5\u671f\u7684\u6700\u5927\u503c;
* period -- \u8d77\u59cb\u65e5\u671f/\u622a\u6b62\u65e5\u671f\u7684\u8de8\u5ea6,\u4ee5\u6708\u4e3a\u5355\u4f4d,\u5982:period=3,\u8868\u793a3\u4e2a\u6708
*
* Return false -- \u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheckDateTwoLimit('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','2007/07/27',6);
*
*/
function checkDateTwoLimit(inputname1,inputname2,msg1,msg2,limitDate,period)
{
var inputobj1=eval(CONST_STRDOC+inputname1);
var inputobj2=eval(CONST_STRDOC+inputname2);
var inputvalue1=isdate(inputobj1.value);
var inputvalue2=isdate(inputobj2.value);
var errmsg="";
if(typeof(inputvalue1) == "number" && inputvalue1 < 0)
errmsg=errmsg+msg1+" ";
if(typeof(inputvalue2) == "number" && inputvalue2 < 0)
errmsg=errmsg+msg2+" ";
if(errmsg!="")
{
alert(errmsg + ENTER_MSG + ILLEGAL_DATE);
return false;
}
if(typeof(inputvalue1) == "number" && inputvalue1 == 0 && typeof(inputvalue2) == "number" && inputvalue2 == 0)
return true;
var limitEndDateValue = isdate(limitDate);
var limitStartDateValue = addDate("m",isdate(limitDate),0-period);
var limitStartDate = date2string(limitStartDateValue,"/");
if(inputvalue2 < inputvalue1)
{
alert(msg2 + DATE_LATER_MSG + msg1 + COMMA_MSG + MODIFY_MSG);
return false;
}
if (limitEndDateValue < inputvalue2)
{
alert(msg2 + DATE_NOTLATER_MSG + limitDate + COMMA_MSG + MODIFY_MSG);
return false;
}
if (inputvalue1 < limitStartDateValue)
{
alert(msg1 + DATE_LATER_MSG + limitStartDate + COMMA_MSG + MODIFY_MSG);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5date,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a,\u4e3b\u8981\u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5,\u540c\u65f6\u9650\u5236\u622a\u6b62\u65e5\u671f\u548c\u8d77\u59cb\u65e5\u671f\u7684\u8303\u56f4
*
* Parameter inputname1,inputname2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg1,msg2 -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
* limitDate -- \u67e5\u8be2\u8303\u56f4\u7684\u8d77\u59cb\u65e5\u671f;
* period -- \u8d77\u59cb\u65e5\u671f/\u622a\u6b62\u65e5\u671f\u7684\u8de8\u5ea6,\u4ee5\u6708\u4e3a\u5355\u4f4d,\u5982:period=3,\u8868\u793a3\u4e2a\u6708
* yPeriod -- \u67e5\u8be2\u8303\u56f4,\u6708\u4e3a\u5355\u4f4d,-12\u8868\u793a\u4ecelimitDate\u5f80\u524d\u4e00\u5e74,12\u8868\u793a\u4ecelimitDate\u5f80\u540e\u4e00\u5e74
*
* Return false -- \u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheckDateTwoLimit('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','2007/07/27',3,-12);
*
*/
function checkDatePeriodLimit(inputname1,inputname2,msg1,msg2,limitDate,period,yPeriod)
{
var inputobj1=eval(CONST_STRDOC+inputname1);
var inputobj2=eval(CONST_STRDOC+inputname2);
var inputvalue1=isdate(inputobj1.value);
var inputvalue2=isdate(inputobj2.value);
var errmsg="";
if(typeof(inputvalue1) == "number" && inputvalue1 < 0)
errmsg=errmsg+msg1+" ";
if(typeof(inputvalue2) == "number" && inputvalue2 < 0)
errmsg=errmsg+msg2+" ";
if(errmsg!="")
{
alert(errmsg + ENTER_MSG + ILLEGAL_DATE);
return false;
}
if(typeof(inputvalue1) == "number" && inputvalue1 == 0 && typeof(inputvalue2) == "number" && inputvalue2 == 0)
return true;
var limitEndDateValue = null;
var limitStartDateValue = null;
if (yPeriod >= 0)
{
limitStartDateValue = isdate(limitDate);
limitEndDateValue = addDate("m",isdate(limitDate),yPeriod);
}
else
{
limitEndDateValue = isdate(limitDate);
limitStartDateValue = addDate("m",isdate(limitDate),yPeriod);
}
var limitStartDate = date2string(limitStartDateValue,"/");
var limitEndDate = date2string(limitEndDateValue,"/");
if(inputvalue2 < inputvalue1)
{
alert(msg2 + DATE_LATER_MSG + msg1 + COMMA_MSG + MODIFY_MSG);
return false;
}
if (addDate("m",inputvalue1,period) < inputvalue2)
{
alert(ILLEGAL_DATE_PERIOD + period + ENTRIES + MONTH + COMMA_MSG + MODIFY_MSG);
return false;
}
if (limitEndDateValue < inputvalue2)
{
alert(msg2 + DATE_NOTLATER_MSG + limitEndDate + COMMA_MSG + MODIFY_MSG);
return false;
}
if (inputvalue1 < limitStartDateValue)
{
alert(msg1 + DATE_LATER_MSG + limitStartDate + COMMA_MSG + MODIFY_MSG);
return false;
}
return true;
}
/**
* \u51fd\u6570\u529f\u80fd\uff1a\u4fee\u6539checkDatePeriodLimit\u51fd\u6570\u529f\u80fd,\u8de8\u5ea6\u65e5\u671f\u5355\u4f4d\u7531\u6708\u6539\u4e3a\u65e5,\u53ef\u4ee5\u5b9e\u73b0"\u8d77\u59cb\u622a\u81f3\u65e5\u671f\u95f4\u9694\u4e0d\u80fd\u8d85\u8fc7XX\u5929"\u7c7b\u7684\u9700\u6c42
*
* \u529f\u80fd: \u68c0\u67e5\u4e24\u4e2a\u65e5\u671f\u662f\u5426\u5408\u6cd5\u3001\u622a\u6b62\u662f\u5426\u665a\u4e8e\u8d77\u59cb\u3001\u65e5\u671f\u8de8\u5ea6\u4e3a\u82e5\u5e72\u5929\u3001\u4e14\u53ef\u67e5\u8be2\u8303\u56f4\u662f\u5426\u5728\u4ee5\u67d0\u4e2a\u65e5\u671f\uff08limitDate\uff09\u4e3a\u57fa\u51c6,\u8303\u56f4\u5728(yPeriod)\u4e4b\u5185,\u8d77\u59cb\u622a\u81f3\u65e5\u671f\u8de8\u5ea6\u4e3aperiod
* function checkDatePeriodLimitByDay(inputname1,inputname2,msg1,msg2,limitDate,period,yPeriod)
*
*
* Parameter:
* 1.inputname1: \u8d77\u59cb\u65e5\u671f\u8f93\u5165\u57df\u540d\u79f0
* 2.inputname2: \u622a\u81f3\u65e5\u671f\u8f93\u5165\u57df\u540d\u79f0
* 3.msg1: \u63d0\u793a\u4fe1\u606f\u4e2d,\u5bf9\u4e8e\u8d77\u59cb\u65e5\u671f\u7684\u7ffb\u8bd1
* 4.msg2: \u63d0\u793a\u4fe1\u606f\u4e2d,\u5bf9\u4e8e\u622a\u81f3\u65e5\u671f\u7684\u7ffb\u8bd1
* 5.limitDate: \u5982\u679c\u67e5\u8be2\u8303\u56f4(yPeriod)>=0,\u5219\u4e3a\u67e5\u8be2\u8303\u56f4\u7684\u8d77\u59cb\u65e5\u671f,\u6839\u636eyPeriod\u987a\u5ef6\u4e4b\u540e\u7684\u65e5\u671f\u4e3a\u67e5\u8be2\u8303\u56f4\u7684\u622a\u81f3\u65e5\u671f;
* \u5982\u679c\u67e5\u8be2\u8303\u56f4(yPeriod)<0,\u5219\u4e3a\u67e5\u8be2\u8303\u56f4\u7684\u622a\u81f3\u65e5\u671f,\u6839\u636eyPeriod\u63d0\u524d\u7684\u65e5\u671f\u4e3a\u67e5\u8be2\u8303\u56f4\u7684\u8d77\u59cb\u65e5\u671f
* 6.period: \u7528\u6237\u8f93\u5165\u7684\u8d77\u59cb\u622a\u81f3\u65e5\u671f\u4e4b\u95f4\u7684\u8de8\u5ea6,\u5355\u4f4d\u4e3a"\u5929"
* 7.yPeriod: \u67e5\u8be2\u8303\u56f4,\u5173\u8054limitDate\u5224\u65ad,\u5355\u4f4d\u4e3a"\u6708"
*
* Return false -- \u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheckDatePeriodLimitByDay('Form1.Input1','Form1.Input2','\u5b57\u6bb51','\u5b57\u6bb52','2007/07/27',15,-12);
*/
function checkDatePeriodLimitByDay (inputname1,inputname2,msg1,msg2,limitDate,period,yPeriod) {
var inputobj1=eval(CONST_STRDOC+inputname1);
var inputobj2=eval(CONST_STRDOC+inputname2);
var inputvalue1=isdate(inputobj1.value);
var inputvalue2=isdate(inputobj2.value);
var errmsg="";
if(typeof(inputvalue1) == "number" && inputvalue1 < 0)
errmsg=errmsg+msg1+" ";
if(typeof(inputvalue2) == "number" && inputvalue2 < 0)
errmsg=errmsg+msg2+" ";
if(errmsg!="")
{
alert(errmsg + ENTER_MSG + ILLEGAL_DATE);
return false;
}
if(typeof(inputvalue1) == "number" && inputvalue1 == 0 && typeof(inputvalue2) == "number" && inputvalue2 == 0)
return true;
var limitEndDateValue = null;
var limitStartDateValue = null;
if (yPeriod >= 0)
{
limitStartDateValue = isdate(limitDate);
limitEndDateValue = addDate("m",isdate(limitDate),yPeriod);
}
else
{
limitEndDateValue = isdate(limitDate);
limitStartDateValue = addDate("m",isdate(limitDate),yPeriod);
}
var limitStartDate = date2string(limitStartDateValue,"/");
var limitEndDate = date2string(limitEndDateValue,"/");
if(inputvalue2 < inputvalue1)
{
alert(msg2 + DATE_LATER_MSG + msg1 + COMMA_MSG + MODIFY_MSG);
return false;
}
if (addDate("d",inputvalue1,period) < inputvalue2)
{
alert(ILLEGAL_DATE_PERIOD + period + DAY + COMMA_MSG + MODIFY_MSG);
return false;
}
if (limitEndDateValue < inputvalue2)
{
alert(msg2 + DATE_NOTLATER_MSG + limitEndDate + COMMA_MSG + MODIFY_MSG);
return false;
}
if (inputvalue1 < limitStartDateValue)
{
alert(msg1 + DATE_LATER_MSG + limitStartDate + COMMA_MSG + MODIFY_MSG);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5224\u65ad\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u65e5\u671f\u6570\u636e,\u83b7\u5f97\u8fd4\u56de\u503c
*
* Parameter onestring -- \u9700\u5224\u65ad\u7684\u5b57\u7b26\u4e32;
*
* Return 0 -- \u5b57\u7b26\u4e32\u4e3a\u7a7a
* -1 -- \u5b57\u7b26\u4e32\u975e\u65e5\u671f\u6570\u636e
* \u65e5\u671f\u503c -- \u5b57\u7b26\u4e32\u4e3a\u65e5\u671f\u6570\u636e\uff0c\u5e76\u83b7\u5f97\u65e5\u671f\u503c
*
* \u4f8b\uff1aisdate("2000/01/01") \u8fd4\u56de20000101
* \u4f8b\uff1aisdate("") \u8fd4\u56de0
* \u4f8b\uff1aisdate("abc") \u8fd4\u56de-1
*
*/
function isdate(onestring)
{
if(onestring.length == 0)
return 0;
if(onestring.length != 10)
return -1;
var pattern = /\d{4}\/\d{2}\/\d{2}/;
if(!pattern.test(onestring))
return -1;
var arrDate = onestring.split("/");
if(parseInt(arrDate[0],10) < 100)
arrDate[0] = 2000 + parseInt(arrDate[0],10) + "";
var newdate = new Date(arrDate[0],(parseInt(arrDate[1],10) -1)+"",arrDate[2]);
if(newdate.getFullYear() == arrDate[0] && newdate.getMonth() == (parseInt(arrDate[1],10) -1)+"" && newdate.getDate() == arrDate[2])
return newdate;
else
return -1;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u662f\u5426\u5b57\u7b26\u4e32\u5168\u4e3a\u4e2d\u6587,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u5305\u542b\u975e\u4e2d\u6587
* true -- \u5168\u4e3a\u4e2d\u6587
*
* \u4f8b\uff1acheck_chinese_only('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_chinese_only('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function check_chinese_only(inputname,msg)
{
var inputobj,inputvalue;
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
inputvalue=inputobj.value;
if(inputvalue.length==0)
return true;
for (var i=0;i<inputvalue.length;i++)
{
if(inputvalue.charCodeAt(i)<=255)
{//find
alert(msg + ENTER_MSG + NOT_ONLY_CHINESE);
return false;
}
}
return true;
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue=inputobj.value;
if(inputvalue.length==0)
continue;
for (var j=0;j<inputvalue.length;j++)
{
if(inputvalue.charCodeAt(j)>255)
{//find
errmsg=errmsg+split_msg[i]+" ";
break;
}
}
}
if(errmsg!="")
{
alert(errmsg + ENTER_MSG + NOT_ONLY_CHINESE);
return false;
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u6570\u5b57\u3001\u52a0\u53f7\u3001\u7a7a\u683c\u3001\u6a2a\u7ebf,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u5305\u542b\u6570\u5b57\u3001\u52a0\u53f7\u3001\u7a7a\u683c\u3001\u6a2a\u7ebf\u4ee5\u5916\u7684\u5b57\u7b26
* true -- \u4e0d\u5305\u542b
*
* \u4f8b\uff1acheck_phone('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_phone('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function check_phone(inputname,msg)
{
return regex_match(inputname,msg,"[ 0-9-///+]*$");
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5224\u65ad\u91d1\u989d\u7684\u5408\u6cd5\u6027,\u540c\u65f6\u6269\u5c55\u4e3a\u666e\u901a\u6d6e\u70b9\u6570\u7684\u68c0\u67e5(\u79c1\u6709\u51fd\u6570\uff0c\u8bf7\u52ff\u8c03\u7528)
*
* Parameter str -- \u9700\u5224\u65ad\u7684\u5b57\u7b26\u4e32;
* llen -- \u91d1\u989d\u6574\u6570\u90e8\u5206\u7684\u957f\u5ea6;
* dec -- \u8f85\u5e01\u4f4d\u6570;
* minusFlag -- \u91d1\u989d\u662f\u5426\u53ef\u4ee5\u4e3a\u8d1f,true:\u53ef\u4ee5\u4e3a\u8d1f,false:\u4e0d\u80fd\u4e3a\u8d1f;
* isFormatMoney -- \u662f\u5426\u662f\u683c\u5f0f\u5316\u91d1\u989d,true:\u662f,false:\u5426;\u5982\u679c\u4e3a\u5426\uff0c\u53ef\u7528\u505a\u666e\u901a\u6d6e\u70b9\u6570\u7684\u5224\u65ad
*
* Return a -- \u5b57\u7b26\u4e32\u4e3a\u7a7a
* b -- \u5b57\u7b26\u4e32\u975e\u6570\u503c\u6570\u636e
* c -- \u91d1\u989d\u4e3a\u8d1f
* d -- \u6574\u6570\u90e8\u5206\u8d85\u957f
* e -- \u5c0f\u6570\u90e8\u5206\u8d85\u957f
* \u6570\u503c -- \u5b57\u7b26\u4e32\u4e3a\u6570\u503c\u6570\u636e\uff0c\u5e76\u83b7\u5f97\u8f6c\u6362\u540e\u7684\u6570\u503c
*
* \u4f8b\uff1amoneyCheck("123,456,789.34",13,2) \u8fd4\u56de123456789.34
*
*/
function moneyCheck(str,llen,dec,minusFlag,isFormatMoney)
{
if(str == null || str == "")
return "a";
if(str.length!=0&&str.trim().length == 0)
return "b";
var regex;
if (isFormatMoney == "true")
regex = new RegExp(/(?!^[-]?[0,]*(\.0{1,4})?$)^[-]?(([1-9]\d{0,2}(,\d{3})*)|([1-9]\d*)|0)(\.\d{1,4})?$/);
else
regex = new RegExp(/(?!^[-]?[0]*(\.0{1,4})?$)^[-]?(([1-9]\d*)|0)(\.\d{1,4})?$/);
if (!regex.test(str))
return "b";
var minus = "";
if (minusFlag == "true")
{
if(str.substring(0,1) == "-")
{
minus = "-";
str = str.substring(1);
}
}
else
{
if(str.substring(0,1) == "-")
return "c";
}
if (str.substring(0,1)==".")
str = "0" + str;
str = replace(str,",","");
if (str.indexOf(".") == -1)
{
if (str.length > llen)
return "d";
return parseFloat(minus + str);
}
else
{
var tmp = str.split(".");
if(tmp.length > 2)
return "b";
if (tmp[0].length > llen)
return "d";
if (tmp[1].length > dec)
return "e";
return parseFloat(minus + tmp[0] + "." + tmp[1]);
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u534a\u89d2\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5168\u89d2\u5b57\u7b26\u4e32(\u516c\u6709\u51fd\u6570\uff0c\u8bf7\u8c03\u7528)
*
* Parameter str -- \u9700\u8981\u8f6c\u6362\u7684\u5b57\u7b26\u4e32\uff0c\u652f\u6301\u534a\u89d2\u5168\u89d2\u6df7\u5408\u5b57\u7b26\u4e32
* flag -- \u8f6c\u6362\u6807\u8bc6\uff0c0\u4e3a\u8f6c\u6362
*
* Return \u5168\u89d2\u5b57\u7b26
*
* \u4f8b\uff1aDBC2SBC("abcdefg",0) \u8fd4\u56de\uff41\uff42\uff43\uff44\uff45\uff46\uff47
*
*/
function DBC2SBC(str,flag) {
var i;
var result='';
if(str.length<=0) {
return result;
}
for(i=0;i<str.length;i++){
str1=str.charCodeAt(i);
if(str1<125&&!flag){
if(str1==32){//\u5982\u679c\u662f\u534a\u89d2\u7a7a\u683c\uff0c\u7279\u6b8a\u5904\u7406
result+=String.fromCharCode(12288);
}else{
result+=String.fromCharCode(str.charCodeAt(i)+65248);
}
}else{
result+=String.fromCharCode(str.charCodeAt(i));
}
}
return result;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u957f\u5ea6\u662f\u5426\u7b49\u4e8e\u679a\u4e3e\u56fa\u5b9a\u957f\u5ea6,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* inputlength -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u6307\u5b9a\u679a\u4e3e\u56fa\u5b9a\u957f\u5ea6;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u4e0d\u7b49\u4e8e
* true -- \u7b49\u4e8e
*
* \u4f8b\uff1acheck_length('Form1.Input1','6|8|10','\u5b57\u6bb51');
*
*/
function check_lengthEnum(inputname,inputlength,msg)
{
var inputobj;
/*
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
if((inputobj.value.length!=0) && (inputobj.value.length!=inputlength))
{
alert(msg + LENGTH_EQUAL_MSG + inputlength + COMMA_MSG + ENTER_MSG + MODIFY_MSG);
return false;
}
return true;
}*/
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_inputlength=inputlength.split("|");
var split_msg=msg.split("|");
var errmsg=FORMAT_ERROR.replace("{0}",msg);
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[0]);
for (var i=0;i<split_inputlength.length;i++)
{
if(inputobj.value.length==split_inputlength[i])
{
errmsg="";
break
}
//errmsg=errmsg+split_msg[i] + LENGTH_EQUAL_MSG + split_inputlength[i] + COMMA_MSG + ENTER_MSG;
}
if(errmsg.length!=0)
{
alert(errmsg + MODIFY_MSG);
return false;
}
return true;
}
/*
*\u51fd\u6570\u529f\u80fd\uff1a\u53bb\u9664\u5b57\u7b26\u4e32\u4e2d\u7684\u6240\u6709\u7a7a\u767d\u7b26(\u5b57\u7b26\u4e32\u524d\u3001\u4e2d\u95f4\u3001\u540e)
*
*Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
*
*
*\u4f8b\u5b50\uff1a onblur="trimAllBlank(document.form1.ToAccountNo)"
*/
function trimAllBlank(inputname)
{
var result=inputname.value.replace(/(\s)/g,"");
inputname.value=result;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5swift\u975e\u6cd5\u5b57\u7b26 ` ~ ! @ # $ % ^ & * _ = [ ] { } ; " < > | \ : -
* \u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u4e0d\u5408\u6cd5
* true -- \u5408\u6cd5
*
* \u4f8b\uff1acheck_swift('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_swift('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function check_swift(inputname,msg)
{
var pattern;
pattern = "^[^`~!@#\\$%\\^&\\*_=\\[\\]{};\\\"<>\\|\\\\:-]*$";
if(inputname.indexOf("|")==-1)
{
inputobj=eval(CONST_STRDOC+inputname);
inputvalue=inputobj.value;
if(inputvalue.length==0)
return true;
return regex_match(inputname,msg,pattern);
}
var split_inputname=inputname.split(".");
var split_inputs=split_inputname[1].split("|");
var split_msg=msg.split("|");
var errmsg="";
for (var i=0;i<split_inputs.length;i++)
{
inputobj=eval(CONST_STRDOC+split_inputname[0]+"."+split_inputs[i]);
inputvalue=inputobj.value;
if(inputvalue.length==0){
continue;
}else if(!regex_match(split_inputname[0]+"."+split_inputs[i],split_msg[i],pattern)){
return false;
}
}
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u68c0\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u4e3a\u5b57\u6bcd\u3001\u6570\u5b57,\u5411\u7528\u6237\u53d1\u51fa\u63d0\u793a
*
* Parameter inputname -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u82f1\u6587\u540d;
* msg -- \u8868\u5355\u57df\u6587\u672c\u6846\u7684\u4e2d\u6587\u6807\u8bc6\u4e3a\u7528\u6237\u63d0\u4f9b\u63d0\u793a\u4fe1\u606f;
*
* Return false --\u5305\u542b\u5b57\u6bcd\u3001\u6570\u5b57\u4ee5\u5916\u7684\u5b57\u7b26
* true -- \u4e0d\u5305\u542b
*
* \u4f8b\uff1acheck_letter_num('Form1.Input1','\u5b57\u6bb51');
* \u4f8b\uff1acheck_letter_num('Form1.Input1|Input2|Input3','\u5b57\u6bb51|\u5b57\u6bb52|\u5b57\u6bb53');
*
*/
function check_letter_num(inputname,msg) {
return regex_match(inputname,msg,"^[ A-Za-z0-9]*$");
}
//**************************************
//*** FORM\u8868\u5355\u68c0\u67e5\u51fd\u6570\u7ed3\u675f
//**************************************
|
JavaScript
|
(function (doc) {
doc.createElement = function(orig) {
return function(name) {
if (name.trim()[0] == '<') {
// We assume the name is correct.
document.head.innerHTML += name;
var obj = document.head.lastChild;
document.head.removeChild(obj);
return obj;
} else {
var val = orig.call(this, name);
if (name == "object") {
val.setAttribute("type", "application/x-itst-activex");
}
return val;
}
}
}(doc.createElement);
})(HTMLDocument.prototype);
|
JavaScript
|
scriptConfig.documentid = true;
|
JavaScript
|
//**************************************
//*** \u4ee5\u4e0b\u51fd\u6570\u662fJS\u516c\u7528\u51fd\u6570
//**************************************
var CONST_STRDOC="document.";
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5220\u9664\u5de6\u53f3\u4e24\u7aef\u7684\u7a7a\u683c
*
*/
String.prototype.trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u8df3\u8f6c\u81f3\u5176\u4ed6\u9875\u9762
*
*/
function gotoPage(url)
{
location.href = url;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u8df3\u8f6c\u81f3\u5176\u4ed6\u9875\u9762,\u5e76\u4f20\u9875\u9762\u53c2\u6570
*
* Parameter url -- \u8df3\u8f6c\u7684\u94fe\u63a5;
* paraName -- \u8981\u4f20\u7684\u53c2\u6570\u7684\u53c2\u6570\u540d\u79f0;
* paraValue -- \u8981\u4f20\u7684\u53c2\u6570\u7684\u53c2\u6570\u503c;
*
* \u4f8b\uff1agotoPage('XXX.do','orderName','ActNo');
* gotoPage('XXX.do','orderName|orderName1|PageNum','ActNo|ibknum|3');
*
*/
function gotoPageByPara(url,paraName,paraValue)
{
var urlHavePara = false;
if (url.indexOf("?") != -1)
urlHavePara = true;
if(paraName.indexOf("|") == -1)
if (urlHavePara)
location.href = url + "&" + paraName + "=" + paraValue ;
else
location.href = url + "?" + paraName + "=" + paraValue ;
else
{
nameArr = paraName.split("|");
paraArr = paraValue.split("|");
var paraStr = "";
for(var i = 0; i < nameArr.length; i++)
{
if (i == 0 && !urlHavePara)
paraStr = "?" + nameArr[i] + "=" + paraArr[i];
else
paraStr += "&" + nameArr[i] + "=" + paraArr[i];
}
location.href = url + paraStr;
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u6570\u636e\u4e0b\u8f7d\u4f7f\u7528\uff0c\u4f7f\u7528topFrame\u4e0b\u8f7d
*
*/
function dataDownload(url)
{
parent.topFrame.location.href = url;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u6570\u636e\u4e0b\u8f7d\u4f7f\u7528\uff0c\u4f7f\u7528topFrame\u4e0b\u8f7d,\u5e76\u4f20\u9875\u9762\u53c2\u6570
*
* Parameter url -- \u8df3\u8f6c\u7684\u94fe\u63a5;
* paraName -- \u8981\u4f20\u7684\u53c2\u6570\u7684\u53c2\u6570\u540d\u79f0;
* paraValue -- \u8981\u4f20\u7684\u53c2\u6570\u7684\u53c2\u6570\u503c;
*
* \u4f8b\uff1adataDownloadByPara('XXX.do','orderName','ActNo');
* dataDownloadByPara('XXX.do','orderName|orderName1|PageNum','ActNo|ibknum|3');
*
*/
function dataDownloadByPara(url,paraName,paraValue)
{
var urlHavePara = false;
if (url.indexOf("?") != -1)
urlHavePara = true;
if(paraName.indexOf("|") == -1)
if (urlHavePara)
parent.topFrame.location.href = url + "&" + paraName + "=" + paraValue ;
else
parent.topFrame.location.href = url + "?" + paraName + "=" + paraValue ;
else
{
nameArr = paraName.split("|");
paraArr = paraValue.split("|");
var paraStr = "";
for(var i = 0; i < nameArr.length; i++)
{
if (i == 0 && !urlHavePara)
paraStr = "?" + nameArr[i] + "=" + paraArr[i];
else
paraStr += "&" + nameArr[i] + "=" + paraArr[i];
}
parent.topFrame.location.href = url + paraStr;
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u6253\u5370\u5f53\u524d\u9875\u9762,\u5e76\u5c4f\u853d\u6253\u5370\u6309\u94ae(\u5982\u679c\u5b58\u5728ID\u4e3aprintDiv\u7684DIV\u5219\u5c4f\u853d)
*
*/
function printPage()
{
var obj = eval(CONST_STRDOC + "all.printDiv")
if (obj && obj.style)
{
obj.style.display = "none";
window.print();
obj.style.display = "";
}
else
window.print();
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u7528\u67d0\u5b57\u7b26\u4e32\u66ff\u6362\u6307\u5b9a\u5b57\u7b26\u4e32\u4e2d\u7684\u67d0\u5b57\u7b26\u4e32
*
* Parameter str -- \u9700\u5904\u7406\u7684\u5e26\u6709\u5f85\u66ff\u6362\u5b57\u4e32\u7684\u5b57\u7b26\u4e32;
* str_s -- \u9700\u67e5\u627e\u7684\u5f85\u66ff\u6362\u7684\u5b57\u7b26\u4e32;
* str_d -- \u8fdb\u884c\u66ff\u6362\u7684\u5b57\u7b26\u4e32;
*
* Return \u5b57\u7b26\u4e32 -- \u66ff\u6362\u540e\u7684\u5b57\u7b26\u4e32
*
* \u4f8b\u5b50\uff1areplace("\u58f9\u4edf\u96f6\u96f6\u53c1","\u96f6\u96f6","\u96f6")
* \u8fd4\u56de\u5b57\u7b26\u4e32\uff1a\u58f9\u4edf\u96f6\u53c1
*/
function replace(str,str_s,str_d)
{
var pos=str.indexOf(str_s);
if (pos==-1)
return str;
var twopart=str.split(str_s);
var ret=twopart[0];
for(pos=1;pos<twopart.length;pos++)
ret=ret+str_d+twopart[pos];
return ret;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u53d6\u5f97\u8868\u5355\u4e2dradio\u7684\u503c
*
* Parameter str -- \u8868\u5355\u4e2dradio\u7684\u540d\u5b57;
*
* Return \u5b57\u7b26\u4e32 -- radio\u7684\u503c
*
* \u4f8b\u5b50\uff1agetRadioValue('form1.radio')
*
*/
function getRadioValue(str)
{
var obj = eval(CONST_STRDOC + str);
if (!obj)
return;
if (!obj.length)
return obj.value;
else
{
for(var i = 0; i < obj.length; i++)
{
if (obj[i].checked)
{
return obj[i].value;
}
}
}
}
//**************************************
//*** JS\u516c\u7528\u51fd\u6570\u7ed3\u675f
//**************************************
//**************************************/
//******* \u8fdb\u5ea6\u6761\u5904\u7406\u51fd\u6570 begin *******/
//**************************************/
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u663e\u793a\u9875\u9762\u5904\u7406\u65f6\u7684\u8fdb\u5ea6\u6761\uff0c\u5e76\u63a7\u5236\u5f53\u524d\u9875\u9762\u7684\u4e8c\u6b21\u63d0\u4ea4\uff0c\u5728checkForm\u4e2d\u8c03\u7528\u3002
*/
function pageProcessing()
{
// try {
// processForm();
// } catch (e) {
// //alert("error: " + e.description);
// }
var processObj = document.all.processDiv;
var processBlockObj = document.all.processBlockDiv;
processObj.style.width = document.documentElement.scrollWidth;
processObj.style.height = document.documentElement.scrollHeight;
processObj.style.display = "";
processBlockObj.style.left = (document.documentElement.clientWidth - parseInt(processBlockObj.style.width)) / 2 + document.documentElement.scrollLeft;
processBlockObj.style.top = (document.documentElement.clientHeight - parseInt(processBlockObj.style.height)) / 2 + document.documentElement.scrollTop;
disableAllSelect();
/** 10\u5206\u949f\u540e\uff0c\u8fdb\u5ea6\u6761\u5931\u6548 */
window.setTimeout("pageProcessingDone();",600000);
}
/** \u4e3a\u6bcf\u4e2a\u9875\u9762\u589e\u52a0\u9632\u7be1\u6539\u529f\u80fd added by fangxi */
var processForm = (function () {
if (typeof BocNet == undefined) {
//alert("BocNet not found........");
return function() {};
} else {
//alert("BocNet defined...");
var VAR1 = "_viewstate1", VAR2 = "_viewstate2";
var f0 = function(m, key, value) { if (!m[key]) m[key] = []; m[key].push(value == null ? '' : String(value)); };
var f1 = function(m, key, item) { f0(m, key, item.value); };
var f2 = function(m, key, item) { if (item.checked) f0(m, key, item.value); };
var f3 = function(m, key, item) { if (item.selectedIndex >= 0) $A(item.options).each(function(e) { if (e.selected) f0(m, key, e.value); }); };
var ByType = { "text": f1, "password": f1, "hidden": f1, "radio": f2, "checkbox":f2, "select-one": f3, "select-multiple": f3 };
var injector = function(m,item) { var key = String(item.name); if (!item.disabled && key && key != VAR1 && key != VAR2) { var f = ByType[item.type]; if (f) f(m, key, item); } return m; };
return function() {
//alert("BocNet defined... " + $A(document.forms).length + " form(s) found...");
$A(document.forms).each(function(theform) {
var theform = $(theform), result = ["", ""];
//alert("form: " + theform.name + " ... " + $A(theform.elements).length + " element(s) found...");
$H($A(theform.elements).inject({}, injector)).each(function(pair) { if (result[0]) { result[0] += ","; result[1] += ","; } result[0] += pair.key; result[1] += pair.key + "=" + pair.value.join(""); });
//alert(result[0] + "\r\n\r\n" + result[1]);
var _viewstate1 = theform.getInputs("hidden", VAR1)[0]; if (!_viewstate1) _viewstate1 = BocNet.Form.createHidden(theform, VAR1);
var _viewstate2 = theform.getInputs("hidden", VAR2)[0]; if (!_viewstate2) _viewstate2 = BocNet.Form.createHidden(theform, VAR2);
_viewstate1.value = binl2b64(str2binl(result[0])); _viewstate2.value = b64_md5(result[1]);
});
}
}
})();
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u9875\u9762\u5904\u7406\u65f6\u7684\u8fdb\u5ea6\u6761\u663e\u793a\u5b8c\u6bd5\u540e\u8c03\u7528\uff0c\u53d6\u6d88\u63a7\u5236\u5f53\u524d\u9875\u9762\u7684\u4e8c\u6b21\u63d0\u4ea4\u3002
*/
function pageProcessingDone()
{
var processObj = document.all.processDiv;
var processBlockObj = document.all.processBlockDiv;
processObj.style.width = "0";
processObj.style.height = "0";
processObj.style.display = "none";
processBlockObj.style.left = "0";
processBlockObj.style.top = "0";
enableAllSelect();
}
/*
* \u51fd\u6570\u529f\u80fd\uff1adisable\u5f53\u524d\u9875\u7684\u6240\u6709\u4e0b\u62c9\u83dc\u5355
*/
function disableAllSelect()
{
var obj = document.getElementsByTagName("SELECT");
for(var i = 0; i < obj.length; i++)
{
obj[i].style.display = "none";
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1aenable\u5f53\u524d\u9875\u7684\u6240\u6709\u4e0b\u62c9\u83dc\u5355
*/
function enableAllSelect()
{
var obj = document.getElementsByTagName("SELECT");
for(var i = 0; i < obj.length; i++)
{
obj[i].style.display = "";
}
}
//**************************************/
//******* \u8fdb\u5ea6\u6761\u5904\u7406\u51fd\u6570 end *******/
//**************************************/
//**************************************/
//******* \u65e5\u671f\u5904\u7406\u51fd\u6570 begin *******/
//**************************************/
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5c06\u65e5\u671f\u6570\u636e\u8f6c\u6362\u4e3a\u5b57\u7b26\u4e32
*
* Parameter datePara -- \u65e5\u671f\u578b\u6570\u636e;
* splitReg -- \u5206\u9694\u7b26
*
* Return \u6309\u7167\u5206\u9694\u7b26\u5206\u9694\u7684\u65e5\u671f\u5b57\u7b26\u4e32\u3002
*
*/
function date2string(datePara,splitReg)
{
var lMonth = datePara.getMonth() + 1;
lMonth = (lMonth < 10 ? "0" + lMonth : lMonth);
var lDate = datePara.getDate();
lDate = (lDate < 10 ? "0" + lDate : lDate);
return datePara.getFullYear() + splitReg + lMonth + splitReg + lDate;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5f97\u5230\u65e5\u671f\u7684\u589e\u51cf
*
* Parameter strInterval -- d:\u6309\u5929;m:\u6309\u6708;y:\u6309\u5e74;
* dateStr -- \u8d77\u59cb\u65e5\u671f,date\u5bf9\u8c61\u6216\u8005yyyy/MM/dd\u683c\u5f0f
* Number -- \u65e5\u671f\u589e\u51cf\u7684\u91cf,\u652f\u6301\u6b63\u8d1f
*
* Return \u6309\u7167\u5206\u9694\u7b26\u5206\u9694\u7684\u65e5\u671f\u5b57\u7b26\u4e32\u3002
*
*/
function addDate(strInterval, dateStr, numberPara)
{
var dtTmp = new Date(Date.parse(dateStr));
switch (strInterval)
{
case 'd' :
return new Date(Date.parse(dtTmp) + (86400000 * numberPara));
case 'm' :
/** xulc modified:\u4fee\u6539\u4e86BUG\uff0c1\u670831\u65e5\u5f80\u540e\u4e00\u4e2a\u6708\u4e3a2\u670828\u65e5\uff0c\u4fee\u6539\u524d\u4e3a3\u67082\u65e5 */
var oldY = dtTmp.getFullYear();
/** \u6b32\u53d8\u66f4\u7684\u6708\u4efd */
var newMon = dtTmp.getMonth() + numberPara;
/** \u53d8\u66f4\u6708\u4efd\u540e\uff0c\u7cfb\u7edf\u751f\u6210\u7684DATE\u5bf9\u8c61 */
var newDate = new Date(dtTmp.getFullYear(), newMon, dtTmp.getDate());
/** \u53d6\u65b0\u7684DATE\u5bf9\u8c61\u4e2d\u7684\u5e74\u548c\u6708\uff0c\u6309\u7167JS\u7684\u5904\u7406\uff0c\u6b64\u65f61\u670831\u65e5\u5f80\u540e\u4e3a3\u67082\u65e5 */
var tmpMon = newDate.getMonth();
var tmpY = newDate.getFullYear();
/** \u5982\u679c\u4e0d\u662f\u5927\u5c0f\u6708\u4ea4\u66ff\u65f6\u7684\u60c5\u51b5\uff0c\u5373\u65b0\u7684\u6708\u548c\u6b32\u53d8\u66f4\u7684\u6708\u4efd\u5e94\u8be5\u76f8\u7b49 || \u5982\u679c\u8de8\u5e74\uff0c\u4e24\u4e2a\u6708\u4efd\u4e5f\u4e0d\u76f8\u7b49\uff0c\u800c12\u6708\u548c1\u6708\u5747\u4e3a\u5927\u6708 */
if (tmpMon == newMon || oldY != tmpY)
return newDate;
/** \u5982\u679c\u4e0d\u80fd\u76f4\u63a5\u8fd4\u56de\uff0c\u5219\u5c06\u9519\u8bef\u7684\u6708\u4efd\u5f80\u524d\u51cf\u5929\uff0c\u76f4\u9053\u627e\u5230\u4e0a\u6708\u7684\u6700\u540e\u4e00\u5929 */
while(tmpMon != newMon)
{
newDate = new Date(newDate.getFullYear(), newDate.getMonth(), (newDate.getDate() - 1));
tmpMon = newDate.getMonth();
}
return newDate;
case 'y' :
return new Date((dtTmp.getFullYear() + numberPara), dtTmp.getMonth(), dtTmp.getDate());
}
}
//**************************************/
//******* \u65e5\u671f\u5904\u7406\u51fd\u6570 end *******/
//**************************************/
//**************************************/
//******* \u4ee3\u7f34\u8d39\u5904\u7406\u51fd\u6570 begin *******/
//**************************************/
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5faa\u73af\u68c0\u67e5\u8868\u5355\u4e2d\u9700\u68c0\u67e5\u7684\u5143\u7d20
*
* Parameter
*
* Return false -- \u4e0d\u7b26\u5408\u8981\u6c42\u683c\u5f0f
* true -- \u7b26\u5408\u8981\u6c42\u683c\u5f0f
*
*/
function paysCheck()
{
for(var i = 0; i < document.forms.length; i++)
{
var obj = document.forms[i];
for(var j = 0; j < obj.elements.length; j++)
{
if (obj.elements[j].check && obj.elements[j].check != "")
{
var checkArr = obj.elements[j].check.split(",");
for(var k = 0; k < checkArr.length; k++)
{
var tmpStr = checkArr[k] + "(\"" + document.forms[i].name + "." + obj.elements[j].name + "\",\"" + obj.elements[j].checkName + "\")";
if (eval(tmpStr))
continue;
else
return false;
}
}
}
}
return true;
}
//**************************************/
//******* \u4ee3\u7f34\u8d39\u5904\u7406\u51fd\u6570 end *******/
//**************************************/
|
JavaScript
|
(function () {
var hiddenDivId = "__hiddendiv_activex";
window.__proto__.ActiveXObject = function(progid) {
progid = progid.trim();
var e = document.createEvent('TextEvent');
e.initTextEvent(
'__npactivex_log_event__', false, false, window,
'Dynamic create ' + progid);
window.dispatchEvent(e);
if (progid == 'Msxml2.XMLHTTP' || progid == 'Microsoft.XMLHTTP')
return new XMLHttpRequest();
var hiddenDiv = document.getElementById(hiddenDivId);
if (!hiddenDiv) {
if (!document.body) return null;
hiddenDiv = document.createElement("div");
hiddenDiv.id = hiddenDivId;
hiddenDiv.setAttribute("style", "width:0px; height:0px");
document.body.insertBefore(hiddenDiv, document.body.firstChild)
}
var obj = document.createElement("object");
obj.setAttribute("type", "application/x-itst-activex");
obj.setAttribute("progid", progid);
obj.setAttribute("style", "width:0px; height:0px");
obj.setAttribute("dynamic", "");
hiddenDiv.appendChild(obj);
if (obj.object === undefined) {
throw new Error('Dynamic create failed ' + progid)
}
return obj.object
}
//console.log("ActiveXObject declared");
})();
|
JavaScript
|
//**************************************
//*** \u663e\u793a\u65e5\u5386
//**************************************
var bMoveable=true; //\u8bbe\u7f6e\u65e5\u5386\u662f\u5426\u53ef\u4ee5\u62d6\u52a8
var strFrame; //\u5b58\u653e\u65e5\u5386\u5c42\u7684HTML\u4ee3\u7801
document.writeln('<iframe src="javascript:false" id=meizzDateLayer frameborder=0 style="position: absolute; width: 176px; height: 187px; z-index: 9998; display: none"></iframe>');
strFrame='<style>';
strFrame+='.calData { border:1px solid #a9a9a9; margin:0px; padding:0px; font-family:Verdana, Arial, Helvetica, sans-serif; }';
strFrame+='.calDay {font-decoration: none; font-family: arial; font-size: 12px; color: #000000; background-color: #F8F8F8;}';
strFrame+='.calHeadZh{font-size: 12px; color:#A50031}';
strFrame+='.calHead{font-size: 9px; color:#A50031}';
strFrame+='</style>';
strFrame+='<scr' + 'ipt>';
strFrame+='var datelayerx,datelayery; /*\u5b58\u653e\u65e5\u5386\u63a7\u4ef6\u7684\u9f20\u6807\u4f4d\u7f6e*/';
strFrame+='var bDrag; /*\u6807\u8bb0\u662f\u5426\u5f00\u59cb\u62d6\u52a8*/';
strFrame+='function document.onmousemove() /*\u5728\u9f20\u6807\u79fb\u52a8\u4e8b\u4ef6\u4e2d\uff0c\u5982\u679c\u5f00\u59cb\u62d6\u52a8\u65e5\u5386\uff0c\u5219\u79fb\u52a8\u65e5\u5386*/';
strFrame+='{if(bDrag && window.event.button==1)';
strFrame+=' {var DateLayer=parent.document.all.meizzDateLayer.style;';
strFrame+=' DateLayer.posLeft += window.event.clientX-datelayerx;/*\u7531\u4e8e\u6bcf\u6b21\u79fb\u52a8\u4ee5\u540e\u9f20\u6807\u4f4d\u7f6e\u90fd\u6062\u590d\u4e3a\u521d\u59cb\u7684\u4f4d\u7f6e\uff0c\u56e0\u6b64\u5199\u6cd5\u4e0ediv\u4e2d\u4e0d\u540c*/';
strFrame+=' DateLayer.posTop += window.event.clientY-datelayery;}}';
strFrame+='function DragStart() /*\u5f00\u59cb\u65e5\u5386\u62d6\u52a8*/';
strFrame+='{var DateLayer=parent.document.all.meizzDateLayer.style;';
strFrame+=' datelayerx=window.event.clientX;';
strFrame+=' datelayery=window.event.clientY;';
strFrame+=' bDrag=true;}';
strFrame+='function DragEnd(){ /*\u7ed3\u675f\u65e5\u5386\u62d6\u52a8*/';
strFrame+=' bDrag=false;}';
strFrame+='</scr' + 'ipt>';
strFrame+='<div style="z-index:9999;position: absolute; left:0; top:0;" onselectstart="return false"><span id=tmpSelectYearLayer style="z-index: 9999;position: absolute;top: 3; left: 19;display: none"></span>';
strFrame+='<span id=tmpSelectMonthLayer style="z-index: 9999;position: absolute;top: 3; left: 110;display: none"></span>';
strFrame+='<table border=1 class="calData" cellspacing=0 cellpadding=0 width=172 height=160 bordercolor=#cecece bgcolor=#ff9900>';
strFrame+=' <tr><td width=172 height=23 bgcolor=#FFFFFF><table border=0 cellspacing=1 cellpadding=0 width=172 height=23>';
strFrame+=' <tr align=center><td width=16 align=center bgcolor=#ffffff style="font-size:12px;cursor: hand;color: #A50031" ';
strFrame+=' onclick="parent.meizzPrevY()"><b><</b>';
strFrame+=' </td><td width=60 align=center style="font-size:12px;cursor:default" ';
strFrame+='onmouseover="style.backgroundColor=\'#cecece\'" onmouseout="style.backgroundColor=\'white\'" ';
strFrame+='onclick="parent.tmpSelectYearInnerHTML(this.innerText.substring(0,4))"><span id=meizzYearHead></span></td>';
strFrame+=' <td width=16 bgcolor=#ffffff align=center style="font-size:12px;cursor: hand;color: #A50031" ';
strFrame+=' onclick="parent.meizzNextY()"><b>></b></td>';
strFrame+='<td width=16 align=center bgcolor=#ffffff style="font-size:12px;cursor: hand;color: #A50031" onclick="parent.meizzPrevM()" title="\u5411\u524d\u7ffb 1 \u6708" ><b><</b></td>';
strFrame+='<td width=48 align=center style="font-size:12px;cursor:default" onmouseover="style.backgroundColor=\'#cecece\'" ';
strFrame+=' onmouseout="style.backgroundColor=\'white\'" onclick="parent.tmpSelectMonthInnerHTML(this.innerText)"';
strFrame+=' ><span id=meizzMonthHead ></span></td>';
strFrame+=' <td width=16 bgcolor=#ffffff align=center style="font-size:12px;cursor: hand;color: #A50031" ';
strFrame+=' onclick="parent.meizzNextM()"><b>></b></td></tr>';
strFrame+=' </table></td></tr>';
strFrame+=' <tr><td width=142 height=18>';
strFrame+='<table border=1 id="calHeadTable" cellspacing=0 cellpadding=0 bgcolor=#cecece ' + (bMoveable? 'onmousedown="DragStart()" onmouseup="DragEnd()"':'');
strFrame+=' BORDERCOLORLIGHT=#ffffff BORDERCOLORDARK=#ffffff width=172 height=20 style="cursor:' + (bMoveable ? 'move':'default') + '">';
strFrame+='<tr align=center valign=bottom><td>' + calDayArr[0] + '</td>';
strFrame+='<td>' + calDayArr[1] + '</td><td>' + calDayArr[2] + '</td>';
strFrame+='<td>' + calDayArr[3] + '</td><td>' + calDayArr[4] + '</td>';
strFrame+='<td>' + calDayArr[5] + '</td><td>' + calDayArr[6] + '</td></tr>';
strFrame+='</table></td></tr>';
strFrame+=' <tr><td width=142 height=120>';
strFrame+=' <table border=1 cellspacing=2 cellpadding=0 BORDERCOLORLIGHT=#ffffff BORDERCOLORDARK=#FFFFFF bgcolor=#ffffff width=172 height=120>';
var n=0; for (j=0;j<5;j++){ strFrame+= ' <tr align=center>'; for (i=0;i<7;i++){
strFrame+='<td width=20 height=20 id=meizzDay'+n+' class="calDay" onclick=parent.meizzDayClick(this.innerText,0)></td>';n++;}
strFrame+='</tr>';}
strFrame+=' <tr align=center>';
for (i=35;i<39;i++)strFrame+='<td width=20 height=20 id=meizzDay'+i+' class="calDay" onclick="parent.meizzDayClick(this.innerText,0)"></td>';
strFrame+=' <td colspan=3 align=right ><span onclick=parent.closeLayer() style="font-size:12px;cursor: hand;color: #A50031"';
strFrame+=' ><b>×</b></span></td></tr>';
strFrame+=' </table></td></tr>';
strFrame+='</table></div>';
window.frames.meizzDateLayer.document.writeln(strFrame);
window.frames.meizzDateLayer.document.close(); //\u89e3\u51b3ie\u8fdb\u5ea6\u6761\u4e0d\u7ed3\u675f\u7684\u95ee\u9898
//==================================================== WEB \u9875\u9762\u663e\u793a\u90e8\u5206 ======================================================
var outObject;
var outButton; //\u70b9\u51fb\u7684\u6309\u94ae
var outDate=""; //\u5b58\u653e\u5bf9\u8c61\u7684\u65e5\u671f
var odatelayer=window.frames.meizzDateLayer.document.all; //\u5b58\u653e\u65e5\u5386\u5bf9\u8c61
var yearPeriod = 12;
function showCalendar()
{
switch (arguments.length)
{
/** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a2,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */
case 2:
showCalendarDeal(arguments[0],arguments[1]);
break;
/** \u5982\u679c\u53c2\u6570\u4e2a\u6570\u4e3a4,\u8c03\u7528\u76f8\u5e94\u51fd\u6570\u5904\u7406 */
case 3:
yearPeriod = arguments[2];
showCalendarDeal(arguments[0],arguments[1]);
break;
default:
showCalendarDeal(arguments[0],arguments[1]);
break;
}
}
function showCalendarDeal(tt,obj) //\u4e3b\u8c03\u51fd\u6570
{
if (arguments.length > 2){alert("\u5bf9\u4e0d\u8d77!\u4f20\u5165\u672c\u63a7\u4ef6\u7684\u53c2\u6570\u592a\u591a!");return;}
if (arguments.length == 0){alert("\u5bf9\u4e0d\u8d77!\u60a8\u6ca1\u6709\u4f20\u56de\u672c\u63a7\u4ef6\u4efb\u4f55\u53c2\u6570!");return;}
if (calLanguage == "zhCN")
odatelayer.calHeadTable.className = "calHeadZh";
else
odatelayer.calHeadTable.className = "calHead";
var dads = document.all.meizzDateLayer.style;
var th = tt;
var ttop = tt.offsetTop; //TT\u63a7\u4ef6\u7684\u5b9a\u4f4d\u70b9\u9ad8
var thei = tt.clientHeight; //TT\u63a7\u4ef6\u672c\u8eab\u7684\u9ad8
var tleft = tt.offsetLeft; //TT\u63a7\u4ef6\u7684\u5b9a\u4f4d\u70b9\u5bbd
var ttyp = tt.type; //TT\u63a7\u4ef6\u7684\u7c7b\u578b
while (tt = tt.offsetParent){ttop+=tt.offsetTop; tleft+=tt.offsetLeft;}
dads.top = (ttyp=="image")? ttop+thei : ttop+thei+6;
dads.left = tleft;
outObject = (arguments.length == 1) ? th : obj;
outButton = (arguments.length == 1) ? null : th; //\u8bbe\u5b9a\u5916\u90e8\u70b9\u51fb\u7684\u6309\u94ae
//\u6839\u636e\u5f53\u524d\u8f93\u5165\u6846\u7684\u65e5\u671f\u663e\u793a\u65e5\u5386\u7684\u5e74\u6708
var reg = /^(\d{4})\/(\d{1,2})\/(\d{1,2})$/;
var r = outObject.value.match(reg);
if(r!=null)
{
r[2]=r[2]-1;
var d= new Date(r[1], r[2],r[3]);
if(d.getFullYear()==r[1] && d.getMonth()==r[2] && d.getDate()==r[3])
{
outDate = d; //\u4fdd\u5b58\u5916\u90e8\u4f20\u5165\u7684\u65e5\u671f
meizzSetDay(r[1],r[2]+1);
}
else
{
outDate = "";
meizzSetDay(new Date().getFullYear(), new Date().getMonth() + 1);
}
}
else
{
outDate="";
meizzSetDay(new Date().getFullYear(), new Date().getMonth() + 1);
}
dads.display = '';
event.returnValue=false;
}
var MonHead = new Array(12); //\u5b9a\u4e49\u9633\u5386\u4e2d\u6bcf\u4e2a\u6708\u7684\u6700\u5927\u5929\u6570
MonHead[0] = 31; MonHead[1] = 28; MonHead[2] = 31; MonHead[3] = 30; MonHead[4] = 31; MonHead[5] = 30;
MonHead[6] = 31; MonHead[7] = 31; MonHead[8] = 30; MonHead[9] = 31; MonHead[10] = 30; MonHead[11] = 31;
var meizzTheYear=new Date().getFullYear(); //\u5b9a\u4e49\u5e74\u7684\u53d8\u91cf\u7684\u521d\u59cb\u503c
var meizzTheMonth=new Date().getMonth()+1; //\u5b9a\u4e49\u6708\u7684\u53d8\u91cf\u7684\u521d\u59cb\u503c
var meizzWDay=new Array(39); //\u5b9a\u4e49\u5199\u65e5\u671f\u7684\u6570\u7ec4
function document.onclick() //\u4efb\u610f\u70b9\u51fb\u65f6\u5173\u95ed\u8be5\u63a7\u4ef6 //ie6\u7684\u60c5\u51b5\u53ef\u4ee5\u7531\u4e0b\u9762\u7684\u5207\u6362\u7126\u70b9\u5904\u7406\u4ee3\u66ff
{
with(window.event)
{
if (srcElement.getAttribute("Author")==null && srcElement != outObject && srcElement != outButton)
closeLayer();
}
}
function document.onkeyup() //\u6309Esc\u952e\u5173\u95ed\uff0c\u5207\u6362\u7126\u70b9\u5173\u95ed
{
if (window.event.keyCode==27){
if(outObject)outObject.blur();
closeLayer();
}
else if(document.activeElement)
if(document.activeElement.getAttribute("Author")==null && document.activeElement != outObject && document.activeElement != outButton)
{
closeLayer();
}
}
function meizzWriteHead(yy,mm) //\u5f80 head \u4e2d\u5199\u5165\u5f53\u524d\u7684\u5e74\u4e0e\u6708
{
odatelayer.meizzYearHead.innerText = yy + calYear;
odatelayer.meizzMonthHead.innerText = calMonthArr[mm - 1];
}
function tmpSelectYearInnerHTML(strYear) //\u5e74\u4efd\u7684\u4e0b\u62c9\u6846
{
if (strYear.match(/\D/)!=null) return;//{alert("\u5e74\u4efd\u8f93\u5165\u53c2\u6570\u4e0d\u662f\u6570\u5b57!");return;}
var m = (strYear) ? strYear : new Date().getFullYear();
// var m = new Date().getFullYear();
if (m < 1000 || m > 9999) return;//{alert("\u5e74\u4efd\u503c\u4e0d\u5728 1000 \u5230 9999 \u4e4b\u95f4!");return;}
//xulc modify
var n = m - yearPeriod/2;
if (n < 1000) n = 1000;
if (n + 10 > 9999) n = 9974;
var s = "<select name=tmpSelectYear style='font-size: 12px' "
s += "onblur='document.all.tmpSelectYearLayer.style.display=\"none\"' "
s += "onchange='document.all.tmpSelectYearLayer.style.display=\"none\";"
s += "parent.meizzTheYear = this.value; parent.meizzSetDay(parent.meizzTheYear,parent.meizzTheMonth)'>\r\n";
var selectInnerHTML = s;
for (var i = n; i < n + yearPeriod; i++)
{
if (i == m)
{selectInnerHTML += "<option value='" + i + "' selected>" + i + "</option>\r\n";}
else {selectInnerHTML += "<option value='" + i + "'>" + i + "</option>\r\n";}
}
selectInnerHTML += "</select>";
odatelayer.tmpSelectYearLayer.style.display="";
odatelayer.tmpSelectYearLayer.innerHTML = selectInnerHTML;
odatelayer.tmpSelectYear.focus();
}
function tmpSelectMonthInnerHTML(strMonth) //\u6708\u4efd\u7684\u4e0b\u62c9\u6846
{
for(var i = 0; i < calMonthArr.length; i++)
{
if (calMonthArr[i] == strMonth)
{
strMonth = String(i + 1);
break;
}
}
if (strMonth.match(/\D/)!=null) return;//{alert("\u6708\u4efd\u8f93\u5165\u53c2\u6570\u4e0d\u662f\u6570\u5b57!");return;}
var m = (strMonth) ? strMonth : new Date().getMonth() + 1;
var s = "<select name=tmpSelectMonth style='font-size: 12px' "
s += "onblur='document.all.tmpSelectMonthLayer.style.display=\"none\"' "
s += "onchange='document.all.tmpSelectMonthLayer.style.display=\"none\";"
s += "parent.meizzTheMonth = this.value; parent.meizzSetDay(parent.meizzTheYear,parent.meizzTheMonth)'>\r\n";
var selectInnerHTML = s;
for (var i = 1; i < 13; i++)
{
if (i == m)
{selectInnerHTML += "<option value='"+i+"' selected>"+calMonthArr[i-1]+"</option>\r\n";}
else {selectInnerHTML += "<option value='"+i+"'>"+calMonthArr[i-1]+"</option>\r\n";}
}
selectInnerHTML += "</select>";
odatelayer.tmpSelectMonthLayer.style.display="";
odatelayer.tmpSelectMonthLayer.innerHTML = selectInnerHTML;
odatelayer.tmpSelectMonth.focus();
}
function closeLayer() //\u8fd9\u4e2a\u5c42\u7684\u5173\u95ed
{
document.all.meizzDateLayer.style.display="none";
}
function IsPinYear(year) //\u5224\u65ad\u662f\u5426\u95f0\u5e73\u5e74
{
if (0==year%4&&((year%100!=0)||(year%400==0))) return true;else return false;
}
function GetMonthCount(year,month) //\u95f0\u5e74\u4e8c\u6708\u4e3a29\u5929
{
var c=MonHead[month-1];if((month==2)&&IsPinYear(year)) c++;return c;
}
function GetDOW(day,month,year) //\u6c42\u67d0\u5929\u7684\u661f\u671f\u51e0
{
var dt=new Date(year,month-1,day).getDay()/7; return dt;
}
function meizzPrevY() //\u5f80\u524d\u7ffb Year
{
if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear--;}
else return;//{alert("\u5e74\u4efd\u8d85\u51fa\u8303\u56f4\uff081000-9999\uff09!");}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzNextY() //\u5f80\u540e\u7ffb Year
{
if(meizzTheYear > 999 && meizzTheYear <10000){meizzTheYear++;}
else return;//{alert("\u5e74\u4efd\u8d85\u51fa\u8303\u56f4\uff081000-9999\uff09!");}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzToday() //Today Button
{
var today;
meizzTheYear = new Date().getFullYear();
meizzTheMonth = new Date().getMonth()+1;
today=new Date().getDate();
//meizzSetDay(meizzTheYear,meizzTheMonth);
if(outObject){
outObject.value=meizzTheYear + "-" + meizzTheMonth + "-" + today;
}
closeLayer();
}
function meizzPrevM() //\u5f80\u524d\u7ffb\u6708\u4efd
{
if(meizzTheMonth>1){meizzTheMonth--}else{meizzTheYear--;meizzTheMonth=12;}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzNextM() //\u5f80\u540e\u7ffb\u6708\u4efd
{
if(meizzTheMonth==12){meizzTheYear++;meizzTheMonth=1}else{meizzTheMonth++}
meizzSetDay(meizzTheYear,meizzTheMonth);
}
function meizzSetDay(yy,mm) //\u4e3b\u8981\u7684\u5199\u7a0b\u5e8f**********
{
meizzWriteHead(yy,mm);
//\u8bbe\u7f6e\u5f53\u524d\u5e74\u6708\u7684\u516c\u5171\u53d8\u91cf\u4e3a\u4f20\u5165\u503c
meizzTheYear=yy;
meizzTheMonth=mm;
for (var i = 0; i < 39; i++){meizzWDay[i]=""}; //\u5c06\u663e\u793a\u6846\u7684\u5185\u5bb9\u5168\u90e8\u6e05\u7a7a
var day1 = 1,day2=1,firstday = new Date(yy,mm-1,1).getDay(); //\u67d0\u6708\u7b2c\u4e00\u5929\u7684\u661f\u671f\u51e0
for (i=0;i<firstday;i++)meizzWDay[i]=GetMonthCount(mm==1?yy-1:yy,mm==1?12:mm-1)-firstday+i+1 //\u4e0a\u4e2a\u6708\u7684\u6700\u540e\u51e0\u5929
for (i = firstday; day1 < GetMonthCount(yy,mm)+1; i++){meizzWDay[i]=day1;day1++;}
for (i=firstday+GetMonthCount(yy,mm);i<39;i++){meizzWDay[i]=day2;day2++}
for (i = 0; i < 39; i++)
{ var da = eval("odatelayer.meizzDay"+i) //\u4e66\u5199\u65b0\u7684\u4e00\u4e2a\u6708\u7684\u65e5\u671f\u661f\u671f\u6392\u5217
if (meizzWDay[i]!="")
{
//\u521d\u59cb\u5316\u8fb9\u6846
da.borderColorLight="#ffffff";
da.borderColorDark="#FFFFFF";
if(i<firstday) //\u4e0a\u4e2a\u6708\u7684\u90e8\u5206
{
da.innerHTML="<b><font color=gray>" + meizzWDay[i] + "</font></b>";
da.title=(mm==1?12:mm-1) +" / " + meizzWDay[i];
da.onclick=Function("meizzDayClick(this.innerText,-1)");
if(!outDate)
da.style.backgroundColor = ((mm==1?yy-1:yy) == new Date().getFullYear() &&
(mm==1?12:mm-1) == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ?
"#A50031":"#efefef";//\u4e0a\u6708\u90e8\u5206\u7684\u80cc\u666f\u8272
else
{
da.style.backgroundColor =((mm==1?yy-1:yy)==outDate.getFullYear() && (mm==1?12:mm-1)== outDate.getMonth() + 1 &&
meizzWDay[i]==outDate.getDate())? "#ffffff" :
(((mm==1?yy-1:yy) == new Date().getFullYear() && (mm==1?12:mm-1) == new Date().getMonth()+1 &&
meizzWDay[i] == new Date().getDate()) ? "#A50031":"#ffffff");//\u9009\u4e2d\u4e0a\u6708\u672c\u5468\u65e5\u671f\u6846\u548c\u989c\u8272\u80cc\u666f
//\u5c06\u9009\u4e2d\u7684\u65e5\u671f\u663e\u793a\u4e3a\u51f9\u4e0b\u53bb
if((mm==1?yy-1:yy)==outDate.getFullYear() && (mm==1?12:mm-1)== outDate.getMonth() + 1 &&
meizzWDay[i]==outDate.getDate())
{
da.borderColorLight="#FFFFFF";
da.borderColorDark="#FF9900";
}
}
}
else if (i>=firstday+GetMonthCount(yy,mm)) //\u4e0b\u4e2a\u6708\u7684\u90e8\u5206
{
da.innerHTML="<b><font color=gray>" + meizzWDay[i] + "</font></b>";
da.title=(mm==12?1:mm+1) +" / " + meizzWDay[i];
da.onclick=Function("meizzDayClick(this.innerText,1)");
if(!outDate)
da.style.backgroundColor = ((mm==12?yy+1:yy) == new Date().getFullYear() &&
(mm==12?1:mm+1) == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate()) ?
"#A50031":"#efefef";//\u4e0b\u6708\u90e8\u5206\u7684\u80cc\u666f\u8272
else
{
da.style.backgroundColor =((mm==12?yy+1:yy)==outDate.getFullYear() && (mm==12?1:mm+1)== outDate.getMonth() + 1 &&
meizzWDay[i]==outDate.getDate())? "#ffffff" :
(((mm==12?yy+1:yy) == new Date().getFullYear() && (mm==12?1:mm+1) == new Date().getMonth()+1 &&
meizzWDay[i] == new Date().getDate()) ? "#A50031":"#ffffff");
//\u5c06\u9009\u4e2d\u7684\u65e5\u671f\u663e\u793a\u4e3a\u51f9\u4e0b\u53bb
if((mm==12?yy+1:yy)==outDate.getFullYear() && (mm==12?1:mm+1)== outDate.getMonth() + 1 &&
meizzWDay[i]==outDate.getDate())
{
da.borderColorLight="#FFFFFF";
da.borderColorDark="#A50031";
}
}
}
else //\u672c\u6708\u7684\u90e8\u5206
{
da.innerHTML="<b>" + meizzWDay[i] + "</b>";
da.title=mm + " / " + meizzWDay[i];
da.onclick=Function("meizzDayClick(this.innerText,0)"); //\u7ed9td\u8d4b\u4e88onclick\u4e8b\u4ef6\u7684\u5904\u7406
//\u5982\u679c\u662f\u5f53\u524d\u9009\u62e9\u7684\u65e5\u671f\uff0c\u5219\u663e\u793a\u4eae\u84dd\u8272\u7684\u80cc\u666f\uff1b\u5982\u679c\u662f\u5f53\u524d\u65e5\u671f\uff0c\u5219\u663e\u793a\u6697\u9ec4\u8272\u80cc\u666f
if(!outDate)
{
if (yy == new Date().getFullYear() && mm == new Date().getMonth()+1 && meizzWDay[i] == new Date().getDate())
{
da.style.backgroundColor = "#A10333";
da.style.color = "#ffffff";
}
else
{
da.style.color = "#000000";
da.style.backgroundColor = "#ffffff";
}
}
else
{
if (yy==outDate.getFullYear() && mm== outDate.getMonth() + 1 && meizzWDay[i]==outDate.getDate())
{
da.style.backgroundColor = "#A10333";
da.style.color = "#ffffff";
}
else
{
da.style.color = "#000000";
da.style.backgroundColor = "#ffffff";
}
//\u5c06\u9009\u4e2d\u7684\u65e5\u671f\u663e\u793a\u4e3a\u51f9\u4e0b\u53bb
if(yy==outDate.getFullYear() && mm== outDate.getMonth() + 1 && meizzWDay[i]==outDate.getDate())
{
da.borderColorLight="#ffffff";
da.borderColorDark="#A50031";
}
}
}
da.style.cursor="hand"
}
else{da.innerHTML="";da.style.backgroundColor="";da.style.cursor="default"}
}
}
function meizzDayClick(n,ex) //\u70b9\u51fb\u663e\u793a\u6846\u9009\u53d6\u65e5\u671f\uff0c\u4e3b\u8f93\u5165\u51fd\u6570*************
{
var yy=meizzTheYear;
var mm = parseInt(meizzTheMonth)+ex; //ex\u8868\u793a\u504f\u79fb\u91cf\uff0c\u7528\u4e8e\u9009\u62e9\u4e0a\u4e2a\u6708\u4efd\u548c\u4e0b\u4e2a\u6708\u4efd\u7684\u65e5\u671f
//\u5224\u65ad\u6708\u4efd\uff0c\u5e76\u8fdb\u884c\u5bf9\u5e94\u7684\u5904\u7406
if(mm<1){
yy--;
mm=12+mm;
}
else if(mm>12){
yy++;
mm=mm-12;
}
if (mm < 10){mm = "0" + mm;}
if (outObject)
{
if (!n) {//outObject.value="";
return;}
if ( n < 10){n = "0" + n;}
outObject.value= yy + "/" + mm + "/" + n ; //\u6ce8\uff1a\u5728\u8fd9\u91cc\u4f60\u53ef\u4ee5\u8f93\u51fa\u6539\u6210\u4f60\u60f3\u8981\u7684\u683c\u5f0f
closeLayer();
}
else {closeLayer();}// alert("\u60a8\u6240\u8981\u8f93\u51fa\u7684\u63a7\u4ef6\u5bf9\u8c61\u5e76\u4e0d\u5b58\u5728!");}
}
//**************************************
//*** \u663e\u793a\u65e5\u5386\u7ed3\u675f
//**************************************
|
JavaScript
|
(function(node) {
node.createPopup = node.createPopup || function() {
var SetElementStyles = function(element, styleDict) {
var style = element.style;
for (var styleName in styleDict) {
style[styleName] = styleDict[styleName];
}
}
var eDiv = document.createElement('div');
SetElementStyles(eDiv, {
'position': 'absolute',
'top': 0 + 'px',
'left': 0 + 'px',
'width': 0 + 'px',
'height': 0 + 'px',
'zIndex': 1000,
'display': 'none',
'overflow': 'hidden'
});
eDiv.body = eDiv;
eDiv.write = function(string) {
eDiv.innerHTML += string;
}
var opened = false;
var setOpened = function(b) {
opened = b;
}
var getOpened = function() {
return opened;
}
var getCoordinates = function(oElement) {
var coordinates = {
x: 0,
y: 0
};
while (oElement) {
coordinates.x += oElement.offsetLeft;
coordinates.y += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return coordinates;
}
return {
htmlTxt: '',
document: eDiv,
isOpen: getOpened(),
isShow: false,
hide: function() {
SetElementStyles(eDiv, {
'top': 0 + 'px',
'left': 0 + 'px',
'width': 0 + 'px',
'height': 0 + 'px',
'display': 'none'
});
eDiv.innerHTML = '';
this.isShow = false;
},
show: function(iX, iY, iWidth, iHeight, oElement) {
if (!getOpened()) {
document.body.appendChild(eDiv);
setOpened(true);
};
this.htmlTxt = eDiv.innerHTML;
if (this.isShow) {
this.hide();
};
eDiv.innerHTML = this.htmlTxt;
var coordinates = getCoordinates(oElement);
eDiv.style.top = (iX + coordinates.x) + 'px';
eDiv.style.left = (iY + coordinates.y) + 'px';
eDiv.style.width = iWidth + 'px';
eDiv.style.height = iHeight + 'px';
eDiv.style.display = 'block';
this.isShow = true;
}
}
}
})(window.__proto__);
|
JavaScript
|
(function() {
function __bugupatch() {
if (typeof cntv != 'undefined') {
cntv.player.util.getPlayerCore = function(orig) {
return function() {
var ret = orig();
if (arguments.callee.caller.toString().indexOf('GetPlayerControl') != -1) {
return {
GetVersion: ret.GetVersion,
GetPlayerControl: ret.GetPlayerControl()
};
} else {
return ret;
};
}
} (cntv.player.util.getPlayerCore);
console.log('buguplayer patched');
window.removeEventListener('beforeload', __bugupatch, true);
}
}
window.addEventListener('beforeload', __bugupatch, true);
})()
|
JavaScript
|
/**
* \u521b\u5efa\u5b89\u5168\u63a7\u4ef6\u811a\u672c
*/
var rs = "";
function CreateControl(DivID, Form, ObjectID, mode, language) {
var d = document.getElementById(DivID);
var obj = document.createElement('object');
d.appendChild(obj);
obj.width = 162;
obj.height = 20;
obj.classid="clsid:E61E8363-041F-455c-8AD0-8A61F1D8E540";
obj.id=ObjectID;
var version = getVersion(obj);
passInit(obj, mode, language, version);
var rc = null;
if (version >= 66816) { //66560 1.4.0.0 //66306 1.3.0.2 //66305 1.3.0.1 //65539 1.3.0
getRS();
if (rs != "") {
obj.RandomKey_S = rs;
rc = obj.RandomKey_C;
}
}
return rc;
}
/**
* \u53d6\u63a7\u4ef6\u7248\u672c\u53f7
*/
function getVersion(obj) {
try {
var version = obj.Version;
try {
if (version == undefined)
return 0;
} catch(ve) {//IE5.0
return 0;
}
return version;
}
catch(e) {
return 0;
}
}
/**
* \u53d6rs
*/
function getRS() {
if (rs == "") {
url = "refreshrs.do";
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
if(xmlhttp) {
xmlhttp.open("POST", url, false);
xmlhttp.send();
rs = xmlhttp.responseText;
if (rs == null) {
alert("Control rs error.");
rs = "";
}
else {
rs = rs.replace(/[ \t\r\n]/g, "");
if (rs.length != 24) {
alert("Control rs error:" + rs.length);
rs = "";
}
}
}
}
}
/**
* \u53d6\u63a7\u4ef6\u7248\u72b6\u6001
*/
function getState(obj) {
try {
var state = obj.State;
try {
if (state == undefined)
return 0;
} catch(ve) {//IE5.0
return 0;
}
return state;
}
catch(e) {
return 0;
}
}
/**
* \u63a7\u4ef6\u68c0\u6d4b
*/
function passControlCheck(obj, mode, language) {
try {
var version = getVersion(obj);
passInit(obj, mode, language, version);
if (version < 65539) {//66560 1.4.0.0 //66306 1.3.0.2 //66305 1.3.0.1 //65539 1.3.0
alert(SAFECONTROL_VERSION);
return false;
}
}
catch(e) {
alert(SAFECONTROL_INSTALL);
return false;
}
return true;
}
/**
* \u8bbe\u7f6e\u63a7\u4ef6
*/
function passInit(obj, mode, language, version) {
obj.SetLanguage(language);
//\u53e3\u4ee4
if (mode == 0) {
obj.PasswordIntensityMinLength = 1;
obj.MaxLength = 20;
obj.OutputValueType = 2;
obj.PasswordIntensityRegularExpression = "^[!-~]*$";
}
//\u65b0\u53e3\u4ee4
else if (mode == 1) {
obj.PasswordIntensityMinLength = 8;
obj.MaxLength = 20;
obj.OutputValueType = 2;
obj.PasswordIntensityRegularExpression = "(^[!-~]*[A-Za-z]+[!-~]*[0-9]+[!-~]*$)|(^[!-~]*[0-9]+[!-~]*[A-Za-z]+[!-~]*$)";
}
//\u52a8\u6001\u53e3\u4ee4
else if (mode == 2) {
obj.PasswordIntensityMinLength = 6;
obj.MaxLength = 6;
obj.OutputValueType = 1;
obj.PasswordIntensityRegularExpression = "^[0-9]{6}$";
}
//\u7535\u8bdd\u94f6\u884c\u5bc6\u7801
else if (mode == 3) {
obj.PasswordIntensityMinLength = 6;
obj.MaxLength = 6;
obj.OutputValueType = 1;
obj.PasswordIntensityRegularExpression = "^[0-9]{6}$";
}
//\u624b\u673a\u94f6\u884c\u5bc6\u7801
else if (mode == 4) {
obj.PasswordIntensityMinLength = 8;
obj.MaxLength = 20;
obj.OutputValueType = 1;
obj.PasswordIntensityRegularExpression = "^[!-~]*$";
}
}
|
JavaScript
|
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 2.1 Copyright (C) Paul Johnston 1999 - 2002.
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* Distributed under the BSD License
* See http://pajhome.org.uk/crypt/md5 for more info.
*/
/*
* Configurable variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
*/
var hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
var b64pad = "="; /* base-64 pad character. "=" for strict RFC compliance */
var chrsz = 16; /* bits per input character. 8 - ASCII; 16 - Unicode */
/*
* These are the functions you'll usually want to call
* They take string arguments and return either hex or base-64 encoded strings
*/
function hex_md5(s){ return binl2hex(core_md5(str2binl(s), s.length * chrsz));}
function b64_md5(s){ return binl2b64(core_md5(str2binl(s), s.length * chrsz));}
function str_md5(s){ return binl2str(core_md5(str2binl(s), s.length * chrsz));}
function hex_hmac_md5(key, data) { return binl2hex(core_hmac_md5(key, data)); }
function b64_hmac_md5(key, data) { return binl2b64(core_hmac_md5(key, data)); }
function str_hmac_md5(key, data) { return binl2str(core_hmac_md5(key, data)); }
/*
* Perform a simple self-test to see if the VM is working
*/
function md5_vm_test()
{
return hex_md5("abc") == "900150983cd24fb0d6963f7d28e17f72";
}
/*
* Calculate the MD5 of an array of little-endian words, and a bit length
*/
function core_md5(x, len)
{
/* append padding */
x[len >> 5] |= 0x80 << ((len) % 32);
x[(((len + 64) >>> 9) << 4) + 14] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
for(var i = 0; i < x.length; i += 16)
{
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
a = md5_ff(a, b, c, d, x[i+ 0], 7 , -680876936);
d = md5_ff(d, a, b, c, x[i+ 1], 12, -389564586);
c = md5_ff(c, d, a, b, x[i+ 2], 17, 606105819);
b = md5_ff(b, c, d, a, x[i+ 3], 22, -1044525330);
a = md5_ff(a, b, c, d, x[i+ 4], 7 , -176418897);
d = md5_ff(d, a, b, c, x[i+ 5], 12, 1200080426);
c = md5_ff(c, d, a, b, x[i+ 6], 17, -1473231341);
b = md5_ff(b, c, d, a, x[i+ 7], 22, -45705983);
a = md5_ff(a, b, c, d, x[i+ 8], 7 , 1770035416);
d = md5_ff(d, a, b, c, x[i+ 9], 12, -1958414417);
c = md5_ff(c, d, a, b, x[i+10], 17, -42063);
b = md5_ff(b, c, d, a, x[i+11], 22, -1990404162);
a = md5_ff(a, b, c, d, x[i+12], 7 , 1804603682);
d = md5_ff(d, a, b, c, x[i+13], 12, -40341101);
c = md5_ff(c, d, a, b, x[i+14], 17, -1502002290);
b = md5_ff(b, c, d, a, x[i+15], 22, 1236535329);
a = md5_gg(a, b, c, d, x[i+ 1], 5 , -165796510);
d = md5_gg(d, a, b, c, x[i+ 6], 9 , -1069501632);
c = md5_gg(c, d, a, b, x[i+11], 14, 643717713);
b = md5_gg(b, c, d, a, x[i+ 0], 20, -373897302);
a = md5_gg(a, b, c, d, x[i+ 5], 5 , -701558691);
d = md5_gg(d, a, b, c, x[i+10], 9 , 38016083);
c = md5_gg(c, d, a, b, x[i+15], 14, -660478335);
b = md5_gg(b, c, d, a, x[i+ 4], 20, -405537848);
a = md5_gg(a, b, c, d, x[i+ 9], 5 , 568446438);
d = md5_gg(d, a, b, c, x[i+14], 9 , -1019803690);
c = md5_gg(c, d, a, b, x[i+ 3], 14, -187363961);
b = md5_gg(b, c, d, a, x[i+ 8], 20, 1163531501);
a = md5_gg(a, b, c, d, x[i+13], 5 , -1444681467);
d = md5_gg(d, a, b, c, x[i+ 2], 9 , -51403784);
c = md5_gg(c, d, a, b, x[i+ 7], 14, 1735328473);
b = md5_gg(b, c, d, a, x[i+12], 20, -1926607734);
a = md5_hh(a, b, c, d, x[i+ 5], 4 , -378558);
d = md5_hh(d, a, b, c, x[i+ 8], 11, -2022574463);
c = md5_hh(c, d, a, b, x[i+11], 16, 1839030562);
b = md5_hh(b, c, d, a, x[i+14], 23, -35309556);
a = md5_hh(a, b, c, d, x[i+ 1], 4 , -1530992060);
d = md5_hh(d, a, b, c, x[i+ 4], 11, 1272893353);
c = md5_hh(c, d, a, b, x[i+ 7], 16, -155497632);
b = md5_hh(b, c, d, a, x[i+10], 23, -1094730640);
a = md5_hh(a, b, c, d, x[i+13], 4 , 681279174);
d = md5_hh(d, a, b, c, x[i+ 0], 11, -358537222);
c = md5_hh(c, d, a, b, x[i+ 3], 16, -722521979);
b = md5_hh(b, c, d, a, x[i+ 6], 23, 76029189);
a = md5_hh(a, b, c, d, x[i+ 9], 4 , -640364487);
d = md5_hh(d, a, b, c, x[i+12], 11, -421815835);
c = md5_hh(c, d, a, b, x[i+15], 16, 530742520);
b = md5_hh(b, c, d, a, x[i+ 2], 23, -995338651);
a = md5_ii(a, b, c, d, x[i+ 0], 6 , -198630844);
d = md5_ii(d, a, b, c, x[i+ 7], 10, 1126891415);
c = md5_ii(c, d, a, b, x[i+14], 15, -1416354905);
b = md5_ii(b, c, d, a, x[i+ 5], 21, -57434055);
a = md5_ii(a, b, c, d, x[i+12], 6 , 1700485571);
d = md5_ii(d, a, b, c, x[i+ 3], 10, -1894986606);
c = md5_ii(c, d, a, b, x[i+10], 15, -1051523);
b = md5_ii(b, c, d, a, x[i+ 1], 21, -2054922799);
a = md5_ii(a, b, c, d, x[i+ 8], 6 , 1873313359);
d = md5_ii(d, a, b, c, x[i+15], 10, -30611744);
c = md5_ii(c, d, a, b, x[i+ 6], 15, -1560198380);
b = md5_ii(b, c, d, a, x[i+13], 21, 1309151649);
a = md5_ii(a, b, c, d, x[i+ 4], 6 , -145523070);
d = md5_ii(d, a, b, c, x[i+11], 10, -1120210379);
c = md5_ii(c, d, a, b, x[i+ 2], 15, 718787259);
b = md5_ii(b, c, d, a, x[i+ 9], 21, -343485551);
a = safe_add(a, olda);
b = safe_add(b, oldb);
c = safe_add(c, oldc);
d = safe_add(d, oldd);
}
return Array(a, b, c, d);
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function md5_cmn(q, a, b, x, s, t)
{
return safe_add(bit_rol(safe_add(safe_add(a, q), safe_add(x, t)), s),b);
}
function md5_ff(a, b, c, d, x, s, t)
{
return md5_cmn((b & c) | ((~b) & d), a, b, x, s, t);
}
function md5_gg(a, b, c, d, x, s, t)
{
return md5_cmn((b & d) | (c & (~d)), a, b, x, s, t);
}
function md5_hh(a, b, c, d, x, s, t)
{
return md5_cmn(b ^ c ^ d, a, b, x, s, t);
}
function md5_ii(a, b, c, d, x, s, t)
{
return md5_cmn(c ^ (b | (~d)), a, b, x, s, t);
}
/*
* Calculate the HMAC-MD5, of a key and some data
*/
function core_hmac_md5(key, data)
{
var bkey = str2binl(key);
if(bkey.length > 16) bkey = core_md5(bkey, key.length * chrsz);
var ipad = Array(16), opad = Array(16);
for(var i = 0; i < 16; i++)
{
ipad[i] = bkey[i] ^ 0x36363636;
opad[i] = bkey[i] ^ 0x5C5C5C5C;
}
var hash = core_md5(ipad.concat(str2binl(data)), 512 + data.length * chrsz);
return core_md5(opad.concat(hash), 512 + 128);
}
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return (msw << 16) | (lsw & 0xFFFF);
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function bit_rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt));
}
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
*/
function str2binl(str)
{
var bin = Array();
var mask = (1 << chrsz) - 1;
for(var i = 0; i < str.length * chrsz; i += chrsz)
bin[i>>5] |= (str.charCodeAt(i / chrsz) & mask) << (i%32);
return bin;
}
/*
* Convert an array of little-endian words to a string
*/
function binl2str(bin)
{
var str = "";
var mask = (1 << chrsz) - 1;
for(var i = 0; i < bin.length * 32; i += chrsz)
str += String.fromCharCode((bin[i>>5] >>> (i % 32)) & mask);
return str;
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
var str = "";
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8 )) & 0xF);
}
return str;
}
/*
* Convert an array of little-endian words to a base-64 string
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
var str = "";
for(var i = 0; i < binarray.length * 4; i += 3)
{
var triplet = (((binarray[i >> 2] >> 8 * ( i %4)) & 0xFF) << 16)
| (((binarray[i+1 >> 2] >> 8 * ((i+1)%4)) & 0xFF) << 8 )
| ((binarray[i+2 >> 2] >> 8 * ((i+2)%4)) & 0xFF);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > binarray.length * 32) str += b64pad;
else str += tab.charAt((triplet >> 6*(3-j)) & 0x3F);
}
}
return str;
}
|
JavaScript
|
scriptConfig.none2block = true;
|
JavaScript
|
window.addEventListener('DOMContentLoaded', function() {
if (window.logonSubmit) {
logonSubmit = function(orig) {
return function() {
try {
orig();
} catch (e) {
if (e.message == 'Error calling method on NPObject.') {
// We assume it has passed the checking.
frmLogon.submit();
clickBoolean = false;
}
}
}
}(logonSubmit);
}
}, false);
|
JavaScript
|
(function() {
function declareEventAsIE(node) {
if (!node.attachEvent) {
node.attachEvent = function(event, operation) {
if (event.substr(0, 2) == "on") this.addEventListener(event.substr(2), operation, false)
}
}
if (!node.detachEvent) {
node.detachEvent = function(event, operation) {
if (event.substr(0, 2) == "on") this.removeEventListener(event.substr(2), operation, false)
}
}
}
declareEventAsIE(window.Node.prototype);
declareEventAsIE(window.__proto__);
})();
|
JavaScript
|
window.addEventListener('load', function() {
delete FrmUserInfo.elements;
FrmUserInfo.elements = function(x){return this[x]};
console.log('cloudzz patch');
onAuthenticated();
}, false);
HTMLElement.prototype.insertAdjacentHTML = function(orig) {
return function() {
this.style.display = "block";
this.style.overflow = "hidden";
orig.apply(this, arguments);
}
}(HTMLElement.prototype.insertAdjacentHTML);
|
JavaScript
|
window.addEventListener('error', function(event) {
function executeScript(file) {
var request = new XMLHttpRequest();
// In case it needs immediate loading, use sync ajax.
request.open('GET', file, false);
request.send();
eval(translate(request.responseText));
}
function translate(text) {
text = text.replace(/function ([\w]+\.[\w\.]+)\(/, "$1 = function (");
return text;
}
if (event.message == 'Uncaught SyntaxError: Unexpected token .') {
executeScript(event.filename);
}
}, true);
|
JavaScript
|
window.addEventListener('load', function() {Exobud.URL = objMmInfo[0].mmUrl}, false);
|
JavaScript
|
(function() {
function reload() {
var maps = document.getElementsByTagName("map");
for (var i = 0; i < maps.length; ++i) {
if (maps[i].name == "") maps[i].name = maps[i].id;
}
}
if (document.readyState == 'complete') {
reload();
} else {
window.addEventListener('load', reload, false);
}
})();
|
JavaScript
|
//********************************************
//*** \u4ee5\u4e0b\u51fd\u6570\u7528\u6765\u5904\u7406\u91d1\u989d\u683c\u5f0f,\u5e76\u663e\u793a\u60ac\u6d6e\u6846
//*** \u6ce8\u610f:\u5f15\u7528\u6b64js\u6587\u4ef6\u65f6,\u5fc5\u987b\u5f15\u7528common.js\u548cformCheck.js
//********************************************
//Begin dHTML Toolltip Timer
var tipTimer;
//End dHTML Toolltip Timer
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u683c\u5f0f\u5316\u91d1\u989d\uff08\u5343\u4f4d\u5206\u9694\u7b26\uff09
*
* Parameter txtObj -- \u9875\u9762\u4e2d\u8f93\u5165\u91d1\u989d\u7684\u6587\u672c\u6846\u5bf9\u8c61;
* formatFlag -- \u662f\u5426\u683c\u5f0f\u5316,true\uff1a\u683c\u5f0f\u5316;false\uff1a\u4e0d\u683c\u5f0f\u5316;
* curCode -- \u8d27\u5e01\u4ee3\u7801;
*
* \u4f8b\u5b50\uff1aonBlur="formatMoney(this,true,'001')" onFocus="formatMoney(this,false,'001')"
*
*/
function formatMoney(txtObj,formatFlag,curCode)
{
var money = txtObj.value;
money = isnumber(money);
if (money != "a")
{
money=money.toString();
if (money.indexOf(",")>0)
money = replace(money,",","");//\u5bf9\u586b\u5199\u8fc7\u7684\u91d1\u989d\u8fdb\u884c\u4fee\u6539\u65f6\uff0c\u5fc5\u987b\u8fc7\u6ee4\u6389','
s = money;
if (s.indexOf("\u3000")>=0)
s = replace(money,"\u3000","");
if (s.indexOf(" ")>=0)
s = replace(money," ","");
if (s.length!=0)
{
var str = changePartition(s,curCode);
if (!formatFlag)
str = replace(str,",","");
txtObj.value = str;
if (!formatFlag)
txtObj.select();
}
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u9690\u85cf\u60ac\u6d6e\u7a97\u53e3\uff08\u5927\u5199\u91d1\u989d\uff09
*
* Parameter txtObj -- \u9875\u9762\u4e2d\u60ac\u6d6e\u7a97\u53e3\uff08\u5927\u5199\u91d1\u989d\uff09\u7684\u6587\u672c\u6846\u5bf9\u8c61;
* curCode -- \u8d27\u5e01\u4ee3\u7801;
*
* \u4f8b\u5b50\uff1a onMouseOut="hideTooltip('dHTMLToolTip','001')"
*
*/
function hideTooltip(object,curCode)
{
/** \u4ec5\u5bf9\u4eba\u6c11\u5e01\u6709\u6548 */
if (curCode == "001")
{
if (document.all)
{
locateObject(object).style.visibility="hidden";
locateObject(object).style.left = 1;
locateObject(object).style.top = 1;
return false;
}
else if (document.layers)
{
locateObject(object).visibility="hide";
locateObject(object).left = 1;
locateObject(object).top = 1;
return false;
}
else
return true;
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u6821\u9a8c\u4ed8\u6b3e\u91d1\u989d\u5e76\u4e14\u5c06\u91d1\u989d\u8f6c\u5316\u4e3a\u6c49\u5b57\u5927\u5199
*
* Parameter txtObj -- \u9875\u9762\u4e2d\u8f93\u5165\u91d1\u989d\u7684\u6587\u672c\u6846\u5bf9\u8c61;
* str -- \u6d6e\u52a8\u6846\u4e2d\u7684\u6807\u9898
* divStr -- \u6d6e\u52a8\u6846\u7684ID\u3002
* curCode -- \u8d27\u5e01\u4ee3\u7801;
*
* \u4f8b\u5b50\uff1aonMouseOver="touppercase(this,'\u4ed8\u6b3e\u91d1\u989d','dHTMLToolTip','001')"
* onMouseOver="touppercase(document.form1.txtInput,'\u4ed8\u6b3e\u91d1\u989d','dHTMLToolTip','001')"
*
*/
function touppercase(txtObj,str,divStr,curCode)
{
/** \u4ec5\u5bf9\u4eba\u6c11\u5e01\u6709\u6548 */
if (curCode == "001")
{
var money=txtObj.value;
money = isnumber(money);
//alert("money is:" + money);
if (money != "a")
{
s = money.toString();
s = replace(s,",","");//\u5bf9\u586b\u5199\u8fc7\u7684\u91d1\u989d\u8fdb\u884c\u4fee\u6539\u65f6\uff0c\u5fc5\u987b\u8fc7\u6ee4\u6389','
s=changeUppercase(s);
showTooltipOfLabel(divStr,event,str,s);
}
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u663e\u793a\u5e26\u6807\u9898\u7684\u60ac\u6d6e\u6846
*
* Parameter divStr -- \u9875\u9762\u4e2d\u5b9a\u4e49\u7684\u6d6e\u52a8\u663e\u793a\u5c42ID;
* e -- \u901a\u5e38\u9ed8\u8ba4\u4f20\u5165\u53c2\u6570\u4e3aevent;
* jelabel -- \u6d6e\u52a8\u6846\u4e2d\u7684\u6807\u9898;
* jestr -- \u91d1\u989d\u5b57\u7b26\u4e32
*
* \u4f8b\u5b50\uff1ashowTooltipOfLabel('dHTMLToolTip',event,'\u624b\u7eed\u8d39','12345');
*
*/
function showTooltipOfLabel(divStr,e,jelabel,jestr)
{
window.clearTimeout(tipTimer);
/* if (document.all)
{
locateObject(obj).style.top = document.body.scrollTop + event.clientY + 20;
locateObject(obj).innerHTML = '<table width=200 height=10 border=1 style="font-family: \u5b8b\u4f53; font-size: 10pt; border-style: ridge; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px;" cellspacing=1 cellpadding=1 bgcolor=#fef5ed bordercolor=#a03952><tr style="color:black"><td height=10 align=right nowrap> '+jelabel+' </td><td height=10 nowrap> '+jestr+' </td></tr></table>';
if ((e.x + locateObject(obj).clientWidth) > (document.body.clientWidth + document.body.scrollLeft))
locateObject(obj).style.left = (document.body.clientWidth + document.body.scrollLeft) - locateObject(obj).clientWidth-10;
else
locateObject(obj).style.left=document.body.scrollLeft+event.clientX;
locateObject(obj).style.visibility="visible";
tipTimer=window.setTimeout("hideTooltip('"+obj+"')", 5000);
return true;
}
else
return true;
*/
var divObj = eval(divStr);
if (document.all)
{
divObj.style.top = document.documentElement.scrollTop + event.clientY + 10;
divObj.innerHTML = '<table border=1 style="font-family: \u5b8b\u4f53; font-size: 10pt; border-style: ridge; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px;" cellspacing=1 cellpadding=1 bgcolor=#fef5ed bordercolor=#a03952><tr style="color:black"><td style="padding-top:4px;" align=right nowrap> '+jelabel+' </td><td style="padding-top:4px;" nowrap> '+jestr+' </td></tr></table>';
if ((e.x + divObj.clientWidth) > (document.documentElement.clientWidth + document.documentElement.scrollLeft))
divObj.style.left = (document.documentElement.clientWidth + document.documentElement.scrollLeft) - divObj.clientWidth-10;
else
divObj.style.left=document.documentElement.scrollLeft+event.clientX;
divObj.style.visibility="visible";
tipTimer = window.setTimeout("hideTooltip('" + divStr + "')", 5000);
return true;
}
else
return true;
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5224\u65ad\u91d1\u989d\u7684\u5408\u6cd5\u6027
*
* Parameter onestring -- \u9700\u5224\u65ad\u7684\u5b57\u7b26\u4e32;
*
* Return 0 -- \u5b57\u7b26\u4e32\u4e3a\u7a7a
* a -- \u5b57\u7b26\u4e32\u975e\u6570\u503c\u6570\u636e
* \u6570\u503c -- \u5b57\u7b26\u4e32\u4e3a\u6570\u503c\u6570\u636e\uff0c\u8fd4\u56de\u5b57\u7b26\u4e32\u6570\u503c
*
* \u4f8b\uff1amoneyCheck("123,456,789.34") \u8fd4\u56de123456789.34
*
*/
function isnumber(onestring)
{
if(onestring.length==0)
return "a";
if(onestring==".")
return "a";
var regex = new RegExp(/(?!^[+-]?[0,]*(\.0{1,4})?$)^[+-]?(([1-9]\d{0,2}(,\d{3})*)|([1-9]\d*)|0)(\.\d{1,4})?$/);
if (!regex.test(onestring))
return "a";
//trim head 0
/*while(onestring.substring(0,1)=="0")
{
onestring = onestring.substring(1,onestring.length);
}*/
if (onestring.substring(0,1)==".")
onestring = "0" + onestring;
onestring = replace(onestring,",","");
var split_onestr=onestring.split(".");
if(split_onestr.length>2)
return "a";
return onestring;
}
function locateObject(n, d)
{ //v3.0
var p,i,x;
if (!d)
d=document;
if ((p=n.indexOf("?"))>0 && parent.frames.length)
{
d = parent.frames[n.substring(p+1)].document;
n=n.substring(0,p);
}
if (!(x=d[n]) && d.all)
x = d.all[n];
for (i = 0; !x && i < d.forms.length; i++)
x = d.forms[i][n];
for (i = 0; !x && d.layers && i < d.layers.length; i++)
x = locateObject(n,d.layers[i].document);
return x;
}
|
JavaScript
|
//**************************************
//*** \u4ee5\u4e0b\u51fd\u6570\u662f\u9875\u9762\u9650\u5236\u51fd\u6570
//**************************************
/**
* \u9875\u9762\u9650\u5236\u5f00\u5173
* true -- \u5f00\u53d1\u6a21\u5f0f\uff0c\u9875\u9762\u4e0d\u505a\u9650\u5236
* false -- \u8fd0\u8425\u6a21\u5f0f\uff0c\u9875\u9762\u9650\u5236
*/
var codingMode = false;
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5c4f\u853d\u53f3\u952e
*/
function click(e)
{
/** \u8868\u793aIE */
if (document.all)
{
if (event.button != 1)
{
oncontextmenu='return false';
}
}
/** \u8868\u793aNC */
if (document.layers)
{
if (e.which == 3)
{
oncontextmenu='return false';
}
}
}
/*
* \u51fd\u6570\u529f\u80fd\uff1a\u5f53\u952e\u76d8\u952e\u88ab\u6309\u4e0b\u65f6\uff0c\u5c4f\u853d\u67d0\u4e9b\u952e\u548c\u7ec4\u5408\u952e
*/
function limitKey(e)
{
/** \u8868\u793aNC,\u6ce8\u610f\uff1a\u9700\u6d4b\u8bd5 */
if (document.layers)
{
if (e.which == 17)
{
alert("\u64cd\u4f5c\u9519\u8bef.\u6216\u8bb8\u662f\u60a8\u6309\u9519\u4e86\u6309\u952e!");
}
/** \u5c4f\u853d Alt(18)+ \u65b9\u5411\u952e \u2192 Alt+ \u65b9\u5411\u952e \u2190 */
if (e.which == 18 && (e.which==37 || e.which == 39))
{
alert("\u4e0d\u51c6\u4f60\u4f7f\u7528ALT+\u65b9\u5411\u952e\u524d\u8fdb\u6216\u540e\u9000\u7f51\u9875\uff01");
e.returnValue=false;
}
/** \u5c4f\u853d F5(116) \u5237\u65b0\u952eCtrl(17) + R(82) */
if (e.which == 116 || (e.which == 17 && e.which==82))
{
e.which=0;
e.returnValue=false;
}
/** \u5c4f\u853dTab(9) \u5c4f\u853dF11(122) \u5c4f\u853d Ctrl+n(78) \u5c4f\u853d shift(16)+F10(121) */
if (e.which == 9 || e.which == 122 || (e.which == 17 && e.which==78) || (e.which == 16 && e.which==121))
{
e.which=0;
e.returnValue=false;
}
}
/** \u8868\u793aIE */
if (document.all)
{
/** \u5c4f\u853d Alt+ \u65b9\u5411\u952e \u2192 Alt+ \u65b9\u5411\u952e \u2190 */
if (window.event.altKey && (window.event.keyCode==37 || window.event.keyCode == 39))
{
alert("\u4e0d\u51c6\u4f60\u4f7f\u7528ALT+\u65b9\u5411\u952e\u524d\u8fdb\u6216\u540e\u9000\u7f51\u9875\uff01");
event.returnValue=false;
}
/** \u5c4f\u853d F5(116) \u5237\u65b0\u952eCtrl + R(82) */
if (window.event.keyCode == 116 || (window.event.ctrlKey && window.event.keyCode==82))
{
event.keyCode=0;
event.returnValue=false;
}
/** \u5c4f\u853dEnter(13) */
if (window.event.keyCode==13 && typeof(openEnterFlag)=='undefined' )
/** openEnterFlag\u662f\u5728JSP\u4e2d\u6253\u5f00Enter\u7684\u5f00\u5173\u3002\u76ee\u524d\u5e94\u7528\u7684\u5c31\u53ea\u6709\u7559\u8a00\u677f\u9875\u9762 */
/** \u4f7f\u7528\u65b9\u6cd5\uff1a\u5728\u9700\u8981\u6253\u5f00Enter\u7684\u9875\u9762tiles:insert\u524d\u5b9a\u4e49\u53d8\u91cfopenEnterFlag\u5373\u53ef */
{
//alert("pagelimt 13");
event.keyCode=0;
event.returnValue=false;
}
/** \u5c4f\u853dF11(122) \u5c4f\u853d Ctrl+n(78) \u5c4f\u853d shift+F10(121) */
if (window.event.keyCode == 122 || (window.event.ctrlKey && window.event.keyCode==78) || (window.event.shiftKey && window.event.keyCode==121))
{
event.keyCode=0;
event.returnValue=false;
}
/** \u5c4f\u853d Ctrl + A(65) Ctrl + C(67) Ctrl + X(86) Ctrl + V(88) modify by jinj BOCNET-1769,\u653e\u5f00Ctrl + C,Ctrl + V*/
if (window.event.ctrlKey && (window.event.keyCode==65 || window.event.keyCode == 88))
{
event.keyCode=0;
event.returnValue=false;
}
if (window.event.srcElement.tagName == "A" && window.event.shiftKey)
window.event.returnValue = false; //\u5c4f\u853d shift \u52a0\u9f20\u6807\u5de6\u952e\u65b0\u5f00\u4e00\u7f51\u9875
}
}
if (!codingMode)
{
if (document.layers)
{
document.captureEvents(Event.MOUSEDOWN);
}
document.onmousedown=click;
document.oncontextmenu = new Function("return false;");
if (document.layers)
document.captureEvents(Event.KEYDOWN);
document.onkeydown=limitKey;
}
//**************************************
//*** \u9875\u9762\u9650\u5236\u51fd\u6570\u7ed3\u675f
//**************************************
|
JavaScript
|
var Renren = Renren || {};
if(!Renren.share){
Renren.share = function() {
var isIE = navigator.userAgent.match(/(msie) ([\w.]+)/i);
var hl = location.href.indexOf('#');
var resUrl = (hl == -1 ? location.href : location.href.substr(0, hl));
var shareImgs = "";
var sl = function(str) {
var placeholder = new Array(23).join('x');
str = str
.replace(
/(https?|ftp|gopher|telnet|prospero|wais|nntp){1}:\/\/\w*[\u4E00-\u9FA5]*((?![\"| |\t|\r|\n]).)+/ig,
function(match) {
return placeholder + match.substr(171);
}).replace(/[^\u0000-\u00ff]/g, "xx");
return Math.ceil(str.length / 2);
};
var cssImport = function(){
var static_url = 'http://xnimg.cn/xnapp/share/css/v2/rrshare.css';
var b = document.createElement("link");
b.rel = "stylesheet";
b.type = "text/css";
b.href = static_url;
(document.getElementsByTagName("head")[0] || document.body).appendChild(b)
};
var getShareType = function (dom) {
return dom.getAttribute("type") || "button"
};
var opts = {};
if(typeof(imgMinWidth)!='undefined'){
opts.imgMinWidth = imgMinWidth || 60;
} else {
opts.imgMinWidth = 60;
}
if(typeof(imgMinHeight)!='undefined'){
opts.imgMinHeight = imgMinHeight || 60;
} else {
opts.imgMinHeight = 60;
}
var renderShareButton = function (btn,index) {
if(btn.rendered){
return;
}
btn.paramIndex = index;
var shareType = getShareType(btn).split("_");
var showType = shareType[0] == "icon" ? "icon" : "button";
var size = shareType[1] || "small";
var shs = "xn_share_"+showType+"_"+size;
var innerHtml = [
'<span class="xn_share_wrapper ',shs,'"></span>'
];
btn.innerHTML = innerHtml.join("");
btn.rendered = true;
};
var postTarget = function(opts) {
var form = document.createElement('form');
form.action = opts.url;
form.target = opts.target;
form.method = 'POST';
form.acceptCharset = "UTF-8";
for (var key in opts.params) {
var val = opts.params[key];
if (val !== null && val !== undefined) {
var input = document.createElement('textarea');
input.name = key;
input.value = val;
form.appendChild(input);
}
}
var hidR = document.getElementById('renren-root-hidden');
if (!hidR) {
hidR = document.createElement('div'), syl = hidR.style;
syl.positon = 'absolute';
syl.top = '-10000px';
syl.width = syl.height = '0px';
hidR.id = 'renren-root-hidden';
(document.body || document.getElementsByTagName('body')[0])
.appendChild(hidR);
}
hidR.appendChild(form);
try {
var cst = null;
if (isIE && document.charset.toUpperCase() != 'UTF-8') {
cst = document.charset;
document.charset = 'UTF-8';
}
form.submit();
} finally {
form.parentNode.removeChild(form);
if (cst) {
document.charset = cst;
}
}
};
var getCharSet = function(){
if(document.charset){
return document.charset.toUpperCase();
} else {
var metas = document.getElementsByTagName("meta");
for(var i=0;i < metas.length;i++){
var meta = metas[i];
var metaCharset = meta.getAttribute('charset');
if(metaCharset){
return meta.getAttribute('charset');
}
var metaContent = meta.getAttribute('content');
if(metaContent){
var contenxt = metaContent.toLowerCase();
var begin = contenxt.indexOf("charset=");
if(begin!=-1){
var end = contenxt.indexOf(";",begin+"charset=".length);
if(end != -1){
return contenxt.substring(begin+"charset=".length,end);
}
return contenxt.substring(begin+"charset=".length);
}
}
}
}
return '';
}
var charset = getCharSet();
var getParam = function (param){
param = param || {};
param.api_key = param.api_key || '';
param.resourceUrl = param.resourceUrl || resUrl;
param.title = param.title || '';
param.pic = param.pic || '';
param.description = param.description || '';
if(resUrl == param.resourceUrl){
param.images = param.images || shareImgs;//一般就是当前页面的分享,因此取当前页面的img
}
param.charset = param.charset || charset || '';
return param;
}
var onclick = function(data) {
var submitUrl = 'http://widget.renren.com/dialog/share';
var p = getParam(data);
var prm = [];
for (var i in p) {
if (p[i])
prm.push(i + '=' + encodeURIComponent(p[i]));
}
var url = submitUrl+"?" + prm.join('&'), maxLgh = (isIE ? 2048 : 4100), wa = 'width=700,height=650,left=0,top=0,resizable=yes,scrollbars=1';
if (url.length > maxLgh) {
window.open('about:blank', 'fwd', wa);
postTarget({
url : submitUrl,
target : 'fwd',
params : p
});
} else {
window.open(url, 'fwd', wa);
}
return false;
};
window["rrShareOnclick"] = onclick;
var init = function() {
if (Renren.share.isReady || document.readyState !== 'complete')
return;
var imgs = document.getElementsByTagName('img'), imga = [];
for (var i = 0; i < imgs.length; i++) {
if (imgs[i].width >= opts.imgMinWidth
&& imgs[i].height >= opts.imgMinHeight) {
imga.push(imgs[i].src);
}
}
window["rrShareImgs"] = imga;
if (imga.length > 0)
shareImgs = imga.join('|');
if (document.addEventListener) {
document.removeEventListener('DOMContentLoaded', init, false);
} else {
document.detachEvent('onreadystatechange', init);
}
cssImport();
var shareBtn = document.getElementsByName("xn_share");
var len = shareBtn?shareBtn.length:0;
for (var b = 0; b < len; b++) {
var a = shareBtn[b];
renderShareButton(a,b);
}
Renren.share.isReady = true;
};
if (document.readyState === 'complete') {
init();
} else if (document.addEventListener) {
document.addEventListener('DOMContentLoaded', init, false);
window.addEventListener('load', init, false);
} else {
document.attachEvent('onreadystatechange', init);
window.attachEvent('onload', init);
}
};
}
|
JavaScript
|
var setting = loadLocalSetting();
var updateSession = new ObjectWithEvent();
setting.cache.listener = updateSession;
startListener();
registerRequestListener();
// If you want to build your own copy with a different id, please keep the
// tracking enabled.
var default_id = 'lgllffgicojgllpmdbemgglaponefajn';
var debug = chrome.i18n.getMessage('@@extension_id') != default_id;
if (debug && firstRun) {
if (confirm('Debugging mode. Disable tracking?')) {
setting.misc.tracking = false;
setting.misc.logEnabled = true;
}
}
window.setTimeout(function() {
setting.loadDefaultConfig();
if (firstRun || firstUpgrade) {
open('donate.html');
}
}, 1000);
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
var USE_RECORD_GAP = 3 * 60 * 1000; // 3 minutes
var _gaq = window._gaq || [];
_gaq.push(['_setAccount', 'UA-28870762-4']);
_gaq.push(['_trackPageview', location.href.replace(/\?.*$/, '')]);
function initGAS() {
var setting = chrome.extension.getBackgroundPage().setting;
if (setting.misc.tracking) {
var ga = document.createElement('script');
ga.type = 'text/javascript'; ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(ga, s);
} else {
// dummy it. Non-debug && non-track
_gaq.push = function() {};
}
}
window.addEventListener('load', initGAS, false);
var useHistory = {};
var issueHistory = {};
function trackCheckSpan(history, item) {
var last = history[item];
if (last && Date.now() - last < USE_RECORD_GAP) {
return false;
}
history[item] = Date.now();
return true;
}
function trackIssue(issue) {
if (!trackCheckSpan(issueHistory, issue.identifier)) {
return;
}
_gaq.push(['_trackEvent', 'usage', 'error', '' + issue.identifier]);
}
function trackVersion(version) {
_gaq.push(['_trackEvent', 'option', 'version', version]);
}
function serializeRule(rule) {
return rule.type[0] + ' ' + rule.value;
}
function trackUse(identifier) {
if (!trackCheckSpan(useHistory, identifier)) {
return;
}
if (identifier.substr(0, 7) == 'custom_') {
var rule = setting.getItem(identifier);
_gaq.push(['_trackEvent', 'usage', 'use-custom', serializeRule(rule)]);
} else {
_gaq.push(['_trackEvent', 'usage', 'use', identifier]);
}
}
var urlHistory = {};
function trackNotUse(url) {
if (!trackCheckSpan(urlHistory, url)) {
return;
}
_gaq.push(['_trackEvent', 'usage', 'notuse', url]);
}
function trackDisable(identifier) {
_gaq.push(['_trackEvent', 'option', 'disable', identifier]);
}
function trackAutoEnable(identifier) {
_gaq.push(['_trackEvent', 'option', 'autoenable', identifier]);
}
function trackEnable(identifier) {
_gaq.push(['_trackEvent', 'option', 'enable', identifier]);
}
function trackAddCustomRule(rule, auto) {
var cmd = 'add';
if (auto) {
cmd = 'add-' + auto;
}
_gaq.push(['_trackEvent', 'option', cmd, serializeRule(rule)]);
}
function trackManualUpdate() {
_gaq.push(['_trackEvent', 'update', 'manual']);
}
function trackUpdateFile(url) {
_gaq.push(['_trackEvent', 'update', 'file', url]);
}
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
var config;
function loadConfig(_resp) {
config = _resp;
$(document).ready(init);
}
function openPopup() {
var url = chrome.extension.getURL('popup.html?tabid=' + config.tabId);
var windowConfig = 'height=380,width=560,toolbar=no,menubar=no,' +
'scrollbars=no,resizable=no,location=no,status=no';
window.open(url, 'popup', windowConfig);
dismiss();
}
function blockSite() {
chrome.extension.sendRequest(
{command: 'BlockSite', site: config.sitePattern});
dismiss();
}
function dismiss() {
chrome.extension.sendRequest({command: 'DismissNotification'});
}
function init() {
$('#enable').click(openPopup);
$('#close').click(dismiss);
$('#block').click(blockSite);
$('#close').text(config.closeMsg);
$('#enable').text(config.enableMsg);
$('#info').text(config.message);
$('#block').text(config.blockMsg);
}
chrome.extension.sendRequest({command: 'GetNotification'}, loadConfig);
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
var tabId = parseInt(location.href.replace(/.*tabid=([0-9]*).*/, '$1'));
if (isNaN(tabId)) {
alert('Invalid tab id');
}
var backgroundPage = chrome.extension.getBackgroundPage();
var tabInfo = backgroundPage.tabStatus[tabId];
var setting = backgroundPage.setting;
if (!tabInfo) {
alert('Cannot get tab tabInfo');
}
$(document).ready(function() {
$('.status').hide();
$('#submitissue').hide();
if (tabInfo.urldetect) {
$('#status_urldetect').show();
} else if (!tabInfo.count) {
// Shouldn't have this popup
} else if (tabInfo.error) {
$('#status_error').show();
} else if (tabInfo.count != tabInfo.actived) {
$('#status_disabled').show();
} else {
$('#status_ok').show();
$('#submitissue').show();
}
});
$(document).ready(function() {
$('#issue_view').hide();
if (tabInfo.error !== 0) {
var errorid = tabInfo.issueId;
var issue = setting.issues[errorid];
$('#issue_content').text(issue.description);
var url = issue.url;
if (!url) {
var issueUrl = 'http://code.google.com/p/np-activex/issues/detail?id=';
url = issueUrl + issue.issueId;
}
$('#issue_track').click(function() {
chrome.tabs.create({url: url});
window.close();
});
$('#issue_view').show();
}
});
function refresh() {
alert($$('refresh_needed'));
window.close();
}
function showEnableBtns() {
var list = $('#enable_btns');
list.hide();
if (tabInfo.urldetect || tabInfo.count > tabInfo.actived) {
list.show();
var info = {actived: true};
for (var i = 0; i < tabInfo.frames && info.actived; ++i) {
for (var j = 0; j < tabInfo.objs[i].length && info.actived; ++j) {
info = tabInfo.objs[i][j];
}
}
if (info.actived) {
return;
}
var rule = setting.getFirstMatchedRule(info, setting.defaultRules);
if (rule) {
var button = $('<button>').addClass('defaultRule');
button.text($$('enable_default_rule', rule.title));
button.click(function() {
setting.activeRule(rule);
refresh();
});
list.append(button);
} else {
var site = info.href.replace(/[^:]*:\/\/([^\/]*).*/, '$1');
var sitepattern = info.href.replace(/([^:]*:\/\/[^\/]*).*/, '$1/*');
var btn1 = $('<button>').addClass('customRule').
text($$('add_rule_site', site)).click(function() {
var rule = setting.createRule();
rule.type = 'wild';
rule.value = sitepattern;
setting.addCustomRule(rule, 'popup');
refresh();
});
var clsid = info.clsid;
var btn2 = $('<button>').addClass('customRule').
text($$('add_rule_clsid')).click(function() {
var rule = setting.createRule();
rule.type = 'clsid';
rule.value = clsid;
setting.addCustomRule(rule, 'popup');
refresh();
});
list.append(btn1).append(btn2);
}
}
}
$(document).ready(function() {
$('#submitissue').click(function() {
tabInfo.tracking = true;
alert($$('issue_submitting_desp'));
window.close();
});
});
$(document).ready(showEnableBtns);
|
JavaScript
|
// Copyright (c) 2010 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
var $$ = chrome.i18n.getMessage;
function loadI18n() {
var spans = document.querySelectorAll('[i18n]');
for (var i = 0; i < spans.length; ++i) {
var obj = spans[i];
v = $$(obj.getAttribute('i18n'));
if (v == '')
v = obj.getAttribute('i18n');
if (obj.tagName == 'INPUT') {
obj.value = v;
} else {
obj.innerText = v;
}
}
document.removeEventListener('DOMContentLoaded', loadI18n, false);
}
document.addEventListener('DOMContentLoaded', loadI18n, false);
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
function ObjectWithEvent() {
this._events = {};
}
ObjectWithEvent.prototype = {
bind: function(name, func) {
if (!Array.isArray(this._events[name])) {
this._events[name] = [];
}
this._events[name].push(func);
},
unbind: function(name, func) {
if (!Array.isArray(this._events[name])) {
return;
}
for (var i = 0; i < this._events[name].length; ++i) {
if (this._events[name][i] == func) {
this._events[name].splice(i, 1);
break;
}
}
},
trigger: function(name, argument) {
if (this._events[name]) {
var handlers = this._events[name];
for (var i = 0; i < handlers.length; ++i) {
handlers[i].apply(this, argument);
}
}
}
};
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
var background = chrome.extension.getBackgroundPage();
var setting = background.setting;
var updateSession = background.updateSession;
function toggleRule(e) {
var line = e.data.line;
var index = line.attr('row');
var item = setting.order[index];
if (item.position == 'default') {
if (item.status == 'enabled') {
item.status = 'disabled';
trackDisable(item.identifier);
} else if (item.status == 'disabled') {
item.status = 'enabled';
trackEnable(item.identifier);
}
}
line.blur();
e.data.list.finishEdit(line);
e.data.list.updateLine(line);
save();
}
var settingProps = [{
header: '',
property: 'status',
type: 'button',
caption: '',
events: {
command: toggleRule,
update: setStatus,
createNew: setStatusNew
}
}, {
header: $$('title'),
property: 'title',
type: 'input'
}, {
header: $$('mode'),
property: 'type',
type: 'select',
option: 'static',
options: [
{value: 'wild', text: $$('WildChar')},
{value: 'regex', text: $$('RegEx')},
{value: 'clsid', text: $$('CLSID')}
]
}, {
header: $$('pattern'),
property: 'value',
type: 'input'
}, {
header: $$('user_agent'),
property: 'userAgent',
type: 'select',
option: 'static',
options: [
{value: '', text: 'Chrome'},
{value: 'ie9', text: 'MSIE9'},
{value: 'ie8', text: 'MSIE8'},
{value: 'ie7', text: 'MSIE7'},
{value: 'ff7win', text: 'Firefox 7'},
{value: 'ip5', text: 'iPhone'},
{value: 'ipad5', text: 'iPad'}
]
}, {
header: $$('helper_script'),
property: 'script',
type: 'input'
}
];
var table;
var dirty = false;
function save() {
dirty = true;
}
function doSave() {
if (dirty) {
dirty = false;
setting.update();
}
}
function setReadonly(e) {
var line = e.data.line;
var id = line.attr('row');
if (id < 0) {
return;
}
var order = setting.order[id];
var divs = $('.listvalue', line);
if (order.position != 'custom') {
divs.addClass('readonly');
} else {
divs.removeClass('readonly');
}
}
$(window).blur(doSave);
function refresh() {
table.refresh();
}
// Main setting
$(document).ready(function() {
table = new List({
props: settingProps,
main: $('#tbSetting'),
lineEvents: {
update: setReadonly
},
getItems: function() {
return setting.order;
},
getItemProp: function(i, prop) {
if (prop in setting.order[i]) {
return setting.order[i][prop];
}
return setting.getItem(setting.order[i])[prop];
},
setItemProp: function(i, prop, value) {
if (prop in setting.order[i]) {
setting.order[i][prop] = value;
} else {
setting.getItem(setting.order[i])[prop] = value;
}
},
defaultValue: setting.createRule(),
count: function() {
return setting.order.length;
},
insert: function(id, newItem) {
setting.addCustomRule(newItem);
this.move(setting.order.length - 1, id);
},
remove: function(id) {
if (setting.order[id].position != 'custom') {
return true;
}
var identifier = setting.order[id].identifier;
delete setting.rules[identifier];
setting.order.splice(id, 1);
},
validate: function(id, rule) {
return setting.validateRule(rule);
}
});
$(table).bind('updated', save);
$('#addRule').bind('click', function() {
table.editNewLine();
});
$(table).bind('select', function() {
var line = table.selectedLine;
if (line < 0) {
$('#moveUp').attr('disabled', 'disabled');
$('#moveDown').attr('disabled', 'disabled');
$('#deleteRule').attr('disabled', 'disabled');
} else {
if (line != 0) {
$('#moveUp').removeAttr('disabled');
} else {
$('#moveUp').attr('disabled', 'disabled');
}
if (line != setting.order.length - 1) {
$('#moveDown').removeAttr('disabled');
} else {
$('#moveDown').attr('disabled', 'disabled');
}
if (setting.order[line].position != 'custom') {
$('#deleteRule').attr('disabled', 'disabled');
} else {
$('#deleteRule').removeAttr('disabled');
}
}
});
$('#moveUp').click(function() {
var line = table.selectedLine;
table.move(line, line - 1, true);
});
$('#moveDown').click(function() {
var line = table.selectedLine;
table.move(line, line + 1, true);
});
$('#deleteRule').click(function() {
var line = table.selectedLine;
table.remove(line);
});
table.init();
updateSession.bind('update', refresh);
});
window.onbeforeunload = function() {
updateSession.unbind('update', refresh);
};
function setStatusNew(e) {
with (e.data) {
s = 'Custom';
color = '#33f';
$('button', line).text(s).css('background-color', color);
}
}
function setStatus(e) {
with (e.data) {
var id = line.attr('row');
var order = setting.order[id];
var rule = setting.getItem(order);
var s, color;
if (order.status == 'enabled') {
s = $$('Enabled');
color = '#0A0';
} else if (order.status == 'disabled') {
s = $$('Disabled');
color = 'indianred';
} else {
s = $$('Custom');
color = '#33f';
}
$('button', line).text(s).css('background-color', color);
}
}
function showTime(time) {
var never = 'Never';
if (time == 0) {
return never;
}
var delta = Date.now() - time;
if (delta < 0) {
return never;
}
function getDelta(delta) {
var sec = delta / 1000;
if (sec < 60) {
return [sec, 'second'];
}
var minute = sec / 60;
if (minute < 60) {
return [minute, 'minute'];
}
var hour = minute / 60;
if (hour < 60) {
return [hour, 'hour'];
}
var day = hour / 24;
return [day, 'day'];
}
var disp = getDelta(delta);
var v1 = Math.floor(disp[0]);
return v1 + ' ' + disp[1] + (v1 != 1 ? 's' : '') + ' ago';
}
$(document).ready(function() {
$('#log_enable').change(function(e) {
setting.misc.logEnabled = e.target.checked;
save();
})[0].checked = setting.misc.logEnabled;
$('#tracking').change(function(e) {
setting.misc.tracking = e.target.checked;
save();
})[0].checked = setting.misc.tracking;
});
$(document).ready(function() {
var help = 'http://code.google.com/p/np-activex/wiki/ExtensionHelp?wl=';
help = help + $$('wikicode');
$('.help').each(function() {
this.href = help;
});
});
$(window).load(function() {
if (background.firstUpgrade) {
background.firstUpgrade = false;
alert($$('upgrade_show'));
}
});
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
List.types.input = function(p, prop) {
p[0].listdata = this;
this.p = p;
var input = this.input = $('<input></input>').addClass('valinput');
this.label = $('<span></span>').addClass('valdisp');
this.label.click(function(e) {
setTimeout(function() {
input.focus();
}, 10);
});
this.input.focus(function(e) {
input.select();
});
this.input.keypress(function(e) {
p.trigger('change');
});
this.input.keyup(function(e) {
p.trigger('change');
});
this.input.change(function(e) {
p.trigger('change');
});
p.append(this.input).append(this.label);
};
List.types.input.prototype.__defineSetter__('value', function(val) {
this.input.val(val);
this.label.text(val);
});
List.types.input.prototype.__defineGetter__('value', function() {
return this.input.val();
});
List.types.select = function(p, prop) {
p[0].listdata = this;
this.p = p;
var input = this.input = $('<select></select>').addClass('valinput');
this.label = $('<span></span>').addClass('valdisp');
if (prop.option == 'static') {
this.loadOptions(prop.options);
}
var select = this;
this.input.change(function(e) {
if (p.hasClass('readonly')) {
select.value = select.lastval;
} else {
p.trigger('change');
}
});
this.label.click(function(e) {
setTimeout(function() {
input.focus();
}, 10);
});
p.append(this.input).append(this.label);
};
List.types.select.prototype.loadOptions = function(options) {
this.options = options;
this.mapping = {};
this.input.html('');
for (var i = 0; i < options.length; ++i) {
this.mapping[options[i].value] = options[i].text;
var o = $('<option></option>').val(options[i].value).text(options[i].text);
this.input.append(o);
}
};
List.types.select.prototype.__defineGetter__('value', function() {
return this.input.val();
});
List.types.select.prototype.__defineSetter__('value', function(val) {
this.lastval = val;
this.input.val(val);
this.label.text(this.mapping[val]);
});
List.types.checkbox = function(p, prop) {
p[0].listdata = this;
this.p = p;
var input = this.input = $('<input type="checkbox">').addClass('valcheck');
var box = this;
this.input.change(function(e) {
if (p.hasClass('readonly')) {
box.value = box.lastval;
} else {
p.trigger('change');
}
});
p.append(this.input);
};
List.types.checkbox.prototype.__defineGetter__('value', function() {
return this.input[0].checked;
});
List.types.checkbox.prototype.__defineSetter__('value', function(val) {
this.lastval = val;
this.input[0].checked = val;
});
List.types.button = function(p, prop) {
p[0].listdata = this;
this.p = p;
var input = this.input = $('<button>');
if (prop.caption) {
input.text(prop.caption);
}
input.click(function(e) {
p.trigger('command');
return false;
});
p.append(this.input);
};
List.types.button.prototype.__defineGetter__('value', function() {
return undefined;
});
|
JavaScript
|
// Copyright (c) 2012 eagleonhill(qiuc12@gmail.com). All rights reserved.
// Use of this source code is governed by a Mozilla-1.1 license that can be
// found in the LICENSE file.
var backgroundPage = chrome.extension.getBackgroundPage();
var defaultTabId = parseInt(location.href.replace(/.*tabid=([0-9]*).*/, '$1'));
function insertTabInfo(tab) {
if (isNaN(defaultTabId)) {
defaultTabId = tab.id;
}
if (uls[tab.id]) {
return;
}
var ul = $('<ul>').appendTo($('#logs_items'));
uls[tab.id] = ul;
var title = tab.title;
if (!title) {
title = 'Tab ' + tab.id;
}
$('<a>').attr('href', '#')
.attr('tabid', tab.id)
.text(title)
.click(function(e) {
loadTabInfo(parseInt($(e.target).attr('tabid')));
}).appendTo(ul);
}
var uls = {};
$(document).ready(function() {
chrome.tabs.query({}, function(tabs) {
for (var i = 0; i < tabs.length; ++i) {
var protocol = tabs[i].url.replace(/(^[^:]*).*/, '$1');
if (protocol != 'http' && protocol != 'https' && protocol != 'file') {
continue;
}
insertTabInfo(tabs[i]);
}
for (var i in backgroundPage.tabStatus) {
insertTabInfo({id: i});
}
$('#tracking').change(function() {
var tabStatus = backgroundPage.tabStatus[currentTab];
if (tabStatus) {
tabStatus.tracking = tracking.checked;
}
});
loadTabInfo(defaultTabId);
});
});
$(document).ready(function() {
$('#beforeSubmit').click(function() {
var link = $('#submitLink');
if (beforeSubmit.checked) {
link.show();
} else {
link.hide();
}
});
});
var currentTab = -1;
function loadTabInfo(tabId) {
if (isNaN(tabId)) {
return;
}
if (tabId != currentTab) {
if (currentTab != -1) {
uls[currentTab].removeClass('selected');
}
currentTab = tabId;
uls[tabId].addClass('selected');
var s = backgroundPage.generateLogFile(tabId);
$('#text').val(s);
tracking.checked = backgroundPage.tabStatus[tabId].tracking;
}
}
|
JavaScript
|
function initShare() {
var link = 'https://chrome.google.com/webstore/detail/' +
'lgllffgicojgllpmdbemgglaponefajn';
var text2 = ['Chrome也能用网银啦!',
'每次付款还要换浏览器?你out啦!',
'现在可以彻底抛弃IE了!',
'让IE去死吧!',
'Chrome用网银:'
];
text2 = text2[Math.floor(Math.random() * 1000121) % text2.length];
text2 = '只要安装了ActiveX for Chrome,就可以直接在Chrome里' +
'使用各种网银、播放器等ActiveX控件了。而且不用切换内核,非常方便。';
var pic = 'http://ww3.sinaimg.cn/bmiddle/8c75b426jw1dqz2l1qfubj.jpg';
var text = text2 + '下载地址:';
// facebook
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/en_US/all.js#xfbml=1';
js.async = true;
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
window.___gcfg = {lang: navigator.language};
// Google plus
(function() {
var po = document.createElement('script');
po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(po, s);
})();
// Sina weibo
(function() {
var _w = 75 , _h = 24;
var param = {
url: link,
type: '2',
count: '1', /**是否显示分享数,1显示(可选)*/
appkey: '798098327', /**您申请的应用appkey,显示分享来源(可选)*/
title: text,
pic: pic, /**分享图片的路径(可选)*/
ralateUid: '2356524070', /**关联用户的UID,分享微博会@该用户(可选)*/
language: 'zh_cn', /**设置语言,zh_cn|zh_tw(可选)*/
rnd: new Date().valueOf()
};
var temp = [];
for (var p in param) {
temp.push(p + '=' + encodeURIComponent(param[p] || ''));
}
weiboshare.innerHTML = '<iframe allowTransparency="true"' +
' frameborder="0" scrolling="no" ' +
'src="http://hits.sinajs.cn/A1/weiboshare.html?' +
temp.join('&') + '" width="' + _w + '" height="' + _h + '"></iframe>';
})();
//renren
function shareClick() {
var rrShareParam = {
resourceUrl: link,
pic: pic,
title: 'Chrome用网银:ActiveX for Chrome',
description: text2
};
rrShareOnclick(rrShareParam);
}
Renren.share();
xn_share.addEventListener('click', shareClick, false);
// Tencent weibo
function postToWb() {
var _url = encodeURIComponent(link);
var _assname = encodeURI('');
var _appkey = encodeURI('801125118');//你从腾讯获得的appkey
var _pic = encodeURI(pic);
var _t = '';
var metainfo = document.getElementsByTagName('meta');
for (var metai = 0; metai < metainfo.length; metai++) {
if ((new RegExp('description', 'gi')).test(
metainfo[metai].getAttribute('name'))) {
_t = metainfo[metai].attributes['content'].value;
}
}
_t = text;
if (_t.length > 120) {
_t = _t.substr(0, 117) + '...';
}
_t = encodeURI(_t);
var _u = 'http://share.v.t.qq.com/index.php?c=share&a=index&url=' + _url +
'&appkey=' + _appkey + '&pic=' + _pic + '&assname=' + _assname +
'&title=' + _t;
window.open(_u, '', 'width=700, height=680, top=0, left=0, toolbar=no,' +
' menubar=no, scrollbars=no, location=yes, resizable=no, status=no');
}
qqweibo.addEventListener('click', postToWb, false);
// Douban
function doubanShare() {
var d = document,
e = encodeURIComponent,
s1 = window.getSelection,
s2 = d.getSelection,
s3 = d.selection,
s = s1 ? s1() : s2 ? s2() : s3 ? s3.createRange().text : '',
r = 'http://www.douban.com/recommend/?url=' + e(link) +
'&title=' + e('ActiveX for Chrome') + '&sel=' + e(s) + '&v=1';
window.open(
r, 'douban',
'toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330');
}
doubanshare.addEventListener('click', doubanShare, false);
}
$(document).ready(function() {
div = $('#share');
div.load('share.html', function() {
setTimeout(initShare, 200);
});
});
document.write('<script type="text/javascript" src="rrshare.js"></script>');
document.write('<div id="share">');
document.write('</div>');
|
JavaScript
|
/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
CKEDITOR.plugins.add('uicolor',{requires:['dialog'],lang:['en'],init:function(a){if(CKEDITOR.env.ie6Compat)return;a.addCommand('uicolor',new CKEDITOR.dialogCommand('uicolor'));a.ui.addButton('UIColor',{label:a.lang.uicolor.title,command:'uicolor',icon:this.path+'uicolor.gif'});CKEDITOR.dialog.add('uicolor',this.path+'dialogs/uicolor.js');CKEDITOR.scriptLoader.load(CKEDITOR.getUrl('plugins/uicolor/yui/yui.js'));a.element.getDocument().appendStyleSheet(CKEDITOR.getUrl('plugins/uicolor/yui/assets/yui.css'));}});
|
JavaScript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.