Помогите реализовать отображение для аддона к mozilla.
Здравствуйте.
Есть шмоток кода, отвечающий за выборку стран, помогите реализовать выборку не по ротации, а рандомно. Спасибо! switchCountry: function () { var countries, menu, context_menu; switch (countryTool.prefManager.getCharPref("extensions.countrytool.country_type")) { countryTool.clearAllCountriesStyles(); var menuitem_country = menu.childNodes[countryTool.currentRotateCountryIndex]; var context_menuitem_country = context_menu.childNodes[countryTool.currentRotateCountryIndex]; menuitem_country.setAttribute("checked", true); context_menuitem_country.setAttribute("checked", true); menuitem_country.setAttribute("style", "font-weight: bold"); context_menuitem_country.setAttribute("style", "font-weight: bold"); if (menuitem_country.hasChildNodes()) countryTool.selectedCountryFlag = menuitem_country.childNodes[0].getAttribute("src"); else countryTool.selectedCountryFlag = ""; var country_info = menuitem_country.getAttribute('value').split(","); countryTool.countryChanged(country_info[0].split(":")); countryTool.selectedCountryCity = (country_info[1] == "undefined") ? "" : country_info[1]; if (country_info[2] != "undefined") countryTool.selectedCountryCity += "," + country_info[2]; var labelText = menuitem_country.getAttribute('label'); var index = labelText.substring(0, labelText.indexOf(".")); var stringbundle = document.getElementById("countrytool-strings"); countryTool.showPopup("country", stringbundle.getString("currentcountryindex") + ": " + index); countryTool.currentRotateCountryIndex++; if (countryTool.currentRotateCountryIndex == countries.length || countries.length == 0) countryTool.currentRotateCountryIndex = 0 }, |
Нет не у кого мыслей? очень надо..
|
Всё ещё интересует ответ на вопрос!
Не могу разобраться, работу дальше продолжить не могу.. Как я понимаю за ротацию отвечают последние 2 строки, что использовать? math.random? |
tabOpened: function (event) { if (countryTool.prefManager.getBoolPref("extensions.countrytool.rotate_country_on_new_window") == true) { countryTool.switchCountry() } }, switchCountry: function () { var countries, menu, context_menu; switch (countryTool.prefManager.getCharPref("extensions.countrytool.country_type")) { case "english": countries = countryTool.prefManager.getCharPref("extensions.countrytool.english_countries").split("|"); menu = document.getElementById("countrytool-menupopup-english-countries-uploaded"); context_menu = document.getElementById("countrytool-context-menupopup-english-countries-uploaded"); break; case "russian": countries = countryTool.prefManager.getCharPref("extensions.countrytool.russian_countries").split("|"); menu = document.getElementById("countrytool-menupopup-russian-countries-uploaded"); context_menu = document.getElementById("countrytool-context-menupopup-russian-countries-uploaded"); break; case "belarus": countries = countryTool.prefManager.getCharPref("extensions.countrytool.belarus_countries").split("|"); menu = document.getElementById("countrytool-menupopup-belarus-countries-uploaded"); context_menu = document.getElementById("countrytool-context-menupopup-belarus-countries-uploaded"); break } countryTool.clearAllCountriesStyles(); var menuitem_country = menu.childNodes[countryTool.currentRotateCountryIndex]; var context_menuitem_country = context_menu.childNodes[countryTool.currentRotateCountryIndex]; menuitem_country.setAttribute("checked", true); context_menuitem_country.setAttribute("checked", true); menuitem_country.setAttribute("style", "font-weight: bold"); context_menuitem_country.setAttribute("style", "font-weight: bold"); if (menuitem_country.hasChildNodes()) countryTool.selectedCountryFlag = menuitem_country.childNodes[0].getAttribute("src"); else countryTool.selectedCountryFlag = ""; var country_info = menuitem_country.getAttribute('value').split(","); countryTool.countryChanged(country_info[0].split(":")); countryTool.selectedCountryCity = (country_info[1] == "undefined") ? "" : country_info[1]; if (country_info[2] != "undefined") countryTool.selectedCountryCity += "," + country_info[2]; var labelText = menuitem_country.getAttribute('label'); var index = labelText.substring(0, labelText.indexOf(".")); var stringbundle = document.getElementById("countrytool-strings"); countryTool.showPopup("country", stringbundle.getString("currentcountryindex") + ": " + index); countryTool.currentRotateCountryIndex++; if (countryTool.currentRotateCountryIndex == countries.length || countries.length == 0) countryTool.currentRotateCountryIndex = 0 }, Помогите! |
Часовой пояс GMT +3, время: 22:30. |