MozillaZine

Very general development question

Discuss building things with or for the Mozilla Platform.
BruceAWittmeier

User avatar
 
Posts: 2617
Joined: June 9th, 2008, 10:53 am
Location: Near 37.501685 -80.147967

Post Posted July 19th, 2014, 2:34 pm

I see a lot of code posted in response to simple questions but I wonder - is this code written from scratch, cut and pasted or is there an editor that provides drop-down selections that one would associate with Object Oriented Programming?

It seems hard for me to to believe that this code is written with the lengthy and sensitive syntax without some editor assistance.

I'm thinking like VB from Microsoft. When you enter an object name in the development environment you would be presented with the methods, functions and variables available for that object. Does such a tool exist for Mozilla and/or the MDN? Comments?
~ I'm only here to Pay it Forward. ~

"I often take a very long windy road to my destination. When I arrive I often wonder how I missed the shortcut".

Philip Chee

User avatar
 
Posts: 6475
Joined: March 1st, 2005, 3:03 pm

Post Posted July 25th, 2014, 1:49 pm

BruceAWittmeier wrote:I see a lot of code posted in response to simple questions but I wonder - is this code written from scratch, cut and pasted or is there an editor that provides drop-down selections that one would associate with Object Oriented Programming?

It seems hard for me to to believe that this code is written with the lengthy and sensitive syntax without some editor assistance.

I'm thinking like VB from Microsoft. When you enter an object name in the development environment you would be presented with the methods, functions and variables available for that object. Does such a tool exist for Mozilla and/or the MDN? Comments?
Ah, Microsoft IntelliSense. Generally such a tool comes with the IDE. Mozilla does not ship with a IDE. There is ongoing work to make Mozilla Firefox to build as a Microsoft Visual Studio project. If this works then you'll have full use of the VS IntelliSense. Other IDEs may or may not have similar faculties. Netbreans, Eclipse, Komodo IDE, etc. Your Mileage May Vary.

Phil

BruceAWittmeier

User avatar
 
Posts: 2617
Joined: June 9th, 2008, 10:53 am
Location: Near 37.501685 -80.147967

Post Posted July 26th, 2014, 9:07 am

Thanks, Phil. I've tinkered with Netbeans for Java and it worked pretty good. It is the only drag-drop GUI builder I've seen since Borland's java builder I had back in the late 1990's.

This suggests an answer to the rest of my question but does not specifically state - everyone is coding all their stuff by writing, cut-n-paste, etc for their pages, extensions and projects.

I don't even know where all the object names exist let alone what methods and variables may apply.

Like this for example (these are just two samples I found in the dev forum):

Code: Select all
    <input class="nav_entity" type="checkbox" id="delchbox_0"
    onclick="if (document.getElementById('delchbox_0').checked) {
                      document.getElementById('ppp_0_no').click();
                      document.getElementById('ppp_0_yes').disabled = true;
                      document.getElementById('lbl_ppp_0]_yes').style.opacity = 0.5;
                      document.getElementById('ppp_0_utp').disabled = true;
                      document.getElementById('lbl_ppp_0_utp').style.opacity = 0.5;
                 } else {
                      document.getElementById('ppp_0_yes').disabled = false;
                      document.getElementById('lbl_ppp_0_yes').style.opacity = 1;
                      document.getElementById('ppp_0_utp').disabled = false;
                      document.getElementById('lbl_ppp_0_utp').style.opacity = 1;
                      document.getElementById('ppp_0_yes').click();
                 }"> <b> <u> To DELETE </u> </b> </input>


or this:
Code: Select all
// ==UserScript==
// @id noWhiteBackgroundColor-gray
// @name noWhiteBackgroundColor-gray
// @version 2.2
// @author HowardSmith
// @modefied ywzhaiqi add support autopager
// @description Version 2: Generic version which can now be configured to any background colour you like:
// @include *
// @run-at document-end
// @namespace https://greasyfork.org/users/145
// ==/UserScript==
(function() {


function changeBackgroundColor(x) { // auto change colors too close to white
if(x.getAttribute("mColored") == "true"){
return;
}
x.setAttribute("mColored", "true");

var elemStyle = window.getComputedStyle(x, null);
if(!elemStyle) return;

var backgroundColorRGB = elemStyle.backgroundColor; // get background-color
if (backgroundColorRGB != "transparent") { // convert hex color to rgb color to compare
var RGBValuesArray = backgroundColorRGB.match(/\d+/g); //get rgb values
var red = RGBValuesArray[0];
var green = RGBValuesArray[1];
var blue = RGBValuesArray[2];

// ============================================================================
// Set the base colors you require:
// use: http://www.colorpicker.com
// to find the rgb values of the base colour you wish to suppress white backgrounds with:
// Default gray provided:
// ============================================================================

var red_needed = 220;
var green_needed = 220;
var blue_needed = 220;

if (red >= 220 && green >= 220 && blue >= 220) { // white range detection

if (red >= 250 && red <= 255 && green >= 250 && green <= 255 && blue >= 250 && blue <= 255) {
red_needed += 0;
green_needed += 0;
} else if (red >= 240 && red <= 255 && green >= 240 && green <= 255 && blue >= 240 && blue <= 255) {
red_needed += 6;
green_needed += 3;
} else if (red >= 230 && red <= 255 && green >= 230 && green <= 255 && blue >= 230 && blue <= 255) {
red_needed += 10;
green_needed += 5;
} else if (red >= 220 && red <= 255 && green >= 220 && green <= 255 && blue >= 220 && blue <= 255) {
red_needed += 14;
green_needed += 7;
}

x.style.backgroundColor = "rgb( " + red_needed + ", " + green_needed + ", " + blue_needed + ")"; // the background-color you want
}
}
}

function fixAutoPage() {
// 创建观察者对象
var observer = new window.MutationObserver(function(mutations){
var nodeAdded = mutations.some(function(x){ return x.addedNodes.length > 0; });
if (nodeAdded) {
noWhiteBackgroundColor();
}
});
observer.observe(document.body, {childList: true, subtree: true});
}

function noWhiteBackgroundColor() {
var allElements = document.querySelectorAll("*:not([mColored='true'])"); // get all elements on a page
for (var i = 0; i < allElements.length; i++) {
changeBackgroundColor(allElements[i]);
}
}

noWhiteBackgroundColor();

fixAutoPage();
})();
~ I'm only here to Pay it Forward. ~

"I often take a very long windy road to my destination. When I arrive I often wonder how I missed the shortcut".

Philip Chee

User avatar
 
Posts: 6475
Joined: March 1st, 2005, 3:03 pm

Post Posted July 27th, 2014, 7:51 am

A lot of stuff just gets cargo-culted around with out fully understanding what it all means.
Some resources I use all the time:

http://mxr.mozilla.org/mozilla-central/
This is Core/Gecko/Toolkit/Firefox/ code. When I'm stuck I use MXR to see if there is any similar code I can borrow or steal.

https://developer.mozilla.org/
Another useful link.

A useful place to ask questions in over IRC
irc://moznet
useful channels:
#introduction beginners to journeyman level questions and answers.
#developers Where the mozilla code wizards hangout. This tends to be very busy and rather overwhelming.

Phil

BruceAWittmeier

User avatar
 
Posts: 2617
Joined: June 9th, 2008, 10:53 am
Location: Near 37.501685 -80.147967

Post Posted July 27th, 2014, 5:44 pm

Thanks, Philip. I've saved those links.
~ I'm only here to Pay it Forward. ~

"I often take a very long windy road to my destination. When I arrive I often wonder how I missed the shortcut".

vutaikt
 
Posts: 2
Joined: August 2nd, 2014, 9:05 am

Post Posted August 2nd, 2014, 9:12 am

i try code. and its ok. thank ur BruceAWittmeier


<input class="nav_entity" type="checkbox" id="delchbox_0"
onclick="if (document.getElementById('delchbox_0').checked) {
document.getElementById('ppp_0_no').click();
document.getElementById('ppp_0_yes').disabled = true;
document.getElementById('lbl_ppp_0]_yes').style.opacity = 0.5;
document.getElementById('ppp_0_utp').disabled = true;
document.getElementById('lbl_ppp_0_utp').style.opacity = 0.5;
} else {
document.getElementById('ppp_0_yes').disabled = false;
document.getElementById('lbl_ppp_0_yes').style.opacity = 1;
document.getElementById('ppp_0_utp').disabled = false;
document.getElementById('lbl_ppp_0_utp').style.opacity = 1;
document.getElementById('ppp_0_yes').click();
}"> <b> <u> To DELETE </u> </b> </input>
: <input class="nav_entity" type="checkbox" id="delchbox_0"
onclick="if (document.getElementById('delchbox_0').checked) {
document.getElementById('ppp_0_no').click();
document.getElementById('ppp_0_yes').disabled = true;
document.getElementById('lbl_ppp_0]_yes').style.opacity = 0.5;
document.getElementById('ppp_0_utp').disabled = true;
document.getElementById('lbl_ppp_0_utp').style.opacity = 0.5;
} else {
document.getElementById('ppp_0_yes').disabled = false;
document.getElementById('lbl_ppp_0_yes').style.opacity = 1;
document.getElementById('ppp_0_utp').disabled = false;
document.getElementById('lbl_ppp_0_utp').style.opacity = 1;
document.getElementById('ppp_0_yes').click();
}"> <b> <u> To DELETE </u> </b> </input>

Return to Mozilla Development


Who is online

Users browsing this forum: No registered users and 1 guest